diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2010-07-21 10:16:46 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2010-07-21 10:16:46 +0200 |
commit | 33b3e798fd6fdd85c6aa09cf30e8b19acacb1543 (patch) | |
tree | 1df113d0a6031dbc97f0a5ad89bc9c7621ec6204 /src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java | |
parent | 8e1cbe1b1079c1a6f5123add0241d32c8452cdae (diff) | |
download | lombok-33b3e798fd6fdd85c6aa09cf30e8b19acacb1543.tar.gz lombok-33b3e798fd6fdd85c6aa09cf30e8b19acacb1543.tar.bz2 lombok-33b3e798fd6fdd85c6aa09cf30e8b19acacb1543.zip |
Added some 'live debugging' - patches to improve error reporting for bugs that are very hard to reproduce.
Diffstat (limited to 'src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java')
-rw-r--r-- | src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java b/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java index 5d0722b0..ba685ced 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java +++ b/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java @@ -20,6 +20,26 @@ public class PatchFixes { return (bits & ALREADY_PROCESSED_FLAG) != 0; } + /** + * XXX LIVE DEBUG + * + * Once in a blue moon eclipse throws a NullPointerException while editing a file. Can't reproduce it while running eclipse in a debugger, + * but at least this way we patch the problem to be a bit more specific in the error that should then appear. + */ + public static boolean debugPrintStateOfScope(Object in) throws Exception { + /* this.scope.enclosingSourceType().sourceName */ + Object scope = in.getClass().getField("scope").get(in); + String msg = null; + if (scope == null) msg = "scope itself is null"; + else { + Object sourceTypeBinding = scope.getClass().getMethod("enclosingSourceType").invoke(scope); + if (sourceTypeBinding == null) msg = "scope.enclosingSourceType() is null"; + } + + if (msg != null) throw new NullPointerException(msg); + return false; + } + public static boolean skipRewritingGeneratedNodes(org.eclipse.jdt.core.dom.ASTNode node) throws Exception { return ((Boolean)node.getClass().getField("$isGenerated").get(node)).booleanValue(); } |