aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java2
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java35
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();
}