diff options
author | Jan Lahoda <lahoda@gmail.com> | 2012-07-11 00:49:00 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2012-07-11 00:50:46 +0200 |
commit | 6bf2b9299d2f1bcc00b8a0f253aae8fd4fcb6baa (patch) | |
tree | 131497420666c913322672b826d138559a9fd1fa /src/core/lombok | |
parent | 0befce2072c811fe6cc4177d43c581f00bc2d578 (diff) | |
download | lombok-6bf2b9299d2f1bcc00b8a0f253aae8fd4fcb6baa.tar.gz lombok-6bf2b9299d2f1bcc00b8a0f253aae8fd4fcb6baa.tar.bz2 lombok-6bf2b9299d2f1bcc00b8a0f253aae8fd4fcb6baa.zip |
Made lombok more stable in netbeans based on some smart observations by Jan Lahoda of team Netbeans.
Diffstat (limited to 'src/core/lombok')
-rw-r--r-- | src/core/lombok/javac/handlers/HandleCleanup.java | 8 | ||||
-rw-r--r-- | src/core/lombok/javac/handlers/HandleSynchronized.java | 4 | ||||
-rw-r--r-- | src/core/lombok/javac/handlers/JavacHandlerUtil.java | 11 |
3 files changed, 19 insertions, 4 deletions
diff --git a/src/core/lombok/javac/handlers/HandleCleanup.java b/src/core/lombok/javac/handlers/HandleCleanup.java index fc74e319..29862e61 100644 --- a/src/core/lombok/javac/handlers/HandleCleanup.java +++ b/src/core/lombok/javac/handlers/HandleCleanup.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2011 The Project Lombok Authors. + * Copyright (C) 2009-2012 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,8 +23,8 @@ package lombok.javac.handlers; import static lombok.javac.handlers.JavacHandlerUtil.*; import lombok.Cleanup; -import lombok.core.AnnotationValues; import lombok.core.AST.Kind; +import lombok.core.AnnotationValues; import lombok.javac.Javac; import lombok.javac.JavacAnnotationHandler; import lombok.javac.JavacNode; @@ -33,7 +33,6 @@ import org.mangosdk.spi.ProviderFor; import com.sun.tools.javac.code.TypeTags; import com.sun.tools.javac.tree.JCTree; -import com.sun.tools.javac.tree.TreeMaker; import com.sun.tools.javac.tree.JCTree.JCAnnotation; import com.sun.tools.javac.tree.JCTree.JCAssign; import com.sun.tools.javac.tree.JCTree.JCBinary; @@ -50,6 +49,7 @@ import com.sun.tools.javac.tree.JCTree.JCMethodInvocation; import com.sun.tools.javac.tree.JCTree.JCStatement; import com.sun.tools.javac.tree.JCTree.JCTypeCast; import com.sun.tools.javac.tree.JCTree.JCVariableDecl; +import com.sun.tools.javac.tree.TreeMaker; import com.sun.tools.javac.util.List; import com.sun.tools.javac.util.ListBuffer; import com.sun.tools.javac.util.Name; @@ -60,6 +60,8 @@ import com.sun.tools.javac.util.Name; @ProviderFor(JavacAnnotationHandler.class) public class HandleCleanup extends JavacAnnotationHandler<Cleanup> { @Override public void handle(AnnotationValues<Cleanup> annotation, JCAnnotation ast, JavacNode annotationNode) { + if (inNetbeansEditor(annotationNode)) return; + deleteAnnotationIfNeccessary(annotationNode, Cleanup.class); String cleanupName = annotation.getInstance().value(); if (cleanupName.length() == 0) { diff --git a/src/core/lombok/javac/handlers/HandleSynchronized.java b/src/core/lombok/javac/handlers/HandleSynchronized.java index 7a9a49ff..04668317 100644 --- a/src/core/lombok/javac/handlers/HandleSynchronized.java +++ b/src/core/lombok/javac/handlers/HandleSynchronized.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2011 The Project Lombok Authors. + * Copyright (C) 2009-2012 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -52,6 +52,8 @@ public class HandleSynchronized extends JavacAnnotationHandler<Synchronized> { private static final String STATIC_LOCK_NAME = "$LOCK"; @Override public void handle(AnnotationValues<Synchronized> annotation, JCAnnotation ast, JavacNode annotationNode) { + if (inNetbeansEditor(annotationNode)) return; + deleteAnnotationIfNeccessary(annotationNode, Synchronized.class); JavacNode methodNode = annotationNode.up(); diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index 6dc97fd4..308e0325 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -68,6 +68,7 @@ import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; import com.sun.tools.javac.util.List; import com.sun.tools.javac.util.ListBuffer; import com.sun.tools.javac.util.Name; +import com.sun.tools.javac.util.Options; /** * Container for static utility methods useful to handlers written for javac. @@ -92,6 +93,16 @@ public class JavacHandlerUtil { private static Map<JCTree, WeakReference<JCTree>> generatedNodes = new WeakHashMap<JCTree, WeakReference<JCTree>>(); + /** + * Contributed by Jan Lahoda; many lombok transformations should not be run (or a lite version should be run) when the netbeans editor + * is running javac on the open source file to find inline errors and such. As class files are compiled separately this does not affect + * actual runtime behaviour or file output of the netbeans IDE. + */ + public static boolean inNetbeansEditor(JavacNode node) { + Options options = Options.instance(node.getContext()); + return (options.keySet().contains("ide") && !options.keySet().contains("backgroundCompilation")); + } + public static JCTree getGeneratedBy(JCTree node) { synchronized (generatedNodes) { WeakReference<JCTree> ref = generatedNodes.get(node); |