aboutsummaryrefslogtreecommitdiff
path: root/src/eclipseAgent/lombok/eclipse/agent
diff options
context:
space:
mode:
authorRoel Spilker <r.spilker@gmail.com>2017-01-19 21:53:17 +0100
committerGitHub <noreply@github.com>2017-01-19 21:53:17 +0100
commitac2bedb8f31c73a9b92793611c9199ba95f904af (patch)
treed6754f3fc0bae404bc0a3164a329315227a6e6a7 /src/eclipseAgent/lombok/eclipse/agent
parent20b5a1204a6763af32d332f53fc4445c8dc4a4f7 (diff)
parentaf3de95b277a5d106aa6a4d8feb03e48dc0af8d0 (diff)
downloadlombok-ac2bedb8f31c73a9b92793611c9199ba95f904af.tar.gz
lombok-ac2bedb8f31c73a9b92793611c9199ba95f904af.tar.bz2
lombok-ac2bedb8f31c73a9b92793611c9199ba95f904af.zip
Merge pull request #1060 from rgra/Issue210
Patch for renaming fields with Getter/Setter/Data in eclipse #210
Diffstat (limited to 'src/eclipseAgent/lombok/eclipse/agent')
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
index 4b18dc0f..77f615b5 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
@@ -30,6 +30,8 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup;
+
import lombok.core.AgentLauncher;
import lombok.patcher.Filter;
import lombok.patcher.Hook;
@@ -120,10 +122,28 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
patchLombokizeAST(sm);
patchEcjTransformers(sm, ecjOnly);
patchExtensionMethod(sm, ecjOnly);
+ patchRenameField(sm);
if (reloadExistingClasses) sm.reloadClasses(instrumentation);
}
+ private static void patchRenameField(ScriptManager sm) {
+ /* RefactoringSearchEngine.search will not return results when renaming field and Data Annotation is present. Return a fake Element to make checks pass */
+ sm.addScript(ScriptBuilder.wrapMethodCall()
+ .target(new MethodTarget("org.eclipse.jdt.internal.corext.refactoring.rename.RenameFieldProcessor", "checkAccessorDeclarations", "org.eclipse.ltk.core.refactoring.RefactoringStatus", "org.eclipse.core.runtime.IProgressMonitor", "org.eclipse.jdt.core.IMethod"))
+ .methodToWrap(new Hook("org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine", "search", "org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup[]", "org.eclipse.jdt.core.search.SearchPattern","org.eclipse.jdt.core.search.IJavaSearchScope","org.eclipse.core.runtime.IProgressMonitor","org.eclipse.ltk.core.refactoring.RefactoringStatus"))
+ .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "createFakeSearchResult", "org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup[]", "org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup[]", "java.lang.Object"))
+ .requestExtra(StackRequest.THIS)
+ .transplant().build());
+
+ /* Filter search results which are Generated and based on Fields, e.g. Generated getters/setters */
+ sm.addScript(ScriptBuilder.wrapMethodCall()
+ .target(new MethodTarget("org.eclipse.jdt.internal.corext.refactoring.rename.RenameFieldProcessor", "addAccessorOccurrences", "void", "org.eclipse.core.runtime.IProgressMonitor", "org.eclipse.jdt.core.IMethod", "java.lang.String","java.lang.String","org.eclipse.ltk.core.refactoring.RefactoringStatus"))
+ .methodToWrap(new Hook("org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup", "getSearchResults", "org.eclipse.jdt.core.search.SearchMatch[]"))
+ .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "removeGenerated", "org.eclipse.jdt.core.search.SearchMatch[]", "org.eclipse.jdt.core.search.SearchMatch[]"))
+ .transplant().build());
+ }
+
private static void patchExtractInterface(ScriptManager sm) {
/* Fix sourceEnding for generated nodes to avoid null pointer */
sm.addScript(ScriptBuilder.wrapMethodCall()