diff options
Diffstat (limited to 'src/lombok/eclipse')
-rw-r--r-- | src/lombok/eclipse/EclipseAST.java | 19 | ||||
-rw-r--r-- | src/lombok/eclipse/EclipseASTAdapter.java | 42 | ||||
-rw-r--r-- | src/lombok/eclipse/EclipseASTVisitor.java | 42 | ||||
-rw-r--r-- | src/lombok/eclipse/handlers/HandleCleanup.java | 9 | ||||
-rw-r--r-- | src/lombok/eclipse/handlers/HandleData.java | 6 | ||||
-rw-r--r-- | src/lombok/eclipse/handlers/HandleGetter.java | 2 | ||||
-rw-r--r-- | src/lombok/eclipse/handlers/HandlePrintAST.java | 2 | ||||
-rw-r--r-- | src/lombok/eclipse/handlers/HandleSetter.java | 2 |
8 files changed, 54 insertions, 70 deletions
diff --git a/src/lombok/eclipse/EclipseAST.java b/src/lombok/eclipse/EclipseAST.java index d202613b..c5bdd2ff 100644 --- a/src/lombok/eclipse/EclipseAST.java +++ b/src/lombok/eclipse/EclipseAST.java @@ -14,7 +14,6 @@ import org.eclipse.jdt.internal.compiler.ast.ASTNode; import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; import org.eclipse.jdt.internal.compiler.ast.Annotation; import org.eclipse.jdt.internal.compiler.ast.Argument; -import org.eclipse.jdt.internal.compiler.ast.Block; import org.eclipse.jdt.internal.compiler.ast.Clinit; import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration; @@ -22,7 +21,6 @@ import org.eclipse.jdt.internal.compiler.ast.ImportReference; import org.eclipse.jdt.internal.compiler.ast.Initializer; import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration; import org.eclipse.jdt.internal.compiler.ast.Statement; -import org.eclipse.jdt.internal.compiler.ast.TryStatement; import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; import org.eclipse.jdt.internal.compiler.problem.DefaultProblem; import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities; @@ -149,23 +147,6 @@ public class EclipseAST extends AST<ASTNode> { super(node, children, kind); } - public void rebuild() { - super.rebuild(); - System.out.println("REBUILD COMPLETE"); - AbstractMethodDeclaration me = (AbstractMethodDeclaration) get(); - for ( Statement outer : me.statements ) { - System.out.println("OUTER: "+ outer); - if ( outer instanceof TryStatement ) { - TryStatement ts = (TryStatement)outer; - Block tb = ((TryStatement) outer).tryBlock; - for ( Statement inner : tb.statements ) { - System.out.println("INNER: " + inner); - } - } - } - System.out.println("/REBUILD COMPLETE"); - } - public void traverse(EclipseASTVisitor visitor) { switch ( getKind() ) { case COMPILATION_UNIT: diff --git a/src/lombok/eclipse/EclipseASTAdapter.java b/src/lombok/eclipse/EclipseASTAdapter.java index 61d161d1..da040037 100644 --- a/src/lombok/eclipse/EclipseASTAdapter.java +++ b/src/lombok/eclipse/EclipseASTAdapter.java @@ -13,25 +13,25 @@ import org.eclipse.jdt.internal.compiler.ast.Statement; import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; public abstract class EclipseASTAdapter implements EclipseASTVisitor { - @Override public void visitCompilationUnit(Node top, CompilationUnitDeclaration unit) {} - @Override public void endVisitCompilationUnit(Node top, CompilationUnitDeclaration unit) {} - @Override public void visitType(Node typeNode, TypeDeclaration type) {} - @Override public void visitAnnotationOnType(TypeDeclaration type, Node annotationNode, Annotation annotation) {} - @Override public void endVisitType(Node typeNode, TypeDeclaration type) {} - @Override public void visitInitializer(Node initializerNode, Initializer initializer) {} - @Override public void endVisitInitializer(Node initializerNode, Initializer initializer) {} - @Override public void visitField(Node fieldNode, FieldDeclaration field) {} - @Override public void visitAnnotationOnField(FieldDeclaration field, Node annotationNode, Annotation annotation) {} - @Override public void endVisitField(Node fieldNode, FieldDeclaration field) {} - @Override public void visitMethod(Node methodNode, AbstractMethodDeclaration method) {} - @Override public void visitAnnotationOnMethod(AbstractMethodDeclaration method, Node annotationNode, Annotation annotation) {} - @Override public void endVisitMethod(Node methodNode, AbstractMethodDeclaration method) {} - @Override public void visitMethodArgument(Node argNode, Argument arg, AbstractMethodDeclaration method) {} - @Override public void visitAnnotationOnMethodArgument(Argument arg, AbstractMethodDeclaration method, Node annotationNode, Annotation annotation) {} - @Override public void endVisitMethodArgument(Node argNode, Argument arg, AbstractMethodDeclaration method) {} - @Override public void visitLocal(Node localNode, LocalDeclaration local) {} - @Override public void visitAnnotationOnLocal(LocalDeclaration local, Node annotationNode, Annotation annotation) {} - @Override public void endVisitLocal(Node localNode, LocalDeclaration local) {} - @Override public void visitStatement(Node statementNode, Statement statement) {} - @Override public void endVisitStatement(Node statementNode, Statement statement) {} + public void visitCompilationUnit(Node top, CompilationUnitDeclaration unit) {} + public void endVisitCompilationUnit(Node top, CompilationUnitDeclaration unit) {} + public void visitType(Node typeNode, TypeDeclaration type) {} + public void visitAnnotationOnType(TypeDeclaration type, Node annotationNode, Annotation annotation) {} + public void endVisitType(Node typeNode, TypeDeclaration type) {} + public void visitInitializer(Node initializerNode, Initializer initializer) {} + public void endVisitInitializer(Node initializerNode, Initializer initializer) {} + public void visitField(Node fieldNode, FieldDeclaration field) {} + public void visitAnnotationOnField(FieldDeclaration field, Node annotationNode, Annotation annotation) {} + public void endVisitField(Node fieldNode, FieldDeclaration field) {} + public void visitMethod(Node methodNode, AbstractMethodDeclaration method) {} + public void visitAnnotationOnMethod(AbstractMethodDeclaration method, Node annotationNode, Annotation annotation) {} + public void endVisitMethod(Node methodNode, AbstractMethodDeclaration method) {} + public void visitMethodArgument(Node argNode, Argument arg, AbstractMethodDeclaration method) {} + public void visitAnnotationOnMethodArgument(Argument arg, AbstractMethodDeclaration method, Node annotationNode, Annotation annotation) {} + public void endVisitMethodArgument(Node argNode, Argument arg, AbstractMethodDeclaration method) {} + public void visitLocal(Node localNode, LocalDeclaration local) {} + public void visitAnnotationOnLocal(LocalDeclaration local, Node annotationNode, Annotation annotation) {} + public void endVisitLocal(Node localNode, LocalDeclaration local) {} + public void visitStatement(Node statementNode, Statement statement) {} + public void endVisitStatement(Node statementNode, Statement statement) {} } diff --git a/src/lombok/eclipse/EclipseASTVisitor.java b/src/lombok/eclipse/EclipseASTVisitor.java index bebabc6b..49a8696b 100644 --- a/src/lombok/eclipse/EclipseASTVisitor.java +++ b/src/lombok/eclipse/EclipseASTVisitor.java @@ -129,7 +129,7 @@ public interface EclipseASTVisitor { return sb.toString(); } - @Override public void visitCompilationUnit(Node node, CompilationUnitDeclaration unit) { + public void visitCompilationUnit(Node node, CompilationUnitDeclaration unit) { out.println("---------------------------------------------------------"); out.println(node.isCompleteParse() ? "COMPLETE" : "incomplete"); @@ -137,26 +137,26 @@ public interface EclipseASTVisitor { indent++; } - @Override public void endVisitCompilationUnit(Node node, CompilationUnitDeclaration unit) { + public void endVisitCompilationUnit(Node node, CompilationUnitDeclaration unit) { indent--; print("</CUD>"); } - @Override public void visitType(Node node, TypeDeclaration type) { + public void visitType(Node node, TypeDeclaration type) { print("<TYPE %s>", str(type.name)); indent++; } - @Override public void visitAnnotationOnType(TypeDeclaration type, Node node, Annotation annotation) { + public void visitAnnotationOnType(TypeDeclaration type, Node node, Annotation annotation) { forcePrint("<ANNOTATION: %s />", annotation); } - @Override public void endVisitType(Node node, TypeDeclaration type) { + public void endVisitType(Node node, TypeDeclaration type) { indent--; print("</TYPE %s>", str(type.name)); } - @Override public void visitInitializer(Node node, Initializer initializer) { + public void visitInitializer(Node node, Initializer initializer) { Block block = initializer.block; boolean s = (block != null && block.statements != null); print("<%s INITIALIZER: %s>", @@ -169,13 +169,13 @@ public interface EclipseASTVisitor { } } - @Override public void endVisitInitializer(Node node, Initializer initializer) { + public void endVisitInitializer(Node node, Initializer initializer) { if ( printContent ) disablePrinting--; indent--; print("</%s INITIALIZER>", (initializer.modifiers & Modifier.STATIC) != 0 ? "static" : "instance"); } - @Override public void visitField(Node node, FieldDeclaration field) { + public void visitField(Node node, FieldDeclaration field) { print("<FIELD %s %s = %s>", str(field.type), str(field.name), field.initialization); indent++; if ( printContent ) { @@ -184,17 +184,17 @@ public interface EclipseASTVisitor { } } - @Override public void visitAnnotationOnField(FieldDeclaration field, Node node, Annotation annotation) { + public void visitAnnotationOnField(FieldDeclaration field, Node node, Annotation annotation) { forcePrint("<ANNOTATION: %s />", annotation); } - @Override public void endVisitField(Node node, FieldDeclaration field) { + public void endVisitField(Node node, FieldDeclaration field) { if ( printContent ) disablePrinting--; indent--; print("</FIELD %s %s>", str(field.type), str(field.name)); } - @Override public void visitMethod(Node node, AbstractMethodDeclaration method) { + public void visitMethod(Node node, AbstractMethodDeclaration method) { String type = method instanceof ConstructorDeclaration ? "CONSTRUCTOR" : "METHOD"; print("<%s %s: %s>", type, str(method.selector), method.statements != null ? "filled" : "blank"); indent++; @@ -204,52 +204,52 @@ public interface EclipseASTVisitor { } } - @Override public void visitAnnotationOnMethod(AbstractMethodDeclaration method, Node node, Annotation annotation) { + public void visitAnnotationOnMethod(AbstractMethodDeclaration method, Node node, Annotation annotation) { forcePrint("<ANNOTATION: %s />", annotation); } - @Override public void endVisitMethod(Node node, AbstractMethodDeclaration method) { + public void endVisitMethod(Node node, AbstractMethodDeclaration method) { if ( printContent ) disablePrinting--; String type = method instanceof ConstructorDeclaration ? "CONSTRUCTOR" : "METHOD"; indent--; print("</%s %s>", type, str(method.selector)); } - @Override public void visitMethodArgument(Node node, Argument arg, AbstractMethodDeclaration method) { + public void visitMethodArgument(Node node, Argument arg, AbstractMethodDeclaration method) { print("<METHODARG %s %s = %s>", str(arg.type), str(arg.name), arg.initialization); indent++; } - @Override public void visitAnnotationOnMethodArgument(Argument arg, AbstractMethodDeclaration method, Node node, Annotation annotation) { + public void visitAnnotationOnMethodArgument(Argument arg, AbstractMethodDeclaration method, Node node, Annotation annotation) { print("<ANNOTATION: %s />", annotation); } - @Override public void endVisitMethodArgument(Node node, Argument arg, AbstractMethodDeclaration method) { + public void endVisitMethodArgument(Node node, Argument arg, AbstractMethodDeclaration method) { indent--; print("</METHODARG %s %s>", str(arg.type), str(arg.name)); } - @Override public void visitLocal(Node node, LocalDeclaration local) { + public void visitLocal(Node node, LocalDeclaration local) { print("<LOCAL %s %s = %s>", str(local.type), str(local.name), local.initialization); indent++; } - @Override public void visitAnnotationOnLocal(LocalDeclaration local, Node node, Annotation annotation) { + public void visitAnnotationOnLocal(LocalDeclaration local, Node node, Annotation annotation) { print("<ANNOTATION: %s />", annotation); } - @Override public void endVisitLocal(Node node, LocalDeclaration local) { + public void endVisitLocal(Node node, LocalDeclaration local) { indent--; print("</LOCAL %s %s>", str(local.type), str(local.name)); } - @Override public void visitStatement(Node node, Statement statement) { + public void visitStatement(Node node, Statement statement) { print("<%s>", statement.getClass()); indent++; print("%s", statement); } - @Override public void endVisitStatement(Node node, Statement statement) { + public void endVisitStatement(Node node, Statement statement) { indent--; print("</%s>", statement.getClass()); } diff --git a/src/lombok/eclipse/handlers/HandleCleanup.java b/src/lombok/eclipse/handlers/HandleCleanup.java index 908a9b04..f381f25e 100644 --- a/src/lombok/eclipse/handlers/HandleCleanup.java +++ b/src/lombok/eclipse/handlers/HandleCleanup.java @@ -35,9 +35,9 @@ import org.mangosdk.spi.ProviderFor; @ProviderFor(EclipseAnnotationHandler.class) public class HandleCleanup implements EclipseAnnotationHandler<Cleanup> { - @Override public boolean handle(AnnotationValues<Cleanup> annotation, Annotation ast, Node annotationNode) { + public boolean handle(AnnotationValues<Cleanup> annotation, Annotation ast, Node annotationNode) { String cleanupName = annotation.getInstance().cleanupMethod(); - if ( cleanupName.isEmpty() ) { + if ( cleanupName.length() == 0 ) { annotationNode.addError("cleanupName cannot be the empty string."); return true; } @@ -49,6 +49,7 @@ public class HandleCleanup implements EclipseAnnotationHandler<Cleanup> { LocalDeclaration decl = (LocalDeclaration)annotationNode.up().get(); + Node ancestor = annotationNode.up().directUp(); ASTNode blockNode = annotationNode.up().directUp().get(); final boolean isSwitch; @@ -124,7 +125,7 @@ public class HandleCleanup implements EclipseAnnotationHandler<Cleanup> { //Remove the stuff we just dumped into the tryBlock, AND the close() call, and then leave room for the try node and the unique name. Statement[] newStatements = new Statement[statements.length - (end-start) +1]; System.arraycopy(statements, 0, newStatements, 0, start); - if ( statements.length - end > 0 ) System.arraycopy(statements, end+1, newStatements, start+2, statements.length - end -1); + System.arraycopy(statements, end+1, newStatements, start+2, statements.length - end -1); TryStatement tryStatement = new TryStatement(); newStatements[start+1] = tryStatement; LocalDeclaration tempVar = new LocalDeclaration(("$lombok$cleanup$" + new String(decl.name)).toCharArray(), 0, 0); @@ -200,6 +201,8 @@ public class HandleCleanup implements EclipseAnnotationHandler<Cleanup> { ((SwitchStatement)blockNode).statements = newStatements; } + ancestor.rebuild(); + return true; } } diff --git a/src/lombok/eclipse/handlers/HandleData.java b/src/lombok/eclipse/handlers/HandleData.java index c26a2697..c17757c9 100644 --- a/src/lombok/eclipse/handlers/HandleData.java +++ b/src/lombok/eclipse/handlers/HandleData.java @@ -69,7 +69,7 @@ import org.mangosdk.spi.ProviderFor; @ProviderFor(EclipseAnnotationHandler.class) public class HandleData implements EclipseAnnotationHandler<Data> { - @Override public boolean handle(AnnotationValues<Data> annotation, Annotation ast, Node annotationNode) { + public boolean handle(AnnotationValues<Data> annotation, Annotation ast, Node annotationNode) { Data ann = annotation.getInstance(); Node typeNode = annotationNode.up(); @@ -105,11 +105,11 @@ public class HandleData implements EclipseAnnotationHandler<Data> { if ( constructorExists(typeNode) == MethodExistsResult.NOT_EXISTS ) { ConstructorDeclaration constructor = createConstructor( - ann.staticConstructor().isEmpty(), typeNode, nodesForConstructorAndToString, ast); + ann.staticConstructor().length() == 0, typeNode, nodesForConstructorAndToString, ast); injectMethod(typeNode, constructor); } - if ( !ann.staticConstructor().isEmpty() ) { + if ( ann.staticConstructor().length() > 0 ) { if ( methodExists("of", typeNode) == MethodExistsResult.NOT_EXISTS ) { MethodDeclaration staticConstructor = createStaticConstructor( ann.staticConstructor(), typeNode, nodesForConstructorAndToString, ast); diff --git a/src/lombok/eclipse/handlers/HandleGetter.java b/src/lombok/eclipse/handlers/HandleGetter.java index 28e61358..159b49fd 100644 --- a/src/lombok/eclipse/handlers/HandleGetter.java +++ b/src/lombok/eclipse/handlers/HandleGetter.java @@ -45,7 +45,7 @@ public class HandleGetter implements EclipseAnnotationHandler<Getter> { createGetterForField(level, fieldNode, errorNode, pos, whineIfExists); } - @Override public boolean handle(AnnotationValues<Getter> annotation, Annotation ast, Node annotationNode) { + public boolean handle(AnnotationValues<Getter> annotation, Annotation ast, Node annotationNode) { Node fieldNode = annotationNode.up(); AccessLevel level = annotation.getInstance().value(); return createGetterForField(level, fieldNode, annotationNode, annotationNode.get(), true); diff --git a/src/lombok/eclipse/handlers/HandlePrintAST.java b/src/lombok/eclipse/handlers/HandlePrintAST.java index cbd2cae1..a2ccad77 100644 --- a/src/lombok/eclipse/handlers/HandlePrintAST.java +++ b/src/lombok/eclipse/handlers/HandlePrintAST.java @@ -16,7 +16,7 @@ import lombok.eclipse.EclipseAST.Node; @ProviderFor(EclipseAnnotationHandler.class) public class HandlePrintAST implements EclipseAnnotationHandler<PrintAST> { - @Override public boolean handle(AnnotationValues<PrintAST> annotation, Annotation ast, Node annotationNode) { + public boolean handle(AnnotationValues<PrintAST> annotation, Annotation ast, Node annotationNode) { if ( !annotationNode.isCompleteParse() ) return false; PrintStream stream = System.out; diff --git a/src/lombok/eclipse/handlers/HandleSetter.java b/src/lombok/eclipse/handlers/HandleSetter.java index 2367d66d..28332bdd 100644 --- a/src/lombok/eclipse/handlers/HandleSetter.java +++ b/src/lombok/eclipse/handlers/HandleSetter.java @@ -49,7 +49,7 @@ public class HandleSetter implements EclipseAnnotationHandler<Setter> { createSetterForField(level, fieldNode, errorNode, pos, whineIfExists); } - @Override public boolean handle(AnnotationValues<Setter> annotation, Annotation ast, Node annotationNode) { + public boolean handle(AnnotationValues<Setter> annotation, Annotation ast, Node annotationNode) { Node fieldNode = annotationNode.up(); if ( fieldNode.getKind() != Kind.FIELD ) return false; AccessLevel level = annotation.getInstance().value(); |