diff options
author | Jappe van der Hel <jappe.vanderhel@gmail.com> | 2012-01-03 21:57:15 +0100 |
---|---|---|
committer | Jappe van der Hel <jappe.vanderhel@gmail.com> | 2012-01-03 21:57:15 +0100 |
commit | bf354e3b5ced16913726afc8247b1dd0321c9d62 (patch) | |
tree | dc4ed1168c06e3a7f9b9cfd5ee47900bd5f3ff6d /src | |
parent | 0095cbbf9ad99def9b0a3ae32d08055c3aa55a97 (diff) | |
download | lombok-bf354e3b5ced16913726afc8247b1dd0321c9d62.tar.gz lombok-bf354e3b5ced16913726afc8247b1dd0321c9d62.tar.bz2 lombok-bf354e3b5ced16913726afc8247b1dd0321c9d62.zip |
Found some earlier fixes, commented them and put them together in the patchExtractInterface method
Diffstat (limited to 'src')
-rw-r--r-- | src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java index b773e3be..cd8bd95b 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java +++ b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java @@ -105,6 +105,27 @@ public class EclipsePatcher extends Agent { } private static void patchExtractInterface(ScriptManager sm) { + /* Fix sourceEnding for generated nodes to avoid null pointer */ + sm.addScript(ScriptBuilder.wrapMethodCall() + .target(new MethodTarget("org.eclipse.jdt.internal.compiler.SourceElementNotifier", "notifySourceElementRequestor", "void", "org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration", "org.eclipse.jdt.internal.compiler.ast.TypeDeclaration", "org.eclipse.jdt.internal.compiler.ast.ImportReference")) + .methodToWrap(new Hook("org.eclipse.jdt.internal.compiler.util.HashtableOfObjectToInt", "get", "int", "java.lang.Object")) + .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "getSourceEndFixed", "int", "int", "org.eclipse.jdt.internal.compiler.ast.ASTNode")) + .requestExtra(StackRequest.PARAM1) + .transplant().build()); + + /* 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", + "org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite", + "org.eclipse.jdt.core.dom.rewrite.ASTRewrite", + "org.eclipse.jdt.core.dom.AbstractTypeDeclaration", + "org.eclipse.jdt.core.dom.MethodDeclaration" + )) + .methodToWrap(new Hook("org.eclipse.jface.text.IDocument", "get", "java.lang.String", "int", "int")) + .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "getRealMethodDeclarationSource", "java.lang.String", "java.lang.String", "org.eclipse.jdt.core.dom.MethodDeclaration")) + .requestExtra(StackRequest.PARAM4) + .build()); + /* get real generated node in stead of a random one generated by the annotation */ sm.addScript(ScriptBuilder.replaceMethodCall() .target(new MethodTarget("org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceProcessor", "createMemberDeclarations")) @@ -259,25 +280,6 @@ public class EclipsePatcher extends Agent { } private static void patchHideGeneratedNodes(ScriptManager sm) { - sm.addScript(ScriptBuilder.wrapMethodCall() - .target(new MethodTarget("org.eclipse.jdt.internal.compiler.SourceElementNotifier", "notifySourceElementRequestor", "void", "org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration", "org.eclipse.jdt.internal.compiler.ast.TypeDeclaration", "org.eclipse.jdt.internal.compiler.ast.ImportReference")) - .methodToWrap(new Hook("org.eclipse.jdt.internal.compiler.util.HashtableOfObjectToInt", "get", "int", "java.lang.Object")) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "getSourceEndFixed", "int", "int", "org.eclipse.jdt.internal.compiler.ast.ASTNode")) - .requestExtra(StackRequest.PARAM1) - .transplant().build()); - - sm.addScript(ScriptBuilder.wrapMethodCall() - .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", - "org.eclipse.jdt.core.dom.MethodDeclaration" - )) - .methodToWrap(new Hook("org.eclipse.jface.text.IDocument", "get", "java.lang.String", "int", "int")) - .wrapMethod(new Hook("lombok.eclipse.agent.PatchFixes", "getRealMethodDeclarationSource", "java.lang.String", "java.lang.String", "org.eclipse.jdt.core.dom.MethodDeclaration")) - .requestExtra(StackRequest.PARAM4) - .build()); - sm.addScript(ScriptBuilder.wrapReturnValue() .target(new MethodTarget("org.eclipse.jdt.internal.corext.dom.LinkedNodeFinder", "findByNode")) .target(new MethodTarget("org.eclipse.jdt.internal.corext.dom.LinkedNodeFinder", "findByBinding")) |