aboutsummaryrefslogtreecommitdiff
path: root/src/lombok/javac/apt
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@tipit.to>2009-08-12 23:23:07 +0200
committerReinier Zwitserloot <reinier@tipit.to>2009-08-12 23:23:07 +0200
commitfe945d91983c854e2c6e79e225761f48ffd04059 (patch)
tree1b27aa485c1e0a46392062664436063c5dae9f53 /src/lombok/javac/apt
parent5f4c415017c303f41469032f4bf9d801f6a3d397 (diff)
downloadlombok-fe945d91983c854e2c6e79e225761f48ffd04059.tar.gz
lombok-fe945d91983c854e2c6e79e225761f48ffd04059.tar.bz2
lombok-fe945d91983c854e2c6e79e225761f48ffd04059.zip
More attempts to fix NullPointerExceptions reported on the forums.
http://groups.google.com/group/project-lombok/browse_thread/thread/a8d59daaf7c1ae09
Diffstat (limited to 'src/lombok/javac/apt')
-rw-r--r--src/lombok/javac/apt/Processor.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/lombok/javac/apt/Processor.java b/src/lombok/javac/apt/Processor.java
index 2d2d06d3..0a5c2424 100644
--- a/src/lombok/javac/apt/Processor.java
+++ b/src/lombok/javac/apt/Processor.java
@@ -41,6 +41,7 @@ import lombok.javac.JavacAST;
import lombok.javac.JavacASTAdapter;
import lombok.javac.JavacAST.Node;
+import com.sun.source.util.TreePath;
import com.sun.source.util.Trees;
import com.sun.tools.javac.processing.JavacProcessingEnvironment;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
@@ -86,7 +87,10 @@ public class Processor extends AbstractProcessor {
IdentityHashMap<JCCompilationUnit, Void> units = new IdentityHashMap<JCCompilationUnit, Void>();
- for ( Element element : roundEnv.getRootElements() ) units.put(toUnit(element), null);
+ for ( Element element : roundEnv.getRootElements() ) {
+ JCCompilationUnit unit = toUnit(element);
+ if ( unit != null ) units.put(unit, null);
+ }
List<JavacAST> asts = new ArrayList<JavacAST>();
@@ -143,6 +147,16 @@ public class Processor extends AbstractProcessor {
}
private JCCompilationUnit toUnit(Element element) {
- return (JCCompilationUnit) trees.getPath(element).getCompilationUnit();
+ TreePath path = trees.getPath(element);
+ if ( path != null ) return (JCCompilationUnit) path.getCompilationUnit();
+ else {
+ if ( element == null ) {
+ processingEnv.getMessager().printMessage(Kind.WARNING, "LOMBOK DIAGNOSTIC: no TreePath returned for element, " +
+ "probably because element is null!");
+ }
+ processingEnv.getMessager().printMessage(Kind.WARNING, "LOMBOK DIAGNOSTIC: no TreePath returned for element of type: " +
+ element.getClass() + "with toString: " + element);
+ return null;
+ }
}
}