From 4e831b05ec08399795d27c343b6324b5b6de3443 Mon Sep 17 00:00:00 2001 From: jvanderhel Date: Thu, 24 Nov 2011 21:31:38 +0100 Subject: Syntax and occurrence highlighting now skip generated positions --- src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java') diff --git a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java index 0ad7102b..ee2fc8e8 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java +++ b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java @@ -92,6 +92,7 @@ public class EclipsePatcher extends Agent { patchFixSourceTypeConverter(sm); patchDisableLombokForCodeFormatterAndCleanup(sm); patchListRewriteHandleGeneratedMethods(sm); + patchSyntaxAndOccurrencesHighlighting(sm); } else { patchPostCompileHookEcj(sm); } @@ -101,6 +102,20 @@ public class EclipsePatcher extends Agent { if (reloadExistingClasses) sm.reloadClasses(instrumentation); } + + private static void patchSyntaxAndOccurrencesHighlighting(ScriptManager sm) { + /* + * Skip generated nodes for "visual effects" (syntax highlighting && highlight occurrences) + */ + sm.addScript(ScriptBuilder.exitEarly() + .target(new MethodTarget("org.eclipse.jdt.internal.ui.search.OccurrencesFinder", "addUsage")) + .target(new MethodTarget("org.eclipse.jdt.internal.ui.search.OccurrencesFinder", "addWrite")) + .target(new MethodTarget("org.eclipse.jdt.internal.ui.javaeditor.SemanticHighlightingReconciler$PositionCollector", "visit", "boolean", "org.eclipse.jdt.core.dom.SimpleName")) + .decisionMethod(new Hook("lombok.eclipse.agent.PatchFixes", "isGenerated", "boolean", "org.eclipse.jdt.core.dom.ASTNode")) + .valueMethod(new Hook("lombok.eclipse.agent.PatchFixes", "returnFalse", "boolean", "java.lang.Object")) + .request(StackRequest.PARAM1) + .build()); + } private static void patchDisableLombokForCodeFormatterAndCleanup(ScriptManager sm) { sm.addScript(ScriptBuilder.setSymbolDuringMethodCall() -- cgit