Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2010-09-10 10:29:27 -0400
committerkmoore2010-09-10 10:29:27 -0400
commit7c60563ac9cdeb5c9f305a7a1c5c959cb676d734 (patch)
tree1388e50444c497bb4ad976e97641ed2256efdbd2
parent020bcd46bf62a4f0ce12ec8424cf8aa4c39fc179 (diff)
downloadwebtools.dali-7c60563ac9cdeb5c9f305a7a1c5c959cb676d734.tar.gz
webtools.dali-7c60563ac9cdeb5c9f305a7a1c5c959cb676d734.tar.xz
webtools.dali-7c60563ac9cdeb5c9f305a7a1c5c959cb676d734.zip
fixing an NPE that happens with invalid nested annotations
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/AnnotationContainerTools.java14
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEntityTests.java6
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaElementCollectionMapping2_0Tests.java4
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaManyToManyMapping2_0Tests.java1
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaOneToManyMapping2_0Tests.java1
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaElementCollectionMappingTests.java4
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaManyToManyMappingTests.java1
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaOneToManyMappingTests.java1
8 files changed, 24 insertions, 8 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);
+ }
}
}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEntityTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEntityTests.java
index aaa33ecce1..5b9de1086b 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEntityTests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEntityTests.java
@@ -108,7 +108,7 @@ public class JavaEntityTests extends ContextModelTestCase
return this.createTestType(new DefaultAnnotationWriter() {
@Override
public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID, JPA.NAMED_QUERIES);
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.ID, JPA.NAMED_QUERIES, JPA.NAMED_QUERY);
}
@Override
public void appendTypeAnnotationTo(StringBuilder sb) {
@@ -1198,6 +1198,7 @@ public class JavaEntityTests extends ContextModelTestCase
JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
typeResource.removeAnnotation(0, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
+ getJpaProject().synchronizeContextModel();
secondaryTables = getJavaEntity().secondaryTables();
assertEquals(2, getJavaEntity().secondaryTablesSize());
@@ -1205,6 +1206,7 @@ public class JavaEntityTests extends ContextModelTestCase
assertEquals("baz", secondaryTables.next().getSpecifiedName());
typeResource.removeAnnotation(0, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES);
+ getJpaProject().synchronizeContextModel();
secondaryTables = getJavaEntity().secondaryTables();
assertEquals(1, getJavaEntity().secondaryTablesSize());
@@ -2856,7 +2858,7 @@ public class JavaEntityTests extends ContextModelTestCase
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
JavaEntity entity = getJavaEntity();
- assertEquals(2, entity.getQueryContainer().namedQueriesSize());
+ assertEquals(1, entity.getQueryContainer().namedQueriesSize());
}
public void testRemoveNamedQuery() throws Exception {
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaElementCollectionMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaElementCollectionMapping2_0Tests.java
index 264396cbf0..460366266f 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaElementCollectionMapping2_0Tests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaElementCollectionMapping2_0Tests.java
@@ -2010,7 +2010,8 @@ public class GenericJavaElementCollectionMapping2_0Tests extends Generic2_0Conte
JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
attributeResource.moveAnnotation(1, 0, AttributeOverridesAnnotation.ANNOTATION_NAME);
-
+ getJpaProject().synchronizeContextModel();
+
Iterator<NestableAnnotation> attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
assertEquals("key.state.name", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
@@ -2031,6 +2032,7 @@ public class GenericJavaElementCollectionMapping2_0Tests extends Generic2_0Conte
attributeResource.moveAnnotation(3, 2, AttributeOverridesAnnotation.ANNOTATION_NAME);
+ getJpaProject().synchronizeContextModel();
attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaManyToManyMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaManyToManyMapping2_0Tests.java
index b9e65ab567..7960dcc4b3 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaManyToManyMapping2_0Tests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaManyToManyMapping2_0Tests.java
@@ -1199,6 +1199,7 @@ public class GenericJavaManyToManyMapping2_0Tests
JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
attributeResource.moveAnnotation(1, 0, AttributeOverridesAnnotation.ANNOTATION_NAME);
+ getJpaProject().synchronizeContextModel();
Iterator<NestableAnnotation> attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaOneToManyMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaOneToManyMapping2_0Tests.java
index 64a72103db..822d5ffc96 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaOneToManyMapping2_0Tests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaOneToManyMapping2_0Tests.java
@@ -1506,6 +1506,7 @@ public class GenericJavaOneToManyMapping2_0Tests
JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
attributeResource.moveAnnotation(1, 0, AttributeOverridesAnnotation.ANNOTATION_NAME);
+ getJpaProject().synchronizeContextModel();
Iterator<NestableAnnotation> attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaElementCollectionMappingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaElementCollectionMappingTests.java
index d5b35d2a62..da78935d74 100644
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaElementCollectionMappingTests.java
+++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaElementCollectionMappingTests.java
@@ -2012,7 +2012,8 @@ public class EclipseLink2_0JavaElementCollectionMappingTests
JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
attributeResource.moveAnnotation(1, 0, AttributeOverridesAnnotation.ANNOTATION_NAME);
-
+ getJpaProject().synchronizeContextModel();
+
Iterator<NestableAnnotation> attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
assertEquals("key.state.name", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
@@ -2033,6 +2034,7 @@ public class EclipseLink2_0JavaElementCollectionMappingTests
attributeResource.moveAnnotation(3, 2, AttributeOverridesAnnotation.ANNOTATION_NAME);
+ getJpaProject().synchronizeContextModel();
attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaManyToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaManyToManyMappingTests.java
index c0309730c5..51126228be 100644
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaManyToManyMappingTests.java
+++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaManyToManyMappingTests.java
@@ -1285,6 +1285,7 @@ public class EclipseLink2_0JavaManyToManyMappingTests
JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
attributeResource.moveAnnotation(1, 0, AttributeOverridesAnnotation.ANNOTATION_NAME);
+ getJpaProject().synchronizeContextModel();
Iterator<NestableAnnotation> attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaOneToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaOneToManyMappingTests.java
index fe53fd9e39..d908bd40ad 100644
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaOneToManyMappingTests.java
+++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaOneToManyMappingTests.java
@@ -1401,6 +1401,7 @@ public class EclipseLink2_0JavaOneToManyMappingTests
JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
attributeResource.moveAnnotation(1, 0, AttributeOverridesAnnotation.ANNOTATION_NAME);
+ getJpaProject().synchronizeContextModel();
Iterator<NestableAnnotation> attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);

Back to the top