JDK_1_5-Merge with HEAD: v_411a
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest2.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest2.java
index e316b20..0ebe2a9 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest2.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest2.java
@@ -7713,4 +7713,73 @@
expectedReplacedSource,
"diet ast");
}
+/*
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=53624
+ */
+public void test0137(){
+ String str =
+ "public class X {\n" +
+ " void foo(){\n" +
+ " new Object(){\n" +
+ " void bar(){\n" +
+ " super.zzz();\n" +
+ " }\n" +
+ " };\n" +
+ " }\n" +
+ "}\n";
+
+
+ String completeBehind = "zzz(";
+ int cursorLocation = str.indexOf("zzz(") + completeBehind.length() - 1;
+ String expectedCompletionNodeToString = "<NONE>";
+ String expectedParentNodeToString = "<NONE>";
+ String completionIdentifier = "<NONE>";
+ String expectedReplacedSource = "<NONE>";
+ String expectedUnitDisplayString =
+ "public class X {\n" +
+ " public X() {\n" +
+ " }\n" +
+ " void foo() {\n" +
+ " }\n" +
+ "}\n";
+
+ checkDietParse(
+ str.toCharArray(),
+ cursorLocation,
+ expectedCompletionNodeToString,
+ expectedParentNodeToString,
+ expectedUnitDisplayString,
+ completionIdentifier,
+ expectedReplacedSource,
+ "diet ast");
+
+ expectedCompletionNodeToString = "<CompleteOnMessageSend:super.zzz()>";
+ expectedParentNodeToString = "<NONE>";
+ completionIdentifier = "";
+ expectedReplacedSource = "zzz(";
+ expectedUnitDisplayString =
+ "public class X {\n" +
+ " public X() {\n" +
+ " }\n" +
+ " void foo() {\n" +
+ " new Object() {\n" +
+ " () {\n" +
+ " }\n" +
+ " void bar() {\n" +
+ " <CompleteOnMessageSend:super.zzz()>;\n" +
+ " }\n" +
+ " };\n" +
+ " }\n" +
+ "}\n";
+
+ checkMethodParse(
+ str.toCharArray(),
+ cursorLocation,
+ expectedCompletionNodeToString,
+ expectedParentNodeToString,
+ expectedUnitDisplayString,
+ completionIdentifier,
+ expectedReplacedSource,
+ "full ast");
+}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest.java
index 0688e77..23b656c 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest.java
@@ -10,250 +10,405 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Map;
+import java.util.StringTokenizer;
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
+import org.eclipse.jdt.core.tests.util.CompilerTestSetup;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
public abstract class JavadocTest extends AbstractRegressionTest {
+
+ boolean useLibrary = false;
+ static String zipFile = "/TestJavadocVisibility.zip";
+ static final String LINE_SEPARATOR = System.getProperty("line.separator");
+ public static ArrayList allTestClasses = null;
+ static final String DOC_COMMENT_SUPPORT = System.getProperty("doc.support");
+// String docCommentSupport;
+ boolean supportJavadoc;
+ static boolean debug = true;
+ static String[] testNames = null;
+ static int[] testNumbers = null;
+ static int[] testRange = null;
+
+ static {
+ allTestClasses = new ArrayList(6);
+ allTestClasses.add(JavadocTestForClass.class);
+ allTestClasses.add(JavadocTestForConstructor.class);
+ allTestClasses.add(JavadocTestForField.class);
+ allTestClasses.add(JavadocTestForInterface.class);
+ allTestClasses.add(JavadocTestForMethod.class);
+ allTestClasses.add(JavadocTestMixed.class);
+ allTestClasses.add(JavadocTestOptions.class);
+ }
-boolean useLibrary = false;
-static String zipFile = "/TestJavadocVisibility.zip";
-static final String LINE_SEPARATOR = System.getProperty("line.separator");
-public static ArrayList allTestClasses = null;
-
-static {
- allTestClasses = new ArrayList(6);
- allTestClasses.add(JavadocTestForClass.class);
- allTestClasses.add(JavadocTestForConstructor.class);
- allTestClasses.add(JavadocTestForField.class);
- allTestClasses.add(JavadocTestForInterface.class);
- allTestClasses.add(JavadocTestForMethod.class);
- allTestClasses.add(JavadocTestMixed.class);
- allTestClasses.add(JavadocTestOptions.class);
-}
-
-
-public static void addTest(TestSuite suite, Class testClass) {
- TestSuite innerSuite = new TestSuite(testClass);
- suite.addTest(innerSuite);
-}
-public static Test suite() {
- TestSuite suite = new TestSuite(JavadocTest.class.getName());
- for (int i=0; i<allTestClasses.size(); i++) {
- addTest(suite, (Class) allTestClasses.get(i));
+
+ public static void addTest(TestSuite suite, Class testClass) {
+ TestSuite innerSuite = new TestSuite(testClass);
+ suite.addTest(innerSuite);
}
- return new RegressionTestSetup(suite, COMPLIANCE_1_4);
-}
-public JavadocTest(String name) {
- super(name);
-}
-
-public static boolean equals(String c, String s) {
- if (c == null) {
- if (s == null)
- return true;
- else
- return false;
+ public static Test buildSuite(Class testClass) {
+ TestSuite suite = new TestSuite(testClass.getName());
+ int complianceLevels = AbstractCompilerTest.getPossibleComplianceLevels();
+ if ((complianceLevels & AbstractCompilerTest.F_1_3) != 0) {
+ suite.addTest(suiteForComplianceLevel(COMPLIANCE_1_3, testClass));
+ }
+ if ((complianceLevels & AbstractCompilerTest.F_1_4) != 0) {
+ suite.addTest(suiteForComplianceLevel(COMPLIANCE_1_4, testClass));
+ }
+ if ((complianceLevels & AbstractCompilerTest.F_1_5) != 0) {
+ suite.addTest(suiteForComplianceLevel(COMPLIANCE_1_5, testClass));
+ }
+ return suite;
}
- return c.equals(s);
-}
+
+ public static Test suiteForComplianceLevel(String level, Class testClass) {
+ TestSuite suite = new TestSuite(level);
+ try {
+// Class[] paramTypes = new Class[] { String.class, String.class };
+ Class[] paramTypes = new Class[] { String.class };
+ Constructor constructor = testClass.getConstructor(paramTypes);
+ // Javadoc ENABLED
+ String support = CompilerOptions.DISABLED;
+ if (DOC_COMMENT_SUPPORT == null) {
+ suite.addTest(suiteForJavadocSupport(level, testClass, constructor, CompilerOptions.ENABLED));
+// suiteForJavadocSupport(suite, testClass, constructor, CompilerOptions.ENABLED);
+ } else {
+ support = DOC_COMMENT_SUPPORT;
+ }
-protected Map getCompilerOptions() {
- Map options = super.getCompilerOptions();
- options.put(CompilerOptions.OPTION_ReportFieldHiding, CompilerOptions.IGNORE);
- options.put(CompilerOptions.OPTION_ReportSyntheticAccessEmulation, CompilerOptions.IGNORE);
- return options;
-}
-
-protected String[] getDefaultClassPaths() {
- if (useLibrary) {
- String[] classLibs = super.getDefaultClassPaths();
- final int length = classLibs.length;
- String[] newClassPaths = new String[length + 1];
- System.arraycopy(classLibs, 0, newClassPaths, 0, length);
- newClassPaths[length] = getClass().getResource(zipFile).getPath();
- return newClassPaths;
- } else {
- return super.getDefaultClassPaths();
+ // Javadoc DISABLED
+ suite.addTest(suiteForJavadocSupport(level, testClass, constructor, support));
+// suiteForJavadocSupport(suite, testClass, constructor, support);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+// return new RegressionTestSetup(suite, level);
+ return suite;
}
-}
-static String[] referencedClasses = null;
-static {
- referencedClasses =
- new String[] {
- "test/AbstractVisibility.java",
- "package test;\n"
- + "public abstract class AbstractVisibility {\n"
- + " private class AvcPrivate {\n"
- + " private int avf_private = 10;\n"
- + " public int avf_public = avf_private;\n"
- + " private int avm_private() {\n"
- + " avf_private = (new AvcPrivate()).avf_private;\n"
- + " return avf_private;\n"
- + " }\n"
- + " public int avm_public() {\n"
- + " return avm_private();\n"
- + " }\n"
- + " }\n"
- + " public class AvcPublic {\n"
- + " private int avf_private = 10;\n"
- + " public int avf_public = avf_private;\n"
- + " private int avm_private() {\n"
- + " avf_private = (new AvcPrivate()).avf_private;\n"
- + " return avf_private;\n"
- + " }\n"
- + " public int avm_public() {\n"
- + " return avm_private();\n"
- + " }\n"
- + " }\n"
- + " private int avf_private = 100;\n"
- + " public int avf_public = avf_private;\n"
- + " \n"
- + " private int avm_private() {\n"
- + " avf_private = (new AvcPrivate()).avf_private;\n"
- + " return avf_private;\n"
- + " }\n"
- + " public int avm_public() {\n"
- + " return avm_private();\n"
- + " }\n"
- + "}\n",
- "test/Visibility.java",
- "package test;\n"
- + "public class Visibility extends AbstractVisibility {\n"
- + " private class VcPrivate {\n"
- + " private int vf_private = 10;\n"
- + " public int vf_public = vf_private;\n"
- + " private int vm_private() {\n"
- + " vf_private = (new VcPrivate()).vf_private;\n"
- + " avf_private = vf_private;\n"
- + " return vf_private+avf_private;\n"
- + " }\n"
- + " public int vm_public() {\n"
- + " return vm_private();\n"
- + " }\n"
- + " };\n"
- + " public class VcPublic {\n"
- + " private int vf_private = 10;\n"
- + " public int vf_public = vf_private;\n"
- + " private int vm_private() {\n"
- + " vf_private = (new VcPrivate()).vf_private;\n"
- + " avf_private = vf_private;\n"
- + " return vf_private+avf_private;\n"
- + " }\n"
- + " public int vm_public() {\n"
- + " return vm_private();\n"
- + " }\n"
- + " };\n"
- + " private int vf_private = 100;\n"
- + " private int avf_private = 100;\n"
- + " public int vf_public = vf_private;\n"
- + " public int avf_public = vf_private;\n"
- + " \n"
- + " private int vm_private() {\n"
- + " vf_private = (new VcPrivate()).vf_private;\n"
- + " avf_private = vf_private;\n"
- + " return vf_private+avf_private;\n"
- + " }\n"
- + " public int vm_public() {\n"
- + " return vm_private();\n"
- + " }\n"
- + "}\n",
- "test/copy/VisibilityPackage.java",
- "package test.copy;\n"
- + "class VisibilityPackage {\n"
- + " private class VpPrivate {\n"
- + " private int vf_private = 10;\n"
- + " public int vf_public = vf_private;\n"
- + " private int vm_private() {\n"
- + " vf_private = (new VpPrivate()).vf_private;\n"
- + " return vf_private;\n"
- + " }\n"
- + " public int vm_public() {\n"
- + " return vm_private();\n"
- + " }\n"
- + " }\n"
- + " public class VpPublic {\n"
- + " private int vf_private = 10;\n"
- + " public int vf_public = vf_private;\n"
- + " private int vm_private() {\n"
- + " vf_private = (new VpPrivate()).vf_private;\n"
- + " return vf_private;\n"
- + " }\n"
- + " public int vm_public() {\n"
- + " return vm_private();\n"
- + " }\n"
- + " }\n"
- + " private int vf_private = 100;\n"
- + " public int vf_public = vf_private;\n"
- + " \n"
- + " private int vm_private() {\n"
- + " vf_private = (new VpPrivate()).vf_private;\n"
- + " return vf_private;\n"
- + " }\n"
- + " public int vm_public() {\n"
- + " return vm_private();\n"
- + " }\n"
- + "}\n",
- "test/copy/VisibilityPublic.java",
- "package test.copy;\n"
- + "public class VisibilityPublic {\n"
- + " private class VpPrivate {\n"
- + " private int vf_private = 10;\n"
- + " public int vf_public = vf_private;\n"
- + " private int vm_private() {\n"
- + " vf_private = (new VpPrivate()).vf_private;\n"
- + " return vf_private;\n"
- + " }\n"
- + " public int vm_public() {\n"
- + " return vm_private();\n"
- + " }\n"
- + " }\n"
- + " public class VpPublic {\n"
- + " private int vf_private = 10;\n"
- + " public int vf_public = vf_private;\n"
- + " private int vm_private() {\n"
- + " vf_private = (new VpPrivate()).vf_private;\n"
- + " return vf_private;\n"
- + " }\n"
- + " public int vm_public() {\n"
- + " return vm_private();\n"
- + " }\n"
- + " }\n"
- + " private int vf_private = 100;\n"
- + " public int vf_public = vf_private;\n"
- + " \n"
- + " private int vm_private() {\n"
- + " vf_private = (new VpPrivate()).vf_private;\n"
- + " return vf_private;\n"
- + " }\n"
- + " public int vm_public() {\n"
- + " return vm_private();\n"
- + " }\n"
- + "}\n" };
-}
+ public static Test suiteForJavadocSupport(/*TestSuite suite,*/ String level, Class testClass, Constructor constructor, String support) throws InvocationTargetException, IllegalAccessException, InstantiationException {
+ TestSuite suite = new TestSuite("Doc "+support);
+ if (testNames != null) {
+ for (int i = 0; i < testNames.length; i++) {
+ String meth = "test" + testNames[i];
+// Object[] params = {meth, support};
+ Object[] params = {meth};
+ suite.addTest((Test)constructor.newInstance(params));
+ }
+ }
+ else if (testNumbers != null) {
+ for (int i = 0; i < testNumbers.length; i++) {
+ String meth = "test";
+ int num = testNumbers[i];
+ if (num < 10) meth += "0";
+ if (num < 100) meth += "0";
+ meth += num;
+// Object[] params = {meth, support};
+ Object[] params = {meth};
+ suite.addTest((Test)constructor.newInstance(params));
+ }
+ }
+ else if (testRange != null && testRange.length == 2 && testRange[0]>=0 && testRange[0]<=testRange[1]) {
+ for (int i=testRange[0]; i<=testRange[1]; i++) {
+ String meth = "test";
+ if (i<10) meth += "0";
+ if (i<100) meth += "0";
+ meth += i;
+// Object[] params = {meth, support};
+ Object[] params = {meth};
+ suite.addTest((Test)constructor.newInstance(params));
+ }
+ } else {
+ // Run all tests
+ Method[] methods = testClass.getMethods();
+ for (int i = 0, max = methods.length; i < max; i++) {
+ if (methods[i].getModifiers() == 1 && methods[i].getName().startsWith("test")) { //$NON-NLS-1$
+// Object[] params = {methods[i].getName(), support};
+ Object[] params = {methods[i].getName()};
+ suite.addTest((Test)constructor.newInstance(params));
+ }
+ }
+ }
+// return suite;
+ return new RegressionTestSetup(suite, level, support);
+ }
-protected void runConformReferenceTest(String[] testFiles) {
- String[] completedFiles = testFiles;
- if (!useLibrary) {
- completedFiles = new String[testFiles.length + referencedClasses.length];
- System.arraycopy(referencedClasses, 0, completedFiles, 0, referencedClasses.length);
- System.arraycopy(testFiles, 0, completedFiles, referencedClasses.length, testFiles.length);
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(JavadocTest.class.getName());
+ for (int i=0; i<allTestClasses.size(); i++) {
+ suite.addTest(buildSuite((Class) allTestClasses.get(i)));
+ }
+ return suite;
}
- runConformTest(completedFiles);
-}
-protected void runNegativeReferenceTest(String[] testFiles, String expected) {
- String[] completedFiles = testFiles;
- if (!useLibrary) {
- completedFiles = new String[testFiles.length + referencedClasses.length];
- System.arraycopy(referencedClasses, 0, completedFiles, 0, referencedClasses.length);
- System.arraycopy(testFiles, 0, completedFiles, referencedClasses.length, testFiles.length);
+
+ public JavadocTest(String name) {
+ this(name, CompilerOptions.ENABLED);
}
- runNegativeTest(completedFiles, expected);
-}
+ public JavadocTest(String name, String support) {
+ super(name);
+ }
+ /**
+ * @return Returns the docCommentSupport.
+ */
+ public String getNamePrefix() {
+ return "Doc "+(this.supportJavadoc?"on":"off")+" - ";
+ }
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#getName()
+ */
+ public String getName() {
+ if (this.docCommentSupport == null) {
+ return super.getName();
+ } else {
+ return getNamePrefix()+super.getName();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.tests.util.AbstractCompilerTest#initialize(org.eclipse.jdt.core.tests.util.CompilerTestSetup)
+ */
+ public void initialize(CompilerTestSetup setUp) {
+ super.initialize(setUp);
+ this.supportJavadoc = !CompilerOptions.DISABLED.equals(this.docCommentSupport);
+ }
+ protected Map getCompilerOptions() {
+ Map options = super.getCompilerOptions();
+ options.put(CompilerOptions.OPTION_ReportFieldHiding, CompilerOptions.IGNORE);
+ options.put(CompilerOptions.OPTION_ReportSyntheticAccessEmulation, CompilerOptions.IGNORE);
+ options.put(CompilerOptions.OPTION_DocCommentSupport, this.docCommentSupport);
+ return options;
+ }
+
+ protected String[] getDefaultClassPaths() {
+ if (useLibrary) {
+ String[] classLibs = super.getDefaultClassPaths();
+ final int length = classLibs.length;
+ String[] newClassPaths = new String[length + 1];
+ System.arraycopy(classLibs, 0, newClassPaths, 0, length);
+ newClassPaths[length] = getClass().getResource(zipFile).getPath();
+ return newClassPaths;
+ } else {
+ return super.getDefaultClassPaths();
+ }
+ }
+
+ static String[] referencedClasses = null;
+ static {
+ referencedClasses =
+ new String[] {
+ "test/AbstractVisibility.java",
+ "package test;\n"
+ + "public abstract class AbstractVisibility {\n"
+ + " private class AvcPrivate {\n"
+ + " private int avf_private = 10;\n"
+ + " public int avf_public = avf_private;\n"
+ + " private int avm_private() {\n"
+ + " avf_private = (new AvcPrivate()).avf_private;\n"
+ + " return avf_private;\n"
+ + " }\n"
+ + " public int avm_public() {\n"
+ + " return avm_private();\n"
+ + " }\n"
+ + " }\n"
+ + " public class AvcPublic {\n"
+ + " private int avf_private = 10;\n"
+ + " public int avf_public = avf_private;\n"
+ + " private int avm_private() {\n"
+ + " avf_private = (new AvcPrivate()).avf_private;\n"
+ + " return avf_private;\n"
+ + " }\n"
+ + " public int avm_public() {\n"
+ + " return avm_private();\n"
+ + " }\n"
+ + " }\n"
+ + " private int avf_private = 100;\n"
+ + " public int avf_public = avf_private;\n"
+ + " \n"
+ + " private int avm_private() {\n"
+ + " avf_private = (new AvcPrivate()).avf_private;\n"
+ + " return avf_private;\n"
+ + " }\n"
+ + " public int avm_public() {\n"
+ + " return avm_private();\n"
+ + " }\n"
+ + "}\n",
+ "test/Visibility.java",
+ "package test;\n"
+ + "public class Visibility extends AbstractVisibility {\n"
+ + " private class VcPrivate {\n"
+ + " private int vf_private = 10;\n"
+ + " public int vf_public = vf_private;\n"
+ + " private int vm_private() {\n"
+ + " vf_private = (new VcPrivate()).vf_private;\n"
+ + " avf_private = vf_private;\n"
+ + " return vf_private+avf_private;\n"
+ + " }\n"
+ + " public int vm_public() {\n"
+ + " return vm_private();\n"
+ + " }\n"
+ + " };\n"
+ + " public class VcPublic {\n"
+ + " private int vf_private = 10;\n"
+ + " public int vf_public = vf_private;\n"
+ + " private int vm_private() {\n"
+ + " vf_private = (new VcPrivate()).vf_private;\n"
+ + " avf_private = vf_private;\n"
+ + " return vf_private+avf_private;\n"
+ + " }\n"
+ + " public int vm_public() {\n"
+ + " return vm_private();\n"
+ + " }\n"
+ + " };\n"
+ + " private int vf_private = 100;\n"
+ + " private int avf_private = 100;\n"
+ + " public int vf_public = vf_private;\n"
+ + " public int avf_public = vf_private;\n"
+ + " \n"
+ + " private int vm_private() {\n"
+ + " vf_private = (new VcPrivate()).vf_private;\n"
+ + " avf_private = vf_private;\n"
+ + " return vf_private+avf_private;\n"
+ + " }\n"
+ + " public int vm_public() {\n"
+ + " return vm_private();\n"
+ + " }\n"
+ + "}\n",
+ "test/copy/VisibilityPackage.java",
+ "package test.copy;\n"
+ + "class VisibilityPackage {\n"
+ + " private class VpPrivate {\n"
+ + " private int vf_private = 10;\n"
+ + " public int vf_public = vf_private;\n"
+ + " private int vm_private() {\n"
+ + " vf_private = (new VpPrivate()).vf_private;\n"
+ + " return vf_private;\n"
+ + " }\n"
+ + " public int vm_public() {\n"
+ + " return vm_private();\n"
+ + " }\n"
+ + " }\n"
+ + " public class VpPublic {\n"
+ + " private int vf_private = 10;\n"
+ + " public int vf_public = vf_private;\n"
+ + " private int vm_private() {\n"
+ + " vf_private = (new VpPrivate()).vf_private;\n"
+ + " return vf_private;\n"
+ + " }\n"
+ + " public int vm_public() {\n"
+ + " return vm_private();\n"
+ + " }\n"
+ + " }\n"
+ + " private int vf_private = 100;\n"
+ + " public int vf_public = vf_private;\n"
+ + " \n"
+ + " private int vm_private() {\n"
+ + " vf_private = (new VpPrivate()).vf_private;\n"
+ + " return vf_private;\n"
+ + " }\n"
+ + " public int vm_public() {\n"
+ + " return vm_private();\n"
+ + " }\n"
+ + "}\n",
+ "test/copy/VisibilityPublic.java",
+ "package test.copy;\n"
+ + "public class VisibilityPublic {\n"
+ + " private class VpPrivate {\n"
+ + " private int vf_private = 10;\n"
+ + " public int vf_public = vf_private;\n"
+ + " private int vm_private() {\n"
+ + " vf_private = (new VpPrivate()).vf_private;\n"
+ + " return vf_private;\n"
+ + " }\n"
+ + " public int vm_public() {\n"
+ + " return vm_private();\n"
+ + " }\n"
+ + " }\n"
+ + " public class VpPublic {\n"
+ + " private int vf_private = 10;\n"
+ + " public int vf_public = vf_private;\n"
+ + " private int vm_private() {\n"
+ + " vf_private = (new VpPrivate()).vf_private;\n"
+ + " return vf_private;\n"
+ + " }\n"
+ + " public int vm_public() {\n"
+ + " return vm_private();\n"
+ + " }\n"
+ + " }\n"
+ + " private int vf_private = 100;\n"
+ + " public int vf_public = vf_private;\n"
+ + " \n"
+ + " private int vm_private() {\n"
+ + " vf_private = (new VpPrivate()).vf_private;\n"
+ + " return vf_private;\n"
+ + " }\n"
+ + " public int vm_public() {\n"
+ + " return vm_private();\n"
+ + " }\n"
+ + "}\n" };
+ }
+
+ protected void runConformReferenceTest(String[] testFiles) {
+ String[] completedFiles = testFiles;
+ if (!useLibrary) {
+ completedFiles = new String[testFiles.length + referencedClasses.length];
+ System.arraycopy(referencedClasses, 0, completedFiles, 0, referencedClasses.length);
+ System.arraycopy(testFiles, 0, completedFiles, referencedClasses.length, testFiles.length);
+ }
+ runConformTest(completedFiles);
+ }
+ protected void runNegativeReferenceTest(String[] testFiles, String expected) {
+ String[] completedFiles = testFiles;
+ if (!useLibrary) {
+ completedFiles = new String[testFiles.length + referencedClasses.length];
+ System.arraycopy(referencedClasses, 0, completedFiles, 0, referencedClasses.length);
+ System.arraycopy(testFiles, 0, completedFiles, referencedClasses.length, testFiles.length);
+ }
+ runNegativeTest(completedFiles, expected);
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest#runNegativeTest(java.lang.String[], java.lang.String)
+ */
+ protected void runNegativeTest(String[] testFiles, String expectedProblemLog) {
+ if (this.supportJavadoc) {
+ super.runNegativeTest(testFiles, expectedProblemLog);
+ } else {
+ StringTokenizer tokenizer = new StringTokenizer(expectedProblemLog);
+ int errors=0, javadocs=0;
+ while (tokenizer.hasMoreTokens()) {
+ String token = tokenizer.nextToken();
+ if ("ERROR".equals(token) || "WARNING".equals(token)) {
+ errors++;
+ } else if ("Javadoc:".equals(token)) {
+ javadocs++;
+ }
+ }
+ if (errors == javadocs) {
+ super.runConformTest(testFiles);
+ } else if (javadocs == 0) {
+ super.runNegativeTest(testFiles, expectedProblemLog);
+ } else {
+ if (debug) System.out.println("Test "+getName()+" skipped due to non-javadoc compiler errors...");
+ }
+ }
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest#runConformTest(java.lang.String[])
+ */
+ protected void runConformTest(String[] testFiles) {
+ if (this.supportJavadoc) {
+ super.runConformTest(testFiles);
+ } else {
+ if (debug) System.out.println("Test "+getName()+" skipped as identical when Javadoc is enabled...");
+ }
+ }
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForClass.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForClass.java
index 372e695..98e18da 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForClass.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForClass.java
@@ -13,54 +13,21 @@
import java.util.Map;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
public class JavadocTestForClass extends JavadocTest {
+
public static Test suite() {
- if (false) {
- TestSuite ts;
- int[] numbers = { 10, 12 };
- //some of the tests depend on the order of this suite.
- ts = new TestSuite();
- for (int i = 0; i < numbers.length; i++) {
- String meth = "test";
- int num = numbers[i];
- if (num < 10) {
- meth += "0";
- }
- if (num < 100) {
- meth += "0";
- }
- meth += num;
- ts.addTest(new JavadocTestForClass(meth));
- }
- return new RegressionTestSetup(ts, COMPLIANCE_1_4);
- }
- if (false) {
- TestSuite ts;
- //some of the tests depend on the order of this suite.
- ts = new TestSuite();
- for (int i=30; i<=30; i++) {
- String meth = "test";
- if (i<10) {
- meth += "0";
- }
- if (i<100) {
- meth += "0";
- }
- meth += i;
- ts.addTest(new JavadocTestForClass(meth));
- }
- return new RegressionTestSetup(ts, COMPLIANCE_1_4);
- }
- return setupSuite(testClass());
+ return buildSuite(javadocTestClass());
}
public JavadocTestForClass(String name) {
super(name);
}
- public static Class testClass() {
+ public JavadocTestForClass(String name, String support) {
+ super(name, support);
+ }
+ public static Class javadocTestClass() {
return JavadocTestForClass.class;
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForConstructor.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForConstructor.java
index b5077b0..e9c7450 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForConstructor.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForConstructor.java
@@ -18,52 +18,22 @@
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
public class JavadocTestForConstructor extends JavadocTest {
- public static Test suite() {
- if (false) {
- TestSuite ts;
- int[] numbers = { 3 };
- //some of the tests depend on the order of this suite.
- ts = new TestSuite();
- for (int i = 0; i < numbers.length; i++) {
- String meth = "test";
- int num = numbers[i];
- if (num < 10) {
- meth += "0";
- }
- if (num < 100) {
- meth += "0";
- }
- meth += num;
- ts.addTest(new JavadocTestForConstructor(meth));
- }
- return new RegressionTestSetup(ts, COMPLIANCE_1_4);
- }
- if (false) {
- TestSuite ts;
- //some of the tests depend on the order of this suite.
- ts = new TestSuite();
- for (int i=1; i<=8; i++) {
- String meth = "test";
- if (i<10) {
- meth += "0";
- }
- if (i<100) {
- meth += "0";
- }
- meth += i;
- ts.addTest(new JavadocTestForConstructor(meth));
- }
- return new RegressionTestSetup(ts, COMPLIANCE_1_4);
- }
- return setupSuite(testClass());
- }
public JavadocTestForConstructor(String name) {
super(name);
}
- public static Class testClass() {
+ public JavadocTestForConstructor(String name, String support) {
+ super(name, support);
+ }
+ public static Class javadocTestClass() {
return JavadocTestForConstructor.class;
}
+ public static Test suite() {
+ return buildSuite(javadocTestClass());
+ }
+ static { // Use this static to initialize testNames (String[]) , testRange (int[2]), testNumbers (int[])
+ }
+
protected Map getCompilerOptions() {
Map options = super.getCompilerOptions();
options.put(CompilerOptions.OPTION_ReportInvalidJavadoc, CompilerOptions.ERROR);
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForField.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForField.java
index 58aeea3..66e001b 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForField.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForField.java
@@ -18,32 +18,20 @@
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
public class JavadocTestForField extends JavadocTest {
- public static Test suite() {
- if (false) {
- TestSuite ts;
- //some of the tests depend on the order of this suite.
- ts = new TestSuite();
- for (int i=50; i<=80; i++) {
- String meth = "test";
- if (i<10) {
- meth += "0";
- }
- if (i<100) {
- meth += "0";
- }
- meth += i;
- ts.addTest(new JavadocTestForField(meth));
- }
- return new RegressionTestSetup(ts, COMPLIANCE_1_4);
- }
- return setupSuite(testClass());
- }
public JavadocTestForField(String name) {
super(name);
}
- public static Class testClass() {
+ public JavadocTestForField(String name, String support) {
+ super(name, support);
+ }
+ public static Class javadocTestClass() {
return JavadocTestForField.class;
}
+ public static Test suite() {
+ return buildSuite(javadocTestClass());
+ }
+ static { // Use this static to initialize testNames (String[]) , testRange (int[2]), testNumbers (int[])
+ }
protected Map getCompilerOptions() {
Map options = super.getCompilerOptions();
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForInterface.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForInterface.java
index e744bcd..760a096 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForInterface.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForInterface.java
@@ -18,33 +18,22 @@
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
public class JavadocTestForInterface extends JavadocTest {
- public static Test suite() {
- if (false) {
- TestSuite ts;
- //some of the tests depend on the order of this suite.
- ts = new TestSuite();
- for (int i = 61; i <= 61; i++) {
- String meth = "test";
- if (i < 10) {
- meth += "0";
- }
- if (i < 100) {
- meth += "0";
- }
- meth += i;
- ts.addTest(new JavadocTestForInterface(meth));
- }
- return new RegressionTestSetup(ts, COMPLIANCE_1_4);
- }
- return setupSuite(testClass());
- }
public JavadocTestForInterface(String name) {
super(name);
}
- public static Class testClass() {
+ public JavadocTestForInterface(String name, String support) {
+ super(name, support);
+ }
+ public static Class javadocTestClass() {
return JavadocTestForInterface.class;
}
+ public static Test suite() {
+ return buildSuite(javadocTestClass());
+ }
+ static { // Use this static to initialize testNames (String[]) , testRange (int[2]), testNumbers (int[])
+ }
+
protected Map getCompilerOptions() {
Map options = super.getCompilerOptions();
options.put(CompilerOptions.OPTION_ReportInvalidJavadoc, CompilerOptions.ERROR);
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForMethod.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForMethod.java
index ba0a5c1..96038a7 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForMethod.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForMethod.java
@@ -18,51 +18,20 @@
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
public class JavadocTestForMethod extends JavadocTest {
- public static Test suite() {
- if (false) {
- TestSuite ts;
- int[] numbers = { 80, 81, 85 };
- //some of the tests depend on the order of this suite.
- ts = new TestSuite();
- for (int i = 0; i < numbers.length; i++) {
- String meth = "test";
- int num = numbers[i];
- if (num < 10) {
- meth += "0";
- }
- if (num < 100) {
- meth += "0";
- }
- meth += num;
- ts.addTest(new JavadocTestForMethod(meth));
- }
- return new RegressionTestSetup(ts, COMPLIANCE_1_4);
- }
- if (false) {
- TestSuite ts;
- //some of the tests depend on the order of this suite.
- ts = new TestSuite();
- for (int i=130; i<=138; i++) {
- String meth = "test";
- if (i<10) {
- meth += "0";
- }
- if (i<100) {
- meth += "0";
- }
- meth += i;
- ts.addTest(new JavadocTestForMethod(meth));
- }
- return new RegressionTestSetup(ts, COMPLIANCE_1_4);
- }
- return setupSuite(testClass());
- }
public JavadocTestForMethod(String name) {
super(name);
}
- public static Class testClass() {
+ public JavadocTestForMethod(String name, String support) {
+ super(name, support);
+ }
+ public static Class javadocTestClass() {
return JavadocTestForMethod.class;
}
+ public static Test suite() {
+ return buildSuite(javadocTestClass());
+ }
+ static { // Use this static to initialize testNames (String[]) , testRange (int[2]), testNumbers (int[])
+ }
protected Map getCompilerOptions() {
Map options = super.getCompilerOptions();
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestMixed.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestMixed.java
index 040e394..8bb5948 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestMixed.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestMixed.java
@@ -13,55 +13,36 @@
import java.util.Map;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
public class JavadocTestMixed extends JavadocTest {
+ String localDocCommentSupport = CompilerOptions.ENABLED;
String reportInvalidJavadoc = CompilerOptions.ERROR;
String reportMissingJavadocComments = null;
public JavadocTestMixed(String name) {
super(name);
}
+ public JavadocTestMixed(String name, String support) {
+ super(name, support);
+ }
- public static Class testClass() {
+ public static Class javadocTestClass() {
return JavadocTestMixed.class;
}
public static Test suite() {
- if (false) {
- TestSuite ts;
- int[] numbers = { 41 };
- //some of the tests depend on the order of this suite.
- ts = new TestSuite();
- for (int i = 0; i < numbers.length; i++) {
- String meth = "test";
- int num = numbers[i];
- if (num < 10) {
- meth += "0";
- }
- if (num < 100) {
- meth += "0";
- }
- meth += num;
- ts.addTest(new JavadocTestMixed(meth));
- }
- return new RegressionTestSetup(ts, COMPLIANCE_1_4);
- }
- if (false) {
- TestSuite ts = new TestSuite();
- ts.addTest(new JavadocTestMixed("testBug52216"));
- ts.addTest(new JavadocTestMixed("testBug52216a"));
- ts.addTest(new JavadocTestMixed("testBug52216b"));
- return new RegressionTestSetup(ts, COMPLIANCE_1_4);
- }
- return setupSuite(testClass());
+ return buildSuite(javadocTestClass());
+ }
+ static {
+// testNames = new String[] { "Bug51529a", "Bug51529b" };
}
protected Map getCompilerOptions() {
Map options = super.getCompilerOptions();
+ options.put(CompilerOptions.OPTION_DocCommentSupport, this.localDocCommentSupport);
options.put(CompilerOptions.OPTION_ReportInvalidJavadoc, reportInvalidJavadoc);
if (reportMissingJavadocComments != null)
options.put(CompilerOptions.OPTION_ReportMissingJavadocComments, reportMissingJavadocComments);
@@ -71,6 +52,7 @@
options.put(CompilerOptions.OPTION_ReportFieldHiding, CompilerOptions.IGNORE);
options.put(CompilerOptions.OPTION_ReportSyntheticAccessEmulation, CompilerOptions.IGNORE);
options.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.ERROR);
+ options.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.ERROR);
return options;
}
/* (non-Javadoc)
@@ -78,6 +60,7 @@
*/
protected void setUp() throws Exception {
super.setUp();
+ this.localDocCommentSupport = this.docCommentSupport;
reportInvalidJavadoc = CompilerOptions.ERROR;
reportMissingJavadocComments = null;
}
@@ -2149,4 +2132,60 @@
"----------\n"
);
}
+
+ /**
+ * Test fix for bug 51529.
+ * @see <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=51529">51529</a>
+ */
+ public void testBug51529() {
+ reportMissingJavadocComments = CompilerOptions.IGNORE;
+ runConformTest(
+ new String[] {
+ "X.java",
+ "import java.util.Vector;\n" +
+ "public class X {\n" +
+ " /**\n" +
+ " * @see Vector\n" +
+ " */\n" +
+ " void foo() {}\n" +
+ "}\n"
+ });
+ }
+ public void testBug51529a() {
+ reportInvalidJavadoc = CompilerOptions.IGNORE;
+ reportMissingJavadocComments = CompilerOptions.IGNORE;
+ runConformTest(
+ new String[] {
+ "X.java",
+ "import java.util.Vector;\n" +
+ "public class X {\n" +
+ " /**\n" +
+ " * @see Vector\n" +
+ " */\n" +
+ " void foo() {}\n" +
+ "}\n"
+ }
+ );
+ }
+ public void testBug51529b() {
+ this.localDocCommentSupport = CompilerOptions.DISABLED;
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "import java.util.Vector;\n" +
+ "public class X {\n" +
+ " /**\n" +
+ " * @see Vector\n" +
+ " */\n" +
+ " void foo() {}\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " import java.util.Vector;\n" +
+ " ^^^^^^^^^^^^^^^^\n" +
+ "The import java.util.Vector is never used\n" +
+ "----------\n"
+ );
+ }
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestOptions.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestOptions.java
index e46f868..57d53b1 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestOptions.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestOptions.java
@@ -13,7 +13,6 @@
import java.util.Map;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
@@ -26,6 +25,7 @@
*/
public class JavadocTestOptions extends JavadocTest {
+ String localDocCommentSupport = null;
String reportInvalidJavadoc = null;
String reportInvalidJavadocTagsVisibility = null;
String reportInvalidJavadocTags = null;
@@ -1513,24 +1513,34 @@
public JavadocTestOptions(String name) {
super(name);
}
-
- public static Class testClass() {
+ public JavadocTestOptions(String name, String support) {
+ super(name, support);
+ }
+ public static Class javadocTestClass() {
return JavadocTestOptions.class;
}
-
public static Test suite() {
- if (false) {
- TestSuite ts = new TestSuite();
- ts.addTest(new JavadocTestOptions("testMissingTagsErrorPrivate"));
- ts.addTest(new JavadocTestOptions("testMissingCommentsErrorPrivate"));
- return new RegressionTestSetup(ts, COMPLIANCE_1_4);
- }
- return setupSuite(testClass());
+ return buildSuite(javadocTestClass());
}
+ static { // Use this static to initialize testNames (String[]) , testRange (int[2]), testNumbers (int[])
+ }
+ /**
+ * @return Returns the docCommentSupport.
+ *
+ public String getNamePrefix() {
+ if (this.localDocCommentSupport == null) {
+ return super.getNamePrefix();
+ } else {
+ return this.localDocCommentSupport;
+ }
+ }
+ */
protected Map getCompilerOptions() {
Map options = super.getCompilerOptions();
// Set javadoc options if non null
+ if (this.localDocCommentSupport != null)
+ options.put(CompilerOptions.OPTION_DocCommentSupport, this.localDocCommentSupport);
if (reportInvalidJavadoc != null)
options.put(CompilerOptions.OPTION_ReportInvalidJavadoc, reportInvalidJavadoc);
if (reportInvalidJavadocTagsVisibility != null)
@@ -1881,4 +1891,34 @@
reportInvalidJavadocTagsVisibility = CompilerOptions.PRIVATE;
runConformTest(MissingTags);
}
+
+ /**
+ * Test fix for bug 52264.
+ * @see <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=52264">52264</a>
+ */
+ // Test invalid javadoc "error" with javadoc comment support disabled
+ public void testInvalidTagsReferencesJavadocSupportDisabled() {
+ this.localDocCommentSupport = CompilerOptions.DISABLED;
+ reportInvalidJavadoc = CompilerOptions.ERROR;
+ reportInvalidJavadocTags = CompilerOptions.ERROR;
+ runConformTest(InvalidReferencesClassJavadocComments);
+ runConformTest(InvalidReferencesFieldJavadocComments);
+ runConformTest(InvalidReferencesMethodJavadocComments);
+ runConformTest(InvalidReferencesConstructorJavadocComments);
+ }
+
+ // Test missing javadoc comments "error" with javadoc comment support disabled
+ public void testMissingCommentsJavadocSupportDisabled() {
+ this.localDocCommentSupport = CompilerOptions.DISABLED;
+ reportMissingJavadocComments = CompilerOptions.ERROR;
+ runConformReferenceTest(MissingComments);
+ }
+
+ // Test missing javadoc tags "error" with javadoc comment support disabled
+ public void testMissingTagsJavadocSupportDisabled() {
+ this.localDocCommentSupport = CompilerOptions.DISABLED;
+ reportMissingJavadocTags = CompilerOptions.ERROR;
+ runConformReferenceTest(MissingTags);
+ }
+
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RegressionTestSetup.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RegressionTestSetup.java
index 015e0de..cefae5f 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RegressionTestSetup.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RegressionTestSetup.java
@@ -26,7 +26,10 @@
public RegressionTestSetup(Test test, String complianceLevel) {
super(test, complianceLevel);
}
-
+ public RegressionTestSetup(Test test, String complianceLevel, String support) {
+ super(test, complianceLevel, support);
+ }
+
protected void setUp() {
if (this.javaClassLib == null) {
// Create name environment
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
index b23e25d..e05f68a 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
@@ -28,7 +28,7 @@
}
public static Test suite() {
ArrayList standardTests = new ArrayList();
- standardTests.addAll(JavadocTest.allTestClasses);
+// standardTests.addAll(JavadocTest.allTestClasses);
standardTests.add(ArrayTest.class);
standardTests.add(AssignmentTest.class);
standardTests.add(BatchCompilerTest.class);
@@ -66,6 +66,8 @@
tests_1_5.add(GenericTypeTest.class);
all.addTest(AbstractCompilerTest.suiteForComplianceLevel(AbstractCompilerTest.COMPLIANCE_1_5, RegressionTestSetup.class, tests_1_5));
}
+ // Add Javadoc test suites
+ all.addTest(JavadocTest.suite());
return all;
}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java
index b7d3459..68f12ca 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java
@@ -34,6 +34,7 @@
private static int possibleComplianceLevels = -1;
protected String complianceLevel;
+ protected String docCommentSupport;
/*
* Returns the possible compliance levels this VM instance can run.
@@ -156,5 +157,6 @@
public void initialize(CompilerTestSetup setUp) {
this.complianceLevel = setUp.complianceLevel;
+ this.docCommentSupport = setUp.docCommentSupport;
}
}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/CompilerTestSetup.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/CompilerTestSetup.java
index 5efd8d2..6c9bc08 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/CompilerTestSetup.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/CompilerTestSetup.java
@@ -20,11 +20,17 @@
public class CompilerTestSetup extends TestDecorator {
String complianceLevel;
+ String docCommentSupport;
public CompilerTestSetup(Test test, String complianceLevel) {
super(test);
this.complianceLevel = complianceLevel;
}
+ public CompilerTestSetup(Test test, String complianceLevel, String support) {
+ super(test);
+ this.complianceLevel = complianceLevel;
+ this.docCommentSupport = support;
+ }
protected void initTest(Object test) {
if (test instanceof AbstractCompilerTest) {
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterJavadocTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterJavadocTest.java
index 1f27e7a..304c3ea 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterJavadocTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterJavadocTest.java
@@ -15,7 +15,6 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -25,21 +24,19 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.ASTVisitor;
+import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.ArrayType;
-import org.eclipse.jdt.core.dom.BlockComment;
import org.eclipse.jdt.core.dom.Comment;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.IBinding;
import org.eclipse.jdt.core.dom.Javadoc;
-import org.eclipse.jdt.core.dom.LineComment;
import org.eclipse.jdt.core.dom.MemberRef;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.MethodRef;
import org.eclipse.jdt.core.dom.MethodRefParameter;
import org.eclipse.jdt.core.dom.Name;
-import org.eclipse.jdt.core.dom.PrimitiveType;
import org.eclipse.jdt.core.dom.QualifiedName;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.SimpleType;
@@ -49,12 +46,18 @@
public class ASTConverterJavadocTest extends ConverterTestSetup {
+ // Test counters
protected static int[] testCounters = { 0, 0, 0, 0 };
+ // Unicode tests
+ protected static boolean unicode = false;
+ // Doc Comment support
+ static final String DOC_COMMENT_SUPPORT = System.getProperty("doc.support");
+ final String docCommentSupport;
// List of comments read from source of test
-// private final int LINE_COMMENT = 100;
-// private final int BLOCK_COMMENT =200;
-// private final int DOC_COMMENT = 300;
+ private final int LINE_COMMENT = 100;
+ private final int BLOCK_COMMENT =200;
+ private final int DOC_COMMENT = 300;
List comments = new ArrayList();
// List of tags contained in each comment read from test source.
List allTags = new ArrayList();
@@ -69,31 +72,59 @@
protected StringBuffer problems;
protected String compilerOption = JavaCore.IGNORE;
protected List failures;
+ protected IJavaProject currentProject;
-
+ /**
+ * @param name
+ * @param support
+ */
+ public ASTConverterJavadocTest(String name, String support) {
+ super(name);
+ this.docCommentSupport = support;
+ }
/**
* @param name
*/
public ASTConverterJavadocTest(String name) {
- super(name);
+ this(name, JavaCore.ENABLED);
}
public static Test suite() {
TestSuite suite = new Suite(ASTConverterJavadocTest.class.getName());
-
+// String param = System.getProperty("unicode");
+// if ("true".equals(param)) {
+// unicode = true;
+// }
if (true) {
- Class c = ASTConverterJavadocTest.class;
- Method[] methods = c.getMethods();
- for (int i = 0, max = methods.length; i < max; i++) {
- if (methods[i].getName().startsWith("test")) { //$NON-NLS-1$
- suite.addTest(new ASTConverterJavadocTest(methods[i].getName()));
- }
+ if (DOC_COMMENT_SUPPORT == null) {
+ buildSuite(suite, JavaCore.ENABLED);
+ buildSuite(suite, JavaCore.DISABLED);
+ } else {
+ String support = DOC_COMMENT_SUPPORT==null ? JavaCore.DISABLED : (DOC_COMMENT_SUPPORT.equals(JavaCore.DISABLED)?JavaCore.DISABLED:JavaCore.ENABLED);
+ buildSuite(suite, support);
}
return suite;
}
- suite.addTest(new ASTConverterJavadocTest("test014"));
+ suite.addTest(new ASTConverterJavadocTest("testBug52908unicode"));
return suite;
}
+
+ public static void buildSuite(TestSuite suite, String support) {
+ Class c = ASTConverterJavadocTest.class;
+ Method[] methods = c.getMethods();
+ for (int i = 0, max = methods.length; i < max; i++) {
+ if (methods[i].getName().startsWith("test")) { //$NON-NLS-1$
+ suite.addTest(new ASTConverterJavadocTest(methods[i].getName(), support));
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#getName()
+ */
+ public String getName() {
+ return "Doc "+this.docCommentSupport+" - "+super.getName();
+ }
/* (non-Javadoc)
* @see junit.framework.TestCase#setUp()
*/
@@ -126,6 +157,8 @@
}
}
assertTrue(title, size==0 || problems.length() > 0);
+ // put default options on project
+ this.currentProject.setOptions(JavaCore.getOptions());
}
/* (non-Javadoc)
* @see junit.framework.TestCase#tearDown()
@@ -144,226 +177,236 @@
}
}
- class ASTConverterJavadocFlattener extends ASTVisitor {
-
- /**
- * The string buffer into which the serialized representation of the AST is
- * written.
- */
- private StringBuffer buffer;
-
- private String comment;
-
- /**
- * Creates a new AST printer.
- */
- ASTConverterJavadocFlattener(String comment) {
- this.buffer = new StringBuffer();
- this.comment = comment;
- }
-
- /**
- * Returns the string accumulated in the visit.
- *
- * @return the serialized
- */
- public String getResult() {
- return this.buffer.toString();
- }
-
- /**
- * Resets this printer so that it can be used again.
- */
- public void reset() {
- this.buffer.setLength(0);
- }
-
-
- /*
- * @see ASTVisitor#visit(ArrayType)
- */
- public boolean visit(ArrayType node) {
- node.getComponentType().accept(this);
- this.buffer.append("[]");//$NON-NLS-1$
- return false;
- }
-
- /*
- * @see ASTVisitor#visit(BlockComment)
- * @since 3.0
- */
- public boolean visit(BlockComment node) {
- this.buffer.append(this.comment);
- return false;
- }
-
- /*
- * @see ASTVisitor#visit(Javadoc)
- */
- public boolean visit(Javadoc node) {
- // ignore deprecated node.getComment()
- this.buffer.append("/**");//$NON-NLS-1$
- ASTNode e = null;
- int start = 3;
- for (Iterator it = node.tags().iterator(); it.hasNext(); ) {
- e = (ASTNode) it.next();
- try {
- this.buffer.append(this.comment.substring(start, e.getStartPosition()-node.getStartPosition()));
- start = e.getStartPosition()-node.getStartPosition();
- } catch (IndexOutOfBoundsException ex) {
- // do nothing
- }
- e.accept(this);
- start += e.getLength();
- }
- this.buffer.append(this.comment.substring(start, node.getLength()));
- return false;
- }
-
- /*
- * @see ASTVisitor#visit(LineComment)
- * @since 3.0
- */
- public boolean visit(LineComment node) {
- this.buffer.append(this.comment);
- return false;
- }
-
- /*
- * @see ASTVisitor#visit(MemberRef)
- * @since 3.0
- */
- public boolean visit(MemberRef node) {
- if (node.getQualifier() != null) {
- node.getQualifier().accept(this);
- }
- this.buffer.append("#");//$NON-NLS-1$
- node.getName().accept(this);
- return false;
- }
-
- /*
- * @see ASTVisitor#visit(MethodRef)
- * @since 3.0
- */
- public boolean visit(MethodRef node) {
- if (node.getQualifier() != null) {
- node.getQualifier().accept(this);
- }
- this.buffer.append("#");//$NON-NLS-1$
- node.getName().accept(this);
- this.buffer.append("(");//$NON-NLS-1$
- for (Iterator it = node.parameters().iterator(); it.hasNext(); ) {
- MethodRefParameter e = (MethodRefParameter) it.next();
- e.accept(this);
- if (it.hasNext()) {
- this.buffer.append(",");//$NON-NLS-1$
- }
- }
- this.buffer.append(")");//$NON-NLS-1$
- return false;
- }
-
- /*
- * @see ASTVisitor#visit(MethodRefParameter)
- * @since 3.0
- */
- public boolean visit(MethodRefParameter node) {
- node.getType().accept(this);
- if (node.getName() != null) {
- this.buffer.append(" ");//$NON-NLS-1$
- node.getName().accept(this);
- }
- return false;
- }
-
- /*
- * @see ASTVisitor#visit(TagElement)
- * @since 3.0
- */
- public boolean visit(TagElement node) {
- Javadoc javadoc = null;
- int start = 0;
- if (node.isNested()) {
- // nested tags are always enclosed in braces
- this.buffer.append("{");//$NON-NLS-1$
- javadoc = (Javadoc) node.getParent().getParent();
- start++;
- } else {
- javadoc = (Javadoc) node.getParent();
- }
- start += node.getStartPosition()-javadoc.getStartPosition();
- if (node.getTagName() != null) {
- this.buffer.append(node.getTagName());
- start += node.getTagName().length();
- }
- for (Iterator it = node.fragments().iterator(); it.hasNext(); ) {
- ASTNode e = (ASTNode) it.next();
- try {
- this.buffer.append(this.comment.substring(start, e.getStartPosition()-javadoc.getStartPosition()));
- start = e.getStartPosition()-javadoc.getStartPosition();
- } catch (IndexOutOfBoundsException ex) {
- // do nothing
- }
- start += e.getLength();
- e.accept(this);
- }
- if (node.isNested()) {
- this.buffer.append("}");//$NON-NLS-1$
- }
- return false;
- }
-
- /*
- * @see ASTVisitor#visit(TextElement)
- * @since 3.0
- */
- public boolean visit(TextElement node) {
- this.buffer.append(node.getText());
- return false;
- }
-
- /*
- * @see ASTVisitor#visit(PrimitiveType)
- */
- public boolean visit(PrimitiveType node) {
- this.buffer.append(node.getPrimitiveTypeCode().toString());
- return false;
- }
-
- /*
- * @see ASTVisitor#visit(QualifiedName)
- */
- public boolean visit(QualifiedName node) {
- node.getQualifier().accept(this);
- this.buffer.append(".");//$NON-NLS-1$
- node.getName().accept(this);
- return false;
- }
-
- /*
- * @see ASTVisitor#visit(SimpleName)
- */
- public boolean visit(SimpleName node) {
- this.buffer.append(node.getIdentifier());
- return false;
- }
-
- /*
- * @see ASTVisitor#visit(SimpleName)
- */
- public boolean visit(SimpleType node) {
- node.getName().accept(this);
- return false;
- }
+ public ASTNode runConversion(char[] source, String unitName, IJavaProject project) {
+ ASTParser parser = ASTParser.newParser(AST.LEVEL_2_0);
+ parser.setSource(source);
+ parser.setUnitName(unitName);
+ parser.setProject(project);
+ parser.setResolveBindings(this.resolveBinding);
+ return parser.createAST(null);
}
+// NOT USED
+// class ASTConverterJavadocFlattener extends ASTVisitor {
+//
+// /**
+// * The string buffer into which the serialized representation of the AST is
+// * written.
+// */
+// private StringBuffer buffer;
+//
+// private String comment;
+//
+// /**
+// * Creates a new AST printer.
+// */
+// ASTConverterJavadocFlattener(String comment) {
+// this.buffer = new StringBuffer();
+// this.comment = comment;
+// }
+//
+// /**
+// * Returns the string accumulated in the visit.
+// *
+// * @return the serialized
+// */
+// public String getResult() {
+// return this.buffer.toString();
+// }
+//
+// /**
+// * Resets this printer so that it can be used again.
+// */
+// public void reset() {
+// this.buffer.setLength(0);
+// }
+//
+// /*
+// * @see ASTVisitor#visit(ArrayType)
+// */
+// public boolean visit(ArrayType node) {
+// node.getComponentType().accept(this);
+// this.buffer.append("[]");//$NON-NLS-1$
+// return false;
+// }
+//
+// /*
+// * @see ASTVisitor#visit(BlockComment)
+// * @since 3.0
+// */
+// public boolean visit(BlockComment node) {
+// this.buffer.append(this.comment);
+// return false;
+// }
+//
+// /*
+// * @see ASTVisitor#visit(Javadoc)
+// */
+// public boolean visit(Javadoc node) {
+//
+// // ignore deprecated node.getComment()
+// this.buffer.append("/**");//$NON-NLS-1$
+// ASTNode e = null;
+// int start = 3;
+// for (Iterator it = node.tags().iterator(); it.hasNext(); ) {
+// e = (ASTNode) it.next();
+// try {
+// this.buffer.append(this.comment.substring(start, e.getStartPosition()-node.getStartPosition()));
+// start = e.getStartPosition()-node.getStartPosition();
+// } catch (IndexOutOfBoundsException ex) {
+// // do nothing
+// }
+// e.accept(this);
+// start += e.getLength();
+// }
+// this.buffer.append(this.comment.substring(start, node.getLength()));
+// return false;
+// }
+//
+// /*
+// * @see ASTVisitor#visit(LineComment)
+// * @since 3.0
+// */
+// public boolean visit(LineComment node) {
+// this.buffer.append(this.comment);
+// return false;
+// }
+//
+// /*
+// * @see ASTVisitor#visit(MemberRef)
+// * @since 3.0
+// */
+// public boolean visit(MemberRef node) {
+// if (node.getQualifier() != null) {
+// node.getQualifier().accept(this);
+// }
+// this.buffer.append("#");//$NON-NLS-1$
+// node.getName().accept(this);
+// return true;
+// }
+//
+// /*
+// * @see ASTVisitor#visit(MethodRef)
+// * @since 3.0
+// */
+// public boolean visit(MethodRef node) {
+// if (node.getQualifier() != null) {
+// node.getQualifier().accept(this);
+// }
+// this.buffer.append("#");//$NON-NLS-1$
+// node.getName().accept(this);
+// this.buffer.append("(");//$NON-NLS-1$
+// for (Iterator it = node.parameters().iterator(); it.hasNext(); ) {
+// MethodRefParameter e = (MethodRefParameter) it.next();
+// e.accept(this);
+// if (it.hasNext()) {
+// this.buffer.append(",");//$NON-NLS-1$
+// }
+// }
+// this.buffer.append(")");//$NON-NLS-1$
+// return true;
+// }
+//
+// /*
+// * @see ASTVisitor#visit(MethodRefParameter)
+// * @since 3.0
+// */
+// public boolean visit(MethodRefParameter node) {
+// node.getType().accept(this);
+// if (node.getName() != null) {
+// this.buffer.append(" ");//$NON-NLS-1$
+// node.getName().accept(this);
+// }
+// return true;
+// }
+//
+// /*
+// * @see ASTVisitor#visit(TagElement)
+// * @since 3.0
+// */
+// public boolean visit(TagElement node) {
+// Javadoc javadoc = null;
+// int start = 0;
+// if (node.isNested()) {
+// // nested tags are always enclosed in braces
+// this.buffer.append("{");//$NON-NLS-1$
+// javadoc = (Javadoc) node.getParent().getParent();
+// start++;
+// } else {
+// javadoc = (Javadoc) node.getParent();
+// }
+// start += node.getStartPosition()-javadoc.getStartPosition();
+// if (node.getTagName() != null) {
+// this.buffer.append(node.getTagName());
+// start += node.getTagName().length();
+// }
+// for (Iterator it = node.fragments().iterator(); it.hasNext(); ) {
+// ASTNode e = (ASTNode) it.next();
+// try {
+// this.buffer.append(this.comment.substring(start, e.getStartPosition()-javadoc.getStartPosition()));
+// start = e.getStartPosition()-javadoc.getStartPosition();
+// } catch (IndexOutOfBoundsException ex) {
+// // do nothing
+// }
+// start += e.getLength();
+// e.accept(this);
+// }
+// if (node.isNested()) {
+// this.buffer.append("}");//$NON-NLS-1$
+// }
+// return true;
+// }
+//
+// /*
+// * @see ASTVisitor#visit(TextElement)
+// * @since 3.0
+// */
+// public boolean visit(TextElement node) {
+// this.buffer.append(node.getText());
+// return false;
+// }
+//
+// /*
+// * @see ASTVisitor#visit(PrimitiveType)
+// */
+// public boolean visit(PrimitiveType node) {
+// this.buffer.append(node.getPrimitiveTypeCode().toString());
+// return false;
+// }
+//
+// /*
+// * @see ASTVisitor#visit(QualifiedName)
+// */
+// public boolean visit(QualifiedName node) {
+// node.getQualifier().accept(this);
+// this.buffer.append(".");//$NON-NLS-1$
+// node.getName().accept(this);
+// return false;
+// }
+//
+// /*
+// * @see ASTVisitor#visit(SimpleName)
+// */
+// public boolean visit(SimpleName node) {
+// this.buffer.append(node.getIdentifier());
+// return false;
+// }
+//
+// /*
+// * @see ASTVisitor#visit(SimpleName)
+// */
+// public boolean visit(SimpleType node) {
+// node.getName().accept(this);
+// return false;
+// }
+// }
+
/*
* Convert Javadoc source to match Javadoc.toString().
* Store converted comments and their corresponding tags respectively
* in this.comments and this.allTags fields
*/
- void setSourceComment(char[] source) {
+ protected void setSourceComment(char[] source) {
this.comments = new ArrayList();
this.allTags = new ArrayList();
StringBuffer buffer = null;
@@ -372,71 +415,205 @@
String tag = null;
List tags = new ArrayList();
int length = source.length;
+ char previousChar=0, currentChar=0;
for (int i=0; i<length; i++) {
- if (comment == 0) {
- switch (source[i]) {
- case '/':
- switch (source[++i]) {
- case '/':
- comment = 1; // line comment
- buffer = new StringBuffer("//");
- i++;
- break;
- case '*':
- if (source[++i] == '*') {
- if (source[++i] == '/') { // empty block comment
- this.comments.add("/**/");
- this.allTags.add(new ArrayList());
+ previousChar = currentChar;
+ // get next char
+ currentChar = source[i];
+ int charLength = 1;
+ if (currentChar == '\\' && source[i+1] == 'u') {
+ //-------------unicode traitement ------------
+ int c1, c2, c3, c4;
+ charLength++;
+ while (source[i+charLength] == 'u') charLength++;
+ if (((c1 = Character.getNumericValue(source[i+charLength++])) > 15
+ || c1 < 0)
+ || ((c2 = Character.getNumericValue(source[i+charLength++])) > 15 || c2 < 0)
+ || ((c3 = Character.getNumericValue(source[i+charLength++])) > 15 || c3 < 0)
+ || ((c4 = Character.getNumericValue(source[i+charLength])) > 15 || c4 < 0)) {
+ throw new RuntimeException("Invalid unicode in source at "+i);
+ }
+ currentChar = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
+ i+=charLength;
+ }
+
+ //
+ switch (comment) {
+ case 0:
+ switch (currentChar) {
+ case '/':
+ comment = 1; // first char for comments...
+ buffer = new StringBuffer();
+ if (charLength == 1) {
+ buffer.append(currentChar);
+ } else {
+ for (int k=i-charLength; k<=i; k++) buffer.append(source[k]);
+ }
+ break;
+ case '\'':
+ while (i<length) {
+ // get next char
+ currentChar = source[i];
+ if (currentChar == '\\' && source[i+1] == 'u') {
+ //-------------unicode traitement ------------
+ i++;
+ int c1, c2, c3, c4;
+ i++;
+ while (source[i] == 'u') i++;
+ if (((c1 = Character.getNumericValue(source[i++])) > 15
+ || c1 < 0)
+ || ((c2 = Character.getNumericValue(source[i++])) > 15 || c2 < 0)
+ || ((c3 = Character.getNumericValue(source[i++])) > 15 || c3 < 0)
+ || ((c4 = Character.getNumericValue(source[i++])) > 15 || c4 < 0)) {
+ throw new RuntimeException("Invalid unicode in source at "+i);
+ }
+ currentChar = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
+ }
+ if (currentChar == '\\') {
+ // get next char
+ currentChar = source[i];
+ if (currentChar == '\\' && source[i+1] == 'u') {
+ //-------------unicode traitement ------------
i++;
- } else {
- comment = 3; // javadoc
- buffer = new StringBuffer("/**");
+ int c1, c2, c3, c4;
+ i++;
+ while (source[i] == 'u') i++;
+ if (((c1 = Character.getNumericValue(source[i++])) > 15
+ || c1 < 0)
+ || ((c2 = Character.getNumericValue(source[i++])) > 15 || c2 < 0)
+ || ((c3 = Character.getNumericValue(source[i++])) > 15 || c3 < 0)
+ || ((c4 = Character.getNumericValue(source[i++])) > 15 || c4 < 0)) {
+ throw new RuntimeException("Invalid unicode in source at "+i);
+ }
+ currentChar = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
}
} else {
- comment = 2; // block comment
- buffer = new StringBuffer("/*");
- }
- break;
- }
- break;
- case '\'':
- while (i<length) {
- i++;
- if (i==length) break;
- if (source[i] == '\\') {
- i++;
- } else {
- if (source[i] == '\'') {
- break;
- }
- }
- }
- break;
- case '"':
- while (i<length) {
- i++;
- if (i==length) break;
- if (source[i] == '\\') {
- i++;
- } else {
- if (source[i] == '"') {
- if ((i+1)==length) break;
- if (source[i+1] == '"') {
- i++;
- } else {
+ if (currentChar == '\'') {
break;
}
}
}
- }
- break;
- }
- }
- switch (comment) {
- case 1: // line comment
- if (source[i] == '\r' || source[i] == '\n') {
+ break;
+ case '"':
+ while (i<length) {
+ // get next char
+ currentChar = source[i];
+ if (currentChar == '\\' && source[i+1] == 'u') {
+ //-------------unicode traitement ------------
+ i++;
+ int c1, c2, c3, c4;
+ i++;
+ while (source[i] == 'u') i++;
+ if (((c1 = Character.getNumericValue(source[i++])) > 15
+ || c1 < 0)
+ || ((c2 = Character.getNumericValue(source[i++])) > 15 || c2 < 0)
+ || ((c3 = Character.getNumericValue(source[i++])) > 15 || c3 < 0)
+ || ((c4 = Character.getNumericValue(source[i++])) > 15 || c4 < 0)) {
+ throw new RuntimeException("Invalid unicode in source at "+i);
+ }
+ currentChar = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
+ }
+ if (currentChar == '\\') {
+ // get next char
+ currentChar = source[i];
+ if (currentChar == '\\' && source[i+1] == 'u') {
+ //-------------unicode traitement ------------
+ i++;
+ int c1, c2, c3, c4;
+ i++;
+ while (source[i] == 'u') i++;
+ if (((c1 = Character.getNumericValue(source[i++])) > 15
+ || c1 < 0)
+ || ((c2 = Character.getNumericValue(source[i++])) > 15 || c2 < 0)
+ || ((c3 = Character.getNumericValue(source[i++])) > 15 || c3 < 0)
+ || ((c4 = Character.getNumericValue(source[i++])) > 15 || c4 < 0)) {
+ throw new RuntimeException("Invalid unicode in source at "+i);
+ }
+ currentChar = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
+ }
+ } else {
+ if (currentChar == '"') {
+ int currentPos=i;
+ // get next char
+ currentChar = source[i];
+ if (currentChar == '\\' && source[i+1] == 'u') {
+ //-------------unicode traitement ------------
+ i++;
+ int c1, c2, c3, c4;
+ i++;
+ while (source[i] == 'u') i++;
+ if (((c1 = Character.getNumericValue(source[i++])) > 15
+ || c1 < 0)
+ || ((c2 = Character.getNumericValue(source[i++])) > 15 || c2 < 0)
+ || ((c3 = Character.getNumericValue(source[i++])) > 15 || c3 < 0)
+ || ((c4 = Character.getNumericValue(source[i++])) > 15 || c4 < 0)) {
+ throw new RuntimeException("Invalid unicode in source at "+i);
+ }
+ currentChar = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
+ }
+ if (source[i+1] != '"') {
+ i=currentPos;
+ break;
+ }
+ }
+ }
+ }
+ break;
+ }
+ break;
+ case 1: // first '/' has been found...
+ switch (currentChar) {
+ case '/':
+ if (charLength == 1) {
+ buffer.append(currentChar);
+ } else {
+ for (int k=i-charLength; k<=i; k++) buffer.append(source[k]);
+ }
+ comment = LINE_COMMENT;
+ break;
+ case '*':
+ if (charLength == 1) {
+ buffer.append(currentChar);
+ } else {
+ for (int k=i-charLength; k<=i; k++) buffer.append(source[k]);
+ }
+ comment = 2; // next step
+ break;
+ default:
+ comment = 0;
+ break;
+ }
+ break;
+ case 2: // '/*' has been found...
+ if (currentChar == '*') {
+ comment = 3; // next step...
+ } else {
+ comment = BLOCK_COMMENT;
+ }
+ if (charLength == 1) {
+ buffer.append(currentChar);
+ } else {
+ for (int k=i-charLength; k<=i; k++) buffer.append(source[k]);
+ }
+ break;
+ case 3: // '/**' has bee found, verify that's not an empty block comment
+ if (charLength == 1) {
+ buffer.append(currentChar);
+ } else {
+ for (int k=i-charLength; k<=i; k++) buffer.append(source[k]);
+ }
+ if (currentChar == '/') { // empty block comment
+ this.comments.add(buffer.toString());
+ this.allTags.add(new ArrayList());
+ comment = 0;
+ } else {
+ comment = DOC_COMMENT;
+ }
+ break;
+ case LINE_COMMENT:
+ if (currentChar == '\r' || currentChar == '\n') {
/*
- if (source[i] == '\r' && source[i+1] == '\n') {
+ if (currentChar == '\r' && source[i+1] == '\n') {
buffer.append(source[++i]);
}
*/
@@ -444,21 +621,25 @@
this.comments.add(buffer.toString());
this.allTags.add(tags);
} else {
- buffer.append(source[i]);
+ if (charLength == 1) {
+ buffer.append(currentChar);
+ } else {
+ for (int k=i-charLength; k<=i; k++) buffer.append(source[k]);
+ }
}
break;
- case 3: // javadoc comment
+ case DOC_COMMENT:
if (tag != null) {
- if (source[i] >= 'a' && source[i] <= 'z') {
- tag += source[i];
+ if (currentChar >= 'a' && currentChar <= 'z') {
+ tag += currentChar;
} else {
tags.add(tag);
tag = null;
}
}
- switch (source[i]) {
+ switch (currentChar) {
case '@':
- if (!lineStarted || source[i-1] == '{') {
+ if (!lineStarted || previousChar == '{') {
tag = "";
lineStarted = true;
}
@@ -470,20 +651,24 @@
case '*':
break;
default:
- if (!Character.isWhitespace(source[i])) {
+ if (!Character.isWhitespace(currentChar)) {
lineStarted = true;
}
}
- case 2: // block comment
- buffer.append(source[i]);
- if (end && source[i] == '/') {
+ case BLOCK_COMMENT:
+ if (charLength == 1) {
+ buffer.append(currentChar);
+ } else {
+ for (int k=i-charLength; k<=i; k++) buffer.append(source[k]);
+ }
+ if (end && currentChar == '/') {
comment = 0;
lineStarted = false;
this.comments.add(buffer.toString());
this.allTags.add(tags);
tags = new ArrayList();
}
- end = source[i] == '*';
+ end = currentChar == '*';
break;
default:
// do nothing
@@ -491,6 +676,52 @@
}
}
}
+
+ /*
+ * Convert Javadoc source to match Javadoc.toString().
+ * Store converted comments and their corresponding tags respectively
+ * in this.comments and this.allTags fields
+ */
+ char[] getUnicodeSource(char[] source) {
+ int length = source.length;
+ int unicodeLength = length*6;
+ char[] unicodeSource = new char[unicodeLength];
+ int u=0;
+ for (int i=0; i<length; i++) {
+ // get next char
+ if (source[i] == '\\' && source[i+1] == 'u') {
+ //-------------unicode traitement ------------
+ int c1, c2, c3, c4;
+ unicodeSource[u++] = source[i];
+ unicodeSource[u++] = source[++i];
+ if (((c1 = Character.getNumericValue(source[i+1])) > 15
+ || c1 < 0)
+ || ((c2 = Character.getNumericValue(source[i+2])) > 15 || c2 < 0)
+ || ((c3 = Character.getNumericValue(source[i+3])) > 15 || c3 < 0)
+ || ((c4 = Character.getNumericValue(source[i+4])) > 15 || c4 < 0)) {
+ throw new RuntimeException("Invalid unicode in source at "+i);
+ }
+ for (int j=0; j<4; j++) unicodeSource[u++] = source[++i];
+ } else {
+ unicodeSource[u++] = '\\';
+ unicodeSource[u++] = 'u';
+ unicodeSource[u++] = '0';
+ unicodeSource[u++] = '0';
+ int val = source[i]/16;
+ unicodeSource[u++] = (char) (val<10 ? val+ 0x30 : val-10+0x61);
+ val = source[i]%16;
+ unicodeSource[u++] = (char) (val<10 ? val+ 0x30 : val-10+0x61);
+ }
+ }
+ // Return one well sized array
+ if (u != unicodeLength) {
+ char[] result = new char[u];
+ System.arraycopy(unicodeSource, 0, result, 0, u);
+ return result;
+ } else {
+ return unicodeSource;
+ }
+ }
/*
* Return all tags number for a given Javadoc
@@ -516,14 +747,11 @@
}
/*
- * Compare a string a subset of a char array.
+ * Add a failure to the list. Use only one method as it easier to put breakpoint to
+ * debug failure when it occurs...
*/
- protected boolean compare(String str, int start, int length, char[] source) {
- if (str.length() != length) return false;
- for (int i=0; i<length; i++) {
- if (str.charAt(i) != source[start+i]) return false;
- }
- return true;
+ private void addFailure(String msg) {
+ this.failures.add(msg);
}
/*
@@ -533,7 +761,7 @@
*/
protected void assumeTrue(String msg, boolean cond) {
if (!cond) {
- this.failures.add(msg);
+ addFailure(msg);
}
}
@@ -544,7 +772,7 @@
*/
protected void assumeNull(String msg, Object obj) {
if (obj != null) {
- this.failures.add(msg);
+ addFailure(msg);
}
}
@@ -555,7 +783,7 @@
*/
protected void assumeNotNull(String msg, Object obj) {
if (obj == null) {
- this.failures.add(msg);
+ addFailure(msg);
}
}
@@ -566,7 +794,7 @@
*/
protected void assumeEquals(String msg, int expected, int actual) {
if (expected != actual) {
- this.failures.add(msg+", expected="+expected+" actual="+actual);
+ addFailure(msg+", expected="+expected+" actual="+actual);
}
}
@@ -580,7 +808,7 @@
return;
if (expected != null && expected.equals(actual))
return;
- this.failures.add(msg+", expected:<"+expected+"> actual:<"+actual+'>');
+ addFailure(msg+", expected:<"+expected+"> actual:<"+actual+'>');
}
/*
@@ -926,15 +1154,41 @@
// Create DOM AST nodes hierarchy
String sourceStr = this.sourceUnit.getSource();
- IJavaProject project = this.sourceUnit.getJavaProject();
- Map originalOptions = project.getOptions(true);
+ this.currentProject = this.sourceUnit.getJavaProject();
+
+ // set up java project options
+ this.currentProject.setOption(JavaCore.COMPILER_PB_INVALID_JAVADOC, this.compilerOption);
+ this.currentProject.setOption(JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS, this.compilerOption);
+ this.currentProject.setOption(JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS, this.compilerOption);
+ this.currentProject.setOption(JavaCore.COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME, JavaCore.IGNORE);
+ this.currentProject.setOption(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, this.docCommentSupport);
+
+ // Verify source regardings converted comments
+ char[] source = sourceStr.toCharArray();
+ String fileName = unit.getPath().toString();
+ verifyComments(fileName, source);
+ }
+
+ protected void verifyComments(String fileName, char[] source) {
+
+ // Get comments infos from test file
+ setSourceComment(source);
+
+ // Verify comments either in unicode or not
+ char[] testedSource = source;
+ if (unicode) {
+ testedSource = getUnicodeSource(source);
+ }
+// Map originalOptions = this.currentProject.getOptions(true);
List unitComments = null;
- try {
- project.setOption(JavaCore.COMPILER_PB_INVALID_JAVADOC, this.compilerOption);
- project.setOption(JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS, this.compilerOption);
- project.setOption(JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS, this.compilerOption);
- project.setOption(JavaCore.COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME, JavaCore.IGNORE);
- CompilationUnit compilUnit = (CompilationUnit) runConversion(this.sourceUnit, this.resolveBinding); // resolve bindings
+// try {
+// this.currentProject.setOption(JavaCore.COMPILER_PB_INVALID_JAVADOC, this.compilerOption);
+// this.currentProject.setOption(JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS, this.compilerOption);
+// this.currentProject.setOption(JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS, this.compilerOption);
+// this.currentProject.setOption(JavaCore.COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME, JavaCore.IGNORE);
+// this.currentProject.setOption(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, this.docCommentSupport);
+ CompilationUnit compilUnit = (CompilationUnit) runConversion(testedSource, fileName, this.currentProject);
+// CompilationUnit compilUnit = (CompilationUnit) runConversion(this.sourceUnit, this.resolveBinding); // resolve bindings
if (this.compilerOption.equals(JavaCore.ERROR)) {
assumeEquals(this.prefix+"Unexpected problems", 0, compilUnit.getProblems().length); //$NON-NLS-1$
} else if (this.compilerOption.equals(JavaCore.WARNING)) {
@@ -948,47 +1202,42 @@
}
}
unitComments = compilUnit.getCommentList();
- } finally {
- project.setOptions(originalOptions);
- }
+// } finally {
+// this.currentProject.setOptions(originalOptions);
+// }
assumeNotNull(this.prefix+"Unexpected problems", unitComments);
- // Verify source regardings converted comments
- char[] source = sourceStr.toCharArray();
- verifyComments(sourceStr, source, unitComments);
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void verifyComments(String sourceStr, char[] source, List unitComments) {
- // Get comments infos from test file
- setSourceComment(source);
-
// Basic comments verification
int size = unitComments.size();
- assumeEquals(this.prefix+"Wrong number of comments in source:\n"+sourceStr+"\n", this.comments.size(), size);
+ assumeEquals(this.prefix+"Wrong number of comments!", this.comments.size(), size);
+
// Verify comments positions and bindings
- for (int i=0; i<size; i++) {
- Comment comment = (Comment) unitComments.get(i);
- List tags = (List) allTags.get(i);
- // Verify flattened content
- String stringComment = (String) this.comments.get(i);
- ASTConverterJavadocFlattener printer = new ASTConverterJavadocFlattener(stringComment);
- comment.accept(printer);
- String text = new String(source, comment.getStartPosition(), comment.getLength());
- assumeEquals(this.prefix+"Flattened comment does NOT match source!", stringComment, text);
- // Verify javdoc tags positions and bindings
- if (comment.isDocComment()) {
- Javadoc docComment = (Javadoc)comment;
- assumeEquals(this.prefix+"Invalid tags number in javadoc:\n"+docComment+"\n", tags.size(), allTags(docComment));
- verifyPositions(docComment, source);
- if (this.resolveBinding) {
- verifyBindings(docComment);
+// if (this.comments.size() == size) {
+ for (int i=0; i<size; i++) {
+ Comment comment = (Comment) unitComments.get(i);
+ List tags = (List) allTags.get(i);
+ // Verify flattened content
+ String stringComment = (String) this.comments.get(i);
+ // ASTConverterJavadocFlattener printer = new ASTConverterJavadocFlattener(stringComment);
+ // comment.accept(printer);
+ String text = new String(testedSource, comment.getStartPosition(), comment.getLength());
+ assumeEquals(this.prefix+"Flattened comment does NOT match source!", stringComment, text);
+ // Verify javdoc tags positions and bindings
+ if (comment.isDocComment()) {
+ Javadoc docComment = (Javadoc)comment;
+ if (this.docCommentSupport.equals(JavaCore.ENABLED)) {
+ assumeEquals(this.prefix+"Invalid tags number in javadoc:\n"+docComment+"\n", tags.size(), allTags(docComment));
+ verifyPositions(docComment, testedSource);
+ if (this.resolveBinding) {
+ verifyBindings(docComment);
+ }
+ } else {
+ assumeEquals("Javadoc should be flat!", 0, docComment.tags().size());
+ }
}
}
- }
+// }
/* Verify each javadoc: not implemented yet
Iterator types = compilUnit.types().listIterator();
@@ -1333,9 +1582,12 @@
public void testBug52908() throws JavaModelException {
verifyComments("testBug52908");
}
+ public void testBug52908unicode() throws JavaModelException {
+ verifyComments("testBug52908unicode");
+ }
/**
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=5xxxA
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=53276
*/
public void testBug53276() throws JavaModelException {
verifyComments("testBug53276");
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java
index d6246d4..284bacf 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java
@@ -96,7 +96,7 @@
return new Suite(ASTConverterTest2.class);
}
TestSuite suite = new Suite(ASTConverterTest2.class.getName());
- suite.addTest(new ASTConverterTest2("test0538d"));
+ suite.addTest(new ASTConverterTest2("test0539"));
return suite;
}
/**
@@ -4287,4 +4287,31 @@
sourceUnit.discardWorkingCopy();
}
}
+ /**
+ * http://dev.eclipse.org/bugs/show_bug.cgi?id=53477
+ */
+ public void test0539() throws JavaModelException {
+ ICompilationUnit sourceUnit = getCompilationUnit("Converter", "src", "test0539", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ char[] source = sourceUnit.getSource().toCharArray();
+ ASTNode result = runConversion(sourceUnit, false);
+ final CompilationUnit unit = (CompilationUnit) result;
+ assertEquals("Wrong number of problems", 0, unit.getProblems().length); //$NON-NLS-1$
+ ASTNode node = getASTNode(unit, 0, 1, 0);
+ assertNotNull("No node", node);
+ assertTrue("not an expression statement", node.getNodeType() == ASTNode.EXPRESSION_STATEMENT);
+ ExpressionStatement expressionStatement = (ExpressionStatement) node;
+ Expression expression = expressionStatement.getExpression();
+ assertTrue("not a class instance creation", expression.getNodeType() == ASTNode.CLASS_INSTANCE_CREATION);
+ ClassInstanceCreation classInstanceCreation = (ClassInstanceCreation) expression;
+ checkSourceRange(classInstanceCreation, "new A(){}.new Inner(){/*x*/}", source);
+ AnonymousClassDeclaration anonymousClassDeclaration = classInstanceCreation.getAnonymousClassDeclaration();
+ Expression expression2 = classInstanceCreation.getExpression();
+ assertTrue("not a class instance creation", expression2.getNodeType() == ASTNode.CLASS_INSTANCE_CREATION);
+ ClassInstanceCreation classInstanceCreation2 = (ClassInstanceCreation) expression2;
+ AnonymousClassDeclaration anonymousClassDeclaration2 = classInstanceCreation2.getAnonymousClassDeclaration();
+ assertNotNull("No anonymous class declaration", anonymousClassDeclaration2);
+ checkSourceRange(anonymousClassDeclaration2, "{}", source);
+ assertNotNull("No anonymous class declaration", anonymousClassDeclaration);
+ checkSourceRange(anonymousClassDeclaration, "{/*x*/}", source);
+ }
}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchJavadocTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchJavadocTests.java
index 3ad2103..0986df9 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchJavadocTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchJavadocTests.java
@@ -11,6 +11,7 @@
package org.eclipse.jdt.core.tests.model;
import java.util.Map;
+import java.util.StringTokenizer;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -28,18 +29,42 @@
public class JavaSearchJavadocTests extends JavaSearchTests {
Map originalOptions;
+ final String docCommentSupport;
+ static final String DOC_COMMENT_SUPPORT = System.getProperty("doc.support");
/**
* @param name
*/
- public JavaSearchJavadocTests(String name) {
+ public JavaSearchJavadocTests(String name, String support) {
super(name);
+ this.docCommentSupport = support;
}
- private void resetProjectOptions() {
+ public JavaSearchJavadocTests(String name) {
+ this(name, JavaCore.ENABLED);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.tests.model.SuiteOfTestCases#setUpSuite()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ this.originalOptions = this.javaProject.getOptions(true);
+ this.javaProject.setOption(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, this.docCommentSupport);
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.tests.model.SuiteOfTestCases#tearDownSuite()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
this.javaProject.setOptions(originalOptions);
}
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#getName()
+ */
+ public String getName() {
+ return "Doc "+this.docCommentSupport+" - "+super.getName();
+ }
private void setJavadocOptions() {
- this.originalOptions = this.javaProject.getOptions(true);
this.javaProject.setOption(JavaCore.COMPILER_PB_INVALID_JAVADOC, JavaCore.WARNING);
this.javaProject.setOption(JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS, JavaCore.ERROR);
}
@@ -47,69 +72,104 @@
// NOTE: cannot use 'new Suite(JavaSearchJavadocTests.class)' as this would include tests from super class
TestSuite suite = new Suite(JavaSearchJavadocTests.class.getName());
- // Tests on type declarations
- suite.addTest(new JavaSearchJavadocTests("testJavadocTypeDeclaration"));
- suite.addTest(new JavaSearchJavadocTests("testJavadocTypeDeclarationWithJavadoc"));
- suite.addTest(new JavaSearchJavadocTests("testJavadocTypeStringDeclaration"));
-
- // Tests on field declarations
- suite.addTest(new JavaSearchJavadocTests("testJavadocFieldDeclaration"));
- suite.addTest(new JavaSearchJavadocTests("testJavadocFieldDeclarationWithJavadoc"));
- suite.addTest(new JavaSearchJavadocTests("testJavadocFieldStringDeclaration"));
-
- // Tests on method declarations
- suite.addTest(new JavaSearchJavadocTests("testJavadocMethodDeclaration"));
- suite.addTest(new JavaSearchJavadocTests("testJavadocMethodArgDeclaration"));
- suite.addTest(new JavaSearchJavadocTests("testJavadocMethodDeclarationWithJavadoc"));
- suite.addTest(new JavaSearchJavadocTests("testJavadocMethodArgDeclarationWithJavadoc"));
- suite.addTest(new JavaSearchJavadocTests("testJavadocMethodStringDeclaration"));
-
- // Tests on type references
- suite.addTest(new JavaSearchJavadocTests("testJavadocTypeReference"));
- suite.addTest(new JavaSearchJavadocTests("testJavadocTypeReferenceWithJavadoc"));
- suite.addTest(new JavaSearchJavadocTests("testJavadocTypeStringReference"));
- suite.addTest(new JavaSearchJavadocTests("testJavadocTypeStringReferenceWithJavadoc"));
-
- // Tests on field references
- suite.addTest(new JavaSearchJavadocTests("testJavadocFieldReference"));
- suite.addTest(new JavaSearchJavadocTests("testJavadocFieldReferenceWithJavadoc"));
- suite.addTest(new JavaSearchJavadocTests("testJavadocFieldStringReference"));
- suite.addTest(new JavaSearchJavadocTests("testJavadocFieldStringReferenceWithJavadoc"));
-
- // Tests on method references
- suite.addTest(new JavaSearchJavadocTests("testJavadocMethodReference"));
- suite.addTest(new JavaSearchJavadocTests("testJavadocMethodArgReference"));
- suite.addTest(new JavaSearchJavadocTests("testJavadocMethodReferenceWithJavadoc"));
- suite.addTest(new JavaSearchJavadocTests("testJavadocMethodArgReferenceWithJavadoc"));
- suite.addTest(new JavaSearchJavadocTests("testJavadocMethodStringReference"));
- suite.addTest(new JavaSearchJavadocTests("testJavadocMethodStringReferenceWithJavadoc"));
-
- // Tests on constructor references
- suite.addTest(new JavaSearchJavadocTests("testJavadocConstructorReference"));
- suite.addTest(new JavaSearchJavadocTests("testJavadocConstructorArgReference"));
- suite.addTest(new JavaSearchJavadocTests("testJavadocConstructorReferenceWithJavadoc"));
- suite.addTest(new JavaSearchJavadocTests("testJavadocConstructorArgReferenceWithJavadoc"));
- suite.addTest(new JavaSearchJavadocTests("testJavadocConstructorStringReference"));
- suite.addTest(new JavaSearchJavadocTests("testJavadocConstructorStringReferenceWithJavadoc"));
-
- // Tests on bugs
- suite.addTest(new JavaSearchJavadocTests("testBug47909"));
- suite.addTest(new JavaSearchJavadocTests("testBug47968type"));
- suite.addTest(new JavaSearchJavadocTests("testBug47968field"));
- suite.addTest(new JavaSearchJavadocTests("testBug47968method"));
- suite.addTest(new JavaSearchJavadocTests("testBug47968constructor"));
- suite.addTest(new JavaSearchJavadocTests("testBug47209type"));
- suite.addTest(new JavaSearchJavadocTests("testBug47209field"));
- suite.addTest(new JavaSearchJavadocTests("testBug47209method"));
- suite.addTest(new JavaSearchJavadocTests("testBug47209constructor"));
- suite.addTest(new JavaSearchJavadocTests("testBug49994"));
- suite.addTest(new JavaSearchJavadocTests("testBug49994field"));
- suite.addTest(new JavaSearchJavadocTests("testBug49994method"));
- suite.addTest(new JavaSearchJavadocTests("testBug49994constructor"));
+ if (DOC_COMMENT_SUPPORT == null) {
+ // Default is to test both Doc Comment Support ON and OFF
+ buildSuite(suite, JavaCore.ENABLED);
+ buildSuite(suite, JavaCore.DISABLED);
+ } else {
+ // Test specified with Doc Comment Support
+ String support = DOC_COMMENT_SUPPORT==null ? JavaCore.DISABLED : (DOC_COMMENT_SUPPORT.equals(JavaCore.DISABLED)?JavaCore.DISABLED:JavaCore.ENABLED);
+ buildSuite(suite, support);
+ }
return suite;
}
+ public static void buildSuite(TestSuite suite, String support) {
+// TestSuite suite = new Suite("Doc "+support);
+ // Tests on type declarations
+ suite.addTest(new JavaSearchJavadocTests("testJavadocTypeDeclaration", support));
+ suite.addTest(new JavaSearchJavadocTests("testJavadocTypeDeclarationWithJavadoc", support));
+ suite.addTest(new JavaSearchJavadocTests("testJavadocTypeStringDeclaration", support));
+
+ // Tests on field declarations
+ suite.addTest(new JavaSearchJavadocTests("testJavadocFieldDeclaration", support));
+ suite.addTest(new JavaSearchJavadocTests("testJavadocFieldDeclarationWithJavadoc", support));
+ suite.addTest(new JavaSearchJavadocTests("testJavadocFieldStringDeclaration", support));
+
+ // Tests on method declarations
+ suite.addTest(new JavaSearchJavadocTests("testJavadocMethodDeclaration", support));
+ suite.addTest(new JavaSearchJavadocTests("testJavadocMethodArgDeclaration", support));
+ suite.addTest(new JavaSearchJavadocTests("testJavadocMethodDeclarationWithJavadoc", support));
+ suite.addTest(new JavaSearchJavadocTests("testJavadocMethodArgDeclarationWithJavadoc", support));
+ suite.addTest(new JavaSearchJavadocTests("testJavadocMethodStringDeclaration", support));
+
+ // Tests on type references
+ suite.addTest(new JavaSearchJavadocTests("testJavadocTypeReference", support));
+ suite.addTest(new JavaSearchJavadocTests("testJavadocTypeReferenceWithJavadoc", support));
+ suite.addTest(new JavaSearchJavadocTests("testJavadocTypeStringReference", support));
+ suite.addTest(new JavaSearchJavadocTests("testJavadocTypeStringReferenceWithJavadoc", support));
+
+ // Tests on field references
+ suite.addTest(new JavaSearchJavadocTests("testJavadocFieldReference", support));
+ suite.addTest(new JavaSearchJavadocTests("testJavadocFieldReferenceWithJavadoc", support));
+ suite.addTest(new JavaSearchJavadocTests("testJavadocFieldStringReference", support));
+ suite.addTest(new JavaSearchJavadocTests("testJavadocFieldStringReferenceWithJavadoc", support));
+
+ // Tests on method references
+ suite.addTest(new JavaSearchJavadocTests("testJavadocMethodReference", support));
+ suite.addTest(new JavaSearchJavadocTests("testJavadocMethodArgReference", support));
+ suite.addTest(new JavaSearchJavadocTests("testJavadocMethodReferenceWithJavadoc", support));
+ suite.addTest(new JavaSearchJavadocTests("testJavadocMethodArgReferenceWithJavadoc", support));
+ suite.addTest(new JavaSearchJavadocTests("testJavadocMethodStringReference", support));
+ suite.addTest(new JavaSearchJavadocTests("testJavadocMethodStringReferenceWithJavadoc", support));
+
+ // Tests on constructor references
+ suite.addTest(new JavaSearchJavadocTests("testJavadocConstructorReference", support));
+ suite.addTest(new JavaSearchJavadocTests("testJavadocConstructorArgReference", support));
+ suite.addTest(new JavaSearchJavadocTests("testJavadocConstructorReferenceWithJavadoc", support));
+ suite.addTest(new JavaSearchJavadocTests("testJavadocConstructorArgReferenceWithJavadoc", support));
+ suite.addTest(new JavaSearchJavadocTests("testJavadocConstructorStringReference", support));
+ suite.addTest(new JavaSearchJavadocTests("testJavadocConstructorStringReferenceWithJavadoc", support));
+
+ // Tests on bugs
+ suite.addTest(new JavaSearchJavadocTests("testBug47909", support));
+ suite.addTest(new JavaSearchJavadocTests("testBug47968type", support));
+ suite.addTest(new JavaSearchJavadocTests("testBug47968field", support));
+ suite.addTest(new JavaSearchJavadocTests("testBug47968method", support));
+ suite.addTest(new JavaSearchJavadocTests("testBug47968constructor", support));
+ suite.addTest(new JavaSearchJavadocTests("testBug47209type", support));
+ suite.addTest(new JavaSearchJavadocTests("testBug47209field", support));
+ suite.addTest(new JavaSearchJavadocTests("testBug47209method", support));
+ suite.addTest(new JavaSearchJavadocTests("testBug47209constructor", support));
+ suite.addTest(new JavaSearchJavadocTests("testBug49994", support));
+ suite.addTest(new JavaSearchJavadocTests("testBug49994field", support));
+ suite.addTest(new JavaSearchJavadocTests("testBug49994method", support));
+ suite.addTest(new JavaSearchJavadocTests("testBug49994constructor", support));
+
+// return suite;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.tests.model.AbstractJavaModelTests#assertSearchResults(java.lang.String, java.lang.Object)
+ */
+ protected void assertSearchResults(String message, String expected, Object collector) {
+ if (JavaCore.ENABLED.equals(this.docCommentSupport)) {
+ super.assertSearchResults(message, expected, collector);
+ } else {
+ StringTokenizer tokenizer = new StringTokenizer(expected, "\n");
+ StringBuffer buffer = new StringBuffer(expected.length());
+ while (tokenizer.hasMoreTokens()) {
+ String token = tokenizer.nextToken();
+ if (token.startsWith("src/j1/JavadocSearched.java") || token.startsWith("test47909.jar")) {
+ if (buffer.length() > 0) buffer.append('\n');
+ buffer.append(token);
+ }
+ }
+// System.out.println(getName()+" - Expected: "+buffer.toString());
+ super.assertSearchResults(message, buffer.toString(), collector);
+ }
+ }
/*
* Test search of type declaration in javadoc comments
* ===================================================
@@ -146,7 +206,7 @@
}
public void testJavadocTypeDeclarationWithJavadoc() throws CoreException {
IType type = getCompilationUnit("JavaSearch", "src", "j1", "JavadocSearched.java").getType("JavadocSearched");
- try {
+// try {
setJavadocOptions();
JavaSearchResultCollector result = new JavaSearchResultCollector();
result.showAccuracy = true;
@@ -160,9 +220,9 @@
assertSearchResults(
"src/j1/JavadocSearched.java j1.JavadocSearched [JavadocSearched] EXACT_MATCH",
result);
- } finally {
- resetProjectOptions();
- }
+// } finally {
+// resetProjectOptions();
+// }
}
/*
@@ -203,7 +263,7 @@
public void testJavadocFieldDeclarationWithJavadoc() throws CoreException {
IType type = getCompilationUnit("JavaSearch", "src", "j1", "JavadocSearched.java").getType("JavadocSearched");
IField field = type.getField("javadocSearchedVar");
- try {
+// try {
setJavadocOptions();
JavaSearchResultCollector result = new JavaSearchResultCollector();
result.showAccuracy = true;
@@ -217,9 +277,9 @@
assertSearchResults(
"src/j1/JavadocSearched.java j1.JavadocSearched.javadocSearchedVar [javadocSearchedVar] EXACT_MATCH",
result);
- } finally {
- resetProjectOptions();
- }
+// } finally {
+// resetProjectOptions();
+// }
}
/*
@@ -276,7 +336,7 @@
}
public void testJavadocMethodDeclarationWithJavadoc() throws CoreException {
IType type = getCompilationUnit("JavaSearch", "src", "j1", "JavadocSearched.java").getType("JavadocSearched");
- try {
+// try {
setJavadocOptions();
IMethod method = type.getMethod("javadocSearchedMethod", null);
JavaSearchResultCollector result = new JavaSearchResultCollector();
@@ -291,13 +351,13 @@
assertSearchResults(
"src/j1/JavadocSearched.java void j1.JavadocSearched.javadocSearchedMethod() [javadocSearchedMethod] EXACT_MATCH",
result);
- } finally {
- resetProjectOptions();
- }
+// } finally {
+// resetProjectOptions();
+// }
}
public void testJavadocMethodArgDeclarationWithJavadoc() throws CoreException {
IType type = getCompilationUnit("JavaSearch", "src", "j1", "JavadocSearched.java").getType("JavadocSearched");
- try {
+// try {
setJavadocOptions();
IMethod method = type.getMethod("javadocSearchedMethod", new String[] { "QString;" });
JavaSearchResultCollector result = new JavaSearchResultCollector();
@@ -312,9 +372,9 @@
assertSearchResults(
"src/j1/JavadocSearched.java void j1.JavadocSearched.javadocSearchedMethod(String) [javadocSearchedMethod] EXACT_MATCH",
result);
- } finally {
- resetProjectOptions();
- }
+// } finally {
+// resetProjectOptions();
+// }
}
/*
@@ -373,7 +433,7 @@
}
public void testJavadocTypeReferenceWithJavadoc() throws CoreException {
IType type = getCompilationUnit("JavaSearch", "src", "j1", "JavadocSearched.java").getType("JavadocSearched");
- try {
+// try {
setJavadocOptions();
JavaSearchResultCollector result = new JavaSearchResultCollector();
result.showAccuracy = true;
@@ -397,12 +457,12 @@
"src/j1/JavadocValidRef.java void j1.JavadocValidRef.valid() [JavadocSearched] EXACT_MATCH\n"+
"src/j1/JavadocValidRef.java void j1.JavadocValidRef.valid() [JavadocSearched] EXACT_MATCH",
result);
- } finally {
- resetProjectOptions();
- }
+// } finally {
+// resetProjectOptions();
+// }
}
public void testJavadocTypeStringReferenceWithJavadoc() throws CoreException {
- try {
+// try {
setJavadocOptions();
JavaSearchResultCollector result = new JavaSearchResultCollector();
result.showAccuracy = true;
@@ -427,9 +487,9 @@
"src/j1/JavadocValidRef.java void j1.JavadocValidRef.valid() [JavadocSearched] EXACT_MATCH\n"+
"src/j1/JavadocValidRef.java void j1.JavadocValidRef.valid() [JavadocSearched] EXACT_MATCH",
result);
- } finally {
- resetProjectOptions();
- }
+// } finally {
+// resetProjectOptions();
+// }
}
/*
@@ -473,7 +533,7 @@
public void testJavadocFieldReferenceWithJavadoc() throws CoreException {
IType type = getCompilationUnit("JavaSearch", "src", "j1", "JavadocSearched.java").getType("JavadocSearched");
IField field = type.getField("javadocSearchedVar");
- try {
+// try {
setJavadocOptions();
JavaSearchResultCollector result = new JavaSearchResultCollector();
result.showAccuracy = true;
@@ -488,12 +548,12 @@
"src/j1/JavadocInvalidRef.java void j1.JavadocInvalidRef.invalid() [javadocSearchedVar] POTENTIAL_MATCH\n" +
"src/j1/JavadocValidRef.java void j1.JavadocValidRef.valid() [javadocSearchedVar] EXACT_MATCH",
result);
- } finally {
- resetProjectOptions();
- }
+// } finally {
+// resetProjectOptions();
+// }
}
public void testJavadocFieldStringReferenceWithJavadoc() throws CoreException {
- try {
+// try {
setJavadocOptions();
JavaSearchResultCollector result = new JavaSearchResultCollector();
result.showAccuracy = true;
@@ -510,9 +570,9 @@
"src/j1/JavadocInvalidRef.java void j1.JavadocInvalidRef.invalid() [javadocSearchedVar] POTENTIAL_MATCH\n" +
"src/j1/JavadocValidRef.java void j1.JavadocValidRef.valid() [javadocSearchedVar] EXACT_MATCH",
result);
- } finally {
- resetProjectOptions();
- }
+// } finally {
+// resetProjectOptions();
+// }
}
/*
@@ -572,7 +632,7 @@
}
public void testJavadocMethodReferenceWithJavadoc() throws CoreException {
IType type = getCompilationUnit("JavaSearch", "src", "j1", "JavadocSearched.java").getType("JavadocSearched");
- try {
+// try {
setJavadocOptions();
IMethod method = type.getMethod("javadocSearchedMethod", null);
JavaSearchResultCollector result = new JavaSearchResultCollector();
@@ -588,13 +648,13 @@
"src/j1/JavadocInvalidRef.java void j1.JavadocInvalidRef.invalid() [javadocSearchedMethod] POTENTIAL_MATCH\n" +
"src/j1/JavadocValidRef.java void j1.JavadocValidRef.valid() [javadocSearchedMethod] EXACT_MATCH",
result);
- } finally {
- resetProjectOptions();
- }
+// } finally {
+// resetProjectOptions();
+// }
}
public void testJavadocMethodArgReferenceWithJavadoc() throws CoreException {
IType type = getCompilationUnit("JavaSearch", "src", "j1", "JavadocSearched.java").getType("JavadocSearched");
- try {
+// try {
setJavadocOptions();
IMethod method = type.getMethod("javadocSearchedMethod", new String[] { "QString;" });
JavaSearchResultCollector result = new JavaSearchResultCollector();
@@ -609,12 +669,12 @@
assertSearchResults(
"src/j1/JavadocValidRef.java void j1.JavadocValidRef.valid() [javadocSearchedMethod] EXACT_MATCH",
result);
- } finally {
- resetProjectOptions();
- }
+// } finally {
+// resetProjectOptions();
+// }
}
public void testJavadocMethodStringReferenceWithJavadoc() throws CoreException {
- try {
+// try {
setJavadocOptions();
JavaSearchResultCollector result = new JavaSearchResultCollector();
result.showAccuracy = true;
@@ -632,9 +692,9 @@
"src/j1/JavadocValidRef.java void j1.JavadocValidRef.valid() [javadocSearchedMethod] EXACT_MATCH\n" +
"src/j1/JavadocValidRef.java void j1.JavadocValidRef.valid() [javadocSearchedMethod] EXACT_MATCH",
result);
- } finally {
- resetProjectOptions();
- }
+// } finally {
+// resetProjectOptions();
+// }
}
/*
@@ -692,7 +752,7 @@
}
public void testJavadocConstructorReferenceWithJavadoc() throws CoreException {
IType type = getCompilationUnit("JavaSearch", "src", "j1", "JavadocSearched.java").getType("JavadocSearched");
- try {
+// try {
setJavadocOptions();
IMethod method = type.getMethod("JavadocSearched", null);
JavaSearchResultCollector result = new JavaSearchResultCollector();
@@ -707,13 +767,13 @@
assertSearchResults(
"src/j1/JavadocValidRef.java void j1.JavadocValidRef.valid() [JavadocSearched] EXACT_MATCH",
result);
- } finally {
- resetProjectOptions();
- }
+// } finally {
+// resetProjectOptions();
+// }
}
public void testJavadocConstructorArgReferenceWithJavadoc() throws CoreException {
IType type = getCompilationUnit("JavaSearch", "src", "j1", "JavadocSearched.java").getType("JavadocSearched");
- try {
+// try {
setJavadocOptions();
IMethod method = type.getMethod("JavadocSearched", new String[] { "QString;" });
JavaSearchResultCollector result = new JavaSearchResultCollector();
@@ -728,12 +788,12 @@
assertSearchResults(
"src/j1/JavadocValidRef.java void j1.JavadocValidRef.valid() [JavadocSearched] EXACT_MATCH",
result);
- } finally {
- resetProjectOptions();
- }
+// } finally {
+// resetProjectOptions();
+// }
}
public void testJavadocConstructorStringReferenceWithJavadoc() throws CoreException {
- try {
+// try {
setJavadocOptions();
JavaSearchResultCollector result = new JavaSearchResultCollector();
result.showAccuracy = true;
@@ -750,9 +810,9 @@
"src/j1/JavadocValidRef.java void j1.JavadocValidRef.valid() [JavadocSearched] EXACT_MATCH\n" +
"src/j1/JavadocValidRef.java void j1.JavadocValidRef.valid() [JavadocSearched] EXACT_MATCH",
result);
- } finally {
- resetProjectOptions();
- }
+// } finally {
+// resetProjectOptions();
+// }
}
/**
@@ -762,7 +822,7 @@
*/
public void testBug47909() throws CoreException {
IType type = getCompilationUnit("JavaSearch", "src", "j3", "Y.java").getType("Y");
- try {
+// try {
setJavadocOptions();
IMethod method = type.getMethod("Y", new String[] { "I" });
JavaSearchResultCollector result = new JavaSearchResultCollector();
@@ -777,9 +837,9 @@
assertSearchResults(
"test47909.jar void j3.X.bar() EXACT_MATCH",
result);
- } finally {
- resetProjectOptions();
- }
+// } finally {
+// resetProjectOptions();
+// }
}
/**
@@ -789,7 +849,7 @@
*/
public void testBug47968type() throws CoreException {
IType type = getCompilationUnit("JavaSearch", "src", "j2", "Bug47968.java").getType("Bug47968");
- try {
+// try {
setJavadocOptions();
JavaSearchResultCollector result = new JavaSearchResultCollector();
result.showAccuracy = true;
@@ -820,13 +880,13 @@
"src/j2/Bug47968s.java void j2.Bug47968s.bar() [Bug47968] EXACT_MATCH\n" +
"src/j2/Bug47968s.java void j2.Bug47968s.bar() [Bug47968] EXACT_MATCH",
result);
- } finally {
- resetProjectOptions();
- }
+// } finally {
+// resetProjectOptions();
+// }
}
public void testBug47968field() throws CoreException {
IType type = getCompilationUnit("JavaSearch", "src", "j2", "Bug47968.java").getType("Bug47968");
- try {
+// try {
setJavadocOptions();
IField field = type.getField("x");
JavaSearchResultCollector result = new JavaSearchResultCollector();
@@ -844,13 +904,13 @@
"src/j2/Bug47968s.java j2.Bug47968s() [x] EXACT_MATCH\n" +
"src/j2/Bug47968s.java void j2.Bug47968s.bar() [x] EXACT_MATCH",
result);
- } finally {
- resetProjectOptions();
- }
+// } finally {
+// resetProjectOptions();
+// }
}
public void testBug47968method() throws CoreException {
IType type = getCompilationUnit("JavaSearch", "src", "j2", "Bug47968.java").getType("Bug47968");
- try {
+// try {
setJavadocOptions();
IMethod method = type.getMethod("foo", new String[] { "I" });
JavaSearchResultCollector result = new JavaSearchResultCollector();
@@ -868,13 +928,13 @@
"src/j2/Bug47968s.java j2.Bug47968s() [foo] EXACT_MATCH\n" +
"src/j2/Bug47968s.java void j2.Bug47968s.bar() [foo] EXACT_MATCH",
result);
- } finally {
- resetProjectOptions();
- }
+// } finally {
+// resetProjectOptions();
+// }
}
public void testBug47968constructor() throws CoreException {
IType type = getCompilationUnit("JavaSearch", "src", "j2", "Bug47968.java").getType("Bug47968");
- try {
+// try {
setJavadocOptions();
IMethod method = type.getMethod("Bug47968", new String[] { "QString;" });
JavaSearchResultCollector result = new JavaSearchResultCollector();
@@ -892,9 +952,9 @@
"src/j2/Bug47968s.java j2.Bug47968s() [Bug47968] EXACT_MATCH\n" +
"src/j2/Bug47968s.java void j2.Bug47968s.bar() [Bug47968] EXACT_MATCH",
result);
- } finally {
- resetProjectOptions();
- }
+// } finally {
+// resetProjectOptions();
+// }
}
/**
@@ -903,7 +963,7 @@
* @throws CoreException
*/
public void testBug47209type() throws CoreException {
- try {
+// try {
setJavadocOptions();
JavaSearchResultCollector result = new JavaSearchResultCollector();
result.showAccuracy = true;
@@ -921,12 +981,12 @@
"src/j4/TC47209.java j4.TC47209(String) [TC47209] EXACT_MATCH\n" +
"src/j4/TM47209.java void j4.TM47209.m47209(int) [TM47209] EXACT_MATCH",
result);
- } finally {
- resetProjectOptions();
- }
+// } finally {
+// resetProjectOptions();
+// }
}
public void testBug47209field() throws CoreException {
- try {
+// try {
setJavadocOptions();
JavaSearchResultCollector result = new JavaSearchResultCollector();
result.showAccuracy = true;
@@ -944,12 +1004,12 @@
"src/j4/FC47209.java j4.FC47209(String) [FC47209] EXACT_MATCH\n" +
"src/j4/FM47209.java void j4.FM47209.m47209(int) [FM47209] EXACT_MATCH",
result);
- } finally {
- resetProjectOptions();
- }
+// } finally {
+// resetProjectOptions();
+// }
}
public void testBug47209method() throws CoreException {
- try {
+// try {
setJavadocOptions();
JavaSearchResultCollector result = new JavaSearchResultCollector();
result.showAccuracy = true;
@@ -967,12 +1027,12 @@
"src/j4/MC47209.java j4.MC47209(String) [MC47209] EXACT_MATCH\n" +
"src/j4/MM47209.java void j4.MM47209.m47209(int) [MM47209] EXACT_MATCH",
result);
- } finally {
- resetProjectOptions();
- }
+// } finally {
+// resetProjectOptions();
+// }
}
public void testBug47209constructor() throws CoreException {
- try {
+// try {
setJavadocOptions();
JavaSearchResultCollector result = new JavaSearchResultCollector();
result.showAccuracy = true;
@@ -990,9 +1050,9 @@
"src/j4/CC47209.java j4.CC47209(String) [CC47209] EXACT_MATCH\n" +
"src/j4/CM47209.java void j4.CM47209.m47209(int) [CM47209] EXACT_MATCH",
result);
- } finally {
- resetProjectOptions();
- }
+// } finally {
+// resetProjectOptions();
+// }
}
/**
@@ -1001,19 +1061,19 @@
* @throws CoreException
*/
public void testBug49994() throws CoreException {
- try {
+// try {
setJavadocOptions();
JavaSearchResultCollector result = new JavaSearchResultCollector();
result.showAccuracy = true;
IType type = getCompilationUnit("JavaSearch", "src", "j5", "Bug49994.java").getType("Bug49994");
new SearchEngine().search(getWorkspace(), type, REFERENCES, getJavaSearchScope(), result);
assertSearchResults("", result);
- } finally {
- resetProjectOptions();
- }
+// } finally {
+// resetProjectOptions();
+// }
}
public void testBug49994field() throws CoreException {
- try {
+// try {
setJavadocOptions();
JavaSearchResultCollector result = new JavaSearchResultCollector();
result.showAccuracy = true;
@@ -1021,12 +1081,12 @@
IField field = type.getField("field");
new SearchEngine().search(getWorkspace(), field, REFERENCES, getJavaSearchScope(), result);
assertSearchResults("src/j5/Bug49994.java void j5.Bug49994.foo() [field] EXACT_MATCH", result);
- } finally {
- resetProjectOptions();
- }
+// } finally {
+// resetProjectOptions();
+// }
}
public void testBug49994method() throws CoreException {
- try {
+// try {
setJavadocOptions();
JavaSearchResultCollector result = new JavaSearchResultCollector();
result.showAccuracy = true;
@@ -1034,12 +1094,12 @@
IMethod method = type.getMethod("bar", new String[0]);
new SearchEngine().search(getWorkspace(), method, REFERENCES, getJavaSearchScope(), result);
assertSearchResults("src/j5/Bug49994.java void j5.Bug49994.foo() [bar] EXACT_MATCH", result);
- } finally {
- resetProjectOptions();
- }
+// } finally {
+// resetProjectOptions();
+// }
}
public void testBug49994constructor() throws CoreException {
- try {
+// try {
setJavadocOptions();
JavaSearchResultCollector result = new JavaSearchResultCollector();
result.showAccuracy = true;
@@ -1047,8 +1107,8 @@
IMethod method = type.getMethod("Bug49994", new String[] { "QString;" });
new SearchEngine().search(getWorkspace(), method, REFERENCES, getJavaSearchScope(), result);
assertSearchResults("src/j5/Bug49994.java void j5.Bug49994.foo() [Bug49994] EXACT_MATCH", result);
- } finally {
- resetProjectOptions();
- }
+// } finally {
+// resetProjectOptions();
+// }
}
}
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java
index 81177f2..a8229f2 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java
@@ -842,39 +842,51 @@
isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE);
} else if (token.equals("javadoc")) {//$NON-NLS-1$
this.options.put(
- CompilerOptions.OPTION_ReportInvalidJavadoc,
- isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE);
- this.options.put(
- CompilerOptions.OPTION_ReportInvalidJavadocTags,
- isEnabling ? CompilerOptions.ENABLED : CompilerOptions.DISABLED);
- this.options.put(
- CompilerOptions.OPTION_ReportInvalidJavadocTagsVisibility,
- isEnabling ? CompilerOptions.PRIVATE : CompilerOptions.PUBLIC);
- this.options.put(
- CompilerOptions.OPTION_ReportMissingJavadocTags,
- isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE);
- this.options.put(
- CompilerOptions.OPTION_ReportMissingJavadocTagsVisibility,
- isEnabling ? CompilerOptions.PRIVATE : CompilerOptions.PUBLIC);
+ CompilerOptions.OPTION_DocCommentSupport,
+ isEnabling ? CompilerOptions.ENABLED: CompilerOptions.DISABLED);
+ // if disabling then it's not necessary to set other javadoc options
+ if (isEnabling) {
+ this.options.put(
+ CompilerOptions.OPTION_ReportInvalidJavadoc,
+ CompilerOptions.WARNING);
+ this.options.put(
+ CompilerOptions.OPTION_ReportInvalidJavadocTags,
+ CompilerOptions.ENABLED);
+ this.options.put(
+ CompilerOptions.OPTION_ReportInvalidJavadocTagsVisibility,
+ CompilerOptions.PRIVATE);
+ this.options.put(
+ CompilerOptions.OPTION_ReportMissingJavadocTags,
+ CompilerOptions.WARNING);
+ this.options.put(
+ CompilerOptions.OPTION_ReportMissingJavadocTagsVisibility,
+ CompilerOptions.PRIVATE);
+ }
} else if (token.equals("allJavadoc")) { //$NON-NLS-1$
this.options.put(
+ CompilerOptions.OPTION_DocCommentSupport,
+ isEnabling ? CompilerOptions.ENABLED: CompilerOptions.DISABLED);
+ // if disabling then it's not necessary to set other javadoc options
+ if (isEnabling) {
+ this.options.put(
CompilerOptions.OPTION_ReportInvalidJavadoc,
- isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE);
- this.options.put(
- CompilerOptions.OPTION_ReportInvalidJavadocTags,
- isEnabling ? CompilerOptions.ENABLED : CompilerOptions.DISABLED);
- this.options.put(
- CompilerOptions.OPTION_ReportInvalidJavadocTagsVisibility,
- isEnabling ? CompilerOptions.PRIVATE : CompilerOptions.PUBLIC);
- this.options.put(
- CompilerOptions.OPTION_ReportMissingJavadocTags,
- isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE);
- this.options.put(
- CompilerOptions.OPTION_ReportMissingJavadocTagsVisibility,
- isEnabling ? CompilerOptions.PRIVATE : CompilerOptions.PUBLIC);
- this.options.put(
- CompilerOptions.OPTION_ReportMissingJavadocComments,
- isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE);
+ CompilerOptions.WARNING);
+ this.options.put(
+ CompilerOptions.OPTION_ReportInvalidJavadocTags,
+ CompilerOptions.ENABLED);
+ this.options.put(
+ CompilerOptions.OPTION_ReportInvalidJavadocTagsVisibility,
+ CompilerOptions.PRIVATE);
+ this.options.put(
+ CompilerOptions.OPTION_ReportMissingJavadocTags,
+ CompilerOptions.WARNING);
+ this.options.put(
+ CompilerOptions.OPTION_ReportMissingJavadocTagsVisibility,
+ CompilerOptions.PRIVATE);
+ this.options.put(
+ CompilerOptions.OPTION_ReportMissingJavadocComments,
+ CompilerOptions.WARNING);
+ }
} else if (token.startsWith("tasks")) { //$NON-NLS-1$
String taskTags = ""; //$NON-NLS-1$
int start = token.indexOf('(');
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties
index f7ce4bd..510d4a7 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties
@@ -12,7 +12,7 @@
### compiler
compiler.name = Eclipse Java Compiler
-compiler.version = 0.411
+compiler.version = 0.412
compiler.copyright = Copyright IBM Corp 2000, 2004. All rights reserved.
### scanning
diff --git a/org.eclipse.jdt.core/buildnotes_jdt-core.html b/org.eclipse.jdt.core/buildnotes_jdt-core.html
index e99c160..d50b2d2 100644
--- a/org.eclipse.jdt.core/buildnotes_jdt-core.html
+++ b/org.eclipse.jdt.core/buildnotes_jdt-core.html
@@ -54,6 +54,44 @@
ArrayStoreException in 1.5 parser
+<a name="v_412"></a>
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK 3.0M8 Build - ?th March 2004
+<br>Project org.eclipse.jdt.core v_412
+(<a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.core/?only_with_tag=v_412">cvs</a>).
+<h2>
+What's new in this drop</h2>
+<ul>
+<li>Added new global option for doc comment (Javadoc) support. By default, this option is enabled for backward compatibility.
+<pre>
+ * COMPILER / Javadoc Comment Support
+ * When this support is disabled, the compiler will ignore all javadoc problems options settings
+ * and will not report any javadoc problem. It will also not find any reference in javadoc comment and
+ * DOM AST Javadoc node will be only a flat text instead of having structured tag elements.
+ * - option id: "org.eclipse.jdt.core.compiler.doc.comment.support"
+ * - possible values: { "enabled", "disabled" }
+ * - default: "enabled"
+</pre>
+See bug <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=52264">52264</a>.
+</li>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=53357">53357</a>
+Java AST creation error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=52264">52264</a>
+Need a global preference to enable Javadoc support
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=51529">51529</a>
+"Organize imports" is confused by references inside Javadoc
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=53477">53477</a>
+AnonymousClassDeclaration has wrong range
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=53624">53624</a>
+StackOverFlow in Code assist
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=50433">50433</a>
+Rationalize signatures of AST.parse* methods
+
<a name="v_411"></a>
<p><hr><h1>
Eclipse Platform Build Notes <br>
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java
index c1e0db0..74b8ce6 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java
@@ -1793,7 +1793,7 @@
pushOnElementStack(K_BETWEEN_CATCH_AND_RIGHT_PAREN);
break;
case TokenNameLPAREN:
- if (this.invocationType == NO_RECEIVER || this.invocationType == NAME_RECEIVER) {
+ if (this.invocationType == NO_RECEIVER || this.invocationType == NAME_RECEIVER || this.invocationType == SUPER_RECEIVER) {
this.qualifier = this.expressionPtr; // remenber the last expression so that arguments are correctly computed
}
switch (previous) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
index 54c28ca..d652a22 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
@@ -31,6 +31,7 @@
public static final String OPTION_LineNumberAttribute = "org.eclipse.jdt.core.compiler.debug.lineNumber"; //$NON-NLS-1$
public static final String OPTION_SourceFileAttribute = "org.eclipse.jdt.core.compiler.debug.sourceFile"; //$NON-NLS-1$
public static final String OPTION_PreserveUnusedLocal = "org.eclipse.jdt.core.compiler.codegen.unusedLocal"; //$NON-NLS-1$
+ public static final String OPTION_DocCommentSupport= "org.eclipse.jdt.core.compiler.doc.comment.support"; //$NON-NLS-1$
public static final String OPTION_ReportMethodWithConstructorName = "org.eclipse.jdt.core.compiler.problem.methodWithConstructorName"; //$NON-NLS-1$
public static final String OPTION_ReportOverridingPackageDefaultMethod = "org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod"; //$NON-NLS-1$
public static final String OPTION_ReportDeprecation = "org.eclipse.jdt.core.compiler.problem.deprecation"; //$NON-NLS-1$
@@ -230,6 +231,9 @@
// JSR bytecode usage
public boolean useJsrBytecode = true;
+ // javadoc comment support
+ public boolean docCommentSupport = false;
+
/**
* Initializing the compiler options with defaults
@@ -254,6 +258,7 @@
optionsMap.put(OPTION_LineNumberAttribute, (this.produceDebugAttributes & Lines) != 0 ? GENERATE : DO_NOT_GENERATE);
optionsMap.put(OPTION_SourceFileAttribute, (this.produceDebugAttributes & Source) != 0 ? GENERATE : DO_NOT_GENERATE);
optionsMap.put(OPTION_PreserveUnusedLocal, this.preserveAllLocalVariables ? PRESERVE : OPTIMIZE_OUT);
+ optionsMap.put(OPTION_DocCommentSupport, this.docCommentSupport ? ENABLED : DISABLED);
optionsMap.put(OPTION_ReportMethodWithConstructorName, getSeverityString(MethodWithConstructorName));
optionsMap.put(OPTION_ReportOverridingPackageDefaultMethod, getSeverityString(OverriddenPackageDefaultMethod));
optionsMap.put(OPTION_ReportDeprecation, getSeverityString(UsingDeprecatedAPI));
@@ -497,6 +502,13 @@
if ((optionValue = optionsMap.get(OPTION_ReportNoEffectAssignment)) != null) updateSeverity(NoEffectAssignment, optionValue);
// Javadoc options
+ if ((optionValue = optionsMap.get(OPTION_DocCommentSupport)) != null) {
+ if (ENABLED.equals(optionValue)) {
+ this.docCommentSupport = true;
+ } else if (DISABLED.equals(optionValue)) {
+ this.docCommentSupport = false;
+ }
+ }
if ((optionValue = optionsMap.get(OPTION_ReportInvalidJavadoc)) != null) {
updateSeverity(InvalidJavadoc, optionValue);
}
@@ -589,15 +601,16 @@
buf.append("\n\t- superfluous semicolon: ").append(getSeverityString(SuperfluousSemicolon)); //$NON-NLS-1$
buf.append("\n\t- uncommented empty block: ").append(getSeverityString(UndocumentedEmptyBlock)); //$NON-NLS-1$
buf.append("\n\t- unnecessary type check: ").append(getSeverityString(UnnecessaryTypeCheck)); //$NON-NLS-1$
- buf.append("\n\t- invalid javadoc: ").append(getSeverityString(InvalidJavadoc)); //$NON-NLS-1$
- buf.append("\n\t- report invalid javadoc tags: ").append(this.reportInvalidJavadocTags ? ENABLED : DISABLED); //$NON-NLS-1$
- buf.append("\n\t- visibility level to report invalid javadoc tags: ").append(getVisibilityString(this.reportInvalidJavadocTagsVisibility)); //$NON-NLS-1$
- buf.append("\n\t- missing javadoc tags: ").append(getSeverityString(MissingJavadocTags)); //$NON-NLS-1$
- buf.append("\n\t- visibility level to report missing javadoc tags: ").append(getVisibilityString(this.reportMissingJavadocTagsVisibility)); //$NON-NLS-1$
- buf.append("\n\t- report missing javadoc tags in overriding methods: ").append(this.reportMissingJavadocTagsOverriding ? ENABLED : DISABLED); //$NON-NLS-1$
- buf.append("\n\t- missing javadoc comments: ").append(getSeverityString(MissingJavadocComments)); //$NON-NLS-1$
- buf.append("\n\t- visibility level to report missing javadoc comments: ").append(getVisibilityString(this.reportMissingJavadocCommentsVisibility)); //$NON-NLS-1$
- buf.append("\n\t- report missing javadoc comments in overriding methods: ").append(this.reportMissingJavadocCommentsOverriding ? ENABLED : DISABLED); //$NON-NLS-1$
+ buf.append("\n\t- javadoc comment support: ").append(this.docCommentSupport ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ buf.append("\n\t\t+ invalid javadoc: ").append(getSeverityString(InvalidJavadoc)); //$NON-NLS-1$
+ buf.append("\n\t\t+ report invalid javadoc tags: ").append(this.reportInvalidJavadocTags ? ENABLED : DISABLED); //$NON-NLS-1$
+ buf.append("\n\t\t+ visibility level to report invalid javadoc tags: ").append(getVisibilityString(this.reportInvalidJavadocTagsVisibility)); //$NON-NLS-1$
+ buf.append("\n\t\t+ missing javadoc tags: ").append(getSeverityString(MissingJavadocTags)); //$NON-NLS-1$
+ buf.append("\n\t\t+ visibility level to report missing javadoc tags: ").append(getVisibilityString(this.reportMissingJavadocTagsVisibility)); //$NON-NLS-1$
+ buf.append("\n\t\t+ report missing javadoc tags in overriding methods: ").append(this.reportMissingJavadocTagsOverriding ? ENABLED : DISABLED); //$NON-NLS-1$
+ buf.append("\n\t\t+ missing javadoc comments: ").append(getSeverityString(MissingJavadocComments)); //$NON-NLS-1$
+ buf.append("\n\t\t+ visibility level to report missing javadoc comments: ").append(getVisibilityString(this.reportMissingJavadocCommentsVisibility)); //$NON-NLS-1$
+ buf.append("\n\t\t+ report missing javadoc comments in overriding methods: ").append(this.reportMissingJavadocCommentsOverriding ? ENABLED : DISABLED); //$NON-NLS-1$
buf.append("\n\t- finally block not completing normally: ").append(getSeverityString(FinallyBlockNotCompleting)); //$NON-NLS-1$
buf.append("\n\t- unused declared thrown exception: ").append(getSeverityString(UnusedDeclaredThrownException)); //$NON-NLS-1$
buf.append("\n\t- unused declared thrown exception when overriding ").append(this.reportUnusedDeclaredThrownExceptionWhenOverriding ? ENABLED : DISABLED); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java
index c118b0b..0bd6b1c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java
@@ -46,6 +46,7 @@
// Public fields
public Scanner scanner;
+ public boolean checkDocComment = false;
// Protected fields
protected boolean inherited, deprecated;
@@ -102,7 +103,8 @@
this.endComment = javadocEnd;
this.index = javadocStart;
readChar(); // starting '/'
- int charPosition = this.index;
+ int previousPosition = this.index;
+ int endTextPosition = this.index;
readChar(); // first '*'
char nextCharacter= readChar(); // second '*'
@@ -124,7 +126,7 @@
// Loop on each comment character
while (this.index < this.endComment) {
- int previousPosition = this.index;
+ previousPosition = this.index;
previousChar = nextCharacter;
// Calculate line end (cannot use this.scanner.linePtr as scanner does not parse line ends again)
@@ -163,12 +165,12 @@
this.lineStarted = true;
if (this.inlineTagStarted) {
this.inlineTagStarted = false;
- if (this.sourceParser != null) this.sourceParser.problemReporter().javadocInvalidTag(this.inlineTagStart, charPosition);
+ if (this.sourceParser != null) this.sourceParser.problemReporter().javadocInvalidTag(this.inlineTagStart, endTextPosition);
validComment = false;
} else {
if (previousChar == '{') {
- if (this.textStart != -1 && this.textStart <= charPosition) {
- pushText(this.textStart, charPosition);
+ if (this.textStart != -1 && this.textStart < endTextPosition) {
+ pushText(this.textStart, endTextPosition);
}
this.inlineTagStarted = true;
}
@@ -283,9 +285,8 @@
break;
case '\r':
case '\n':
- int position = previousChar == '{' ? this.inlineTagStart : charPosition;
- if (this.lineStarted && this.textStart <= position) {
- pushText(this.textStart, position);
+ if (this.lineStarted && this.textStart < previousPosition) {
+ pushText(this.textStart, previousPosition);
}
this.lineStarted = false;
this.inlineTagStarted = false;
@@ -294,18 +295,18 @@
break;
case '}' :
if (this.inlineTagStarted) {
- if (this.lineStarted && this.textStart != -1 && this.textStart <= charPosition) {
- pushText(this.textStart, charPosition);
+ if (this.lineStarted && this.textStart != -1 && this.textStart < previousPosition) {
+ pushText(this.textStart, previousPosition);
}
if (this.kind == DOM_PARSER) refreshInlineTagPosition(previousPosition);
this.textStart = this.index;
this.inlineTagStarted = false;
- } else /*if (this.index <= this.lineEnd)*/ {
+ } else {
if (!this.lineStarted) {
this.textStart = previousPosition;
}
this.lineStarted = true;
- charPosition = previousPosition;
+ endTextPosition = previousPosition;
}
break;
case '{' :
@@ -321,10 +322,11 @@
}
break;
case '*' :
- charPosition = previousPosition;
+ // do nothing for '*' character
+ endTextPosition = previousPosition;
break;
default :
- charPosition = previousPosition;
+ endTextPosition = previousPosition;
if (!CharOperation.isWhitespace(nextCharacter)) {
if (!this.lineStarted) {
this.textStart = previousPosition;
@@ -333,8 +335,8 @@
}
}
}
- if (this.lineStarted && this.textStart <= charPosition) {
- pushText(this.textStart, charPosition);
+ if (this.lineStarted && this.textStart < previousPosition) {
+ pushText(this.textStart, previousPosition);
}
updateDocComment();
} catch (Exception ex) {
@@ -678,7 +680,7 @@
if (this.source[this.index] == '\r' || this.source[this.index] == '\n') {
if (this.kind == DOM_PARSER) {
parseTag();
- pushText(previousPosition, this.index-1);
+ pushText(previousPosition, this.index);
}
return true;
}
@@ -698,7 +700,7 @@
if (this.source[this.index] == '\r' || this.source[this.index] == '\n') {
if (this.kind == DOM_PARSER) {
parseTag();
- pushText(previousPosition, this.index-1);
+ pushText(previousPosition, this.index);
}
return true;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java
index 7016c8f..4f7d12b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java
@@ -38,12 +38,10 @@
// Public fields
public Javadoc docComment;
- public boolean checkDocComment = false;
JavadocParser(Parser sourceParser) {
super(sourceParser);
- this.checkDocComment = (this.sourceParser.options.getSeverity(CompilerOptions.InvalidJavadoc) != ProblemSeverities.Ignore) ||
- (this.sourceParser.options.getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore);
+ this.checkDocComment = this.sourceParser.options.docCommentSupport;
this.kind = COMPIL_PARSER;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
index 9e44d03..2d82112 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
@@ -501,7 +501,11 @@
case IProblem.JavadocInvalidSeeHref:
case IProblem.JavadocInvalidSeeArgs:
case IProblem.JavadocInvalidTag:
- return this.options.getSeverity(CompilerOptions.InvalidJavadoc);
+ if (this.options.docCommentSupport) {
+ return this.options.getSeverity(CompilerOptions.InvalidJavadoc);
+ } else {
+ return ProblemSeverities.Ignore;
+ }
/*
* Javadoc tags resolved references errors
@@ -533,10 +537,11 @@
case IProblem.JavadocInternalTypeNameProvided:
case IProblem.JavadocNoMessageSendOnArrayType:
case IProblem.JavadocNoMessageSendOnBaseType:
- if (!this.options.reportInvalidJavadocTags)
- return ProblemSeverities.Ignore;
- else
+ if (this.options.docCommentSupport && this.options.reportInvalidJavadocTags) {
return this.options.getSeverity(CompilerOptions.InvalidJavadoc);
+ } else {
+ return ProblemSeverities.Ignore;
+ }
/*
* Javadoc missing tags errors
@@ -544,13 +549,21 @@
case IProblem.JavadocMissingParamTag:
case IProblem.JavadocMissingReturnTag:
case IProblem.JavadocMissingThrowsTag:
- return this.options.getSeverity(CompilerOptions.MissingJavadocTags);
+ if (this.options.docCommentSupport) {
+ return this.options.getSeverity(CompilerOptions.MissingJavadocTags);
+ } else {
+ return ProblemSeverities.Ignore;
+ }
/*
* Missing Javadoc errors
*/
case IProblem.JavadocMissing:
- return this.options.getSeverity(CompilerOptions.MissingJavadocComments);
+ if (this.options.docCommentSupport) {
+ return this.options.getSeverity(CompilerOptions.MissingJavadocComments);
+ } else {
+ return ProblemSeverities.Ignore;
+ }
// by default problems are errors.
default:
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java
index 539e35b..1f5fac3 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java
@@ -395,7 +395,7 @@
}
try {
this.disableEvents++;
- this.eventHandler.preRemoveChildEvent(node, child, property);
+ this.eventHandler.postRemoveChildEvent(node, child, property);
// N.B. even if event handler blows up, the AST is not
// corrupted since node has not been changed yet
} finally {
@@ -469,7 +469,7 @@
}
try {
this.disableEvents++;
- this.eventHandler.postAddChildEvent(node, child, property);
+ this.eventHandler.preAddChildEvent(node, child, property);
// N.B. even if event handler blows up, the AST is not
// corrupted since node has already been changed
} finally {
@@ -517,7 +517,7 @@
}
try {
this.disableEvents++;
- this.eventHandler.postValueChangeEvent(node, property);
+ this.eventHandler.preValueChangeEvent(node, property);
// N.B. even if event handler blows up, the AST is not
// corrupted since node has already been changed
} finally {
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java
index 92e5238..7a292dd 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java
@@ -44,6 +44,7 @@
private IProgressMonitor monitor;
// comments
private boolean insideComments;
+ private DocCommentParser docParser;
private Comment[] commentsTable;
public ASTConverter(Map options, boolean resolveBindings, IProgressMonitor monitor) {
@@ -56,11 +57,12 @@
null /*taskTags*/,
null/*taskPriorities*/);
this.monitor = monitor;
- this.insideComments = true;
+ this.insideComments = JavaCore.ENABLED.equals(options.get(JavaCore.COMPILER_DOC_COMMENT_SUPPORT));
}
public void setAST(AST ast) {
this.ast = ast;
+ this.docParser = new DocCommentParser(this.ast, this.scanner, this.insideComments);
}
/*
@@ -132,7 +134,7 @@
// Parse comments
int[][] comments = unit.comments;
- if (comments != null && this.insideComments) {
+ if (comments != null) {
buildCommentsTable(compilationUnit, comments);
}
@@ -1124,7 +1126,7 @@
}
}
AnonymousClassDeclaration anonymousClassDeclaration = this.ast.newAnonymousClassDeclaration();
- int start = retrieveStartBlockPosition(declarationSourceStart, allocation.anonymousType.bodyEnd);
+ int start = retrieveStartBlockPosition(allocation.anonymousType.sourceEnd, allocation.anonymousType.bodyEnd);
anonymousClassDeclaration.setSourceRange(start, allocation.anonymousType.bodyEnd - start + 1);
classInstanceCreation.setAnonymousClassDeclaration(anonymousClassDeclaration);
buildBodyDeclarations(allocation.anonymousType, anonymousClassDeclaration);
@@ -3094,8 +3096,7 @@
int end = positions[1];
if (positions[1]>0) { // Javadoc comments have positive end position
this.ast.newJavadoc();
- DocCommentParser docParser = new DocCommentParser(this.ast, this.scanner);
- Javadoc docComment = docParser.parse(positions);
+ Javadoc docComment = this.docParser.parse(positions);
if (docComment == null) return null;
comment = docComment;
} else {
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter2.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter2.java
index 8514e9e..8a46fae 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter2.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter2.java
@@ -44,6 +44,7 @@
private IProgressMonitor monitor;
// comments
private boolean insideComments;
+ private DocCommentParser docParser;
private Comment[] commentsTable;
public ASTConverter2(Map options, boolean resolveBindings, IProgressMonitor monitor) {
@@ -56,11 +57,12 @@
null /*taskTags*/,
null/*taskPriorities*/);
this.monitor = monitor;
- this.insideComments = true;
+ this.insideComments = JavaCore.ENABLED.equals(options.get(JavaCore.COMPILER_DOC_COMMENT_SUPPORT));
}
public void setAST(AST ast) {
this.ast = ast;
+ this.docParser = new DocCommentParser(this.ast, this.scanner, this.insideComments);
}
/*
@@ -132,7 +134,7 @@
// Parse comments
int[][] comments = unit.comments;
- if (comments != null && this.insideComments) {
+ if (comments != null) {
buildCommentsTable(compilationUnit, comments);
}
@@ -1124,7 +1126,7 @@
}
}
AnonymousClassDeclaration anonymousClassDeclaration = this.ast.newAnonymousClassDeclaration();
- int start = retrieveStartBlockPosition(declarationSourceStart, allocation.anonymousType.bodyEnd);
+ int start = retrieveStartBlockPosition(allocation.anonymousType.sourceEnd, allocation.anonymousType.bodyEnd);
anonymousClassDeclaration.setSourceRange(start, allocation.anonymousType.bodyEnd - start + 1);
classInstanceCreation.setAnonymousClassDeclaration(anonymousClassDeclaration);
buildBodyDeclarations(allocation.anonymousType, anonymousClassDeclaration);
@@ -3094,8 +3096,7 @@
int end = positions[1];
if (positions[1]>0) { // Javadoc comments have positive end position
this.ast.newJavadoc();
- DocCommentParser docParser = new DocCommentParser(this.ast, this.scanner);
- Javadoc docComment = docParser.parse(positions);
+ Javadoc docComment = this.docParser.parse(positions);
if (docComment == null) return null;
comment = docComment;
} else {
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java
index 8eeca85..68839d3 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java
@@ -54,6 +54,7 @@
import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
+import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
/**
* Internal class for resolving bindings using old ASTs.
@@ -132,10 +133,14 @@
// a extra lookup is required
BlockScope internalScope = (BlockScope) this.astNodesToBlockScope.get(name);
Binding binding = null;
- if (internalScope == null) {
- binding = this.scope.getTypeOrPackage(CharOperation.subarray(tokens, 0, indexInQualifiedName));
- } else {
- binding = internalScope.getTypeOrPackage(CharOperation.subarray(tokens, 0, indexInQualifiedName));
+ try {
+ if (internalScope == null) {
+ binding = this.scope.getTypeOrPackage(CharOperation.subarray(tokens, 0, indexInQualifiedName));
+ } else {
+ binding = internalScope.getTypeOrPackage(CharOperation.subarray(tokens, 0, indexInQualifiedName));
+ }
+ } catch (AbortCompilation e) {
+ // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=53357
}
if (binding instanceof org.eclipse.jdt.internal.compiler.lookup.PackageBinding) {
return this.getPackageBinding((org.eclipse.jdt.internal.compiler.lookup.PackageBinding)binding);
@@ -205,10 +210,14 @@
if (indexInQualifiedName >= 0) {
BlockScope internalScope = (BlockScope) this.astNodesToBlockScope.get(name);
Binding binding = null;
- if (internalScope == null) {
- binding = this.scope.getTypeOrPackage(CharOperation.subarray(qualifiedTypeReference.tokens, 0, indexInQualifiedName));
- } else {
- binding = internalScope.getTypeOrPackage(CharOperation.subarray(qualifiedTypeReference.tokens, 0, indexInQualifiedName));
+ try {
+ if (internalScope == null) {
+ binding = this.scope.getTypeOrPackage(CharOperation.subarray(qualifiedTypeReference.tokens, 0, indexInQualifiedName));
+ } else {
+ binding = internalScope.getTypeOrPackage(CharOperation.subarray(qualifiedTypeReference.tokens, 0, indexInQualifiedName));
+ }
+ } catch (AbortCompilation e) {
+ // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=53357
}
if (binding instanceof org.eclipse.jdt.internal.compiler.lookup.PackageBinding) {
return this.getPackageBinding((org.eclipse.jdt.internal.compiler.lookup.PackageBinding)binding);
@@ -225,7 +234,12 @@
int importReferenceLength = importReference.tokens.length;
int indexInImportReference = importReferenceLength - index; // one-based
if (indexInImportReference >= 0) {
- Binding binding = this.scope.getTypeOrPackage(CharOperation.subarray(importReference.tokens, 0, indexInImportReference));
+ Binding binding = null;
+ try {
+ binding = this.scope.getTypeOrPackage(CharOperation.subarray(importReference.tokens, 0, indexInImportReference));
+ } catch (AbortCompilation e) {
+ // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=53357
+ }
if (binding != null) {
if (binding instanceof org.eclipse.jdt.internal.compiler.lookup.PackageBinding) {
return this.getPackageBinding((org.eclipse.jdt.internal.compiler.lookup.PackageBinding)binding);
@@ -709,34 +723,38 @@
* @see BindingResolver#resolveImport(ImportDeclaration)
*/
IBinding resolveImport(ImportDeclaration importDeclaration) {
- org.eclipse.jdt.internal.compiler.ast.ASTNode node = (org.eclipse.jdt.internal.compiler.ast.ASTNode) this.newAstToOldAst.get(importDeclaration);
- if (node instanceof ImportReference) {
- ImportReference importReference = (ImportReference) node;
- if (importReference.onDemand) {
- Binding binding = this.scope.getTypeOrPackage(CharOperation.subarray(importReference.tokens, 0, importReference.tokens.length));
- if (binding != null) {
- if (binding.bindingType() == BindingIds.PACKAGE) {
- IPackageBinding packageBinding = this.getPackageBinding((org.eclipse.jdt.internal.compiler.lookup.PackageBinding) binding);
- if (packageBinding == null) {
- return null;
+ try {
+ org.eclipse.jdt.internal.compiler.ast.ASTNode node = (org.eclipse.jdt.internal.compiler.ast.ASTNode) this.newAstToOldAst.get(importDeclaration);
+ if (node instanceof ImportReference) {
+ ImportReference importReference = (ImportReference) node;
+ if (importReference.onDemand) {
+ Binding binding = this.scope.getTypeOrPackage(CharOperation.subarray(importReference.tokens, 0, importReference.tokens.length));
+ if (binding != null) {
+ if (binding.bindingType() == BindingIds.PACKAGE) {
+ IPackageBinding packageBinding = this.getPackageBinding((org.eclipse.jdt.internal.compiler.lookup.PackageBinding) binding);
+ if (packageBinding == null) {
+ return null;
+ }
+ return packageBinding;
+ } else {
+ // if it is not a package, it has to be a type
+ ITypeBinding typeBinding = this.getTypeBinding((org.eclipse.jdt.internal.compiler.lookup.TypeBinding) binding);
+ if (typeBinding == null) {
+ return null;
+ }
+ return typeBinding;
}
- return packageBinding;
- } else {
- // if it is not a package, it has to be a type
+ }
+ } else {
+ Binding binding = this.scope.getTypeOrPackage(importReference.tokens);
+ if (binding != null && binding instanceof org.eclipse.jdt.internal.compiler.lookup.TypeBinding) {
ITypeBinding typeBinding = this.getTypeBinding((org.eclipse.jdt.internal.compiler.lookup.TypeBinding) binding);
- if (typeBinding == null) {
- return null;
- }
- return typeBinding;
+ return typeBinding == null ? null : typeBinding;
}
}
- } else {
- Binding binding = this.scope.getTypeOrPackage(importReference.tokens);
- if (binding != null && binding instanceof org.eclipse.jdt.internal.compiler.lookup.TypeBinding) {
- ITypeBinding typeBinding = this.getTypeBinding((org.eclipse.jdt.internal.compiler.lookup.TypeBinding) binding);
- return typeBinding == null ? null : typeBinding;
- }
}
+ } catch(AbortCompilation e) {
+ // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=53357
}
return null;
}
@@ -745,22 +763,26 @@
* @see BindingResolver#resolvePackage(PackageDeclaration)
*/
IPackageBinding resolvePackage(PackageDeclaration pkg) {
- org.eclipse.jdt.internal.compiler.ast.ASTNode node = (org.eclipse.jdt.internal.compiler.ast.ASTNode) this.newAstToOldAst.get(pkg);
- if (node instanceof ImportReference) {
- ImportReference importReference = (ImportReference) node;
- Binding binding = this.scope.getTypeOrPackage(CharOperation.subarray(importReference.tokens, 0, importReference.tokens.length));
- if ((binding != null) && (binding.isValidBinding())) {
- IPackageBinding packageBinding = this.getPackageBinding((org.eclipse.jdt.internal.compiler.lookup.PackageBinding) binding);
- if (packageBinding == null) {
- return null;
+ try {
+ org.eclipse.jdt.internal.compiler.ast.ASTNode node = (org.eclipse.jdt.internal.compiler.ast.ASTNode) this.newAstToOldAst.get(pkg);
+ if (node instanceof ImportReference) {
+ ImportReference importReference = (ImportReference) node;
+ Binding binding = this.scope.getTypeOrPackage(CharOperation.subarray(importReference.tokens, 0, importReference.tokens.length));
+ if ((binding != null) && (binding.isValidBinding())) {
+ IPackageBinding packageBinding = this.getPackageBinding((org.eclipse.jdt.internal.compiler.lookup.PackageBinding) binding);
+ if (packageBinding == null) {
+ return null;
+ }
+ this.bindingsToAstNodes.put(packageBinding, pkg);
+ String key = packageBinding.getKey();
+ if (key != null) {
+ this.bindingKeysToAstNodes.put(key, pkg);
+ }
+ return packageBinding;
}
- this.bindingsToAstNodes.put(packageBinding, pkg);
- String key = packageBinding.getKey();
- if (key != null) {
- this.bindingKeysToAstNodes.put(key, pkg);
- }
- return packageBinding;
}
+ } catch (AbortCompilation e) {
+ // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=53357
}
return null;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DocCommentParser.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DocCommentParser.java
index dec3fb0..1e3d3d3 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DocCommentParser.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DocCommentParser.java
@@ -26,15 +26,16 @@
class DocCommentParser extends AbstractCommentParser {
// Public fields
- private Javadoc docComment;
- private AST ast;
// Private fields
+ private Javadoc docComment;
+ private AST ast;
- DocCommentParser(AST ast, Scanner scanner) {
+ DocCommentParser(AST ast, Scanner scanner, boolean check) {
super(null);
this.ast = ast;
this.scanner = scanner;
+ this.checkDocComment = check;
this.kind = DOM_PARSER;
}
@@ -55,7 +56,9 @@
this.docComment = this.ast.newJavadoc();
// Parse
- parseComment(start, start+length-1);
+ if (this.checkDocComment) {
+ parseComment(start, start+length-1);
+ }
this.docComment.setSourceRange(start, length);
setComment(start, length); // backward compatibility
return this.docComment;
@@ -344,13 +347,13 @@
*/
protected void pushText(int start, int end) {
TextElement text = this.ast.newTextElement();
- text.setText(new String( this.source, start, end-start+1));
- text.setSourceRange(start, end-start+1);
+ text.setText(new String( this.source, start, end-start));
+ text.setSourceRange(start, end-start);
TagElement previousTag = null;
int previousStart = start;
if (this.astPtr == -1) {
previousTag = this.ast.newTagElement();
- previousTag.setSourceRange(start, end-start+1);
+ previousTag.setSourceRange(start, end-start);
pushOnAstStack(previousTag, true);
} else {
previousTag = (TagElement) this.astStack[this.astPtr];
@@ -370,7 +373,7 @@
}
}
previousTag.fragments().add(text);
- previousTag.setSourceRange(previousStart, end-previousStart+1);
+ previousTag.setSourceRange(previousStart, end-previousStart);
this.textStart = -1;
}
/* (non-Javadoc)
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/EnumDeclaration.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/EnumDeclaration.java
index 86d5539..77e417e 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/EnumDeclaration.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/EnumDeclaration.java
@@ -22,7 +22,7 @@
* [ Javadoc ] { ExtendedModifier } <b>enum</b> Identifier
* [ <b>implements</b> Type { <b>,</b> Type } ]
* <b>{</b>
- * [ EnumConstantDeclaration { <b>,</b> EnumConstantDeclaration } ]
+ * [ EnumConstantDeclaration { <b>,</b> EnumConstantDeclaration } ] [ <b>,</b> ]
* [ <b>;</b> { ClassBodyDeclaration | <b>;</b> } ]
* <b>}</b>
* </pre>
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICompilationUnit.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICompilationUnit.java
index 0503c0c..b7c396c 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICompilationUnit.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICompilationUnit.java
@@ -537,6 +537,7 @@
* if the working copy was already consistent.
* </p>
*
+ * @param createAST boolean indicating whether a compilation unit AST should be created.
* @param forceProblemDetection boolean indicating whether problem should be recomputed
* even if the source hasn't changed.
* @param owner the owner of working copies that take precedence over the original compilation units,
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java
index e4e3a75..ac712ca 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java
@@ -152,6 +152,12 @@
/**
* Possible configurable option ID.
* @see #getDefaultOptions()
+ * @since 3.0
+ */
+ public static final String COMPILER_DOC_COMMENT_SUPPORT = PLUGIN_ID + ".compiler.doc.comment.support"; //$NON-NLS-1$
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions()
* @deprecated - discontinued since turning off would violate language specs
*/
public static final String COMPILER_PB_UNREACHABLE_CODE = PLUGIN_ID + ".compiler.problem.unreachableCode"; //$NON-NLS-1$
@@ -348,14 +354,6 @@
public static final String COMPILER_PB_INVALID_JAVADOC = PLUGIN_ID + ".compiler.problem.invalidJavadoc"; //$NON-NLS-1$
/**
* Possible configurable option ID.
- * @see #COMPILER_PB_INVALID_JAVADOC
- * @deprecated
- * TODO (frederic) remove after 3.0 M6
- */
- public static final String COMPILER_PB_INVALID_ANNOTATION = COMPILER_PB_INVALID_JAVADOC;
- public static final String OLD_COMPILER_PB_INVALID_ANNOTATION = PLUGIN_ID + ".compiler.problem.invalidAnnotation"; //$NON-NLS-1$
- /**
- * Possible configurable option ID.
* @see #getDefaultOptions()
* @since 3.0
*/
@@ -394,23 +392,6 @@
* Possible configurable option ID.
* @see #getDefaultOptions()
* @since 3.0
- * @deprecated
- * TODO (frederic) remove after 3.0 M7
- */
- public static final String COMPILER_PB_MISSING_JAVADOC = COMPILER_PB_MISSING_JAVADOC_COMMENTS;
- public static final String OLD_COMPILER_PB_MISSING_JAVADOC = PLUGIN_ID + ".compiler.problem.missingJavadoc"; //$NON-NLS-1$
- /**
- * Possible configurable option ID.
- * @see #COMPILER_PB_MISSING_JAVADOC
- * @deprecated
- * TODO (frederic) after 3.0 M6
- */
- public static final String COMPILER_PB_MISSING_ANNOTATION = COMPILER_PB_MISSING_JAVADOC;
- public static final String OLD_COMPILER_PB_MISSING_ANNOTATION = PLUGIN_ID + ".compiler.problem.missingAnnotation"; //$NON-NLS-1$
- /**
- * Possible configurable option ID.
- * @see #getDefaultOptions()
- * @since 3.0
*/
public static final String COMPILER_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY = PLUGIN_ID + ".compiler.problem.missingJavadocCommentsVisibility"; //$NON-NLS-1$
/**
@@ -1420,6 +1401,14 @@
* - possible values: { "1.1", "1.2", "1.3", "1.4" }
* - default: "1.2"
*
+ * COMPILER / Javadoc Comment Support
+ * When this support is disabled, the compiler will ignore all javadoc problems options settings
+ * and will not report any javadoc problem. It will also not find any reference in javadoc comment and
+ * DOM AST Javadoc node will be only a flat text instead of having structured tag elements.
+ * - option id: "org.eclipse.jdt.core.compiler.doc.comment.support"
+ * - possible values: { "enabled", "disabled" }
+ * - default: "enabled"
+ *
* COMPILER / Reporting Attempt to Override Package-Default Method
* A package default method is not visible in a different package, and thus
* cannot be overridden. When enabling this option, the compiler will signal
@@ -2098,31 +2087,6 @@
if (optionNames.contains(propertyName)){
options.put(propertyName, value);
}
- // bug 45112 backward compatibility.
- // TODO (frederic) remove after 3.0 M6
- else if (CompilerOptions.OPTION_ReportInvalidAnnotation.equals(propertyName)) {
- options.put(COMPILER_PB_INVALID_JAVADOC, value);
- }
- else if (CompilerOptions.OPTION_ReportMissingAnnotation.equals(propertyName)) {
- if (ENABLED.equals(value)) {
- value = preferences.getString(CompilerOptions.OPTION_ReportInvalidAnnotation);
- } else {
- value = IGNORE;
- }
- options.put(COMPILER_PB_MISSING_JAVADOC_COMMENTS, value);
- }
- // end bug 45112
- // bug 46854 backward compatibility
- // TODO (frederic) remove after 3.0 M7
- else if (CompilerOptions.OPTION_ReportMissingJavadoc.equals(propertyName)) {
- if (ENABLED.equals(value)) {
- value = preferences.getString(COMPILER_PB_INVALID_JAVADOC);
- } else {
- value = IGNORE;
- }
- options.put(COMPILER_PB_MISSING_JAVADOC_COMMENTS, value);
- }
- // end bug 46854
// TODO (olivier) Remove after M7
else if (propertyName.startsWith(JavaCore.PLUGIN_ID + ".formatter")) {//$NON-NLS-1$
Util.convertFormatterDeprecatedOptions(propertyName, value, options);
@@ -2329,7 +2293,8 @@
preferences.setDefault(COMPILER_CODEGEN_UNUSED_LOCAL, PRESERVE);
preferences.setDefault(COMPILER_TASK_TAGS, DEFAULT_TASK_TAG);
preferences.setDefault(COMPILER_TASK_PRIORITIES, DEFAULT_TASK_PRIORITY);
-
+ preferences.setDefault(COMPILER_DOC_COMMENT_SUPPORT, ENABLED);
+
// Builder settings
preferences.setDefault(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, ""); //$NON-NLS-1$
optionNames.add(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER);
@@ -3490,24 +3455,16 @@
preferences.setValue(key, value);
}
- // Backward compatibility
+ /* Test OPTION_DocCommentSupport
String[] propertyNames = preferences.propertyNames();
for (int i = 0; i < propertyNames.length; i++){
String propertyName = propertyNames[i];
- // bug 45112
- if (CompilerOptions.OPTION_ReportInvalidAnnotation.equals(propertyName)) {
- preferences.setToDefault(OLD_COMPILER_PB_INVALID_ANNOTATION);
+ // set same value than missing javadoc comments overriding
+ if (CompilerOptions.OPTION_ReportMissingJavadocCommentsOverriding.equals(propertyName)) {
+ preferences.setValue(COMPILER_DOC_COMMENT_SUPPORT, preferences.getString(propertyName));
}
- else if (CompilerOptions.OPTION_ReportMissingAnnotation.equals(propertyName)) {
- preferences.setToDefault(OLD_COMPILER_PB_MISSING_ANNOTATION);
- }
- // end bug 45112
- // bug 46854
- else if (CompilerOptions.OPTION_ReportMissingJavadoc.equals(propertyName)) {
- preferences.setToDefault(OLD_COMPILER_PB_MISSING_JAVADOC);
- }
- // end bug 46854
}
+ */
// persist options
getPlugin().savePluginPreferences();
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java
index 81451ad..1c603e7 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java
@@ -69,7 +69,6 @@
import org.eclipse.jdt.core.WorkingCopyOwner;
import org.eclipse.jdt.core.eval.IEvaluationContext;
import org.eclipse.jdt.internal.codeassist.ISearchableNameEnvironment;
-import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.util.ObjectVector;
import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
import org.eclipse.jdt.internal.core.eval.EvaluationContextWrapper;
@@ -1432,31 +1431,6 @@
if (optionNames.contains(propertyName)){
options.put(propertyName, value);
}
- // bug 45112 backward compatibility.
- // TODO (frederic) remove after 3.0 M6
- else if (CompilerOptions.OPTION_ReportInvalidAnnotation.equals(propertyName)) {
- options.put(JavaCore.COMPILER_PB_INVALID_JAVADOC, value);
- }
- else if (CompilerOptions.OPTION_ReportMissingAnnotation.equals(propertyName)) {
- if (JavaCore.ENABLED.equals(value)) {
- value = preferences.getString(JavaCore.COMPILER_PB_INVALID_JAVADOC);
- } else {
- value = JavaCore.IGNORE;
- }
- options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS, value);
- }
- // end bug 45112
- // bug 46854 backward compatibility
- // TODO (frederic) remove after 3.0 M7
- else if (CompilerOptions.OPTION_ReportMissingJavadoc.equals(propertyName)) {
- if (JavaCore.ENABLED.equals(value)) {
- value = preferences.getString(JavaCore.COMPILER_PB_INVALID_JAVADOC);
- } else {
- value = JavaCore.IGNORE;
- }
- options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS, value);
- }
- // end bug 46854
// TODO (olivier) Remove after M7
else if (propertyName.startsWith(JavaCore.PLUGIN_ID + ".formatter")) {//$NON-NLS-1$
Util.convertFormatterDeprecatedOptions(propertyName, value, options);
@@ -2521,24 +2495,16 @@
}
}
- // Backward compatibility
+ /* Test OPTION_DocCommentSupport
String[] propertyNames = preferences.propertyNames();
for (int i = 0; i < propertyNames.length; i++){
String propertyName = propertyNames[i];
- // bug 45112
- if (CompilerOptions.OPTION_ReportInvalidAnnotation.equals(propertyName)) {
- preferences.setToDefault(JavaCore.OLD_COMPILER_PB_INVALID_ANNOTATION);
+ // set same value than missing javadoc comments overriding
+ if (CompilerOptions.OPTION_ReportMissingJavadocCommentsOverriding.equals(propertyName)) {
+ preferences.setValue(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, preferences.getString(propertyName));
}
- else if (CompilerOptions.OPTION_ReportMissingAnnotation.equals(propertyName)) {
- preferences.setToDefault(JavaCore.OLD_COMPILER_PB_MISSING_ANNOTATION);
- }
- // end bug 45112
- // bug 46854
- else if (CompilerOptions.OPTION_ReportMissingJavadoc.equals(propertyName)) {
- preferences.setToDefault(JavaCore.OLD_COMPILER_PB_MISSING_JAVADOC);
- }
- // end bug 46854
}
+ */
// persist options
savePreferences(preferences);
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CommentRecorderParser.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CommentRecorderParser.java
index 922662a..6199584 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CommentRecorderParser.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CommentRecorderParser.java
@@ -35,7 +35,6 @@
*/
public CommentRecorderParser(ProblemReporter problemReporter, boolean optimizeStringLiterals) {
super(problemReporter, optimizeStringLiterals);
- this.javadocParser.checkDocComment = true;
}
// old javadoc style check which doesn't include all leading comments into declaration
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PublicScanner.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PublicScanner.java
index bd19da5..63bce13 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PublicScanner.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PublicScanner.java
@@ -62,6 +62,7 @@
public int[] commentStops = new int[10];
public int[] commentStarts = new int[10];
public int commentPtr = -1; // no comment test with commentPtr value -1
+ protected int lastCommentLinePosition = -1;
// task tag support
public char[][] foundTaskTags = null;
@@ -1226,6 +1227,7 @@
{
int test;
if ((test = getNextChar('/', '*')) == 0) { //line comment
+ this.lastCommentLinePosition = this.currentPosition;
try { //get the next char
if (((this.currentCharacter = this.source[this.currentPosition++]) == '\\')
&& (this.source[this.currentPosition] == 'u')) {
@@ -1256,6 +1258,7 @@
} //jump over the \\
boolean isUnicode = false;
while (this.currentCharacter != '\r' && this.currentCharacter != '\n') {
+ this.lastCommentLinePosition = this.currentPosition;
//get the next char
isUnicode = false;
if (((this.currentCharacter = this.source[this.currentPosition++]) == '\\')
@@ -1638,6 +1641,7 @@
int test;
if ((test = getNextChar('/', '*')) == 0) { //line comment
try {
+ this.lastCommentLinePosition = this.currentPosition;
//get the next char
if (((this.currentCharacter = this.source[this.currentPosition++]) == '\\')
&& (this.source[this.currentPosition] == 'u')) {
@@ -1668,6 +1672,7 @@
} //jump over the \\
boolean isUnicode = false;
while (this.currentCharacter != '\r' && this.currentCharacter != '\n') {
+ this.lastCommentLinePosition = this.currentPosition;
//get the next char
isUnicode = false;
if (((this.currentCharacter = this.source[this.currentPosition++]) == '\\')
@@ -2280,16 +2285,26 @@
}
}
public void recordComment(int token) {
+ // compute position
+ int stopPosition = this.currentPosition;
+ switch (token) {
+ case TokenNameCOMMENT_LINE:
+ stopPosition = -this.lastCommentLinePosition;
+ break;
+ case TokenNameCOMMENT_BLOCK:
+ stopPosition = -this.currentPosition;
+ break;
+ }
// a new comment is recorded
try {
- this.commentStops[++this.commentPtr] = (token==TokenNameCOMMENT_JAVADOC) ? this.currentPosition : -this.currentPosition;
+ this.commentStops[++this.commentPtr] = stopPosition;
} catch (IndexOutOfBoundsException e) {
int oldStackLength = this.commentStops.length;
int[] oldStack = this.commentStops;
this.commentStops = new int[oldStackLength + 30];
System.arraycopy(oldStack, 0, this.commentStops, 0, oldStackLength);
- this.commentStops[this.commentPtr] = (token==TokenNameCOMMENT_JAVADOC) ? this.currentPosition : -this.currentPosition;
+ this.commentStops[this.commentPtr] = stopPosition;
//grows the positions buffers too
int[] old = this.commentStarts;
this.commentStarts = new int[oldStackLength + 30];
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java
index 59b1466..508d030 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java
@@ -96,9 +96,6 @@
? new MethodButNoClassDeclarationVisitor()
: new NoClassNoMethodDeclarationVisitor();
}
-
- // Always check javadoc while matching indexes
- this.javadocParser.checkDocComment = true;
}
public void checkComment() {
super.checkComment();