diff options
author | Robbert Jan Grootjans <grootjans@gmail.com> | 2012-06-18 23:58:51 +0200 |
---|---|---|
committer | Robbert Jan Grootjans <grootjans@gmail.com> | 2012-06-18 23:59:05 +0200 |
commit | 3ed67fc8aecf50757d85bdfb55075015c6627740 (patch) | |
tree | 28618c792f6578de68e74eb8da7a497149fd053a /src/core/lombok/eclipse/EclipseAstProblemView.java | |
parent | 2af094030f2025f0853955585c150b5451b108d2 (diff) | |
download | lombok-3ed67fc8aecf50757d85bdfb55075015c6627740.tar.gz lombok-3ed67fc8aecf50757d85bdfb55075015c6627740.tar.bz2 lombok-3ed67fc8aecf50757d85bdfb55075015c6627740.zip |
Fixed Help Content in Eclipse / ecj support.
- Moved Completion proposal code to the PatchExtensionMethodCompletionProposal
class
- Moved out error reporting from EclipseAST.
- Fixed error reporting of the portals.
Diffstat (limited to 'src/core/lombok/eclipse/EclipseAstProblemView.java')
-rw-r--r-- | src/core/lombok/eclipse/EclipseAstProblemView.java | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/core/lombok/eclipse/EclipseAstProblemView.java b/src/core/lombok/eclipse/EclipseAstProblemView.java new file mode 100644 index 00000000..a2d5b833 --- /dev/null +++ b/src/core/lombok/eclipse/EclipseAstProblemView.java @@ -0,0 +1,56 @@ +package lombok.eclipse; + + +import org.eclipse.jdt.core.compiler.CategorizedProblem; +import org.eclipse.jdt.internal.compiler.CompilationResult; +import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; +import org.eclipse.jdt.internal.compiler.problem.DefaultProblem; +import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities; +import org.eclipse.jdt.internal.compiler.util.Util; + +public class EclipseAstProblemView { + /** + * Adds a problem to the provided CompilationResult object so that it will show up + * in the Problems/Warnings view. + */ + public static void addProblemToCompilationResult(CompilationUnitDeclaration ast, + boolean isWarning, String message, int sourceStart, int sourceEnd) { + if (ast.compilationResult == null) return; + char[] fileNameArray = ast.getFileName(); + if (fileNameArray == null) fileNameArray = "(unknown).java".toCharArray(); + int lineNumber = 0; + int columnNumber = 1; + CompilationResult result = ast.compilationResult; + int[] lineEnds = null; + lineNumber = sourceStart >= 0 + ? Util.getLineNumber(sourceStart, lineEnds = result.getLineSeparatorPositions(), 0, lineEnds.length-1) + : 0; + columnNumber = sourceStart >= 0 + ? Util.searchColumnNumber(result.getLineSeparatorPositions(), lineNumber,sourceStart) + : 0; + + CategorizedProblem ecProblem = new LombokProblem( + fileNameArray, message, 0, new String[0], + isWarning ? ProblemSeverities.Warning : ProblemSeverities.Error, + sourceStart, sourceEnd, lineNumber, columnNumber); + ast.compilationResult.record(ecProblem, null); + } + + private static class LombokProblem extends DefaultProblem { + private static final String MARKER_ID = "org.eclipse.jdt.apt.pluggable.core.compileProblem"; //$NON-NLS-1$ + + public LombokProblem(char[] originatingFileName, String message, int id, + String[] stringArguments, int severity, + int startPosition, int endPosition, int line, int column) { + super(originatingFileName, message, id, stringArguments, severity, startPosition, endPosition, line, column); + } + + @Override public int getCategoryID() { + return CAT_UNSPECIFIED; + } + + @Override public String getMarkerType() { + return MARKER_ID; + } + } +} |