summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Rennie2013-08-22 14:16:52 (EDT)
committerMike Rennie2013-08-22 14:16:52 (EDT)
commit6f1e8e3195c73ba4e71b730b2f74c3e5bea474c8 (patch)
treeba0e3dfd7dfa734ddc9ef0f0b87ec6e1d5976cee
parenta4c8649b25cad9a30be7fd6d4cc83d8acba95fa2 (diff)
downloadeclipse.pde.ui-6f1e8e3195c73ba4e71b730b2f74c3e5bea474c8.zip
eclipse.pde.ui-6f1e8e3195c73ba4e71b730b2f74c3e5bea474c8.tar.gz
eclipse.pde.ui-6f1e8e3195c73ba4e71b730b2f74c3e5bea474c8.tar.bz2
Bug 415596 - Properly place problem markers for restricted annotations
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/usage/AnnotationUsageTests.java347
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/usage/EnumUsageTests.java59
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/usage/UsageTest.java2
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test1.java17
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test2.java19
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test3.java21
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test4.java21
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test5.java21
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test6.java21
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test7.java23
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test8.java24
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test9.java23
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/test-builder/usageprojects/refproject/META-INF/MANIFEST.MF4
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/test-builder/usageprojects/refproject/src/a/NoRefAnnotation.java20
-rw-r--r--apitools/org.eclipse.pde.api.tools.tests/test-builder/usageprojects/refproject/src/e/NoRefEnum.java18
-rw-r--r--apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/JavadocTagManager.java16
-rw-r--r--apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractIllegalTypeReference.java150
-rw-r--r--apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractProblemDetector.java215
-rw-r--r--apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/IllegalAnnotationReferenceDetector.java131
-rw-r--r--apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/ProblemDetectorBuilder.java24
-rw-r--r--apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/Reference.java6
-rw-r--r--apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/ReferenceExtractor.java69
-rw-r--r--apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/TagValidator.java242
-rw-r--r--apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/ApiProblemFactory.java53
-rw-r--r--apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/problemmessages.properties10
-rw-r--r--apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/builder/IReference.java8
-rw-r--r--apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/problems/IApiProblem.java11
27 files changed, 1279 insertions, 296 deletions
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/usage/AnnotationUsageTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/usage/AnnotationUsageTests.java
new file mode 100644
index 0000000..43d69c5
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/usage/AnnotationUsageTests.java
@@ -0,0 +1,347 @@
+/*******************************************************************************
+ * Copyright (c) Aug 22, 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.builder.tests.usage;
+
+import junit.framework.Test;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.pde.api.tools.internal.problems.ApiProblemFactory;
+import org.eclipse.pde.api.tools.internal.provisional.descriptors.IElementDescriptor;
+import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem;
+
+/**
+ * Tests using restricted annotations
+ *
+ * @since 1.0.400
+ */
+public class AnnotationUsageTests extends UsageTest {
+
+ static final String RESTRICTED_ANNOTATION_NAME = "NoRefAnnotation";
+
+ /**
+ * @param name
+ */
+ public AnnotationUsageTests(String name) {
+ super(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.builder.tests.ApiBuilderTest#getDefaultProblemId()
+ */
+ @Override
+ protected int getDefaultProblemId() {
+ return ApiProblemFactory.createProblemId(
+ IApiProblem.CATEGORY_USAGE,
+ IElementDescriptor.TYPE,
+ IApiProblem.ILLEGAL_REFERENCE,
+ IApiProblem.ANNOTATION);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.builder.tests.usage.UsageTest#getTestSourcePath()
+ */
+ @Override
+ protected IPath getTestSourcePath() {
+ return super.getTestSourcePath().append("annotation");
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.builder.tests.ApiBuilderTest#getTestCompliance()
+ */
+ @Override
+ protected String getTestCompliance() {
+ return CompilerOptions.VERSION_1_5;
+ }
+
+ public static Test suite() {
+ return buildTestSuite(AnnotationUsageTests.class);
+ }
+
+ /**
+ * Tests using a restricted annotation on a type during a full build
+ * @throws Exception
+ */
+ public void testAnnotationUsage1F() throws Exception {
+ x1(false);
+ }
+
+ /**
+ * Tests using a restricted annotation on a type during an incremental build
+ * @throws Exception
+ */
+ public void testAnnotationUsage1I() throws Exception {
+ x1(true);
+ }
+
+ private void x1(boolean inc) {
+ String typename = "test1";
+ int problemid = getDefaultProblemId();
+ setExpectedProblemIds(new int[] {
+ problemid
+ });
+ setExpectedLineMappings(new LineMapping[] {
+ new LineMapping(15, problemid, new String[] {RESTRICTED_ANNOTATION_NAME})
+ });
+ setExpectedMessageArgs(new String[][] {
+ {RESTRICTED_ANNOTATION_NAME}
+ });
+ deployUsageTest(typename, inc);
+ }
+
+ /**
+ * Tests using a restricted annotation on a field during a full build
+ * @throws Exception
+ */
+ public void testAnnotationUsage2F() throws Exception {
+ x2(false);
+ }
+
+ /**
+ * Tests using a restricted annotation on a field during an incremental build
+ * @throws Exception
+ */
+ public void testAnnotationUsage2I() throws Exception {
+ x2(true);
+ }
+
+ private void x2(boolean inc) {
+ String typename = "test2";
+ int problemid = getDefaultProblemId();
+ setExpectedProblemIds(new int[] {
+ problemid
+ });
+ setExpectedLineMappings(new LineMapping[] {
+ new LineMapping(17, problemid, new String[] {RESTRICTED_ANNOTATION_NAME})
+ });
+ setExpectedMessageArgs(new String[][] {
+ {RESTRICTED_ANNOTATION_NAME}
+ });
+ deployUsageTest(typename, inc);
+ }
+
+ /**
+ * Tests using a restricted annotation on a method during a full build
+ * @throws Exception
+ */
+ public void testAnnotationUsage3F() throws Exception {
+ x3(false);
+ }
+
+ /**
+ * Tests using a restricted annotation on a method during an incremental build
+ * @throws Exception
+ */
+ public void testAnnotationUsage3I() throws Exception {
+ x3(true);
+ }
+
+ private void x3(boolean inc) {
+ String typename = "test3";
+ int problemid = getDefaultProblemId();
+ setExpectedProblemIds(new int[] {
+ problemid
+ });
+ setExpectedLineMappings(new LineMapping[] {
+ new LineMapping(17, problemid, new String[] {RESTRICTED_ANNOTATION_NAME})
+ });
+ setExpectedMessageArgs(new String[][] {
+ {RESTRICTED_ANNOTATION_NAME}
+ });
+ deployUsageTest(typename, inc);
+ }
+
+ /**
+ * Tests using a restricted annotation on a member type during a full build
+ * @throws Exception
+ */
+ public void testAnnotationUsage4F() throws Exception {
+ x4(false);
+ }
+
+ /**
+ * Tests using a restricted annotation on a member during an incremental build
+ * @throws Exception
+ */
+ public void testAnnotationUsage4I() throws Exception {
+ x4(true);
+ }
+
+ private void x4(boolean inc) {
+ String typename = "test4";
+ int problemid = getDefaultProblemId();
+ setExpectedProblemIds(new int[] {
+ problemid
+ });
+ setExpectedLineMappings(new LineMapping[] {
+ new LineMapping(17, problemid, new String[] {RESTRICTED_ANNOTATION_NAME})
+ });
+ setExpectedMessageArgs(new String[][] {
+ {RESTRICTED_ANNOTATION_NAME}
+ });
+ deployUsageTest(typename, inc);
+ }
+
+ /**
+ * Tests using a restricted annotation on a secondary type during a full build
+ * @throws Exception
+ */
+ public void testAnnotationUsage5F() throws Exception {
+ x5(false);
+ }
+
+ /**
+ * Tests using a restricted annotation on a secondary type during an incremental build
+ * @throws Exception
+ */
+ public void testAnnotationUsage5I() throws Exception {
+ x5(true);
+ }
+
+ private void x5(boolean inc) {
+ String typename = "test5";
+ int problemid = getDefaultProblemId();
+ setExpectedProblemIds(new int[] {
+ problemid
+ });
+ setExpectedLineMappings(new LineMapping[] {
+ new LineMapping(18, problemid, new String[] {RESTRICTED_ANNOTATION_NAME})
+ });
+ setExpectedMessageArgs(new String[][] {
+ {RESTRICTED_ANNOTATION_NAME}
+ });
+ deployUsageTest(typename, inc);
+ }
+
+ /**
+ * Tests using a restricted annotation on a field in a member type during a full build
+ * @throws Exception
+ */
+ public void testAnnotationUsage6F() throws Exception {
+ x6(false);
+ }
+
+ /**
+ * Tests using a restricted annotation on a field in a member type during an incremental build
+ * @throws Exception
+ */
+ public void testAnnotationUsage6I() throws Exception {
+ x6(true);
+ }
+
+ private void x6(boolean inc) {
+ String typename = "test6";
+ int problemid = getDefaultProblemId();
+ setExpectedProblemIds(new int[] {
+ problemid
+ });
+ setExpectedLineMappings(new LineMapping[] {
+ new LineMapping(18, problemid, new String[] {RESTRICTED_ANNOTATION_NAME})
+ });
+ setExpectedMessageArgs(new String[][] {
+ {RESTRICTED_ANNOTATION_NAME}
+ });
+ deployUsageTest(typename, inc);
+ }
+
+ /**
+ * Tests using a restricted annotation on a method in a member type during a full build
+ * @throws Exception
+ */
+ public void testAnnotationUsage7F() throws Exception {
+ x7(false);
+ }
+
+ /**
+ * Tests using a restricted annotation on a method in a member type during an incremental build
+ * @throws Exception
+ */
+ public void testAnnotationUsage7I() throws Exception {
+ x7(true);
+ }
+
+ private void x7(boolean inc) {
+ String typename = "test7";
+ int problemid = getDefaultProblemId();
+ setExpectedProblemIds(new int[] {
+ problemid
+ });
+ setExpectedLineMappings(new LineMapping[] {
+ new LineMapping(18, problemid, new String[] {RESTRICTED_ANNOTATION_NAME})
+ });
+ setExpectedMessageArgs(new String[][] {
+ {RESTRICTED_ANNOTATION_NAME}
+ });
+ deployUsageTest(typename, inc);
+ }
+
+ /**
+ * Tests using a restricted annotation on a member type of a secondary type during a full build
+ * @throws Exception
+ */
+ public void testAnnotationUsage8F() throws Exception {
+ x8(false);
+ }
+
+ /**
+ * Tests using a restricted annotation on a member type or a secondary type during an incremental build
+ * @throws Exception
+ */
+ public void testAnnotationUsage8I() throws Exception {
+ x8(true);
+ }
+
+ private void x8(boolean inc) {
+ String typename = "test8";
+ int problemid = getDefaultProblemId();
+ setExpectedProblemIds(new int[] {
+ problemid
+ });
+ setExpectedLineMappings(new LineMapping[] {
+ new LineMapping(20, problemid, new String[] {RESTRICTED_ANNOTATION_NAME})
+ });
+ setExpectedMessageArgs(new String[][] {
+ {RESTRICTED_ANNOTATION_NAME}
+ });
+ deployUsageTest(typename, inc);
+ }
+
+ /**
+ * Tests using a restricted annotation on a local type during a full build
+ * @throws Exception
+ */
+ public void testAnnotationUsage9F() throws Exception {
+ x9(false);
+ }
+
+ /**
+ * Tests using a restricted annotation on a local type during an incremental build
+ * @throws Exception
+ */
+ public void testAnnotationUsage9I() throws Exception {
+ x9(true);
+ }
+
+ private void x9(boolean inc) {
+ String typename = "test9";
+ int problemid = getDefaultProblemId();
+ setExpectedProblemIds(new int[] {
+ problemid
+ });
+ setExpectedLineMappings(new LineMapping[] {
+ new LineMapping(18, problemid, new String[] {RESTRICTED_ANNOTATION_NAME})
+ });
+ setExpectedMessageArgs(new String[][] {
+ {RESTRICTED_ANNOTATION_NAME}
+ });
+ deployUsageTest(typename, inc);
+ }
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/usage/EnumUsageTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/usage/EnumUsageTests.java
new file mode 100644
index 0000000..a0142b3
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/usage/EnumUsageTests.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) Aug 22, 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.builder.tests.usage;
+
+import junit.framework.Test;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+
+/**
+ * Tests using restricted enums
+ *
+ * @since 1.0.400
+ */
+public class EnumUsageTests extends UsageTest {
+
+ /**
+ * @param name
+ */
+ public EnumUsageTests(String name) {
+ super(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.builder.tests.ApiBuilderTest#getDefaultProblemId()
+ */
+ @Override
+ protected int getDefaultProblemId() {
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.builder.tests.usage.UsageTest#getTestSourcePath()
+ */
+ @Override
+ protected IPath getTestSourcePath() {
+ return super.getTestSourcePath().append("enum");
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.builder.tests.ApiBuilderTest#getTestCompliance()
+ */
+ @Override
+ protected String getTestCompliance() {
+ return CompilerOptions.VERSION_1_5;
+ }
+
+ public static Test suite() {
+ return buildTestSuite(EnumUsageTests.class);
+ }
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/usage/UsageTest.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/usage/UsageTest.java
index 2139a2d..940888d 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/usage/UsageTest.java
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/usage/UsageTest.java
@@ -224,6 +224,8 @@ public abstract class UsageTest extends ApiBuilderTest {
classes.add(Java5FieldUsageTests.class);
classes.add(Java5MethodUsageTests.class);
classes.add(Java5ClassUsageTests.class);
+ classes.add(AnnotationUsageTests.class);
+ classes.add(EnumUsageTests.class);
}
if(ProjectUtils.isJava7Compatible()) {
classes.add(Java7MethodUsageTests.class);
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test1.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test1.java
new file mode 100644
index 0000000..e6f4914
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test1.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) Aug 22, 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 x.y.z;
+
+import a.NoRefAnnotation;
+
+@NoRefAnnotation
+public class test1 {
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test2.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test2.java
new file mode 100644
index 0000000..41fa16e
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test2.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) Aug 22, 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 x.y.z;
+
+import a.NoRefAnnotation;
+
+public class test2 {
+
+ @NoRefAnnotation
+ String name = "";
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test3.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test3.java
new file mode 100644
index 0000000..4ab9cd8
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test3.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) Aug 22, 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 x.y.z;
+
+import a.NoRefAnnotation;
+
+public class test3 {
+
+ @NoRefAnnotation
+ void method1() {
+
+ }
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test4.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test4.java
new file mode 100644
index 0000000..fd8dffe
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test4.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) Aug 22, 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 x.y.z;
+
+import a.NoRefAnnotation;
+
+public class test4 {
+
+ @NoRefAnnotation
+ class inner {
+
+ }
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test5.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test5.java
new file mode 100644
index 0000000..57e2236
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test5.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) Aug 22, 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 x.y.z;
+
+import a.NoRefAnnotation;
+
+public class test5 {
+
+}
+@NoRefAnnotation
+class outer {
+
+} \ No newline at end of file
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test6.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test6.java
new file mode 100644
index 0000000..a53c74a
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test6.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) Aug 22, 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 x.y.z;
+
+import a.NoRefAnnotation;
+
+public class test6 {
+
+ class inner {
+ @NoRefAnnotation
+ String name = "";
+ }
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test7.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test7.java
new file mode 100644
index 0000000..bf75181
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test7.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) Aug 22, 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 x.y.z;
+
+import a.NoRefAnnotation;
+
+public class test7 {
+
+ class inner {
+ @NoRefAnnotation
+ void method1() {
+
+ }
+ }
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test8.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test8.java
new file mode 100644
index 0000000..5b76578
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test8.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) Aug 22, 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 x.y.z;
+
+import a.NoRefAnnotation;
+
+public class test8 {
+
+}
+
+class outer2 {
+ @NoRefAnnotation
+ class inner {
+
+ }
+} \ No newline at end of file
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test9.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test9.java
new file mode 100644
index 0000000..89dc7b0
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/usage/annotation/test9.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) Aug 22, 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 x.y.z;
+
+import a.NoRefAnnotation;
+
+public class test9 {
+
+ void method1 () {
+ @NoRefAnnotation
+ class local {
+
+ }
+ }
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/usageprojects/refproject/META-INF/MANIFEST.MF b/apitools/org.eclipse.pde.api.tools.tests/test-builder/usageprojects/refproject/META-INF/MANIFEST.MF
index afde6da..80820ac 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/test-builder/usageprojects/refproject/META-INF/MANIFEST.MF
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/usageprojects/refproject/META-INF/MANIFEST.MF
@@ -3,7 +3,9 @@ Bundle-ManifestVersion: 2
Bundle-Name: refproject
Bundle-SymbolicName: refproject
Bundle-Version: 1.0.0
-Export-Package: c,
+Export-Package: a,
+ c,
+ e,
f,
i,
m,
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/usageprojects/refproject/src/a/NoRefAnnotation.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/usageprojects/refproject/src/a/NoRefAnnotation.java
new file mode 100644
index 0000000..253057c
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/usageprojects/refproject/src/a/NoRefAnnotation.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) Aug 21, 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;
+
+import java.lang.annotation.Documented;
+
+/**
+ * @noreference This annotation is not intended to be referenced by clients.
+ */
+public @interface NoRefAnnotation {
+
+}
diff --git a/apitools/org.eclipse.pde.api.tools.tests/test-builder/usageprojects/refproject/src/e/NoRefEnum.java b/apitools/org.eclipse.pde.api.tools.tests/test-builder/usageprojects/refproject/src/e/NoRefEnum.java
new file mode 100644
index 0000000..8d89c3f
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools.tests/test-builder/usageprojects/refproject/src/e/NoRefEnum.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) Apr 11, 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 e;
+
+/**
+ * @noreference This enum is not intended to be referenced by clients.
+ */
+public enum NoRefEnum {
+
+}
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/JavadocTagManager.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/JavadocTagManager.java
index 8cf83b9..9d0a3f2 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/JavadocTagManager.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/JavadocTagManager.java
@@ -162,21 +162,21 @@ public final class JavadocTagManager {
newtag.setApplicableTo(IApiJavadocTag.TYPE_CLASS,
IApiJavadocTag.MEMBER_METHOD,
CoreMessages.JavadocTagManager_method_no_reference);
+ newtag.setApplicableTo(IApiJavadocTag.TYPE_CLASS,
+ IApiJavadocTag.MEMBER_CONSTRUCTOR,
+ CoreMessages.JavadocTagManager_constructor_no_reference);
+ newtag.setApplicableTo(IApiJavadocTag.TYPE_CLASS,
+ IApiJavadocTag.MEMBER_FIELD,
+ CoreMessages.JavadocTagManager_field_no_reference);
newtag.setApplicableTo(IApiJavadocTag.TYPE_INTERFACE,
IApiJavadocTag.MEMBER_METHOD,
CoreMessages.JavadocTagManager_method_no_reference);
newtag.setApplicableTo(IApiJavadocTag.TYPE_INTERFACE,
- IApiJavadocTag.MEMBER_NONE,
- CoreMessages.JavadocTagManager_interface_no_reference);
- newtag.setApplicableTo(IApiJavadocTag.TYPE_CLASS,
IApiJavadocTag.MEMBER_FIELD,
CoreMessages.JavadocTagManager_field_no_reference);
newtag.setApplicableTo(IApiJavadocTag.TYPE_INTERFACE,
- IApiJavadocTag.MEMBER_FIELD,
- CoreMessages.JavadocTagManager_field_no_reference);
- newtag.setApplicableTo(IApiJavadocTag.TYPE_CLASS,
- IApiJavadocTag.MEMBER_CONSTRUCTOR,
- CoreMessages.JavadocTagManager_constructor_no_reference);
+ IApiJavadocTag.MEMBER_NONE,
+ CoreMessages.JavadocTagManager_interface_no_reference);
newtag.setApplicableTo(IApiJavadocTag.TYPE_ENUM,
IApiJavadocTag.MEMBER_NONE,
CoreMessages.JavadocTagManager_enum_no_reference);
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractIllegalTypeReference.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractIllegalTypeReference.java
index 20c5505..9424623 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractIllegalTypeReference.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractIllegalTypeReference.java
@@ -15,19 +15,10 @@ import java.util.Map;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.Signature;
import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.ASTParser;
-import org.eclipse.jdt.core.dom.ASTVisitor;
-import org.eclipse.jdt.core.dom.AnonymousClassDeclaration;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.Position;
@@ -47,67 +38,11 @@ import org.eclipse.pde.api.tools.internal.util.Signatures;
* Base implementation of a problem detector for type references
*
* @since 1.1
- * @noextend This class is not intended to be subclassed by clients.
+ * @noextend This class is not intended to be sub-classed by clients.
*/
public abstract class AbstractIllegalTypeReference extends AbstractProblemDetector {
/**
- * Class used to look up the name of the enclosing method for an {@link IApiType} when we do not have any
- * enclosing method infos (pre Java 1.5 class files
- */
- class MethodFinder extends ASTVisitor {
- IMethod method = null;
- private IType jtype = null;
- private ApiType type = null;
-
- public MethodFinder(ApiType type, IType jtype) {
- this.type = type;
- this.jtype = jtype;
- }
- public boolean visit(AnonymousClassDeclaration node) {
- if(method == null) {
- ITypeBinding binding = node.resolveBinding();
- String binaryName = binding.getBinaryName();
- if(type.getName().endsWith(binaryName)) {
- try {
- IJavaElement element = jtype.getCompilationUnit().getElementAt(node.getStartPosition());
- if(element != null) {
- IJavaElement ancestor = element.getAncestor(IJavaElement.METHOD);
- if(ancestor != null) {
- method = (IMethod) ancestor;
- }
- }
- }
- catch(JavaModelException jme) {}
- return false;
- }
- }
- return true;
- }
- public boolean visit(TypeDeclaration node) {
- if(method == null && node.isLocalTypeDeclaration()) {
- ITypeBinding binding = node.resolveBinding();
- String binaryName = binding.getBinaryName();
- if(type.getName().endsWith(binaryName)) {
- try {
- IJavaElement element = jtype.getCompilationUnit().getElementAt(node.getStartPosition());
- if(element.getElementType() == IJavaElement.TYPE) {
- IType ltype = (IType) element;
- IJavaElement parent = ltype.getParent();
- if(parent.getElementType() == IJavaElement.METHOD) {
- method = (IMethod) parent;
- }
- }
- }
- catch(JavaModelException jme) {}
- return false;
- }
- }
- return true;
- }
- };
-
- /**
* Map of fully qualified type names to associated component IDs that
* represent illegal references
*/
@@ -155,90 +90,7 @@ public abstract class AbstractIllegalTypeReference extends AbstractProblemDetect
return isReferenceFromComponent(reference, componentId);
}
- /**
- * Returns the enclosing {@link IMethod} for the given type or <code>null</code>
- * if it cannot be computed
- * @param type
- * @param jtype
- * @param reference
- * @param document
- * @return the {@link IMethod} enclosing the given type or <code>null</code>
- * @throws CoreException
- */
- protected IMethod getEnclosingMethod(final IType jtype, IReference reference, IDocument document) throws CoreException {
- IApiMember member = reference.getMember();
- if((member.getType() == IApiElement.TYPE)) {
- ApiType type = (ApiType) member;
- IApiMethod apimethod = type.getEnclosingMethod();
- if(apimethod != null) {
- String signature = Signatures.processMethodSignature(apimethod);
- String methodname = Signatures.getMethodName(apimethod);
- IMethod method = jtype.getMethod(methodname, Signature.getParameterTypes(signature));
- if(method.exists()) {
- return method;
- }
- }
- else {
- //try to look it up
- IMethod method = null;
- if(reference.getLineNumber() > -1) {
- try {
- int offset = document.getLineOffset(reference.getLineNumber());
- method = quickLookup(jtype, document, reference, offset);
- }
- catch(BadLocationException ble) {}
- }
- if(method == null) {
- //look it up the hard way
- ISourceRange range = jtype.getCompilationUnit().getSourceRange();
- ASTParser parser = ASTParser.newParser(AST.JLS4);
- parser.setSource(jtype.getCompilationUnit());
- parser.setSourceRange(range.getOffset(), range.getLength());
- parser.setResolveBindings(true);
- ASTNode ptype = parser.createAST(null);
- MethodFinder finder = new MethodFinder(type, jtype);
- ptype.accept(finder);
- method = finder.method;
- }
- if(method != null && method.exists()) {
- ApiType etype = (ApiType) type.getEnclosingType();
- IApiMethod[] methods = etype.getMethods();
- String msig = null;
- for (int i = 0; i < methods.length; i++) {
- msig = methods[i].getSignature();
- if(Signatures.getMethodName(methods[i]).equals(method.getElementName()) &&
- Signatures.matchesSignatures(msig.replace('/', '.'), method.getSignature())) {
- type.setEnclosingMethodInfo(methods[i].getName(), msig);
- }
- }
- return method;
- }
- }
- }
- return null;
- }
- /**
- * Performs a quick look-up using the offset into the the {@link ICompilationUnit}
- * @param jtype
- * @param document
- * @param reference
- * @param offset
- * @return
- * @throws JavaModelException
- */
- protected IMethod quickLookup(final IType jtype, IDocument document, IReference reference, int offset) throws JavaModelException {
- if(offset > -1) {
- IJavaElement element = jtype.getCompilationUnit().getElementAt(offset);
- if(element != null) {
- IJavaElement ancestor = element.getAncestor(IJavaElement.METHOD);
- if (ancestor != null) {
- return (IMethod) ancestor;
- }
- }
- }
- return null;
- }
/* (non-Javadoc)
* @see org.eclipse.pde.api.tools.internal.search.AbstractProblemDetector#getSourceRange(org.eclipse.jdt.core.IType, org.eclipse.jface.text.IDocument, org.eclipse.pde.api.tools.internal.provisional.model.IReference)
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractProblemDetector.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractProblemDetector.java
index c7fe8d7..fdd69eb 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractProblemDetector.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractProblemDetector.java
@@ -31,10 +31,18 @@ import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
+import org.eclipse.jdt.core.dom.AST;
+import org.eclipse.jdt.core.dom.ASTNode;
+import org.eclipse.jdt.core.dom.ASTParser;
+import org.eclipse.jdt.core.dom.ASTVisitor;
+import org.eclipse.jdt.core.dom.AnonymousClassDeclaration;
+import org.eclipse.jdt.core.dom.ITypeBinding;
+import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Position;
+import org.eclipse.pde.api.tools.internal.model.ApiType;
import org.eclipse.pde.api.tools.internal.model.ProjectComponent;
import org.eclipse.pde.api.tools.internal.problems.ApiProblemFactory;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
@@ -57,6 +65,62 @@ import org.eclipse.pde.api.tools.internal.util.Util;
public abstract class AbstractProblemDetector implements IApiProblemDetector {
/**
+ * Class used to look up the name of the enclosing method for an {@link IApiType} when we do not have any
+ * enclosing method infos (pre Java 1.5 class files
+ */
+ class MethodFinder extends ASTVisitor {
+ IMethod method = null;
+ private IType jtype = null;
+ private ApiType type = null;
+
+ public MethodFinder(ApiType type, IType jtype) {
+ this.type = type;
+ this.jtype = jtype;
+ }
+ public boolean visit(AnonymousClassDeclaration node) {
+ if(method == null) {
+ ITypeBinding binding = node.resolveBinding();
+ String binaryName = binding.getBinaryName();
+ if(type.getName().endsWith(binaryName)) {
+ try {
+ IJavaElement element = jtype.getCompilationUnit().getElementAt(node.getStartPosition());
+ if(element != null) {
+ IJavaElement ancestor = element.getAncestor(IJavaElement.METHOD);
+ if(ancestor != null) {
+ method = (IMethod) ancestor;
+ }
+ }
+ }
+ catch(JavaModelException jme) {}
+ return false;
+ }
+ }
+ return true;
+ }
+ public boolean visit(TypeDeclaration node) {
+ if(method == null && node.isLocalTypeDeclaration()) {
+ ITypeBinding binding = node.resolveBinding();
+ String binaryName = binding.getBinaryName();
+ if(type.getName().endsWith(binaryName)) {
+ try {
+ IJavaElement element = jtype.getCompilationUnit().getElementAt(node.getStartPosition());
+ if(element.getElementType() == IJavaElement.TYPE) {
+ IType ltype = (IType) element;
+ IJavaElement parent = ltype.getParent();
+ if(parent.getElementType() == IJavaElement.METHOD) {
+ method = (IMethod) parent;
+ }
+ }
+ }
+ catch(JavaModelException jme) {}
+ return false;
+ }
+ }
+ return true;
+ }
+ };
+
+ /**
* List of potential {@link IReference} problems
*/
private List fPotentialProblems = new LinkedList();
@@ -508,6 +572,157 @@ public abstract class AbstractProblemDetector implements IApiProblemDetector {
}
/**
+ * Tries to find the given {@link IApiField} in the given {@link IType}. If the field cannot be found
+ * <code>null</code> is returned
+ *
+ * @param type
+ * @param field
+ * @return the {@link IField} matching the given {@link IApiField} or <code>null</code>
+ * @since 1.0.600
+ * @throws JavaModelException
+ */
+ protected IField findFieldInType(IType type, IApiField field) throws JavaModelException {
+ IField match = null;
+ match = type.getField(field.getName());
+ if(!match.exists()) {
+ IField[] fields = type.getFields();
+ //optimistically try to find the first match
+ for (int i = 0; i < fields.length; i++) {
+ if(fields[i].getElementName().equals(field.getName())) {
+ match = fields[i];
+ break;
+ }
+ }
+ }
+ return match;
+ }
+
+ /**
+ * Tries to find the given {@link IApiType} in the given {@link IType}. If no match is found
+ * <code>null</code> is returned.
+ * @param type
+ * @param apitype
+ * @param reference
+ * @param doc
+ * @return the matching {@link IType} or <code>null</code>
+ * @since 1.0.600
+ * @throws CoreException
+ * @throws JavaModelException
+ */
+ protected IType findTypeInType(IType type, IApiType apitype, IReference reference, IDocument doc) throws CoreException, JavaModelException {
+ if(apitype.isLocal()) {
+ String name = apitype.getSimpleName();
+ ICompilationUnit cunit = type.getCompilationUnit();
+ if(cunit.isWorkingCopy()) {
+ cunit.reconcile(AST.JLS4, false, null, null);
+ }
+ IMethod method = getEnclosingMethod(type, reference, doc);
+ if(method != null) {
+ return method.getType(name, 1);
+ }
+ }
+ String tname = type.getElementName();
+ if(tname.equals(apitype.getName()) ||
+ tname.equals(apitype.getSimpleName())) {
+ return type;
+ }
+ IType match = null;
+ IType[] types = type.getTypes();
+ for (int i = 0; i < types.length; i++) {
+ if((types[i].getElementName().equals(apitype.getName()))) {
+ match = types[i];
+ break;
+ }
+ }
+ return match;
+ }
+
+ /**
+ * Returns the enclosing {@link IMethod} for the given type or <code>null</code>
+ * if it cannot be computed
+ * @param type
+ * @param jtype
+ * @param reference
+ * @param document
+ * @return the {@link IMethod} enclosing the given type or <code>null</code>
+ * @throws CoreException
+ */
+ protected IMethod getEnclosingMethod(final IType jtype, IReference reference, IDocument document) throws CoreException {
+ IApiMember member = reference.getMember();
+ if((member.getType() == IApiElement.TYPE)) {
+ ApiType type = (ApiType) member;
+ IApiMethod apimethod = type.getEnclosingMethod();
+ if(apimethod != null) {
+ String signature = Signatures.processMethodSignature(apimethod);
+ String methodname = Signatures.getMethodName(apimethod);
+ IMethod method = jtype.getMethod(methodname, Signature.getParameterTypes(signature));
+ if(method.exists()) {
+ return method;
+ }
+ }
+ else {
+ //try to look it up
+ IMethod method = null;
+ if(reference.getLineNumber() > -1) {
+ try {
+ int offset = document.getLineOffset(reference.getLineNumber());
+ method = quickLookup(jtype, document, reference, offset);
+ }
+ catch(BadLocationException ble) {}
+ }
+ if(method == null) {
+ //look it up the hard way
+ ISourceRange range = jtype.getCompilationUnit().getSourceRange();
+ ASTParser parser = ASTParser.newParser(AST.JLS4);
+ parser.setSource(jtype.getCompilationUnit());
+ parser.setSourceRange(range.getOffset(), range.getLength());
+ parser.setResolveBindings(true);
+ ASTNode ptype = parser.createAST(null);
+ MethodFinder finder = new MethodFinder(type, jtype);
+ ptype.accept(finder);
+ method = finder.method;
+ }
+ if(method != null && method.exists()) {
+ ApiType etype = (ApiType) type.getEnclosingType();
+ IApiMethod[] methods = etype.getMethods();
+ String msig = null;
+ for (int i = 0; i < methods.length; i++) {
+ msig = methods[i].getSignature();
+ if(Signatures.getMethodName(methods[i]).equals(method.getElementName()) &&
+ Signatures.matchesSignatures(msig.replace('/', '.'), method.getSignature())) {
+ type.setEnclosingMethodInfo(methods[i].getName(), msig);
+ }
+ }
+ return method;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Performs a quick look-up using the offset into the the {@link ICompilationUnit}
+ * @param jtype
+ * @param document
+ * @param reference
+ * @param offset
+ * @return
+ * @throws JavaModelException
+ */
+ protected IMethod quickLookup(final IType jtype, IDocument document, IReference reference, int offset) throws JavaModelException {
+ if(offset > -1) {
+ IJavaElement element = jtype.getCompilationUnit().getElementAt(offset);
+ if(element != null) {
+ IJavaElement ancestor = element.getAncestor(IJavaElement.METHOD);
+ if (ancestor != null) {
+ return (IMethod) ancestor;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
* Returns the source range for the given {@link IApiMethod} within the given {@link IType}
* @param type the type to look for the method within
* @param reference the reference the method comes from
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/IllegalAnnotationReferenceDetector.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/IllegalAnnotationReferenceDetector.java
new file mode 100644
index 0000000..a835bc7
--- /dev/null
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/IllegalAnnotationReferenceDetector.java
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * Copyright (c) Aug 21, 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.builder;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IAnnotatable;
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.ISourceRange;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Position;
+import org.eclipse.pde.api.tools.internal.provisional.builder.IReference;
+import org.eclipse.pde.api.tools.internal.provisional.model.IApiElement;
+import org.eclipse.pde.api.tools.internal.provisional.model.IApiField;
+import org.eclipse.pde.api.tools.internal.provisional.model.IApiMember;
+import org.eclipse.pde.api.tools.internal.provisional.model.IApiMethod;
+import org.eclipse.pde.api.tools.internal.provisional.model.IApiType;
+import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem;
+import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblemTypes;
+import org.eclipse.pde.api.tools.internal.util.Signatures;
+
+/**
+ * Detector for illegally referenced annotations
+ *
+ * @since 1.0.600
+ */
+public class IllegalAnnotationReferenceDetector extends AbstractIllegalTypeReference {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.internal.provisional.builder.IApiProblemDetector#getReferenceKinds()
+ */
+ public int getReferenceKinds() {
+ return IReference.REF_ANNOTATION_USE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.internal.builder.AbstractProblemDetector#getProblemFlags(org.eclipse.pde.api.tools.internal.provisional.builder.IReference)
+ */
+ protected int getProblemFlags(IReference reference) {
+ return IApiProblem.ANNOTATION;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.internal.builder.AbstractProblemDetector#getProblemKind()
+ */
+ protected int getProblemKind() {
+ return IApiProblem.ILLEGAL_REFERENCE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.internal.builder.AbstractProblemDetector#getSeverityKey()
+ */
+ protected String getSeverityKey() {
+ return IApiProblemTypes.ILLEGAL_REFERENCE;
+ }
+
+ public boolean considerReference(IReference reference) {
+ return super.considerReference(reference);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.internal.builder.AbstractIllegalTypeReference#getSourceRange(org.eclipse.jdt.core.IType, org.eclipse.jface.text.IDocument, org.eclipse.pde.api.tools.internal.provisional.builder.IReference)
+ */
+ protected Position getSourceRange(IType type, IDocument doc, IReference reference) throws CoreException, BadLocationException {
+ IApiMember member = reference.getMember();
+ if(member != null) {
+ IAnnotatable annotable = findAnnotableElement(type, member, reference, doc);
+ if(annotable != null) {
+ IAnnotation[] annots = annotable.getAnnotations();
+ String typename = Signatures.getSimpleTypeName(reference.getResolvedReference().getName());
+ for (int i = 0; i < annots.length; i++) {
+ if(annots[i].getElementName().equals(typename)) {
+ ISourceRange range = annots[i].getNameRange();
+ if(range != null) {
+ //select the '@' as well - augment offset and length accordingly
+ return new Position(range.getOffset()-1, range.getLength()+1);
+ }
+ else {
+ break;
+ }
+ }
+ }
+ }
+ }
+ return defaultSourcePosition(type, reference);
+ }
+
+ /**
+ * Tries to find the {@link IAnnotatable} parent for the given {@link IApiMember}. If the direct parent
+ * cannot be computed return <code>null</code> and not the enclosing {@link IAnnotatable} (if there is one). That way
+ * we can fetch the default illegal type reference message location
+ *
+ * @param type
+ * @param member
+ * @param reference
+ * @param doc
+ * @return the {@link IAnnotatable} parent or <code>null</code> if it could not be computed.
+ * @throws CoreException
+ */
+ IAnnotatable findAnnotableElement(IType type, IApiMember member, IReference reference, IDocument doc) throws CoreException {
+ switch(member.getType()) {
+ case IApiElement.TYPE: {
+ return findTypeInType(type, (IApiType) member, reference, doc);
+ }
+ case IApiElement.FIELD: {
+ return findFieldInType(type, (IApiField) member);
+ }
+ case IApiElement.METHOD: {
+ return findMethodInType(type, (IApiMethod) member);
+ }
+ default: break;
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.api.tools.internal.search.AbstractProblemDetector#getMessageArgs(org.eclipse.pde.api.tools.internal.provisional.model.IReference)
+ */
+ protected String[] getMessageArgs(IReference reference) throws CoreException {
+ return new String[] {getSimpleTypeName(reference.getResolvedReference())};
+ }
+}
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/ProblemDetectorBuilder.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/ProblemDetectorBuilder.java
index 8ae8401..fb007ae 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/ProblemDetectorBuilder.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/ProblemDetectorBuilder.java
@@ -68,6 +68,7 @@ public class ProblemDetectorBuilder extends ApiDescriptionVisitor {
private IllegalOverrideProblemDetector fIllegalOverride = null;
private IllegalMethodReferenceDetector fIllegalMethodRef = null;
private IllegalFieldReferenceDetector fIllegalFieldRef = null;
+ private IllegalAnnotationReferenceDetector fIllegalAnnotationRef = null;
private SystemApiDetector fSystemApiDetector = null;
/**
@@ -123,23 +124,27 @@ public class ProblemDetectorBuilder extends ApiDescriptionVisitor {
}
case IElementDescriptor.TYPE: {
if((fKindMask & K_USE) > 0) {
+ String symbolicname = fComponent.getSymbolicName();
IReferenceTypeDescriptor type = (IReferenceTypeDescriptor) element;
if (RestrictionModifiers.isExtendRestriction(mask) && fIllegalExtends != null) {
- fIllegalExtends.addIllegalType(type, fComponent.getSymbolicName());
+ fIllegalExtends.addIllegalType(type, symbolicname);
}
if (RestrictionModifiers.isImplementRestriction(mask) && fIllegalImplements != null) {
- fIllegalImplements.addIllegalType(type, fComponent.getSymbolicName());
+ fIllegalImplements.addIllegalType(type, symbolicname);
}
if (RestrictionModifiers.isInstantiateRestriction(mask) && fIllegalInstantiate != null) {
- fIllegalInstantiate.addIllegalType(type, fComponent.getSymbolicName());
+ fIllegalInstantiate.addIllegalType(type, symbolicname);
}
if(RestrictionModifiers.isReferenceRestriction(mask)) {
fRestrictedTypes.add(element);
if(fIllegalFieldRef != null) {
- fIllegalFieldRef.addIllegalType(type, fComponent.getSymbolicName());
+ fIllegalFieldRef.addIllegalType(type, symbolicname);
}
if(fIllegalMethodRef != null) {
- fIllegalMethodRef.addIllegalType(type, fComponent.getSymbolicName());
+ fIllegalMethodRef.addIllegalType(type, symbolicname);
+ }
+ if(fIllegalAnnotationRef != null) {
+ fIllegalAnnotationRef.addIllegalType(type, symbolicname);
}
}
}
@@ -147,13 +152,14 @@ public class ProblemDetectorBuilder extends ApiDescriptionVisitor {
}
case IElementDescriptor.METHOD: {
if((fKindMask & K_USE) > 0) {
+ String symbolicname = fComponent.getSymbolicName();
IMethodDescriptor method = (IMethodDescriptor) element;
if(RestrictionModifiers.isOverrideRestriction(mask) && fIllegalOverride != null) {
- fIllegalOverride.addIllegalMethod(method, fComponent.getSymbolicName());
+ fIllegalOverride.addIllegalMethod(method, symbolicname);
}
if(fIllegalMethodRef != null) {
if (RestrictionModifiers.isReferenceRestriction(mask)) {
- fIllegalMethodRef.addIllegalMethod(method, fComponent.getSymbolicName());
+ fIllegalMethodRef.addIllegalMethod(method, symbolicname);
}
}
}
@@ -301,6 +307,8 @@ public class ProblemDetectorBuilder extends ApiDescriptionVisitor {
detectors.add(fIllegalMethodRef);
fIllegalFieldRef = new IllegalFieldReferenceDetector();
detectors.add(fIllegalFieldRef);
+ fIllegalAnnotationRef = new IllegalAnnotationReferenceDetector();
+ detectors.add(fIllegalAnnotationRef);
}
}
else {
@@ -317,6 +325,8 @@ public class ProblemDetectorBuilder extends ApiDescriptionVisitor {
detectors.add(fIllegalMethodRef);
fIllegalFieldRef = new IllegalFieldReferenceDetector();
detectors.add(fIllegalFieldRef);
+ fIllegalAnnotationRef = new IllegalAnnotationReferenceDetector();
+ detectors.add(fIllegalAnnotationRef);
}
}
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/Reference.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/Reference.java
index 322fddf..eb1152b 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/Reference.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/Reference.java
@@ -734,6 +734,12 @@ public class Reference implements IReference {
}
buffer.append("SUPER_CONSTRUCTORMETHOD"); //$NON-NLS-1$
}
+ if((kind & IReference.REF_ANNOTATION_USE) > 0) {
+ if(buffer.length() != 0) {
+ buffer.append(" | "); //$NON-NLS-1$
+ }
+ buffer.append("ANNOTATION_USE"); //$NON-NLS-1$
+ }
if(buffer.length() == 0) {
buffer.append(Util.UNKNOWN_KIND);
}
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/ReferenceExtractor.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/ReferenceExtractor.java
index f269577..fff0075 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/ReferenceExtractor.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/ReferenceExtractor.java
@@ -34,6 +34,8 @@ import org.eclipse.pde.api.tools.internal.provisional.model.IApiMethod;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiType;
import org.eclipse.pde.api.tools.internal.util.Signatures;
import org.eclipse.pde.api.tools.internal.util.Util;
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
import org.objectweb.asm.ClassAdapter;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.FieldVisitor;
@@ -55,7 +57,6 @@ public class ReferenceExtractor extends ClassAdapter {
/**
* A visitor for visiting java 5+ signatures
- * TODO this visitor does not currently visit annotations
*
* ClassSignature = (visitFormalTypeParameter visitClassBound? visitInterfaceBound* )* (visitSuperClass visitInterface* )
* MethodSignature = (visitFormalTypeParameter visitClassBound? visitInterfaceBound* )* (visitParameterType visitReturnType visitExceptionType* )
@@ -200,6 +201,7 @@ public class ReferenceExtractor extends ClassAdapter {
public SignatureVisitor visitTypeArgument(char wildcard) {
return this;
}
+
/* (non-Javadoc)
* @see org.objectweb.asm.signature.SignatureVisitor#visitEnd()
*/
@@ -440,10 +442,6 @@ public class ReferenceExtractor extends ClassAdapter {
this.linePositionTracker.addLineInfo(line, start);
}
- public void visitCode() {
- super.visitCode();
- }
-
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@@ -593,7 +591,45 @@ public class ReferenceExtractor extends ClassAdapter {
}
}
-
+ /* (non-Javadoc)
+ * @see org.objectweb.asm.MethodAdapter#visitAnnotation(java.lang.String, boolean)
+ */
+ public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
+ Type ctype = this.getTypeFromDescription(desc);
+ Reference reference = ReferenceExtractor.this.addTypeReference(ctype, IReference.REF_ANNOTATION_USE);
+ if(reference != null) {
+ linePositionTracker.addLocation(reference);
+ }
+ return null;
+ }
+ }
+
+ /**
+ * {@link FieldVisitor} to track use of types in annotations
+ *
+ * @since 1.0.600
+ */
+ class ClassFileFieldVisitor implements FieldVisitor {
+
+ /* (non-Javadoc)
+ * @see org.objectweb.asm.FieldVisitor#visitAnnotation(java.lang.String, boolean)
+ */
+ public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
+ addTypeReference(Type.getType(desc), IReference.REF_ANNOTATION_USE);
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.objectweb.asm.FieldVisitor#visitAttribute(org.objectweb.asm.Attribute)
+ */
+ public void visitAttribute(Attribute attr) {}
+
+ /* (non-Javadoc)
+ * @see org.objectweb.asm.FieldVisitor#visitEnd()
+ */
+ public void visitEnd() {
+ exitMember();
+ }
}
/**
@@ -903,6 +939,12 @@ public class ReferenceExtractor extends ClassAdapter {
static int TYPE = 0, FIELD = 1, METHOD = 2;
/**
+ * {@link FieldVisitor} used to track and collect references to annotation types
+ * @since 1.0.600
+ */
+ private ClassFileFieldVisitor fieldvisitor = new ClassFileFieldVisitor();
+
+ /**
* Constructor
* @param type the type to extract references from
* @param collector the listing of references to annotate from this pass
@@ -1222,7 +1264,7 @@ public class ReferenceExtractor extends ClassAdapter {
else {
fieldtracker.addField(addTypeReference(Type.getType(desc), IReference.REF_FIELDDECL));
}
- this.exitMember();
+ return fieldvisitor;
}
return null;
}
@@ -1284,6 +1326,19 @@ public class ReferenceExtractor extends ClassAdapter {
}
/* (non-Javadoc)
+ * @see org.objectweb.asm.ClassAdapter#visitAnnotation(java.lang.String, boolean)
+ */
+ public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
+ try {
+ addTypeReference(Type.getType(desc), IReference.REF_ANNOTATION_USE);
+ }
+ catch(ArrayIndexOutOfBoundsException e) {
+ //when file has compile errors this gets thrown, but we can ignore it
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
* @see org.objectweb.asm.ClassVisitor#visitMethod(int, java.lang.String, java.lang.String, java.lang.String, java.lang.String[])
*/
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
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 12bc530..5b738f1 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
@@ -201,22 +201,28 @@ public class TagValidator extends ASTVisitor {
case ASTNode.ENUM_DECLARATION: {
Item item = (Item) fStack.peek();
Set supported = getSupportedTagNames(IApiJavadocTag.TYPE_ENUM, IApiJavadocTag.MEMBER_NONE);
+ HashSet processed = new HashSet();
for (Iterator i = tags.iterator(); i.hasNext();) {
TagElement tag = (TagElement) i.next();
String tagname = tag.getTagName();
if(tagname == null || !JavadocTagManager.ALL_TAGS.contains(tagname)) {
continue;
}
- if(!supported.contains(tagname)) {
+ if(processed.contains(tagname)) {
+ processTagProblem(item.typename,
+ tag,
+ IElementDescriptor.METHOD,
+ IApiProblem.DUPLICATE_TAG_USE,
+ IApiMarkerConstants.DUPLICATE_TAG_MARKER_ID,
+ null);
+ } else if(!supported.contains(tagname)) {
processTagProblem(item.typename,
tag,
IElementDescriptor.TYPE,
IApiProblem.UNSUPPORTED_TAG_USE,
IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
BuilderMessages.TagValidator_an_enum);
- continue;
- }
- if(!item.visible) {
+ } else if(!item.visible) {
processTagProblem(item.typename,
tag,
IElementDescriptor.TYPE,
@@ -224,6 +230,7 @@ public class TagValidator extends ASTVisitor {
IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
BuilderMessages.TagValidator_enum_not_visible);
}
+ processed.add(tagname);
}
break;
}
@@ -247,22 +254,28 @@ public class TagValidator extends ASTVisitor {
case ASTNode.ANNOTATION_TYPE_DECLARATION: {
Item item = (Item) fStack.peek();
Set supported = getSupportedTagNames(IApiJavadocTag.TYPE_ANNOTATION, IApiJavadocTag.MEMBER_NONE);
+ HashSet processed = new HashSet();
for (Iterator i = tags.iterator(); i.hasNext();) {
TagElement tag = (TagElement) i.next();
String tagname = tag.getTagName();
if(tagname == null || !JavadocTagManager.ALL_TAGS.contains(tagname)) {
continue;
}
- if(!supported.contains(tagname)) {
+ if(processed.contains(tagname)) {
+ processTagProblem(item.typename,
+ tag,
+ IElementDescriptor.METHOD,
+ IApiProblem.DUPLICATE_TAG_USE,
+ IApiMarkerConstants.DUPLICATE_TAG_MARKER_ID,
+ null);
+ } else if(!supported.contains(tagname)) {
processTagProblem(item.typename,
tag,
IElementDescriptor.TYPE,
IApiProblem.UNSUPPORTED_TAG_USE,
IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
BuilderMessages.TagValidator_an_annotation);
- continue;
- }
- if(!item.visible) {
+ } else if(!item.visible) {
processTagProblem(item.typename,
tag,
IElementDescriptor.TYPE,
@@ -270,6 +283,7 @@ public class TagValidator extends ASTVisitor {
IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
BuilderMessages.TagValidator_annotation_not_visible);
}
+ processed.add(tagname);
}
break;
}
@@ -563,104 +577,85 @@ public class TagValidator extends ASTVisitor {
}
else {
switch(pkind) {
- case IApiJavadocTag.TYPE_ENUM: {
- if(!supportedtags.contains(tagname)) {
- processTagProblem(item.typename,
- tag,
- IElementDescriptor.METHOD,
- IApiProblem.UNSUPPORTED_TAG_USE,
- IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
- BuilderMessages.TagValidator_an_enum_method);
- }
- else if(Flags.isPrivate(mods)) {
- processTagProblem(item.typename,
- tag,
- IElementDescriptor.METHOD,
- IApiProblem.UNSUPPORTED_TAG_USE,
- IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
- BuilderMessages.TagValidator_private_enum_method);
- }
- else if(Flags.isPackageDefault(mods)) {
- processTagProblem(item.typename,
- tag,
- IElementDescriptor.METHOD,
- IApiProblem.UNSUPPORTED_TAG_USE,
- IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
- BuilderMessages.TagValidator_a_package_default_enum);
- }
- else if(!item.visible) {
- processTagProblem(item.typename,
- tag,
- IElementDescriptor.METHOD,
- IApiProblem.UNSUPPORTED_TAG_USE,
- IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
- BuilderMessages.TagValidator_not_visible_enum_method);
- }
- break;
- }
- case IApiJavadocTag.TYPE_INTERFACE: {
- if(!supportedtags.contains(tagname)) {
- processTagProblem(item.typename,
- tag,
- IElementDescriptor.METHOD,
- IApiProblem.UNSUPPORTED_TAG_USE,
- IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
- BuilderMessages.TagValidator_an_interface_method);
- }
- else if(!item.visible) {
- processTagProblem(item.typename,
- tag,
- IElementDescriptor.METHOD,
- IApiProblem.UNSUPPORTED_TAG_USE,
- IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
- BuilderMessages.TagValidator_not_visible_interface_method);
- }
- break;
- }
- case IApiJavadocTag.TYPE_CLASS: {
- if(!supportedtags.contains(tagname)) {
- processTagProblem(item.typename,
- tag,
- IElementDescriptor.METHOD,
- IApiProblem.UNSUPPORTED_TAG_USE,
- IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
- isconstructor ? BuilderMessages.TagValidator_a_constructor : BuilderMessages.TagValidator_a_method);
- }
- else if(Flags.isPrivate(mods)) {
- processTagProblem(item.typename,
- tag,
- IElementDescriptor.METHOD,
- IApiProblem.UNSUPPORTED_TAG_USE,
- IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
- isconstructor ? BuilderMessages.TagValidator_private_constructor : BuilderMessages.TagValidator_private_method);
+ case IApiJavadocTag.TYPE_ENUM: {
+ if(!supportedtags.contains(tagname)) {
+ processTagProblem(item.typename,
+ tag,
+ IElementDescriptor.METHOD,
+ IApiProblem.UNSUPPORTED_TAG_USE,
+ IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
+ BuilderMessages.TagValidator_an_enum_method);
+ }
+ else if(Flags.isPrivate(mods)) {
+ processTagProblem(item.typename,
+ tag,
+ IElementDescriptor.METHOD,
+ IApiProblem.UNSUPPORTED_TAG_USE,
+ IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
+ BuilderMessages.TagValidator_private_enum_method);
+ }
+ else if(Flags.isPackageDefault(mods)) {
+ processTagProblem(item.typename,
+ tag,
+ IElementDescriptor.METHOD,
+ IApiProblem.UNSUPPORTED_TAG_USE,
+ IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
+ BuilderMessages.TagValidator_a_package_default_enum);
+ }
+ else if(!item.visible) {
+ processTagProblem(item.typename,
+ tag,
+ IElementDescriptor.METHOD,
+ IApiProblem.UNSUPPORTED_TAG_USE,
+ IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
+ BuilderMessages.TagValidator_not_visible_enum_method);
+ }
+ break;
}
- else if(Flags.isPackageDefault(mods)) {
- if(isstatic) {
+ case IApiJavadocTag.TYPE_INTERFACE: {
+ if(!supportedtags.contains(tagname)) {
processTagProblem(item.typename,
tag,
IElementDescriptor.METHOD,
IApiProblem.UNSUPPORTED_TAG_USE,
IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
- isconstructor ? BuilderMessages.TagValidator_static_package_constructor : BuilderMessages.TagValidator_a_static_package_default_method);
+ BuilderMessages.TagValidator_an_interface_method);
}
- else {
+ else if(!item.visible) {
processTagProblem(item.typename,
tag,
IElementDescriptor.METHOD,
IApiProblem.UNSUPPORTED_TAG_USE,
IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
- isconstructor ? BuilderMessages.TagValidator_a_package_default_constructor : BuilderMessages.TagValidator_a_package_default_method);
+ BuilderMessages.TagValidator_not_visible_interface_method);
}
+ break;
}
- else if(JavadocTagManager.TAG_NOOVERRIDE.equals(tagname)) {
- if (Flags.isFinal(mods)) {
+ case IApiJavadocTag.TYPE_CLASS: {
+ if(!supportedtags.contains(tagname)) {
+ processTagProblem(item.typename,
+ tag,
+ IElementDescriptor.METHOD,
+ IApiProblem.UNSUPPORTED_TAG_USE,
+ IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
+ isconstructor ? BuilderMessages.TagValidator_a_constructor : BuilderMessages.TagValidator_a_method);
+ }
+ else if(Flags.isPrivate(mods)) {
+ processTagProblem(item.typename,
+ tag,
+ IElementDescriptor.METHOD,
+ IApiProblem.UNSUPPORTED_TAG_USE,
+ IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
+ isconstructor ? BuilderMessages.TagValidator_private_constructor : BuilderMessages.TagValidator_private_method);
+ }
+ else if(Flags.isPackageDefault(mods)) {
if(isstatic) {
processTagProblem(item.typename,
tag,
IElementDescriptor.METHOD,
IApiProblem.UNSUPPORTED_TAG_USE,
IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
- isconstructor ? BuilderMessages.TagValidator_static_final_constructor : BuilderMessages.TagValidator_a_static_final_method);
+ isconstructor ? BuilderMessages.TagValidator_static_package_constructor : BuilderMessages.TagValidator_a_static_package_default_method);
}
else {
processTagProblem(item.typename,
@@ -668,24 +663,52 @@ public class TagValidator extends ASTVisitor {
IElementDescriptor.METHOD,
IApiProblem.UNSUPPORTED_TAG_USE,
IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
- isconstructor ? BuilderMessages.TagValidator_final_constructor : BuilderMessages.TagValidator_a_final_method);
+ isconstructor ? BuilderMessages.TagValidator_a_package_default_constructor : BuilderMessages.TagValidator_a_package_default_method);
}
}
- else if(isstatic) {
- processTagProblem(item.typename,
- tag,
- IElementDescriptor.METHOD,
- IApiProblem.UNSUPPORTED_TAG_USE,
- IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
- isconstructor ? BuilderMessages.TagValidator_a_static_constructor : BuilderMessages.TagValidator_a_static_method);
- }
- else if(Flags.isFinal(getParentModifiers(method))) {
- processTagProblem(item.typename,
- tag,
- IElementDescriptor.METHOD,
- IApiProblem.UNSUPPORTED_TAG_USE,
- IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
- isconstructor ? BuilderMessages.TagValidator_constructor_in_final_class : BuilderMessages.TagValidator_a_method_in_a_final_class);
+ else if(JavadocTagManager.TAG_NOOVERRIDE.equals(tagname)) {
+ if (Flags.isFinal(mods)) {
+ if(isstatic) {
+ processTagProblem(item.typename,
+ tag,
+ IElementDescriptor.METHOD,
+ IApiProblem.UNSUPPORTED_TAG_USE,
+ IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
+ isconstructor ? BuilderMessages.TagValidator_static_final_constructor : BuilderMessages.TagValidator_a_static_final_method);
+ }
+ else {
+ processTagProblem(item.typename,
+ tag,
+ IElementDescriptor.METHOD,
+ IApiProblem.UNSUPPORTED_TAG_USE,
+ IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
+ isconstructor ? BuilderMessages.TagValidator_final_constructor : BuilderMessages.TagValidator_a_final_method);
+ }
+ }
+ else if(isstatic) {
+ processTagProblem(item.typename,
+ tag,
+ IElementDescriptor.METHOD,
+ IApiProblem.UNSUPPORTED_TAG_USE,
+ IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
+ isconstructor ? BuilderMessages.TagValidator_a_static_constructor : BuilderMessages.TagValidator_a_static_method);
+ }
+ else if(Flags.isFinal(getParentModifiers(method))) {
+ processTagProblem(item.typename,
+ tag,
+ IElementDescriptor.METHOD,
+ IApiProblem.UNSUPPORTED_TAG_USE,
+ IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
+ isconstructor ? BuilderMessages.TagValidator_constructor_in_final_class : BuilderMessages.TagValidator_a_method_in_a_final_class);
+ }
+ else if(!item.visible) {
+ processTagProblem(item.typename,
+ tag,
+ IElementDescriptor.METHOD,
+ IApiProblem.UNSUPPORTED_TAG_USE,
+ IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
+ isconstructor ? BuilderMessages.TagValidator_not_visible_constructor : BuilderMessages.TagValidator_a_method_that_is_not_visible);
+ }
}
else if(!item.visible) {
processTagProblem(item.typename,
@@ -695,21 +718,12 @@ public class TagValidator extends ASTVisitor {
IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
isconstructor ? BuilderMessages.TagValidator_not_visible_constructor : BuilderMessages.TagValidator_a_method_that_is_not_visible);
}
+ break;
}
- else if(!item.visible) {
- processTagProblem(item.typename,
- tag,
- IElementDescriptor.METHOD,
- IApiProblem.UNSUPPORTED_TAG_USE,
- IApiMarkerConstants.UNSUPPORTED_TAG_MARKER_ID,
- isconstructor ? BuilderMessages.TagValidator_not_visible_constructor : BuilderMessages.TagValidator_a_method_that_is_not_visible);
+ default: {
+ break;
}
- break;
}
- default: {
- break;
- }
- }
}
processed.add(tagname);
}
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/ApiProblemFactory.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/ApiProblemFactory.java
index 7a785e2..5539d5e 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/ApiProblemFactory.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/ApiProblemFactory.java
@@ -119,11 +119,15 @@ public class ApiProblemFactory {
for (int i = 0; i < argumentsCharsLength;) {
char c = argumentsChars[i];
switch(c) {
- case '(' :
- balance++;
- break;
- case ')' :
- balance--;
+ case '(' : {
+ balance++;
+ break;
+ }
+ case ')' : {
+ balance--;
+ break;
+ }
+ default: break;
}
if (c == delimiterChars[0] && balance == 0) {
// see if this is a matching delimiter start only if not within parenthesis (balance == 0)
@@ -537,6 +541,7 @@ public class ApiProblemFactory {
case IApiProblem.CATEGORY_API_BASELINE: {
switch(kind) {
case IApiProblem.API_BASELINE_MISSING: return 1;
+ default: break;
}
break;
}
@@ -545,6 +550,7 @@ public class ApiProblemFactory {
case IApiProblem.SINCE_TAG_INVALID: return 2;
case IApiProblem.SINCE_TAG_MALFORMED: return 3;
case IApiProblem.SINCE_TAG_MISSING: return 4;
+ default: break;
}
break;
}
@@ -556,6 +562,7 @@ public class ApiProblemFactory {
case IApiProblem.MINOR_VERSION_CHANGE_NO_NEW_API: return 56;
case IApiProblem.REEXPORTED_MAJOR_VERSION_CHANGE : return 19;
case IApiProblem.REEXPORTED_MINOR_VERSION_CHANGE : return 20;
+ default: break;
}
break;
}
@@ -568,6 +575,7 @@ public class ApiProblemFactory {
case IApiProblem.LOCAL_TYPE: return 18;
case IApiProblem.INDIRECT_LOCAL_REFERENCE: return 37;
case IApiProblem.ANONYMOUS_TYPE: return 27;
+ default: break;
}
break;
}
@@ -576,6 +584,7 @@ public class ApiProblemFactory {
case IApiProblem.NO_FLAGS: return 9;
case IApiProblem.LOCAL_TYPE : return 25;
case IApiProblem.ANONYMOUS_TYPE: return 28;
+ default: break;
}
break;
}
@@ -586,6 +595,8 @@ public class ApiProblemFactory {
case IApiProblem.FIELD: return 12;
case IApiProblem.CONSTRUCTOR_METHOD: return 110;
case IApiProblem.METHOD: return 111;
+ case IApiProblem.ANNOTATION: return 42;
+ default: break;
}
break;
}
@@ -597,6 +608,7 @@ public class ApiProblemFactory {
case IApiProblem.LEAK_RETURN_TYPE: return 16;
case IApiProblem.LEAK_METHOD_PARAMETER: return 17;
case IApiProblem.LEAK_CONSTRUCTOR_PARAMETER: return 109;
+ default: break;
}
break;
}
@@ -611,6 +623,7 @@ public class ApiProblemFactory {
}
case IApiProblem.UNUSED_PROBLEM_FILTERS: return 30;
case IApiProblem.MISSING_EE_DESCRIPTIONS: return 38;
+ default: break;
}
break;
}
@@ -622,12 +635,14 @@ public class ApiProblemFactory {
switch(flags) {
case IDelta.METHOD: return 41;
case IDelta.RESTRICTIONS: return 72;
+ default: break;
}
break;
}
case IDelta.ANNOTATION_ELEMENT_TYPE: {
switch(flags) {
case IDelta.FIELD: return 39;
+ default: break;
}
break;
}
@@ -637,14 +652,18 @@ public class ApiProblemFactory {
case IDelta.METHOD: return 44;
case IDelta.RESTRICTIONS: return 72;
case IDelta.SUPER_INTERFACE_WITH_METHODS : return 133;
+ default: break;
}
break;
}
case IDelta.METHOD_ELEMENT_TYPE : {
switch(flags) {
case IDelta.RESTRICTIONS: return 132;
+ default: break;
}
+ break;
}
+ default: break;
}
switch(flags) {
case IDelta.CLASS_BOUND: return 21;
@@ -653,6 +672,7 @@ public class ApiProblemFactory {
case IDelta.METHOD_WITHOUT_DEFAULT_VALUE: return 29;
case IDelta.TYPE_PARAMETER: return 32;
case IDelta.TYPE_ARGUMENT: return 106;
+ default: break;
}
break;
}
@@ -666,6 +686,7 @@ public class ApiProblemFactory {
case IDelta.NON_FINAL_TO_FINAL: return 118;
case IDelta.STATIC_TO_NON_STATIC: return 121;
case IDelta.NON_STATIC_TO_STATIC: return 69;
+ default: break;
}
break;
}
@@ -676,14 +697,18 @@ public class ApiProblemFactory {
case IDelta.NON_FINAL_TO_FINAL: return 119;
case IDelta.NON_STATIC_TO_STATIC: return 120;
case IDelta.STATIC_TO_NON_STATIC: return 122;
+ default: break;
}
break;
}
case IDelta.CONSTRUCTOR_ELEMENT_TYPE : {
switch(flags) {
case IDelta.DECREASE_ACCESS : return 116;
+ default: break;
}
+ break;
}
+ default: break;
}
switch(flags) {
case IDelta.CLASS_BOUND: return 52;
@@ -698,6 +723,7 @@ public class ApiProblemFactory {
case IDelta.TYPE_CONVERSION: return TYPE_CONVERSION_ID;
case IDelta.VARARGS_TO_ARRAY: return 85;
case IDelta.TYPE_ARGUMENT: return 124;
+ default: break;
}
break;
}
@@ -729,20 +755,25 @@ public class ApiProblemFactory {
case IDelta.SUPERCLASS: return 131;
case IDelta.REEXPORTED_API_TYPE: return 134;
case IDelta.REEXPORTED_TYPE: return 135;
+ default: break;
}
+ break;
}
+ default: break;
}
break;
}
case IApiProblem.CATEGORY_API_COMPONENT_RESOLUTION: {
switch(kind) {
case IApiProblem.API_COMPONENT_RESOLUTION: return 99;
+ default: break;
}
break;
}
case IApiProblem.CATEGORY_FATAL_PROBLEM: {
switch(kind) {
case IApiProblem.FATAL_JDT_BUILDPATH_PROBLEM: return 31;
+ default: break;
}
break;
}
@@ -751,8 +782,11 @@ public class ApiProblemFactory {
case IApiProblem.API_USE_SCAN_TYPE_PROBLEM: return 136 + flags;
case IApiProblem.API_USE_SCAN_METHOD_PROBLEM: return 138 + flags;
case IApiProblem.API_USE_SCAN_FIELD_PROBLEM: return 140 + flags;
+ default: break;
}
+ break;
}
+ default: break;
}
return 0;
}
@@ -770,18 +804,21 @@ public class ApiProblemFactory {
case IApiProblem.CATEGORY_FATAL_PROBLEM: {
switch(problem.getKind()) {
case IApiProblem.FATAL_JDT_BUILDPATH_PROBLEM: return IApiProblemTypes.FATAL_PROBLEMS;
+ default: break;
}
break;
}
case IApiProblem.CATEGORY_API_COMPONENT_RESOLUTION : {
switch(problem.getKind()) {
case IApiProblem.API_COMPONENT_RESOLUTION: return IApiProblemTypes.REPORT_RESOLUTION_ERRORS_API_COMPONENT;
+ default: break;
}
break;
}
case IApiProblem.CATEGORY_API_BASELINE: {
switch(problem.getKind()) {
case IApiProblem.API_BASELINE_MISSING: return IApiProblemTypes.MISSING_DEFAULT_API_BASELINE;
+ default: break;
}
break;
}
@@ -790,6 +827,7 @@ public class ApiProblemFactory {
case IApiProblem.SINCE_TAG_INVALID: return IApiProblemTypes.INVALID_SINCE_TAG_VERSION;
case IApiProblem.SINCE_TAG_MALFORMED: return IApiProblemTypes.MALFORMED_SINCE_TAG;
case IApiProblem.SINCE_TAG_MISSING: return IApiProblemTypes.MISSING_SINCE_TAG;
+ default: break;
}
break;
}
@@ -811,6 +849,7 @@ public class ApiProblemFactory {
case IApiProblem.LEAK_CONSTRUCTOR_PARAMETER:
case IApiProblem.LEAK_METHOD_PARAMETER : return IApiProblemTypes.LEAK_METHOD_PARAM;
case IApiProblem.LEAK_RETURN_TYPE : return IApiProblemTypes.LEAK_METHOD_RETURN_TYPE;
+ default: break;
}
break;
}
@@ -819,6 +858,7 @@ public class ApiProblemFactory {
case IApiProblem.INVALID_REFERENCE_IN_SYSTEM_LIBRARIES: return IApiProblemTypes.INVALID_REFERENCE_IN_SYSTEM_LIBRARIES;
case IApiProblem.UNUSED_PROBLEM_FILTERS: return IApiProblemTypes.UNUSED_PROBLEM_FILTERS;
case IApiProblem.MISSING_EE_DESCRIPTIONS: return IApiProblemTypes.MISSING_EE_DESCRIPTIONS;
+ default: break;
}
break;
}
@@ -830,8 +870,11 @@ public class ApiProblemFactory {
case IApiProblem.API_USE_SCAN_TYPE_PROBLEM : return IApiProblemTypes.API_USE_SCAN_TYPE_SEVERITY;
case IApiProblem.API_USE_SCAN_METHOD_PROBLEM : return IApiProblemTypes.API_USE_SCAN_METHOD_SEVERITY;
case IApiProblem.API_USE_SCAN_FIELD_PROBLEM : return IApiProblemTypes.API_USE_SCAN_FIELD_SEVERITY;
+ default: break;
}
+ break;
}
+ default: break;
}
return null;
}
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/problemmessages.properties b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/problemmessages.properties
index f16f75d..4b1792f 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/problemmessages.properties
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/problemmessages.properties
@@ -8,11 +8,10 @@
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
-# remove messages for 38, 42,
-# 45, 46, 47, 48, 49, 50, 51, 52, 53, 57, 58, 59, 60, 62, 63, 65, 68, 70, 71, 74, 75, 80,
-# 82, 83, 88, 90, 93, 05
+# available message ids 45, 46, 47, 48, 49, 50, 51, 53, 57, 58, 59, 60, 62, 63, 65, 68, 70, 71, 75, 80,
+# 82, 83, 88, 90, 93
-#api baseline
+#API baseline
1 = An API baseline has not been set for the current workspace.
31 = API analysis aborted for ''{0}'' since its build path is incomplete
38 = Execution environment references were not checked for ''{0}'' because no environment descriptions are installed.
@@ -30,7 +29,7 @@
19 = The major version should be incremented in version {0}, because the modification of the version range for the re-exported bundle {1} requires a major version change
20 = The minor version should be incremented in version {0}, because the modification of the version range for the re-exported bundle {1} requires a minor version change
-#api usage problems
+#API usage problems
#{0} = referenced type name
#{1} = local type name
#{2} = field or method name
@@ -57,6 +56,7 @@
35 = The field {1}.{2} referenced in {0} is not defined in the bundle''s required execution environment: {3}
36 = The type {1} referenced in {0} is not defined in the bundle''s required execution environment: {2}
37 = The local type {0} defined in {1} illegally implements {3} via {2}
+42 = The annotation {0} is being illegally referenced
109 = Constructor for {1} with non-API parameter type {0}
110 = {1} illegally references constructor {0}
111 = {1} illegally references method {0}.{2}
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/builder/IReference.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/builder/IReference.java
index f7e068f..d2fb117 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/builder/IReference.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/builder/IReference.java
@@ -294,6 +294,14 @@ public interface IReference {
*/
public static final int REF_SUPER_CONSTRUCTORMETHOD = 0x1 << 29;
/**
+ * Constant representing an annotation member was referenced
+ * <br><br>
+ * Value is: <code>2^30</code>
+ *
+ * @since 1.0.600
+ */
+ public static final int REF_ANNOTATION_USE = 0x1 << 30;
+ /**
* Bit mask used to indicate all kinds of references.
*
* @see #getReferenceKind()
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/problems/IApiProblem.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/problems/IApiProblem.java
index 068b0f2..ff5e727 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/problems/IApiProblem.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/problems/IApiProblem.java
@@ -419,6 +419,17 @@ public interface IApiProblem {
* @see #CATEGORY_USAGE
*/
public static final int INDIRECT_LOCAL_REFERENCE = 13;
+ /**
+ * Flags to indicate a reference to an annotation
+ * <br><br>
+ * Values is: <code>14</code>
+ *
+ * @see #getFlags()
+ * @see #CATEGORY_USAGE
+ *
+ * @since 1.0.600
+ */
+ public static final int ANNOTATION = 14;
/**
* Constant representing the value of a default API profile {@link IApiProblem} kind.