}
@Override
public lombok.ast.Node parseJava(@NonNull JavaContext context) {
// Use Eclipse's compiler
EcjTreeConverter converter = new EcjTreeConverter();
String code = context.getContents();
if (code == null) {
return null;
}
CompilationUnit sourceUnit = new CompilationUnit(code.toCharArray(),
context.file.getName(), "UTF-8"); //$NON-NLS-1$
CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
CompilationUnitDeclaration unit;
try {
unit = mParser.parse(sourceUnit, compilationResult);
} catch (AbortCompilation e) {
// No need to report Java parsing errors while running in Eclipse.
// Eclipse itself will already provide problem markers for these files,
// so all this achieves is creating "multiple annotations on this line"
// tooltips instead.
return null;
}
if (unit == null) {
return null;
}
try {
converter.visit(code, unit);
List<? extends Node> nodes = converter.getAll();
// There could be more than one node when there are errors; pick out the
// compilation unit node
for (lombok.ast.Node node : nodes) {
if (node instanceof lombok.ast.CompilationUnit) {