diff options
author | kmoore | 2010-09-10 14:29:27 +0000 |
---|---|---|
committer | kmoore | 2010-09-10 14:29:27 +0000 |
commit | 7c60563ac9cdeb5c9f305a7a1c5c959cb676d734 (patch) | |
tree | 1388e50444c497bb4ad976e97641ed2256efdbd2 /jpa/plugins/org.eclipse.jpt.core | |
parent | 020bcd46bf62a4f0ce12ec8424cf8aa4c39fc179 (diff) | |
download | webtools.dali-7c60563ac9cdeb5c9f305a7a1c5c959cb676d734.tar.gz webtools.dali-7c60563ac9cdeb5c9f305a7a1c5c959cb676d734.tar.xz webtools.dali-7c60563ac9cdeb5c9f305a7a1c5c959cb676d734.zip |
fixing an NPE that happens with invalid nested annotations
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.core')
-rw-r--r-- | jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/AnnotationContainerTools.java | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/AnnotationContainerTools.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/AnnotationContainerTools.java index b3ddfd6fd8..1b2a0e867e 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/AnnotationContainerTools.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/AnnotationContainerTools.java @@ -160,17 +160,20 @@ public final class AnnotationContainerTools { /** * Add whatever annotations are represented by the specified expression to - * the specified list. Add null to the list for any non-annotation expression. + * the specified list. Do not add null to the list for any non-annotation expression. */ private static void addAstAnnotationsTo(Expression expression, String annotationName, ArrayList<Annotation> astAnnotations) { if (expression == null) { - astAnnotations.add(null); // not sure how we would get here... + //do not add null to the list, not sure how we would get here... } else if (expression.getNodeType() == ASTNode.ARRAY_INITIALIZER) { addAstAnnotationsTo((ArrayInitializer) expression, annotationName, astAnnotations); } else { - astAnnotations.add(getAstAnnotation_(expression, annotationName)); + Annotation astAnnotation = getAstAnnotation_(expression, annotationName); + if (astAnnotation != null) { + astAnnotations.add(astAnnotation); + } } } @@ -178,7 +181,10 @@ public final class AnnotationContainerTools { @SuppressWarnings("unchecked") List<Expression> expressions = arrayInitializer.expressions(); for (Expression expression : expressions) { - astAnnotations.add(getAstAnnotation(expression, annotationName)); + Annotation astAnnotation = getAstAnnotation(expression, annotationName); + if (astAnnotation != null) { + astAnnotations.add(astAnnotation); + } } } |