summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Rennie2013-07-30 10:37:46 (EDT)
committer Gerrit Code Review @ Eclipse.org2013-07-30 13:56:27 (EDT)
commitb5693e62f2ee5a29d0f69d3180b8974f96dab36a (patch)
tree0ff91cbbd154c21ab15ce26744f8d4ade0f0c83f
parenta09228385a8437df5174822fdbbec9e9f5d4b86a (diff)
downloadeclipse.pde.ui-b5693e62f2ee5a29d0f69d3180b8974f96dab36a.zip
eclipse.pde.ui-b5693e62f2ee5a29d0f69d3180b8974f96dab36a.tar.gz
eclipse.pde.ui-b5693e62f2ee5a29d0f69d3180b8974f96dab36a.tar.bz2
Bug 410151 - CCE in TagValidator.visitrefs/changes/74/14974/2
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/InvalidAnnotationTagTests.java20
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/ValidAnnotationTagTests.java16
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/annotation/test14.java55
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/annotation/valid/test3.java54
-rw-r--r--apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/TagValidator.java29
5 files changed, 168 insertions, 6 deletions
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/InvalidAnnotationTagTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/InvalidAnnotationTagTests.java
index 3f3f6bf..cc42a6d 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/InvalidAnnotationTagTests.java
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/InvalidAnnotationTagTests.java
@@ -291,4 +291,24 @@ public class InvalidAnnotationTagTests extends TagTest {
String typename = "test13.java";
deployTagTest(typename, inc, true);
}
+
+ public void testInvalidAnnotationTag14I() {
+ x14(true);
+ }
+
+ public void testInvalidAnnotationTag14F() {
+ x14(false);
+ }
+
+ /**
+ * Tests for an invalid @noreference tag on a field in a visible member annotation
+ */
+ private void x14(boolean inc) {
+ setExpectedProblemIds(getDefaultProblemSet(7));
+ setExpectedMessageArgs(new String[][] {
+ {"@noreference", BuilderMessages.TagValidator_annotation_field}
+ });
+ String typename = "test14.java";
+ deployTagTest(typename, inc, true);
+ }
} \ No newline at end of file
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/ValidAnnotationTagTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/ValidAnnotationTagTests.java
index b6105ef..e7094ab 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/ValidAnnotationTagTests.java
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/ValidAnnotationTagTests.java
@@ -83,4 +83,20 @@ public class ValidAnnotationTagTests extends InvalidAnnotationTagTests {
deployTagTest(typename, inc, true);
}
+ public void testInvalidAnnotationTag3I() {
+ x3(true);
+ }
+
+ public void testInvalidAnnotationTag3F() {
+ x3(false);
+ }
+
+ /**
+ * Tests having a bunch tags on member annotation elements
+ */
+ private void x3(boolean inc) {
+ String typename = "test2.java";
+ deployTagTest(typename, inc, true);
+ }
+
}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/annotation/test14.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/annotation/test14.java
new file mode 100644
index 0000000..a8025f7
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/annotation/test14.java
@@ -0,0 +1,55 @@
+package x.y.z;
+/*******************************************************************************
+ * Copyright (c) 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+/**
+ * Tests all tags are invalid when parent annotation is private or package default
+ */
+public @interface test14 {
+
+ public @interface inner1 {
+
+ /**
+ * @noextend
+ * @noinstantiate
+ * @noreference
+ */
+ public static class Clazz {
+ }
+
+ /**
+ * @noextend
+ * @noimplement
+ * @noreference
+ */
+ public interface inter {
+ }
+
+ /**
+ * @noreference
+ */
+ public int field = 0;
+
+ /**
+ * @noreference
+ */
+ public @interface annot {
+
+ }
+
+ /**
+ * @noreference
+ */
+ enum enu {
+ }
+ }
+
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/annotation/valid/test3.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/annotation/valid/test3.java
new file mode 100644
index 0000000..9c99af6
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/annotation/valid/test3.java
@@ -0,0 +1,54 @@
+package x.y.z;
+/*******************************************************************************
+ * Copyright (c) 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+/**
+ * Tests all tags are invalid when parent annotation is private or package default
+ */
+public @interface test3 {
+
+ public @interface inner1 {
+
+ /**
+ * @noextend
+ * @noinstantiate
+ * @noreference
+ */
+ public static class Clazz {
+ }
+
+ /**
+ * @noextend
+ * @noimplement
+ * @noreference
+ */
+ public interface inter {
+ }
+
+ /**
+ */
+ public int field = 0;
+
+ /**
+ * @noreference
+ */
+ public @interface annot {
+
+ }
+
+ /**
+ * @noreference
+ */
+ enum enu {
+ }
+ }
+
+}
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/TagValidator.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/TagValidator.java
index 3bf9562..0428e76 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/TagValidator.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/TagValidator.java
@@ -113,12 +113,29 @@ public class TagValidator extends ASTVisitor {
allinterfaces = true;
}
if(isvisible) {
- TypeDeclaration parent = (TypeDeclaration) node.getParent();
- if(parent.isInterface() && Flags.isPublic(parent.getModifiers())) {
- isvisible = true;
- }
- else if(!allinterfaces){
- isvisible &= !Flags.isPrivate(flags) && !Flags.isPackageDefault(flags);
+ switch(node.getParent().getNodeType()) {
+ case ASTNode.ANNOTATION_TYPE_DECLARATION: {
+ AbstractTypeDeclaration parent = (AbstractTypeDeclaration) node.getParent();
+ if(Flags.isPublic(parent.getModifiers())) {
+ isvisible = true;
+ }
+ else if(!allinterfaces) {
+ isvisible &= !Flags.isPrivate(flags) && !Flags.isPackageDefault(flags);
+ }
+ break;
+ }
+ case ASTNode.TYPE_DECLARATION: {
+ TypeDeclaration parent = (TypeDeclaration) node.getParent();
+ if(parent.isInterface() && Flags.isPublic(parent.getModifiers())) {
+ isvisible = true;
+ }
+ else if(!allinterfaces){
+ isvisible &= !Flags.isPrivate(flags) && !Flags.isPackageDefault(flags);
+ }
+ break;
+ }
+ default:
+ break;
}
}
}