diff options
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 3f3f6bf835..cc42a6d9a8 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 b6105ef626..e7094ab512 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 0000000000..a8025f736e --- /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 0000000000..9c99af67e6 --- /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 3bf9562791..0428e769e4 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; } } } |