aboutsummaryrefslogtreecommitdiff
path: root/src/eclipseAgent/lombok/eclipse/agent
diff options
context:
space:
mode:
authorjvanderhel <Jappe.vanderhel@gmail.com>2011-11-24 21:31:38 +0100
committerjvanderhel <Jappe.vanderhel@gmail.com>2011-11-24 21:31:38 +0100
commit4e831b05ec08399795d27c343b6324b5b6de3443 (patch)
treea9c372d0f81b6d1ae569f022f740ee406fe4376f /src/eclipseAgent/lombok/eclipse/agent
parentef820d8d5ab76c6db8335201da3c7ab9de7cb56a (diff)
downloadlombok-4e831b05ec08399795d27c343b6324b5b6de3443.tar.gz
lombok-4e831b05ec08399795d27c343b6324b5b6de3443.tar.bz2
lombok-4e831b05ec08399795d27c343b6324b5b6de3443.zip
Syntax and occurrence highlighting now skip generated positions
Diffstat (limited to 'src/eclipseAgent/lombok/eclipse/agent')
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java15
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java12
2 files changed, 24 insertions, 3 deletions
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()
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java b/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java
index 69024afa..640cafd8 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java
@@ -43,16 +43,22 @@ import org.eclipse.jdt.internal.core.dom.rewrite.RewriteEvent;
import org.eclipse.jdt.internal.core.dom.rewrite.TokenScanner;
public class PatchFixes {
- public static boolean isGenerated(org.eclipse.jdt.core.dom.Statement statement) {
+ public static boolean isGenerated(org.eclipse.jdt.core.dom.ASTNode node) {
boolean result = false;
try {
- result = ((Boolean)statement.getClass().getField("$isGenerated").get(statement)).booleanValue();
+ result = ((Boolean)node.getClass().getField("$isGenerated").get(node)).booleanValue();
+ if (!result && node.getParent() != null && node.getParent() instanceof org.eclipse.jdt.core.dom.QualifiedName)
+ result = isGenerated(node.getParent());
} catch (Exception e) {
// better to assume it isn't generated
}
return result;
}
-
+
+ public static boolean returnFalse(java.lang.Object object) {
+ return false;
+ }
+
public static int fixRetrieveStartingCatchPosition(int original, int start) {
return original == -1 ? start : original;
}