diff options
author | Roel Spilker <r.spilker@gmail.com> | 2012-01-09 20:42:10 +0100 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2012-01-09 20:42:10 +0100 |
commit | 1085c902ca7942e1f972b3af9bc2c0e9c873978e (patch) | |
tree | 4e1df005b40f602584813bac0f14d674d5a4216f /src | |
parent | 3796efe82e73fe60a15c0fd1a827dd417dfbcb57 (diff) | |
download | lombok-1085c902ca7942e1f972b3af9bc2c0e9c873978e.tar.gz lombok-1085c902ca7942e1f972b3af9bc2c0e9c873978e.tar.bz2 lombok-1085c902ca7942e1f972b3af9bc2c0e9c873978e.zip |
Code review
Diffstat (limited to 'src')
-rw-r--r-- | src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java | 2 | ||||
-rw-r--r-- | src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java | 35 |
2 files changed, 27 insertions, 10 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java index 04f83e66..69a3deaf 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java +++ b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java @@ -115,7 +115,7 @@ public class EclipsePatcher extends Agent { /* Make sure the generated source element is found instead of the annotation */ sm.addScript(ScriptBuilder.wrapMethodCall() - .target(new MethodTarget("org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceProcessor", "createMethodDeclaration", "void", + .target(new MethodTarget("org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceProcessor", "createMethodDeclaration", "void", "org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite", "org.eclipse.jdt.core.dom.rewrite.ASTRewrite", "org.eclipse.jdt.core.dom.AbstractTypeDeclaration", diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java b/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java index 2f61be7f..a1825074 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java +++ b/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java @@ -84,16 +84,33 @@ public class PatchFixes { /* Very practical implementation, but works for getter and setter even with type parameters */ public static java.lang.String getRealMethodDeclarationSource(java.lang.String original, org.eclipse.jdt.core.dom.MethodDeclaration declaration) { - if(isGenerated(declaration)) { - String returnType = declaration.getReturnType2().toString(); - String params = ""; - for (Object object : declaration.parameters()) { - org.eclipse.jdt.core.dom.ASTNode parameter = ((org.eclipse.jdt.core.dom.ASTNode)object); - params += ","+parameter.toString(); - } - return returnType + " "+declaration.getName().getFullyQualifiedName()+"("+(params.isEmpty() ? "" : params.substring(1))+");"; + if (!isGenerated(declaration)) return original; + + StringBuilder signature = new StringBuilder(); + + // We should get these from the refactor action + boolean needsPublic = true, needsAbstract = true; + + if (needsPublic) signature.append("public "); + if (needsAbstract) signature.append("abstract "); + + signature + .append(declaration.getReturnType2().toString()) + .append(" ").append(declaration.getName().getFullyQualifiedName()) + .append("("); + + boolean first = true; + for (Object parameter : declaration.parameters()) { + if (!first) signature.append(", "); + first = false; + // The annotations are still missing + // Note: what happens to imports for the annotations? + // I assume they have been taken care of by the default extraction system + signature.append(parameter); } - return original; + + signature.append(");"); + return signature.toString(); } |