diff options
author | Jappe van der Hel <jappe.vanderhel@gmail.com> | 2011-12-21 20:32:03 +0100 |
---|---|---|
committer | Jappe van der Hel <jappe.vanderhel@gmail.com> | 2011-12-21 20:32:03 +0100 |
commit | 8749b4b547a30503568c304a011ab25ea4af2be2 (patch) | |
tree | 79ddfa433afd3e203ba775255d6cdf4731635c7a /src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java | |
parent | 02d7e29dd9e821ae1ff51762bb02f002d93bbd4e (diff) | |
download | lombok-8749b4b547a30503568c304a011ab25ea4af2be2.tar.gz lombok-8749b4b547a30503568c304a011ab25ea4af2be2.tar.bz2 lombok-8749b4b547a30503568c304a011ab25ea4af2be2.zip |
Extract interface now works when @Data is present.
For all methods even generated by lombok;
comments for generated methods are placed above the "managing" annotations
@Override for generated methods are skipped (since there is no valid position for this annotation)
Diffstat (limited to 'src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java')
-rw-r--r-- | src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java b/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java index a63de8f1..99b0f4c2 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java +++ b/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java @@ -36,11 +36,15 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.jdt.core.IAnnotatable; import org.eclipse.jdt.core.IAnnotation; import org.eclipse.jdt.core.IMethod; +import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; +import org.eclipse.jdt.core.dom.MethodDeclaration; import org.eclipse.jdt.core.dom.SimpleName; import org.eclipse.jdt.internal.compiler.ast.Annotation; import org.eclipse.jdt.internal.core.dom.rewrite.NodeRewriteEvent; import org.eclipse.jdt.internal.core.dom.rewrite.RewriteEvent; import org.eclipse.jdt.internal.core.dom.rewrite.TokenScanner; +import org.eclipse.jdt.internal.corext.refactoring.structure.ASTNodeSearchUtil; public class PatchFixes { public static boolean isGenerated(org.eclipse.jdt.core.dom.ASTNode node) { @@ -55,6 +59,10 @@ public class PatchFixes { return result; } + public static boolean isListRewriteOnGeneratedNode(org.eclipse.jdt.core.dom.rewrite.ListRewrite rewrite) { + return isGenerated(rewrite.getParent()); + } + public static boolean returnFalse(java.lang.Object object) { return false; } @@ -87,6 +95,30 @@ public class PatchFixes { return original; } + +// lombok.eclipse.agent.PatchFixes.getRealMethodDeclarationNode(Lorg/eclipse/jdt/core/IMethod;Lorg/eclipse/jdt/core/dom/CompilationUnit;)Lorg/eclipse/jdt/core/dom/MethodDeclaration; + public static org.eclipse.jdt.core.dom.MethodDeclaration getRealMethodDeclarationNode(org.eclipse.jdt.core.IMethod sourceMethod, org.eclipse.jdt.core.dom.CompilationUnit cuUnit) throws JavaModelException { + MethodDeclaration methodDeclarationNode = ASTNodeSearchUtil.getMethodDeclarationNode(sourceMethod, cuUnit); + if (isGenerated(methodDeclarationNode)) { + String typeName = sourceMethod.getTypeRoot().getElementName(); + String methodName = sourceMethod.getElementName(); + for (Object type : cuUnit.types()) { + org.eclipse.jdt.core.dom.AbstractTypeDeclaration typeDeclaration = (AbstractTypeDeclaration)type; + if ((typeDeclaration.getName()+".java").equals(typeName)) { + for (Object declaration : typeDeclaration.bodyDeclarations()) { + if (declaration instanceof org.eclipse.jdt.core.dom.MethodDeclaration) { + org.eclipse.jdt.core.dom.MethodDeclaration methodDeclaration = (org.eclipse.jdt.core.dom.MethodDeclaration) declaration; + if (methodDeclaration.getName().toString().equals(methodName)) { + return methodDeclaration; + } + } + } + } + } + } + return methodDeclarationNode; + } + public static int getSourceEndFixed(int sourceEnd, org.eclipse.jdt.internal.compiler.ast.ASTNode node) throws Exception { if (sourceEnd == -1) { org.eclipse.jdt.internal.compiler.ast.ASTNode object = (org.eclipse.jdt.internal.compiler.ast.ASTNode)node.getClass().getField("$generatedBy").get(node); |