summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Rennie2013-08-21 10:38:14 (EDT)
committerMike Rennie2013-08-21 10:38:14 (EDT)
commit544164355471771a7310be8d28781203feb13fd1 (patch)
tree6ee263bb039473acbfec1b380e02803ae5b7e5a5
parent519ecbb200f385c8b0626442126e068f5c36ebe1 (diff)
downloadeclipse.pde.ui-544164355471771a7310be8d28781203feb13fd1.zip
eclipse.pde.ui-544164355471771a7310be8d28781203feb13fd1.tar.gz
eclipse.pde.ui-544164355471771a7310be8d28781203feb13fd1.tar.bz2
Bug 409428 - Consistently handle implicitly public members pt2
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/InvalidAnnotationTagTests.java78
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/InvalidClassTagTests.java4
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/InvalidEnumTagTests.java17
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/ValidInterfaceTagTests.java32
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/model/tests/BadClassfileTests.java2
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/annotation/test13.java1
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/annotation/test15.java30
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/annotation/test16.java39
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/annotation/test17.java40
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/field/interface/test11.java12
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/field/interface/test9.java12
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/interface/test1.java12
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/interface/valid/test8.java2
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/interface/valid/test9.java48
-rw-r--r--apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/completion/APIToolsJavadocCompletionProposalComputer.java59
-rw-r--r--apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/BuilderMessages.java2
-rw-r--r--apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/TagValidator.java131
-rw-r--r--apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/buildermessages.properties2
-rw-r--r--apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/JavaUtils.java73
19 files changed, 429 insertions, 167 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 839d2b8..5451afc 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
@@ -276,17 +276,10 @@ public class InvalidAnnotationTagTests extends TagTest {
* Tests all tags are invalid when parent annotation is private or package default
*/
private void x13(boolean inc) {
- setExpectedProblemIds(getDefaultProblemSet(7));
+ setExpectedProblemIds(getDefaultProblemSet(2));
setExpectedMessageArgs(new String[][] {
- {"@noextend", BuilderMessages.TagValidator_a_class_that_is_not_visible},
- {"@noinstantiate", BuilderMessages.TagValidator_a_class_that_is_not_visible},
- {"@noreference", BuilderMessages.TagValidator_a_class_that_is_not_visible},
- {"@noextend", BuilderMessages.TagValidator_an_interface_that_is_not_visible},
- {"@noimplement", BuilderMessages.TagValidator_an_interface_that_is_not_visible},
- {"@noreference", BuilderMessages.TagValidator_an_interface_that_is_not_visible},
- {"@noreference", BuilderMessages.TagValidator_annotation_field}
- /*{"@noreference", BuilderMessages.TagValidator_an_annotation},
- {"@noreference", BuilderMessages.TagValidator_an_enum},*/
+ {"@noreference", BuilderMessages.TagValidator_annotation_field},
+ {"@noreference", BuilderMessages.TagValidator_enum_not_visible},
});
String typename = "test13.java";
deployTagTest(typename, inc, true);
@@ -304,11 +297,72 @@ public class InvalidAnnotationTagTests extends TagTest {
* Tests for an invalid @noreference tag on a field in a visible member annotation
*/
private void x14(boolean inc) {
- setExpectedProblemIds(getDefaultProblemSet(1));
+ setExpectedProblemIds(getDefaultProblemSet(2));
setExpectedMessageArgs(new String[][] {
- {"@noreference", BuilderMessages.TagValidator_annotation_field}
+ {"@noreference", BuilderMessages.TagValidator_annotation_field},
+ {"@noreference", BuilderMessages.TagValidator_enum_not_visible}
});
String typename = "test14.java";
deployTagTest(typename, inc, true);
}
+
+ public void testInvalidAnnotationTag15I() {
+ x15(true);
+ }
+
+ public void testInvalidAnnotationTag15F() {
+ x15(false);
+ }
+
+ /**
+ * Tests for an invalid @noreference tag on a non-visible member annotation
+ */
+ private void x15(boolean inc) {
+ setExpectedProblemIds(getDefaultProblemSet(1));
+ setExpectedMessageArgs(new String[][] {
+ {"@noreference", BuilderMessages.TagValidator_annotation_not_visible},
+ });
+ String typename = "test15.java";
+ deployTagTest(typename, inc, true);
+ }
+
+ public void testInvalidAnnotationTag16I() {
+ x16(true);
+ }
+
+ public void testInvalidAnnotationTag16F() {
+ x16(false);
+ }
+
+ /**
+ * Tests for an invalid @noreference tag on a non-visible member annotation
+ */
+ private void x16(boolean inc) {
+ setExpectedProblemIds(getDefaultProblemSet(1));
+ setExpectedMessageArgs(new String[][] {
+ {"@noreference", BuilderMessages.TagValidator_annotation_not_visible},
+ });
+ String typename = "test16.java";
+ deployTagTest(typename, inc, true);
+ }
+
+ public void testInvalidAnnotationTag17I() {
+ x17(true);
+ }
+
+ public void testInvalidAnnotationTag17F() {
+ x17(false);
+ }
+
+ /**
+ * Tests for an invalid @noreference tag on a non-visible member annotation
+ */
+ private void x17(boolean inc) {
+ setExpectedProblemIds(getDefaultProblemSet(1));
+ setExpectedMessageArgs(new String[][] {
+ {"@noreference", BuilderMessages.TagValidator_annotation_not_visible},
+ });
+ String typename = "test17.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/InvalidClassTagTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/InvalidClassTagTests.java
index 7a53bb0..e23a3b8 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/InvalidClassTagTests.java
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/InvalidClassTagTests.java
@@ -329,7 +329,7 @@ public class InvalidClassTagTests extends TagTest {
}
private void x12(boolean inc) {
- setExpectedProblemIds(getDefaultProblemSet(11));
+ setExpectedProblemIds(getDefaultProblemSet(13));
setExpectedMessageArgs(new String[][] {
{"@noextend", BuilderMessages.TagValidator_a_class_that_is_not_visible},
{"@noextend", BuilderMessages.TagValidator_an_interface_that_is_not_visible},
@@ -339,6 +339,8 @@ public class InvalidClassTagTests extends TagTest {
{"@noreference", BuilderMessages.TagValidator_an_interface_that_is_not_visible},
{"@noreference", BuilderMessages.TagValidator_a_field_that_is_not_visible},
{"@noreference", BuilderMessages.TagValidator_a_class_that_is_not_visible},
+ {"@noreference", BuilderMessages.TagValidator_enum_not_visible},
+ {"@noreference", BuilderMessages.TagValidator_annotation_not_visible},
{"@noreference", BuilderMessages.TagValidator_a_method_that_is_not_visible},
{"@nooverride", BuilderMessages.TagValidator_a_method_that_is_not_visible},
{"@noinstantiate", BuilderMessages.TagValidator_a_class_that_is_not_visible}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/InvalidEnumTagTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/InvalidEnumTagTests.java
index ebfc64b..e760951 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/InvalidEnumTagTests.java
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/InvalidEnumTagTests.java
@@ -78,13 +78,12 @@ public class InvalidEnumTagTests extends TagTest {
* Tests having an @noreference tag on a variety of inner / outer / top-level enums in package a.b.c
*/
private void x1(boolean inc) {
- /*setExpectedProblemIds(getDefaultProblemSet(4));
+ setExpectedProblemIds(getDefaultProblemSet(3));
setExpectedMessageArgs(new String[][] {
- {"@noreference", BuilderMessages.TagValidator_an_enum},
- {"@noreference", BuilderMessages.TagValidator_an_enum},
- {"@noreference", BuilderMessages.TagValidator_an_enum},
- {"@noreference", BuilderMessages.TagValidator_an_enum}
- });*/
+ {"@noreference", BuilderMessages.TagValidator_enum_not_visible},
+ {"@noreference", BuilderMessages.TagValidator_enum_not_visible},
+ {"@noreference", BuilderMessages.TagValidator_enum_not_visible},
+ });
deployTagTest("test1.java", inc, false);
}
@@ -264,10 +263,10 @@ public class InvalidEnumTagTests extends TagTest {
* Tests all tags are invalid when parent enum is private or package default
*/
private void x11(boolean inc) {
- setExpectedProblemIds(getDefaultProblemSet(1));
+ setExpectedProblemIds(getDefaultProblemSet(2));
setExpectedMessageArgs(new String[][] {
- {"@noreference", BuilderMessages.TagValidator_an_enum_constant}
- /*{"@noreference", BuilderMessages.TagValidator_an_enum},*/
+ {"@noreference", BuilderMessages.TagValidator_an_enum_constant},
+ {"@noreference", BuilderMessages.TagValidator_enum_not_visible}
});
deployTagTest("test11.java", inc, true);
}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/ValidInterfaceTagTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/ValidInterfaceTagTests.java
index 5a172c4..5c6bb1f 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/ValidInterfaceTagTests.java
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/ValidInterfaceTagTests.java
@@ -131,9 +131,39 @@ public class ValidInterfaceTagTests extends InvalidInterfaceTagTests {
}
/**
- * Tests having an @noextend tag on an outer interface in package a.b.c
+ * Tests having an @noreference tag on outer / inner interfaces in package a.b.c
*/
private void x7(boolean inc) {
deployTagTest("test7.java", inc, false);
}
+
+ public void testInvalidInterfaceTag8I() {
+ x8(true);
+ }
+
+ public void testInvalidInterfaceTag8F() {
+ x8(false);
+ }
+
+ /**
+ * Tests having an @noreference tag on outer/inner interfaces in package a.b.c
+ */
+ private void x8(boolean inc) {
+ deployTagTest("test8.java", inc, false);
+ }
+
+ public void testInvalidInterfaceTag9I() {
+ x9(true);
+ }
+
+ public void testInvalidInterfaceTag9F() {
+ x9(false);
+ }
+
+ /**
+ * Tests having an @noextend tag on an outer interface in package a.b.c
+ */
+ private void x9(boolean inc) {
+ deployTagTest("test9.java", inc, false);
+ }
}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/model/tests/BadClassfileTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/model/tests/BadClassfileTests.java
index 69bd336..33ea2f0 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/model/tests/BadClassfileTests.java
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/model/tests/BadClassfileTests.java
@@ -153,7 +153,7 @@ public class BadClassfileTests extends TestCase {
/**
* Tests that the {@link org.eclipse.pde.api.tools.internal.provisional.scanner.TagScanner}
- * handles ad class files
+ * handles bad class files
*/
public void testTagScanner() throws Exception {
writePreamble("testTagScanner()");
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/annotation/test13.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/annotation/test13.java
index 7b6a09d..b10ea4b 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/annotation/test13.java
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/annotation/test13.java
@@ -20,7 +20,6 @@ public @interface test13 {
* @noextend
* @noinstantiate
* @noreference
- *
*/
public static class Clazz {
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/annotation/test15.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/annotation/test15.java
new file mode 100644
index 0000000..9109a72
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/annotation/test15.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) Aug 20, 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
+ *******************************************************************************/
+package a.b.c;
+
+/**
+ *
+ */
+public class test15 {
+
+ /**
+ * @noreference This annotation is not intended to be referenced by clients.
+ */
+ private @interface inner1 {
+
+ /**
+ * @noreference
+ */
+ @interface inner2 {
+
+ }
+ }
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/annotation/test16.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/annotation/test16.java
new file mode 100644
index 0000000..e1453fc
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/annotation/test16.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) Aug 20, 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
+ *******************************************************************************/
+package a.b.c;
+
+/**
+ *
+ */
+public class test16 {
+
+ /**
+ * @noreference This interface is not intended to be referenced by clients.
+ */
+ interface inner1 {
+
+ /**
+ * @noreference This annotation is not intended to be referenced by clients.
+ */
+ @interface inner2 {
+
+ }
+
+ static class C1 {
+ /**
+ * @noreference
+ */
+ @interface A1 {
+
+ }
+ }
+ }
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/annotation/test17.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/annotation/test17.java
new file mode 100644
index 0000000..813c707
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/annotation/test17.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) Aug 20, 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
+ *******************************************************************************/
+package a.b.c;
+
+/**
+ *
+ */
+public class test17 {
+
+ /**
+ * @noreference
+ */
+ private @interface inner {
+
+ }
+
+ public static class C1 {
+ /**
+ * @noreference This annotation is not intended to be referenced by clients.
+ */
+ @interface A1 {
+ class C2 {
+ /**
+ * @noreference
+ */
+ @interface A2 {
+
+ }
+ }
+ }
+ }
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/field/interface/test11.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/field/interface/test11.java
index af25013..e52cde1 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/field/interface/test11.java
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/field/interface/test11.java
@@ -19,11 +19,13 @@ public interface test11 {
* @noreference
*/
public final int f2 = 0;
- interface inner2 {
- /**
- * @noreference
- */
- public final char[] f3 = {};
+ class C {
+ interface inner2 {
+ /**
+ * @noreference
+ */
+ public final char[] f3 = {};
+ }
}
}
}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/field/interface/test9.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/field/interface/test9.java
index f30e28c..765db95 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/field/interface/test9.java
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/field/interface/test9.java
@@ -19,11 +19,13 @@ public interface test9 {
* @noreference
*/
public final int f2 = 0;
- interface inner2 {
- /**
- * @noreference
- */
- public final char[] f3 = {};
+ class C {
+ interface inner2 {
+ /**
+ * @noreference
+ */
+ public final char[] f3 = {};
+ }
}
}
}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/interface/test1.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/interface/test1.java
index 3f89b82..b006f4c 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/interface/test1.java
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/interface/test1.java
@@ -16,11 +16,13 @@ package a.b.c;
*/
public interface test1 {
- /**
- * @noreference
- */
- interface inner {
-
+ class C1 {
+ /**
+ * @noreference
+ */
+ interface inner {
+
+ }
}
interface inner1 {
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/interface/valid/test8.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/interface/valid/test8.java
index da06f00..1ca2d71 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/interface/valid/test8.java
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/interface/valid/test8.java
@@ -14,7 +14,7 @@ package a.b.c;
* Test supported @noreference tag on an interface
* @noreference
*/
-public interface test6 {
+public interface test8 {
/**
* @noreference
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/interface/valid/test9.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/interface/valid/test9.java
new file mode 100644
index 0000000..43263bc
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/tags/interface/valid/test9.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 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
+ *******************************************************************************/
+package a.b.c;
+
+/**
+ * Tests invalid @noreference tags on nested inner interfaces
+ * @noreference
+ */
+public interface test9 {
+
+ /**
+ * @noreference
+ */
+ interface inner {
+
+ }
+
+ interface inner1 {
+ /**
+ * @noreference
+ */
+ interface inner2 {
+
+ }
+ }
+
+ interface inner2 {
+
+ }
+}
+
+interface outer {
+
+ /**
+ * @noreference
+ */
+ interface InnerNoRef4 {
+
+ }
+}
diff --git a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/completion/APIToolsJavadocCompletionProposalComputer.java b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/completion/APIToolsJavadocCompletionProposalComputer.java
index edf4387..ec7d4a6 100644
--- a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/completion/APIToolsJavadocCompletionProposalComputer.java
+++ b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/completion/APIToolsJavadocCompletionProposalComputer.java
@@ -44,9 +44,9 @@ import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.pde.api.tools.internal.JavadocTagManager;
+import org.eclipse.pde.api.tools.internal.builder.TagValidator;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
import org.eclipse.pde.api.tools.internal.provisional.IApiJavadocTag;
-import org.eclipse.pde.api.tools.internal.util.JavaUtils;
import org.eclipse.pde.api.tools.internal.util.Util;
import org.eclipse.pde.api.tools.ui.internal.ApiUIPlugin;
import org.eclipse.swt.graphics.Image;
@@ -54,7 +54,10 @@ import org.eclipse.swt.graphics.Image;
/**
* This class creates completion proposals to javadoc header blocks
* for the javadoc tags contributed via the apiJavadocTags extension point.
+ * <br><br>
+ * Any changes to the visibility logic here also must be updated in the {@link TagValidator}
*
+ * @see TagValidator
* @see IApiJavadocTag
* @see JavadocTagManager
* @see APIToolsJavadocCompletionProposal
@@ -122,7 +125,7 @@ public class APIToolsJavadocCompletionProposalComputer implements IJavaCompletio
try {
int offset = jcontext.getInvocationOffset();
IJavaElement element = cunit.getElementAt(offset);
- if (!JavaUtils.isVisible(element)) {
+ if (!isVisible(element)) {
return Collections.EMPTY_LIST;
}
ImageDescriptor imagedesc = jcontext.getLabelProvider().createImageDescriptor(
@@ -178,6 +181,58 @@ public class APIToolsJavadocCompletionProposalComputer implements IJavaCompletio
}
/**
+ * Returns if the given {@link IJavaElement} is externally visible
+ * <br><br>
+ * Changes to the logic here must also be made in the {@link TagValidator} to ensure the
+ * visibility is computed equally.
+ *
+ * @see TagValidator
+ * @param element
+ * @return <code>true</code> if the given element is visible <code>false</code> otherwise
+ * @throws JavaModelException if a model lookup fails
+ */
+ boolean isVisible(IJavaElement element) throws JavaModelException {
+ if(element != null) {
+ switch(element.getElementType()) {
+ case IJavaElement.FIELD:
+ case IJavaElement.METHOD: {
+ IMember member = (IMember) element;
+ int flags = member.getFlags();
+ IType type = member.getDeclaringType();
+ if(Flags.isPublic(flags) || Flags.isProtected(flags) || (type != null && type.isInterface())) {
+ return isVisible(type);
+ }
+ break;
+ }
+ case IJavaElement.TYPE: {
+ IType type = (IType) element;
+ int flags = type.getFlags();
+ if(type.isLocal() && !type.isAnonymous() || Flags.isPrivate(flags)) {
+ return false;
+ }
+ if(type.isMember()) {
+ if((Flags.isPublic(flags) && Flags.isStatic(flags)) ||
+ Flags.isPublic(flags) ||
+ Flags.isProtected(flags) ||
+ type.isInterface()) {
+ return isVisible(type.getDeclaringType());
+ }
+ }
+ else {
+ return Flags.isPublic(flags) || type.isInterface();
+ }
+ break;
+ }
+ default: {
+ break;
+ }
+
+ }
+ }
+ return false;
+ }
+
+ /**
* Method to post process returned flags from the {@link org.eclipse.pde.api.tools.internal.JavadocTagManager}
* @param tag the tag to process
* @param element the {@link IJavaElement} the tag will appear on
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/BuilderMessages.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/BuilderMessages.java
index f3b5d60..23b5123 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/BuilderMessages.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/BuilderMessages.java
@@ -81,8 +81,10 @@ public class BuilderMessages extends NLS {
public static String TagValidator_an_interface_method;
public static String TagValidator_an_interface_that_is_not_visible;
public static String TagValidator_annotation_field;
+ public static String TagValidator_annotation_not_visible;
public static String TagValidator_constructor_in_final_class;
public static String TagValidator_enum_field;
+ public static String TagValidator_enum_not_visible;
public static String TagValidator_final_constructor;
public static String TagValidator_not_visible_constructor;
public static String TagValidator_not_visible_enum_field;
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 0428e76..12bc530 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
@@ -47,6 +47,11 @@ import org.eclipse.pde.api.tools.internal.util.Util;
/**
* Visit Javadoc comments of types and member to find API javadoc tags that are being misused
+ * <br><br>
+ * The logic in this class must be kept in sync with how we determine what is visible in out
+ * completion proposal code
+ *
+ * @see org.eclipse.pde.api.tools.ui.internal.completion.APIToolsJavadocCompletionProposalComputer
*
* @since 1.0.0
*/
@@ -55,12 +60,10 @@ public class TagValidator extends ASTVisitor {
class Item {
String typename;
int flags;
- boolean allints = false;
boolean visible = false;
- Item(String name, int flags, boolean ints, boolean vis) {
+ Item(String name, int flags, boolean vis) {
typename = name;
this.flags = flags;
- allints = ints;
visible = vis;
}
}
@@ -71,7 +74,6 @@ public class TagValidator extends ASTVisitor {
private ArrayList fTagProblems = null;
private ICompilationUnit fCompilationUnit = null;
- boolean allinterfaces = true;
boolean isvisible = true;
Stack fStack/*<Item>*/ = new Stack();
@@ -95,78 +97,88 @@ public class TagValidator extends ASTVisitor {
return false;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.AnnotationTypeDeclaration)
+ */
public boolean visit(AnnotationTypeDeclaration node) {
- int flags = node.getModifiers();
- isvisible = !Flags.isPrivate(flags) && !Flags.isPackageDefault(flags);
- fStack.push(new Item(getTypeName(node), node.getModifiers(), allinterfaces, isvisible));
+ isvisible &= !Flags.isPrivate(node.getModifiers());
+ fStack.push(new Item(getTypeName(node), node.getModifiers(), isvisible));
return true;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#endVisit(org.eclipse.jdt.core.dom.AnnotationTypeDeclaration)
+ */
public void endVisit(AnnotationTypeDeclaration node) {
fStack.pop();
+ if(!fStack.isEmpty()) {
+ Item item = (Item) fStack.peek();
+ isvisible = item.visible;
+ }
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.TypeDeclaration)
+ */
public boolean visit(TypeDeclaration node) {
int flags = node.getModifiers();
- if(node.isInterface() && node.isMemberTypeDeclaration()) {
- if(Flags.isPublic(flags)) {
- allinterfaces = true;
+ if(Flags.isPrivate(flags)) {
+ isvisible &= false;
+ } else {
+ if(node.isMemberTypeDeclaration()) {
+ isvisible &= (Flags.isPublic(flags) && Flags.isStatic(flags)) ||
+ Flags.isPublic(flags) ||
+ Flags.isProtected(flags) ||
+ node.isInterface();
}
- if(isvisible) {
- 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;
- }
+ else {
+ isvisible &= (!Flags.isPrivate(flags) && !Flags.isPackageDefault(flags)) || node.isInterface();
}
}
- else {
- allinterfaces &= node.isInterface();
- isvisible &= !Flags.isPrivate(flags) && !Flags.isPackageDefault(flags);
- }
- fStack.push(new Item(getTypeName(node), node.getModifiers(), allinterfaces, isvisible));
+ fStack.push(new Item(getTypeName(node), node.getModifiers(), isvisible));
return true;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#endVisit(org.eclipse.jdt.core.dom.TypeDeclaration)
+ */
public void endVisit(TypeDeclaration node) {
fStack.pop();
- if(!fStack.empty()) {
- Item i = (Item) fStack.peek();
- allinterfaces = i.allints;
- isvisible = i.visible;
+ if(!fStack.isEmpty()) {
+ Item item = (Item) fStack.peek();
+ isvisible = item.visible;
}
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.EnumDeclaration)
+ */
public boolean visit(EnumDeclaration node) {
int flags = node.getModifiers();
- isvisible = !Flags.isPrivate(flags) && !Flags.isPackageDefault(flags);
- fStack.push(new Item(getTypeName(node), node.getModifiers(), allinterfaces, isvisible));
+ if(node.isMemberTypeDeclaration()) {
+ isvisible &= Flags.isPublic(flags);
+ }
+ else {
+ isvisible &= !Flags.isPrivate(flags) && !Flags.isPackageDefault(flags);
+ }
+ fStack.push(new Item(getTypeName(node), node.getModifiers(), isvisible));
return true;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#endVisit(org.eclipse.jdt.core.dom.EnumDeclaration)
+ */
public void endVisit(EnumDeclaration node){
fStack.pop();
+ if(!fStack.isEmpty()) {
+ Item item = (Item) fStack.peek();
+ isvisible = item.visible;
+ }
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#endVisit(org.eclipse.jdt.core.dom.CompilationUnit)
+ */
public void endVisit(CompilationUnit node) {
fStack.clear();
}
@@ -202,6 +214,15 @@ public class TagValidator extends ASTVisitor {
IApiProblem.UNSUPPORTED_TAG_USE,
IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
BuilderMessages.TagValidator_an_enum);
+ continue;
+ }
+ if(!item.visible) {
+ processTagProblem(item.typename,
+ tag,
+ IElementDescriptor.TYPE,
+ IApiProblem.UNSUPPORTED_TAG_USE,
+ IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
+ BuilderMessages.TagValidator_enum_not_visible);
}
}
break;
@@ -225,7 +246,7 @@ public class TagValidator extends ASTVisitor {
}
case ASTNode.ANNOTATION_TYPE_DECLARATION: {
Item item = (Item) fStack.peek();
- Set supported = getSupportedTagNames(IApiJavadocTag.TYPE_ENUM, IApiJavadocTag.MEMBER_NONE);
+ Set supported = getSupportedTagNames(IApiJavadocTag.TYPE_ANNOTATION, IApiJavadocTag.MEMBER_NONE);
for (Iterator i = tags.iterator(); i.hasNext();) {
TagElement tag = (TagElement) i.next();
String tagname = tag.getTagName();
@@ -239,6 +260,15 @@ public class TagValidator extends ASTVisitor {
IApiProblem.UNSUPPORTED_TAG_USE,
IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
BuilderMessages.TagValidator_an_annotation);
+ continue;
+ }
+ if(!item.visible) {
+ processTagProblem(item.typename,
+ tag,
+ IElementDescriptor.TYPE,
+ IApiProblem.UNSUPPORTED_TAG_USE,
+ IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
+ BuilderMessages.TagValidator_annotation_not_visible);
}
}
break;
@@ -301,7 +331,6 @@ public class TagValidator extends ASTVisitor {
}
else {
Set supportedtags = getSupportedTagNames(type.isInterface() ? IApiJavadocTag.TYPE_INTERFACE : IApiJavadocTag.TYPE_CLASS, IApiJavadocTag.MEMBER_NONE);
- boolean visible = item.allints && item.visible;
if(!type.isInterface()) {
int flags = type.getModifiers();
if(!supportedtags.contains(tagname)) {
@@ -361,7 +390,7 @@ public class TagValidator extends ASTVisitor {
IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
BuilderMessages.TagValidator_an_interface);
}
- else if(!visible) {
+ else if(!item.visible) {
processTagProblem(item.typename,
tag,
IElementDescriptor.TYPE,
@@ -450,7 +479,7 @@ public class TagValidator extends ASTVisitor {
IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
BuilderMessages.TagValidator_an_interface_field);
}
- else if(!(item.visible && item.allints)) {
+ else if(!item.visible) {
processTagProblem(item.typename,
tag,
IElementDescriptor.FIELD,
@@ -578,7 +607,7 @@ public class TagValidator extends ASTVisitor {
IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
BuilderMessages.TagValidator_an_interface_method);
}
- else if(!(item.allints && item.visible)) {
+ else if(!item.visible) {
processTagProblem(item.typename,
tag,
IElementDescriptor.METHOD,
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/buildermessages.properties b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/buildermessages.properties
index 3935e3f..7cd3e41 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/buildermessages.properties
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/buildermessages.properties
@@ -69,8 +69,10 @@ TagValidator_an_interface_field=an interface field
TagValidator_an_interface_method=an interface method
TagValidator_an_interface_that_is_not_visible=an interface that is not visible
TagValidator_annotation_field=an annotation field
+TagValidator_annotation_not_visible=an annotation that is not visible
TagValidator_constructor_in_final_class=a constructor in a final class
TagValidator_enum_field=an enum field
+TagValidator_enum_not_visible=an enum that is not visible
TagValidator_final_constructor=a final constructor
TagValidator_not_visible_constructor=a constructor that is not visible
TagValidator_not_visible_enum_field=an enum field that is not visible
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/JavaUtils.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/JavaUtils.java
deleted file mode 100644
index 7e11e7c..0000000
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/JavaUtils.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) Aug 13, 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
- *******************************************************************************/
-package org.eclipse.pde.api.tools.internal.util;
-
-import org.eclipse.jdt.core.Flags;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-
-/**
- * A collection of utility methods to help with handling {@link org.eclipse.jdt.core.IJavaElement}s
- * and {@link org.eclipse.jdt.core.dom.AST} elements
- *
- * @since 1.0.600
- */
-public class JavaUtils {
-
- private JavaUtils() {}
-
- /**
- * Returns if the given {@link IJavaElement} is externally visible
- *
- * @param element
- * @return <code>true</code> if the given element is visible <code>false</code> otherwise
- * @throws JavaModelException if a model lookup fails
- */
- public static final boolean isVisible(IJavaElement element) throws JavaModelException {
- if(element != null) {
- switch(element.getElementType()) {
- case IJavaElement.FIELD:
- case IJavaElement.METHOD: {
- IMember member = (IMember) element;
- int flags = member.getFlags();
- IType type = member.getDeclaringType();
- if(Flags.isPublic(flags) || Flags.isProtected(flags) || (type != null && type.isInterface())) {
- return isVisible(type);
- }
- break;
- }
- case IJavaElement.TYPE: {
- IType type = (IType) element;
- int flags = type.getFlags();
- if(type.isLocal() && !type.isAnonymous()) {
- return false;
- }
- if(type.isMember()) {
- if((Flags.isPublic(flags) && Flags.isStatic(flags)) || type.isInterface()) {
- return isVisible(type.getDeclaringType());
- }
- }
- else {
- return Flags.isPublic(flags) || type.isInterface();
- }
- break;
- }
- default: {
- break;
- }
-
- }
- }
- return false;
- }
-}