diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2010-11-29 22:28:32 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2010-12-01 20:00:43 +0100 |
commit | e308909def27a6940792cb04c1a9ec618c5df3cc (patch) | |
tree | 6b4a7e1157b9aef1d75f028bc34b651f94b8babd /src/core | |
parent | b0072a17eba21cdc6f8ba51693bb39d1c9aba319 (diff) | |
download | lombok-e308909def27a6940792cb04c1a9ec618c5df3cc.tar.gz lombok-e308909def27a6940792cb04c1a9ec618c5df3cc.tar.bz2 lombok-e308909def27a6940792cb04c1a9ec618c5df3cc.zip |
@Delegate in eclipse now uses more of the standard infrastructure to inject methods.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/lombok/eclipse/TransformEclipseAST.java | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/src/core/lombok/eclipse/TransformEclipseAST.java b/src/core/lombok/eclipse/TransformEclipseAST.java index dff11442..bfc35244 100644 --- a/src/core/lombok/eclipse/TransformEclipseAST.java +++ b/src/core/lombok/eclipse/TransformEclipseAST.java @@ -84,6 +84,29 @@ public class TransformEclipseAST { transform(parser, ast); } + public static EclipseAST getAST(CompilationUnitDeclaration ast) { + EclipseAST existing = null; + if (astCacheField != null) { + try { + existing = (EclipseAST)astCacheField.get(ast); + } catch (Exception e) { + // existing remains null + } + } + + if (existing == null) { + existing = new EclipseAST(ast); + if (astCacheField != null) try { + astCacheField.set(ast, existing); + } catch (Exception ignore) { + } + } else { + existing.reparse(); + } + + return existing; + } + /** * This method is called immediately after Eclipse finishes building a CompilationUnitDeclaration, which is * the top-level AST node when Eclipse parses a source file. The signature is 'magic' - you should not @@ -101,11 +124,7 @@ public class TransformEclipseAST { if (Symbols.hasSymbol("lombok.disable")) return; try { - EclipseAST existing = getCache(ast); - if (existing == null) { - existing = new EclipseAST(ast); - setCache(ast, existing); - } else existing.reparse(); + EclipseAST existing = getAST(ast); new TransformEclipseAST(existing).go(); } catch (Throwable t) { try { @@ -129,24 +148,6 @@ public class TransformEclipseAST { } } - private static EclipseAST getCache(CompilationUnitDeclaration ast) { - if (astCacheField == null) return null; - try { - return (EclipseAST)astCacheField.get(ast); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - private static void setCache(CompilationUnitDeclaration ast, EclipseAST cache) { - if (astCacheField != null) try { - astCacheField.set(ast, cache); - } catch (Exception ignore) { - ignore.printStackTrace(); - } - } - public TransformEclipseAST(EclipseAST ast) { this.ast = ast; } |