Update jdt.core & tests to v20120428-0556.
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java
index 4a8b0fa..875c58e 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java
@@ -47,7 +47,7 @@
// Static initializer to specify tests subset using TESTS_* static variables
// All specified tests which do not belong to the class are skipped...
static {
-// TESTS_NAMES = new String[] { "testBug365437" };
+// TESTS_NAMES = new String[] { "testBug376429" };
// TESTS_NUMBERS = new int[] { 297 };
// TESTS_RANGE = new int[] { 294, -1 };
}
@@ -10517,4 +10517,95 @@
"----------\n",
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
}
+public void testBug376429a() {
+ this.runNegativeTest(
+ new String[] {
+ "Try.java",
+ "public @interface Try { \n" +
+ " byte[] value(); \n" +
+ " @Try t();\n"+
+ " @Try u();\n"+
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in Try.java (at line 3)\n" +
+ " @Try t();\n" +
+ " ^^^^\n" +
+ "The annotation @Try must define the attribute value\n" +
+ "----------\n" +
+ "2. ERROR in Try.java (at line 3)\n" +
+ " @Try t();\n" +
+ " ^^^\n" +
+ "Return type for the method is missing\n" +
+ "----------\n" +
+ "3. ERROR in Try.java (at line 3)\n" +
+ " @Try t();\n" +
+ " ^^^\n" +
+ "Return type for the method is missing\n" +
+ "----------\n" +
+ "4. ERROR in Try.java (at line 4)\n" +
+ " @Try u();\n" +
+ " ^^^^\n" +
+ "The annotation @Try must define the attribute value\n" +
+ "----------\n" +
+ "5. ERROR in Try.java (at line 4)\n" +
+ " @Try u();\n" +
+ " ^^^\n" +
+ "Return type for the method is missing\n" +
+ "----------\n");
+}
+public void testBug376429b() {
+ this.runNegativeTest(
+ new String[] {
+ "Try.java",
+ "public @interface Try { \n" +
+ " @Try t();\n"+
+ " byte[] value(); \n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in Try.java (at line 2)\n" +
+ " @Try t();\n" +
+ " ^^^^\n" +
+ "The annotation @Try must define the attribute value\n" +
+ "----------\n" +
+ "2. ERROR in Try.java (at line 2)\n" +
+ " @Try t();\n" +
+ " ^^^\n" +
+ "Return type for the method is missing\n" +
+ "----------\n");
+}
+
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=371832
+//Unused imports should be reported even if other errors are suppressed.
+public void testBug371832() throws Exception {
+ Map customOptions = getCompilerOptions();
+ customOptions.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.ERROR);
+ customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.ERROR);
+ customOptions.put(CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED);
+ customOptions.put(CompilerOptions.OPTION_ReportMissingSerialVersion, CompilerOptions.ERROR);
+ String testFiles [] = new String[] {
+ "A.java",
+ "import java.util.List;\n"+
+ "@SuppressWarnings(\"serial\")\n" +
+ "public class A implements java.io.Serializable {\n" +
+ " void foo() { \n" +
+ " }\n"+
+ "}\n"
+ };
+ String expectedErrorString =
+ "----------\n" +
+ "1. ERROR in A.java (at line 1)\n" +
+ " import java.util.List;\n" +
+ " ^^^^^^^^^^^^^^\n" +
+ "The import java.util.List is never used\n" +
+ "----------\n";
+ runNegativeTest(
+ true,
+ testFiles,
+ null,
+ customOptions,
+ expectedErrorString,
+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
+}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
index 9fc3c72..71499b1 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
@@ -19,6 +19,7 @@
* bug 365208 - [compiler][batch] command line options for annotation based null analysis
* bug 370639 - [compiler][resource] restore the default for resource leak warnings
* bug 365859 - [compiler][null] distinguish warnings based on flow analysis vs. null annotations
+ * bug 374605 - Unreasonable warning for enum-based switch statements
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -1744,7 +1745,9 @@
" discouraged + use of types matching a discouraged access rule\n" +
" emptyBlock undocumented empty block\n" +
" enumIdentifier ''enum'' used as identifier\n" +
- " enumSwitch incomplete enum switch\n" +
+ " enumSwitch incomplete enum switch\n" +
+ " enumSwitchPedantic + report missing enum switch cases even\n" +
+ " in the presence of a default case\n" +
//OT:
" exceptioninguard + guard predicate throwing checked exception\n" +
" fallthrough possible fall-through case\n" +
@@ -1800,6 +1803,7 @@
" suppress + enable @SuppressWarnings\n" +
" When used with -err:, it can also silent optional\n" +
" errors and warnings\n" +
+ " switchDefault + switch statement lacking a default case\n" +
" syncOverride missing synchronized in synchr. method override\n" +
" syntheticAccess synthetic access for innerclass\n" +
" tasks(<tags separated by |>) tasks identified by tags inside comments\n" +
@@ -1929,7 +1933,9 @@
" <option key=\"org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility\" value=\"public\"/>\n" +
" <option key=\"org.eclipse.jdt.core.compiler.problem.localVariableHiding\" value=\"ignore\"/>\n" +
" <option key=\"org.eclipse.jdt.core.compiler.problem.methodWithConstructorName\" value=\"warning\"/>\n" +
+ " <option key=\"org.eclipse.jdt.core.compiler.problem.missingDefaultCase\" value=\"ignore\"/>\n" +
" <option key=\"org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation\" value=\"ignore\"/>\n" +
+ " <option key=\"org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault\" value=\"disabled\"/>\n" +
" <option key=\"org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod\" value=\"ignore\"/>\n" +
" <option key=\"org.eclipse.jdt.core.compiler.problem.missingJavadocComments\" value=\"ignore\"/>\n" +
" <option key=\"org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding\" value=\"disabled\"/>\n" +
@@ -12801,6 +12807,103 @@
true);
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=374605
+// -warn/-error option : enumSwitchPedantic
+public void test317_warn_options() {
+ this.runConformTest(
+ new String[] {
+ "p/X.java",
+ "package p;\n" +
+ "enum Color { RED, GREEN };\n" +
+ "public class X {\n" +
+ " int getVal(Color c) {\n" +
+ " switch (c) {\n" +
+ " case RED: return 1;\n" +
+ " default : return 0;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ },
+ "\"" + OUTPUT_DIR + File.separator + "p" + File.separator + "X.java\""
+ + " -sourcepath \"" + OUTPUT_DIR + "\""
+ + " -1.5"
+ + " -warn:+enumSwitchPedantic -proc:none -d \"" + OUTPUT_DIR + "\"",
+ "",
+ "----------\n" +
+ "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/p/X.java (at line 5)\n" +
+ " switch (c) {\n" +
+ " ^\n" +
+ "The enum constant GREEN should have a corresponding case label in this enum switch on Color. To suppress this problem, add a comment //$CASES-OMITTED$ on the line above the 'default:'\n" +
+ "----------\n" +
+ "1 problem (1 warning)",
+ true);
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=374605
+// -warn/-error option : enumSwitchPedantic: increase severity to ERROR
+public void test318_warn_options() {
+ this.runNegativeTest(
+ new String[] {
+ "p/X.java",
+ "package p;\n" +
+ "enum Color { RED, GREEN };\n" +
+ "public class X {\n" +
+ " int getVal(Color c) {\n" +
+ " switch (c) {\n" +
+ " case RED: return 1;\n" +
+ " default : return 0;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ },
+ "\"" + OUTPUT_DIR + File.separator + "p" + File.separator + "X.java\""
+ + " -sourcepath \"" + OUTPUT_DIR + "\""
+ + " -1.5"
+ + " -err:+enumSwitchPedantic -proc:none -d \"" + OUTPUT_DIR + "\"",
+ "",
+ "----------\n" +
+ "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/p/X.java (at line 5)\n" +
+ " switch (c) {\n" +
+ " ^\n" +
+ "The enum constant GREEN should have a corresponding case label in this enum switch on Color. To suppress this problem, add a comment //$CASES-OMITTED$ on the line above the 'default:'\n" +
+ "----------\n" +
+ "1 problem (1 error)",
+ true);
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=374605
+// -warn/-error option : switchDefault
+public void test319_warn_options() {
+ this.runConformTest(
+ new String[] {
+ "p/X.java",
+ "package p;\n" +
+ "enum Color { RED, GREEN };\n" +
+ "public class X {\n" +
+ " int getVal(Color c) {\n" +
+ " switch (c) {\n" +
+ " case RED: return 1;\n" +
+ " case GREEN : return 2;\n" +
+ " }\n" +
+ " return 0;\n" +
+ " }\n" +
+ "}\n"
+ },
+ "\"" + OUTPUT_DIR + File.separator + "p" + File.separator + "X.java\""
+ + " -sourcepath \"" + OUTPUT_DIR + "\""
+ + " -1.5"
+ + " -warn:+switchDefault -proc:none -d \"" + OUTPUT_DIR + "\"",
+ "",
+ "----------\n" +
+ "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/p/X.java (at line 5)\n" +
+ " switch (c) {\n" +
+ " ^\n" +
+ "The switch over the enum type Color should have a default case\n" +
+ "----------\n" +
+ "1 problem (1 warning)",
+ true);
+}
+
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=220928
//-nowarn option - regression tests
//default
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
index 4790325..d9d4a26 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
@@ -15,6 +15,7 @@
* bug 186342 - [compiler][null] Using annotations for null checking
* bug 365662 - [compiler][null] warn on contradictory and redundant null annotations
* bug 365859 - [compiler][null] distinguish warnings based on flow analysis vs. null annotations
+ * bug 374605 - Unreasonable warning for enum-based switch statements
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -699,9 +700,11 @@
expectedProblemAttributes.put("MethodReturnsVoid", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("MethodVarargsArgumentNeedCast", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("MissingArgumentsForParameterizedMemberType", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
+ expectedProblemAttributes.put("MissingDefaultCase", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("MissingEnclosingInstance", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("MissingEnclosingInstanceForConstructorCall", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("MissingEnumConstantCase", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
+ expectedProblemAttributes.put("MissingEnumConstantCaseDespiteDefault", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("MissingEnumDefaultCase", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("MissingNonNullByDefaultAnnotationOnPackage", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("MissingNonNullByDefaultAnnotationOnType", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
@@ -825,6 +828,7 @@
expectedProblemAttributes.put("SafeVarargsOnNonFinalInstanceMethod", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("ShouldImplementHashcode", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("ShouldReturnValue", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
+ expectedProblemAttributes.put("ShouldReturnValueHintMissingDefault", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("SpecdNonNullLocalVariableComparisonYieldsFalse", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("StaticInheritedMethodConflicts", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("StaticMemberOfParameterizedType", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
@@ -887,7 +891,9 @@
expectedProblemAttributes.put("UnhandledExceptionOnAutoClose", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("UnhandledWarningToken", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE));
expectedProblemAttributes.put("UninitializedBlankFinalField", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
+ expectedProblemAttributes.put("UninitializedBlankFinalFieldHintMissingDefault", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("UninitializedLocalVariable", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
+ expectedProblemAttributes.put("UninitializedLocalVariableHintMissingDefault", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("UnmatchedBracket", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("UnnecessaryArgumentCast", DEPRECATED);
expectedProblemAttributes.put("UnnecessaryCast", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE));
@@ -1481,10 +1487,12 @@
expectedProblemAttributes.put("MethodReturnsVoid", SKIP);
expectedProblemAttributes.put("MethodVarargsArgumentNeedCast", new ProblemAttributes(JavaCore.COMPILER_PB_VARARGS_ARGUMENT_NEED_CAST));
expectedProblemAttributes.put("MissingArgumentsForParameterizedMemberType", SKIP);
+ expectedProblemAttributes.put("MissingDefaultCase", new ProblemAttributes(JavaCore.COMPILER_PB_SWITCH_MISSING_DEFAULT_CASE));
expectedProblemAttributes.put("MissingEnclosingInstance", SKIP);
expectedProblemAttributes.put("MissingEnclosingInstanceForConstructorCall", SKIP);
expectedProblemAttributes.put("MissingEnumConstantCase", new ProblemAttributes(JavaCore.COMPILER_PB_INCOMPLETE_ENUM_SWITCH));
- expectedProblemAttributes.put("MissingEnumDefaultCase", new ProblemAttributes(JavaCore.COMPILER_PB_INCOMPLETE_ENUM_SWITCH));
+ expectedProblemAttributes.put("MissingEnumConstantCaseDespiteDefault", new ProblemAttributes(JavaCore.COMPILER_PB_INCOMPLETE_ENUM_SWITCH));
+ expectedProblemAttributes.put("MissingEnumDefaultCase", new ProblemAttributes(JavaCore.COMPILER_PB_SWITCH_MISSING_DEFAULT_CASE));
expectedProblemAttributes.put("MissingNonNullByDefaultAnnotationOnPackage", new ProblemAttributes(JavaCore.COMPILER_PB_MISSING_NONNULL_BY_DEFAULT_ANNOTATION));
expectedProblemAttributes.put("MissingNonNullByDefaultAnnotationOnType", new ProblemAttributes(JavaCore.COMPILER_PB_MISSING_NONNULL_BY_DEFAULT_ANNOTATION));
expectedProblemAttributes.put("MissingOverrideAnnotation", new ProblemAttributes(JavaCore.COMPILER_PB_MISSING_OVERRIDE_ANNOTATION));
@@ -1607,6 +1615,7 @@
expectedProblemAttributes.put("SafeVarargsOnNonFinalInstanceMethod", SKIP);
expectedProblemAttributes.put("ShouldImplementHashcode", new ProblemAttributes(JavaCore.COMPILER_PB_MISSING_HASHCODE_METHOD));
expectedProblemAttributes.put("ShouldReturnValue", SKIP);
+ expectedProblemAttributes.put("ShouldReturnValueHintMissingDefault", SKIP);
expectedProblemAttributes.put("SpecdNonNullLocalVariableComparisonYieldsFalse", new ProblemAttributes(JavaCore.COMPILER_PB_REDUNDANT_NULL_CHECK));
expectedProblemAttributes.put("StaticInheritedMethodConflicts", SKIP);
expectedProblemAttributes.put("StaticMemberOfParameterizedType", SKIP);
@@ -1669,7 +1678,9 @@
expectedProblemAttributes.put("UnhandledExceptionOnAutoClose", SKIP);
expectedProblemAttributes.put("UnhandledWarningToken", new ProblemAttributes(JavaCore.COMPILER_PB_UNHANDLED_WARNING_TOKEN));
expectedProblemAttributes.put("UninitializedBlankFinalField", SKIP);
+ expectedProblemAttributes.put("UninitializedBlankFinalFieldHintMissingDefault", SKIP);
expectedProblemAttributes.put("UninitializedLocalVariable", SKIP);
+ expectedProblemAttributes.put("UninitializedLocalVariableHintMissingDefault", SKIP);
expectedProblemAttributes.put("UnmatchedBracket", SKIP);
expectedProblemAttributes.put("UnnecessaryArgumentCast", SKIP);
expectedProblemAttributes.put("UnnecessaryCast", new ProblemAttributes(JavaCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK));
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java
index f3fbf69..b6cb60c 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java
@@ -10,6 +10,7 @@
* Stephan Herrmann - Contributions for
* Bug 365519 - editorial cleanup after bug 186342 and bug 365387
* Bug 265744 - Enum switch should warn about missing default
+ * Bug 374605 - Unreasonable warning for enum-based switch statements
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -36,7 +37,7 @@
// Static initializer to specify tests subset using TESTS_* static variables
// All specified tests which does not belong to the class are skipped...
static {
-// TESTS_NAMES = new String[] { "test146" };
+// TESTS_NAMES = new String[] { "test187" };
// TESTS_NUMBERS = new int[] { 185 };
// TESTS_RANGE = new int[] { 21, 50 };
}
@@ -735,22 +736,17 @@
"}\n",
},
"----------\n" +
- "1. WARNING in X.java (at line 6)\n" +
- " switch(e) {\n" +
- " ^\n" +
- "The switch on the enum type X.MX should have a default case\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 7)\n" +
+ "1. ERROR in X.java (at line 7)\n" +
" case MX.BLEU : break;\n" +
" ^^^^^^^\n" +
"The qualified case label X.MX.BLEU must be replaced with the unqualified enum constant BLEU\n" +
"----------\n" +
- "3. ERROR in X.java (at line 8)\n" +
+ "2. ERROR in X.java (at line 8)\n" +
" case MX.BLANC : break;\n" +
" ^^^^^^^^\n" +
"The qualified case label X.MX.BLANC must be replaced with the unqualified enum constant BLANC\n" +
"----------\n" +
- "4. ERROR in X.java (at line 9)\n" +
+ "3. ERROR in X.java (at line 9)\n" +
" case MX.ROUGE : break;\n" +
" ^^^^^^^^\n" +
"The qualified case label X.MX.ROUGE must be replaced with the unqualified enum constant ROUGE\n" +
@@ -1818,24 +1814,19 @@
"1. WARNING in X.java (at line 8)\n" +
" switch (x) {\n" +
" ^\n" +
- "The switch on the enum type X should have a default case\n" +
+ "The enum constant A needs a corresponding case label in this enum switch on X\n" +
"----------\n" +
"2. WARNING in X.java (at line 8)\n" +
" switch (x) {\n" +
" ^\n" +
- "The enum constant A needs a corresponding case label in this enum switch on X\n" +
+ "The enum constant B needs a corresponding case label in this enum switch on X\n" +
"----------\n" +
"3. WARNING in X.java (at line 8)\n" +
" switch (x) {\n" +
" ^\n" +
- "The enum constant B needs a corresponding case label in this enum switch on X\n" +
- "----------\n" +
- "4. WARNING in X.java (at line 8)\n" +
- " switch (x) {\n" +
- " ^\n" +
"The enum constant C needs a corresponding case label in this enum switch on X\n" +
"----------\n" +
- "5. ERROR in X.java (at line 9)\n" +
+ "4. ERROR in X.java (at line 9)\n" +
" case D:\n" +
" ^\n" +
"The field X.D cannot be referenced from an enum case label; only enum constants can be used in enum switch\n" +
@@ -1846,6 +1837,8 @@
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=82217 - variation with qualified name
*/
public void test062() {
+ Map options = getCompilerOptions();
+ options.put(JavaCore.COMPILER_PB_SWITCH_MISSING_DEFAULT_CASE, JavaCore.WARNING);
this.runNegativeTest(
new String[] {
"X.java",
@@ -1866,7 +1859,7 @@
"1. WARNING in X.java (at line 8)\n" +
" switch (x) {\n" +
" ^\n" +
- "The switch on the enum type X should have a default case\n" +
+ "The switch over the enum type X should have a default case\n" +
"----------\n" +
"2. WARNING in X.java (at line 8)\n" +
" switch (x) {\n" +
@@ -1887,7 +1880,10 @@
" case X.D:\n" +
" ^\n" +
"The field X.D cannot be referenced from an enum case label; only enum constants can be used in enum switch\n" +
- "----------\n");
+ "----------\n",
+ null, // classlibs
+ true, // flush
+ options);
}
/**
@@ -3141,24 +3137,19 @@
"1. WARNING in E.java (at line 5)\n" +
" switch (color) {\n" +
" ^^^^^\n" +
- "The switch on the enum type Colors should have a default case\n" +
+ "The enum constant BLACK needs a corresponding case label in this enum switch on Colors\n" +
"----------\n" +
"2. WARNING in E.java (at line 5)\n" +
" switch (color) {\n" +
" ^^^^^\n" +
- "The enum constant BLACK needs a corresponding case label in this enum switch on Colors\n" +
+ "The enum constant RED needs a corresponding case label in this enum switch on Colors\n" +
"----------\n" +
"3. WARNING in E.java (at line 5)\n" +
" switch (color) {\n" +
" ^^^^^\n" +
- "The enum constant RED needs a corresponding case label in this enum switch on Colors\n" +
- "----------\n" +
- "4. WARNING in E.java (at line 5)\n" +
- " switch (color) {\n" +
- " ^^^^^\n" +
"The enum constant WHITE needs a corresponding case label in this enum switch on Colors\n" +
"----------\n" +
- "5. ERROR in E.java (at line 16)\n" +
+ "4. ERROR in E.java (at line 16)\n" +
" Zork z;\n" +
" ^^^^\n" +
"Zork cannot be resolved to a type\n" +
@@ -4759,15 +4750,10 @@
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 4)\n" +
- " switch (e) {\n" +
- " ^\n" +
- "The switch on the enum type E should have a default case\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 12)\n" +
+ "1. ERROR in X.java (at line 12)\n" +
" return b;\n" +
" ^\n" +
- "The local variable b may not have been initialized\n" +
+ "The local variable b may not have been initialized. Note that a problem regarding missing 'default:' on 'switch' has been suppressed, which is perhaps related to this problem\n" +
"----------\n");
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=151368
@@ -5179,14 +5165,49 @@
"1. ERROR in X.java (at line 6)\n" +
" public X(MyEnum e) { // error\n" +
" ^^^^^^^^^^^\n" +
- "The blank final field test may not have been initialized\n" +
- "----------\n" +
- "2. WARNING in X.java (at line 7)\n" +
- " switch (e) {\n" +
- " ^\n" +
- "The switch on the enum type X.MyEnum should have a default case\n" +
+ "The blank final field test may not have been initialized. Note that a problem regarding missing 'default:' on 'switch' has been suppressed, which is perhaps related to this problem\n" +
"----------\n");
}
+// normal error when other warning is enabled
+public void test146b() {
+ Map options = getCompilerOptions();
+ options.put(JavaCore.COMPILER_PB_SWITCH_MISSING_DEFAULT_CASE, JavaCore.WARNING);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " enum MyEnum {\n" +
+ " A, B\n" +
+ " }\n" +
+ " final String test;\n" +
+ " public X(MyEnum e) { // error\n" +
+ " switch (e) {\n" +
+ " case A:\n" +
+ " test = \"a\";\n" +
+ " break;\n" +
+ " case B:\n" +
+ " test = \"a\";\n" +
+ " break;\n" +
+ " // default: test = \"unknown\"; // enabling this line fixes above error\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " public X(MyEnum e) { // error\n" +
+ " ^^^^^^^^^^^\n" +
+ "The blank final field test may not have been initialized\n" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 7)\n" +
+ " switch (e) {\n" +
+ " ^\n" +
+ "The switch over the enum type X.MyEnum should have a default case\n" +
+ "----------\n",
+ null,
+ true,
+ options);
+}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=227502
public void test147() {
this.runNegativeTest(
@@ -6839,4 +6860,176 @@
"Unhandled exception type Exception\n" +
"----------\n");
}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=374605
+public void test186() {
+ Map options = getCompilerOptions();
+ options.put(JavaCore.COMPILER_PB_MISSING_ENUM_CASE_DESPITE_DEFAULT, JavaCore.ENABLED);
+ this.runNegativeTest(
+ new String[] {
+ "Y.java",
+ "enum X {\n" +
+ " A, B;\n" +
+ "}\n" +
+ "public class Y {\n" +
+ " void test(X x) {\n" +
+ " switch (x) {\n" +
+ " case A: System.out.println(\"A\"); break;\n" +
+ " default : System.out.println(\"unknown\"); break;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING in Y.java (at line 6)\n" +
+ " switch (x) {\n" +
+ " ^\n" +
+ "The enum constant B should have a corresponding case label in this enum switch on X. To suppress this problem, add a comment //$CASES-OMITTED$ on the line above the 'default:'\n" +
+ "----------\n",
+ null, // classlibs
+ true, // flush
+ options);
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=374605
+public void test187() {
+ Map options = getCompilerOptions();
+ options.put(JavaCore.COMPILER_PB_MISSING_ENUM_CASE_DESPITE_DEFAULT, JavaCore.ENABLED);
+ options.put(JavaCore.COMPILER_PB_INCOMPLETE_ENUM_SWITCH, JavaCore.ERROR);
+ this.runConformTest(
+ new String[] {
+ "Y.java",
+ "enum X {\n" +
+ " A, B;\n" +
+ "}\n" +
+ "public class Y {\n" +
+ " void test(X x) {\n" +
+ " switch (x) {\n" +
+ " case A: System.out.println(\"A\");\n" +
+ " //$FALL-THROUGH$\n" +
+ " //$CASES-OMITTED$\n" +
+ " default : System.out.println(\"unknown\"); break;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n",
+ },
+ "",
+ null, // classlibs
+ true, // flush
+ null, // vmArgs
+ options,
+ null /*requestor*/);
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=374605
+public void test187a() {
+ Map options = getCompilerOptions();
+ options.put(JavaCore.COMPILER_PB_MISSING_ENUM_CASE_DESPITE_DEFAULT, JavaCore.ENABLED);
+ this.runNegativeTest(
+ new String[] {
+ "Y.java",
+ "enum X {\n" +
+ " A, B;\n" +
+ "}\n" +
+ "public class Y {\n" +
+ " void test(X x) {\n" +
+ " switch (x) {\n" +
+ " case A: System.out.println(\"A\"); break;\n" +
+ " //$CASES-OMITTED$\n" + // not strong enough to suppress the warning if default: is missing
+ " }\n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING in Y.java (at line 6)\n" +
+ " switch (x) {\n" +
+ " ^\n" +
+ "The enum constant B needs a corresponding case label in this enum switch on X\n" +
+ "----------\n",
+ null, // classlibs
+ true, // flush
+ options);
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=374605
+public void test187b() {
+ Map options = getCompilerOptions();
+ options.put(JavaCore.COMPILER_PB_SWITCH_MISSING_DEFAULT_CASE, JavaCore.ERROR);
+ options.put(JavaCore.COMPILER_PB_SUPPRESS_OPTIONAL_ERRORS, JavaCore.ENABLED);
+ this.runConformTest(
+ new String[] {
+ "Y.java",
+ "enum X {\n" +
+ " A, B;\n" +
+ "}\n" +
+ "public class Y {\n" +
+ " @SuppressWarnings(\"incomplete-switch\")\n" +
+ " void test(X x) {\n" +
+ " switch (x) {\n" +
+ " case A: System.out.println(\"A\"); break;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n",
+ },
+ "",
+ null, // classlibs
+ true, // flush
+ null, // vmArgs
+ options,
+ null /*requestor*/);
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=374605
+public void test188() {
+ Map options = getCompilerOptions();
+ options.put(JavaCore.COMPILER_PB_SWITCH_MISSING_DEFAULT_CASE, JavaCore.WARNING);
+ this.runNegativeTest(
+ new String[] {
+ "Y.java",
+ "enum X {\n" +
+ " A, B;\n" +
+ "}\n" +
+ "public class Y {\n" +
+ " void test(X x) {\n" +
+ " switch (x) {\n" +
+ " case A: System.out.println(\"A\"); break;\n" +
+ " case B: System.out.println(\"B\"); break;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING in Y.java (at line 6)\n" +
+ " switch (x) {\n" +
+ " ^\n" +
+ "The switch over the enum type X should have a default case\n" +
+ "----------\n",
+ null, // classlibs
+ true, // flush
+ options);
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=374605
+public void test189() {
+ Map options = getCompilerOptions();
+ //options.put(JavaCore.COMPILER_PB_MISSING_DEFAULT_CASE, JavaCore.WARNING);
+ this.runNegativeTest(
+ new String[] {
+ "Y.java",
+ "enum X {\n" +
+ " A, B;\n" +
+ "}\n" +
+ "public class Y {\n" +
+ " int test(X x) {\n" +
+ " switch (x) {\n" +
+ " case A: return 1;\n" +
+ " case B: return 2;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in Y.java (at line 5)\n" +
+ " int test(X x) {\n" +
+ " ^^^^^^^^^\n" +
+ "This method must return a result of type int. Note that a problem regarding missing 'default:' on 'switch' has been suppressed, which is perhaps related to this problem\n" +
+ "----------\n",
+ null, // classlibs
+ true, // flush
+ options);
+}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java
index ee7d81e..00813bf 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java
@@ -2568,4 +2568,34 @@
"Bound mismatch: The generic method foo(C1, C2) of type X is not applicable for the arguments (C2, C1). The inferred type C1 is not a valid substitute for the bounded parameter <C2 extends Collection<Object>>\n" +
"----------\n");
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=375394
+public void test375394a() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_7)
+ return;
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " B<C, ? extends C<C>, ? extends C<C>> b = new B<>();\n" +
+ "}\n" +
+ "class B <T, U extends C<T>, V extends U>{}\n" +
+ "class C<T> {}\n",
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 2)\n" +
+ " B<C, ? extends C<C>, ? extends C<C>> b = new B<>();\n" +
+ " ^\n" +
+ "C is a raw type. References to generic type C<T> should be parameterized\n" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 2)\n" +
+ " B<C, ? extends C<C>, ? extends C<C>> b = new B<>();\n" +
+ " ^\n" +
+ "C is a raw type. References to generic type C<T> should be parameterized\n" +
+ "----------\n" +
+ "3. WARNING in X.java (at line 2)\n" +
+ " B<C, ? extends C<C>, ? extends C<C>> b = new B<>();\n" +
+ " ^\n" +
+ "C is a raw type. References to generic type C<T> should be parameterized\n" +
+ "----------\n");
+}
}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java
index 75f02e8..899041f 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -4916,13 +4916,23 @@
"Javadoc: Invalid member type qualification\n" +
"----------\n" +
"----------\n" +
- "1. ERROR in boden\\TestInvalid3.java (at line 5)\n" +
+ "1. ERROR in boden\\TestInvalid3.java (at line 2)\n"+
+ " import boden.IAFAState.ValidationException;\n"+
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The import boden.IAFAState.ValidationException is never used\n"+
+ "----------\n"+
+ "2. ERROR in boden\\TestInvalid3.java (at line 5)\n" +
" * @see IAFAState.ValidationException#IAFA.State.ValidationException(String, IAFAState)\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: Invalid member type qualification\n" +
"----------\n" +
"----------\n" +
- "1. ERROR in boden\\TestInvalid4.java (at line 5)\n" +
+ "1. ERROR in boden\\TestInvalid4.java (at line 2)\n"+
+ " import boden.IAFAState.ValidationException;\n"+
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The import boden.IAFAState.ValidationException is never used\n"+
+ "----------\n"+
+ "2. ERROR in boden\\TestInvalid4.java (at line 5)\n" +
" * @see IAFAState.ValidationException#IAFAState .ValidationException(String, IAFAState)\n" +
" ^^^^^^^^^\n" +
"Javadoc: IAFAState cannot be resolved or is not a field\n" +
@@ -4934,13 +4944,23 @@
//boden\TestInvalid3.java:6: warning - Tag @see: can't find IAFA.State.ValidationException(String, IAFAState) in boden.IAFAState.ValidationException
//boden\TestInvalid4.java:6: warning - Tag @see: can't find IAFAState in boden.IAFAState.ValidationException
"----------\n" +
- "1. ERROR in boden\\TestInvalid3.java (at line 5)\n" +
+ "1. ERROR in boden\\TestInvalid3.java (at line 2)\n"+
+ " import boden.IAFAState.ValidationException;\n"+
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The import boden.IAFAState.ValidationException is never used\n"+
+ "----------\n"+
+ "2. ERROR in boden\\TestInvalid3.java (at line 5)\n" +
" * @see IAFAState.ValidationException#IAFA.State.ValidationException(String, IAFAState)\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: Invalid member type qualification\n" +
"----------\n" +
"----------\n" +
- "1. ERROR in boden\\TestInvalid4.java (at line 5)\n" +
+ "1. ERROR in boden\\TestInvalid4.java (at line 2)\n"+
+ " import boden.IAFAState.ValidationException;\n"+
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The import boden.IAFAState.ValidationException is never used\n"+
+ "----------\n"+
+ "2. ERROR in boden\\TestInvalid4.java (at line 5)\n" +
" * @see IAFAState.ValidationException#IAFAState .ValidationException(String, IAFAState)\n" +
" ^^^^^^^^^\n" +
"Javadoc: IAFAState cannot be resolved or is not a field\n" +
@@ -6966,7 +6986,12 @@
"Javadoc: Invalid member type qualification\n" +
"----------\n" +
"----------\n" +
- "1. ERROR in pkg3\\Invalid3.java (at line 6)\n" +
+ "1. ERROR in pkg3\\Invalid3.java (at line 2)\n" +
+ " import mainpkg.Outer.*;\n"+
+ " ^^^^^^^^^^^^^\n"+
+ "The import mainpkg.Outer is never used\n" +
+ "----------\n" +
+ "2. ERROR in pkg3\\Invalid3.java (at line 6)\n" +
" * {@link MostInner} -- error/warning \n" +
" ^^^^^^^^^\n" +
"Javadoc: MostInner cannot be resolved to a type\n" +
@@ -6975,7 +7000,12 @@
String error50 = new String (
//pkg3\Invalid3.java:12: warning - Tag @link: reference not found: MostInner
"----------\n" +
- "1. ERROR in pkg3\\Invalid3.java (at line 6)\n" +
+ "1. ERROR in pkg3\\Invalid3.java (at line 2)\n" +
+ " import mainpkg.Outer.*;\n"+
+ " ^^^^^^^^^^^^^\n"+
+ "The import mainpkg.Outer is never used\n" +
+ "----------\n" +
+ "2. ERROR in pkg3\\Invalid3.java (at line 6)\n" +
" * {@link MostInner} -- error/warning \n" +
" ^^^^^^^^^\n" +
"Javadoc: MostInner cannot be resolved to a type\n" +
@@ -7070,7 +7100,12 @@
"Javadoc: Invalid member type qualification\n" +
"----------\n" +
"----------\n" +
- "1. ERROR in pkg3\\Invalid3.java (at line 6)\n" +
+ "1. ERROR in pkg3\\Invalid3.java (at line 2)\n" +
+ " import mainpkg.Outer.*;\n"+
+ " ^^^^^^^^^^^^^\n"+
+ "The import mainpkg.Outer is never used\n" +
+ "----------\n" +
+ "2. ERROR in pkg3\\Invalid3.java (at line 6)\n" +
" * {@link MostInner} -- error/warning \n" +
" ^^^^^^^^^\n" +
"Javadoc: MostInner cannot be resolved to a type\n" +
@@ -7079,7 +7114,12 @@
String error50 = new String(
//pkg3\Invalid3.java:12: warning - Tag @link: reference not found: MostInner
"----------\n" +
- "1. ERROR in pkg3\\Invalid3.java (at line 6)\n" +
+ "1. ERROR in pkg3\\Invalid3.java (at line 2)\n" +
+ " import mainpkg.Outer.*;\n"+
+ " ^^^^^^^^^^^^^\n"+
+ "The import mainpkg.Outer is never used\n" +
+ "----------\n" +
+ "2. ERROR in pkg3\\Invalid3.java (at line 6)\n" +
" * {@link MostInner} -- error/warning \n" +
" ^^^^^^^^^\n" +
"Javadoc: MostInner cannot be resolved to a type\n" +
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 917fc28..13375e6 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -950,12 +950,17 @@
+ " }\n"
+ "}\n" },
"----------\n" +
- "1. ERROR in test\\X.java (at line 6)\n" +
+ "1. WARNING in test\\X.java (at line 2)\n"+
+ " import test.copy.*;\n"+
+ " ^^^^^^^^^\n"+
+ "The import test.copy is never used\n"+
+ "----------\n"+
+ "2. ERROR in test\\X.java (at line 6)\n" +
" * @see VisibilityPackage#unknown() Invalid ref: non visible class (non existent method)\n" +
" ^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
"----------\n" +
- "2. ERROR in test\\X.java (at line 7)\n" +
+ "3. ERROR in test\\X.java (at line 7)\n" +
" * @see test.copy.VisibilityPackage#unknown() Invalid ref: non visible class (non existent method)\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type test.copy.VisibilityPackage is not visible\n" +
@@ -1018,7 +1023,12 @@
"}\n",
},
"----------\n" +
- "1. ERROR in X.java (at line 6)\n" +
+ "1. WARNING in X.java (at line 2)\n"+
+ " import java.util.Map.Entry;\n"+
+ " ^^^^^^^^^^^^^^^^^^^\n"+
+ "The import java.util.Map.Entry is never used\n"+
+ "----------\n"+
+ "2. ERROR in X.java (at line 6)\n" +
" * <li> {@link Entry} </li>\n" +
" ^^^^^\n" +
"Javadoc: Invalid member type qualification\n" +
@@ -1090,7 +1100,12 @@
"}\n",
},
"----------\n" +
- "1. ERROR in X.java (at line 6)\n" +
+ "1. WARNING in X.java (at line 2)\n"+
+ " import java.util.Map.Entry;\n"+
+ " ^^^^^^^^^^^^^^^^^^^\n"+
+ "The import java.util.Map.Entry is never used\n"+
+ "----------\n"+
+ "2. ERROR in X.java (at line 6)\n" +
" * <li> {@link Entry} </li>\n" +
" ^^^^^\n" +
"Javadoc: Invalid member type qualification\n" +
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 8dfdbfd..bfd127c 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -903,12 +903,17 @@
+ " }\n"
+ "}\n" },
"----------\n" +
- "1. ERROR in test\\X.java (at line 7)\n" +
+ "1. WARNING in test\\X.java (at line 2)\n"+
+ " import test.copy.*;\n"+
+ " ^^^^^^^^^\n"+
+ "The import test.copy is never used\n"+
+ "----------\n"+
+ "2. ERROR in test\\X.java (at line 7)\n" +
" * @see VisibilityPackage#unknown() Invalid ref: non visible class (non existent method)\n" +
" ^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
"----------\n" +
- "2. ERROR in test\\X.java (at line 8)\n" +
+ "3. ERROR in test\\X.java (at line 8)\n" +
" * @see test.copy.VisibilityPackage#unknown() Invalid ref: non visible class (non existent method)\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type test.copy.VisibilityPackage is not visible\n" +
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 1694201..54e65ab 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -977,12 +977,17 @@
+ " public int x;\n"
+ "}\n" },
"----------\n" +
- "1. ERROR in test\\X.java (at line 7)\n" +
+ "1. WARNING in test\\X.java (at line 2)\n"+
+ " import test.copy.*;\n"+
+ " ^^^^^^^^^\n"+
+ "The import test.copy is never used\n"+
+ "----------\n"+
+ "2. ERROR in test\\X.java (at line 7)\n" +
" * @see VisibilityPackage#unknown() Invalid ref: non visible class (non existent method)\n" +
" ^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
"----------\n" +
- "2. ERROR in test\\X.java (at line 8)\n" +
+ "3. ERROR in test\\X.java (at line 8)\n" +
" * @see test.copy.VisibilityPackage#unknown() Invalid ref: non visible class (non existent method)\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type test.copy.VisibilityPackage is not visible\n" +
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 4fb36c2..d6b993b 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -910,12 +910,17 @@
+ " public void foo();\n"
+ "}\n" },
"----------\n" +
- "1. ERROR in test\\IX.java (at line 6)\n" +
+ "1. WARNING in test\\IX.java (at line 2)\n"+
+ " import test.copy.*;\n"+
+ " ^^^^^^^^^\n"+
+ "The import test.copy is never used\n"+
+ "----------\n"+
+ "2. ERROR in test\\IX.java (at line 6)\n" +
" * @see VisibilityPackage#unknown() Invalid ref: non visible class (non existent method)\n" +
" ^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
"----------\n" +
- "2. ERROR in test\\IX.java (at line 7)\n" +
+ "3. ERROR in test\\IX.java (at line 7)\n" +
" * @see test.copy.VisibilityPackage#unknown() Invalid ref: non visible class (non existent method)\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type test.copy.VisibilityPackage is not visible\n" +
@@ -2198,12 +2203,17 @@
+ " public void foo();\n"
+ "}\n" },
"----------\n" +
- "1. ERROR in test\\IX.java (at line 7)\n" +
+ "1. WARNING in test\\IX.java (at line 2)\n"+
+ " import test.copy.*;\n"+
+ " ^^^^^^^^^\n"+
+ "The import test.copy is never used\n"+
+ "----------\n"+
+ "2. ERROR in test\\IX.java (at line 7)\n" +
" * @see VisibilityPackage#unknown() Invalid ref: non visible class (non existent method)\n" +
" ^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
"----------\n" +
- "2. ERROR in test\\IX.java (at line 8)\n" +
+ "3. ERROR in test\\IX.java (at line 8)\n" +
" * @see test.copy.VisibilityPackage#unknown() Invalid ref: non visible class (non existent method)\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type test.copy.VisibilityPackage is not visible\n" +
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 c616f73..9d00e0d 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -1037,12 +1037,17 @@
+ " }\n"
+ "}\n" },
"----------\n" +
- "1. ERROR in X.java (at line 5)\n" +
+ "1. WARNING in X.java (at line 1)\n"+
+ " import java.util.Hashtable;\n"+
+ " ^^^^^^^^^^^^^^^^^^^\n"+
+ "The import java.util.Hashtable is never used\n"+
+ "----------\n"+
+ "2. ERROR in X.java (at line 5)\n" +
" * @param Hashtable\n" +
" ^^^^^^^^^\n" +
"Javadoc: Parameter Hashtable is not declared\n" +
"----------\n" +
- "2. ERROR in X.java (at line 7)\n" +
+ "3. ERROR in X.java (at line 7)\n" +
" public void p_foo(int x) {\n" +
" ^\n" +
"Javadoc: Missing tag for parameter x\n" +
@@ -2341,47 +2346,52 @@
+ " }\n"
+ "}\n" },
"----------\n" +
- "1. ERROR in test\\X.java (at line 7)\n" +
+ "1. WARNING in test\\X.java (at line 2)\n"+
+ " import test.copy.*;\n"+
+ " ^^^^^^^^^\n"+
+ "The import test.copy is never used\n"+
+ "----------\n"+
+ "2. ERROR in test\\X.java (at line 7)\n" +
" * @see VisibilityPackage#unknown Invalid ref: non visible class (non existent field)\n" +
" ^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
"----------\n" +
- "2. ERROR in test\\X.java (at line 8)\n" +
+ "3. ERROR in test\\X.java (at line 8)\n" +
" * @see VisibilityPackage#vf_private Invalid ref: non visible class (non existent field)\n" +
" ^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
"----------\n" +
- "3. ERROR in test\\X.java (at line 9)\n" +
+ "4. ERROR in test\\X.java (at line 9)\n" +
" * @see VisibilityPackage#vf_public Invalid ref: non visible class (visible field)\n" +
" ^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
"----------\n" +
- "4. ERROR in test\\X.java (at line 10)\n" +
+ "5. ERROR in test\\X.java (at line 10)\n" +
" * @see VisibilityPackage.VpPrivate#unknown Invalid ref: non visible class and non visible inner class (non existent field)\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
"----------\n" +
- "5. ERROR in test\\X.java (at line 11)\n" +
+ "6. ERROR in test\\X.java (at line 11)\n" +
" * @see VisibilityPackage.VpPrivate#vf_private Invalid ref: non visible class and non visible inner class (non visible field)\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
"----------\n" +
- "6. ERROR in test\\X.java (at line 12)\n" +
+ "7. ERROR in test\\X.java (at line 12)\n" +
" * @see VisibilityPackage.VpPrivate#vf_public Invalid ref: non visible class and non visible inner class (visible field)\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
"----------\n" +
- "7. ERROR in test\\X.java (at line 13)\n" +
+ "8. ERROR in test\\X.java (at line 13)\n" +
" * @see VisibilityPackage.VpPublic#unknown Invalid ref: non visible class and visible inner class (non existent field)\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
"----------\n" +
- "8. ERROR in test\\X.java (at line 14)\n" +
+ "9. ERROR in test\\X.java (at line 14)\n" +
" * @see VisibilityPackage.VpPublic#vf_private Invalid ref: non visible class and visible inner class (non visible field)\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
"----------\n" +
- "9. ERROR in test\\X.java (at line 15)\n" +
+ "10. ERROR in test\\X.java (at line 15)\n" +
" * @see VisibilityPackage.VpPublic#vf_public Invalid ref: non visible class and visible inner class (visible field)\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
@@ -3782,22 +3792,27 @@
+ " }\n"
+ "}\n" },
"----------\n" +
- "1. ERROR in test\\deep\\qualified\\name\\p\\X.java (at line 7)\n" +
+ "1. WARNING in test\\deep\\qualified\\name\\p\\X.java (at line 2)\n"+
+ " import java.util.Vector;\n"+
+ " ^^^^^^^^^^^^^^^^\n"+
+ "The import java.util.Vector is never used\n"+
+ "----------\n"+
+ "2. ERROR in test\\deep\\qualified\\name\\p\\X.java (at line 7)\n" +
" * @see test.deep.qualified.name.p.X#smr_foo(boolean,int i,byte,short s,char,long l,float,double d) Invalid reference: mixed argument declaration\n" +
" ^^^^^^^^^^^^^^\n" +
"Javadoc: Invalid parameters declaration\n" +
"----------\n" +
- "2. ERROR in test\\deep\\qualified\\name\\p\\X.java (at line 8)\n" +
+ "3. ERROR in test\\deep\\qualified\\name\\p\\X.java (at line 8)\n" +
" * @see test.deep.qualified.name.p.X#smr_foo(String,String y,int) Invalid reference: mixed argument declaration\n" +
" ^^^^^^^^^^^^^^^^\n" +
"Javadoc: Invalid parameters declaration\n" +
"----------\n" +
- "3. ERROR in test\\deep\\qualified\\name\\p\\X.java (at line 9)\n" +
+ "4. ERROR in test\\deep\\qualified\\name\\p\\X.java (at line 9)\n" +
" * @see test.deep.qualified.name.p.X#smr_foo(Hashtable,Vector,boolean b) Invalid reference: mixed argument declaration\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: Invalid parameters declaration\n" +
"----------\n" +
- "4. ERROR in test\\deep\\qualified\\name\\p\\X.java (at line 10)\n" +
+ "5. ERROR in test\\deep\\qualified\\name\\p\\X.java (at line 10)\n" +
" * @see test.deep.qualified.name.p.X#smr_foo(Hashtable,Vector,boolean b) Invalid reference: mixed argument declaration\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: Invalid parameters declaration\n" +
@@ -4213,77 +4228,82 @@
+ " }\n"
+ "}\n" },
"----------\n" +
- "1. ERROR in test\\X.java (at line 7)\n" +
+ "1. WARNING in test\\X.java (at line 2)\n"+
+ " import test.copy.*;\n"+
+ " ^^^^^^^^^\n"+
+ "The import test.copy is never used\n"+
+ "----------\n"+
+ "2. ERROR in test\\X.java (at line 7)\n" +
" * @see VisibilityPackage#unknown() Invalid ref: non visible class (non existent method)\n" +
" ^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
"----------\n" +
- "2. ERROR in test\\X.java (at line 8)\n" +
+ "3. ERROR in test\\X.java (at line 8)\n" +
" * @see VisibilityPackage#vm_private() Invalid ref: non visible class (non visible method)\n" +
" ^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
"----------\n" +
- "3. ERROR in test\\X.java (at line 9)\n" +
+ "4. ERROR in test\\X.java (at line 9)\n" +
" * @see VisibilityPackage#vm_private(boolean) Invalid ref: non visible class (non existent method)\n" +
" ^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
"----------\n" +
- "4. ERROR in test\\X.java (at line 10)\n" +
+ "5. ERROR in test\\X.java (at line 10)\n" +
" * @see VisibilityPackage#vm_public() Invalid ref: non visible class (visible method)\n" +
" ^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
"----------\n" +
- "5. ERROR in test\\X.java (at line 11)\n" +
+ "6. ERROR in test\\X.java (at line 11)\n" +
" * @see VisibilityPackage#vm_public(long,long,long,int) Invalid ref: non visible class (visible method)\n" +
" ^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
"----------\n" +
- "6. ERROR in test\\X.java (at line 12)\n" +
+ "7. ERROR in test\\X.java (at line 12)\n" +
" * @see VisibilityPackage.VpPrivate#unknown() Invalid ref: non visible class and non visible inner class (non existent method)\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
"----------\n" +
- "7. ERROR in test\\X.java (at line 13)\n" +
+ "8. ERROR in test\\X.java (at line 13)\n" +
" * @see VisibilityPackage.VpPrivate#vm_private() Invalid ref: non visible class and non visible inner class (non visible method)\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
"----------\n" +
- "8. ERROR in test\\X.java (at line 14)\n" +
+ "9. ERROR in test\\X.java (at line 14)\n" +
" * @see VisibilityPackage.VpPrivate#vm_private(boolean, String) Invalid ref: non visible class and non visible inner class (non applicable method)\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
"----------\n" +
- "9. ERROR in test\\X.java (at line 15)\n" +
+ "10. ERROR in test\\X.java (at line 15)\n" +
" * @see VisibilityPackage.VpPrivate#vm_public() Invalid ref: non visible class and non visible inner class (visible method)\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
"----------\n" +
- "10. ERROR in test\\X.java (at line 16)\n" +
+ "11. ERROR in test\\X.java (at line 16)\n" +
" * @see VisibilityPackage.VpPrivate#vm_public(Object, float) Invalid ref: non visible class and non visible inner class (non applicable visible method)\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
"----------\n" +
- "11. ERROR in test\\X.java (at line 17)\n" +
+ "12. ERROR in test\\X.java (at line 17)\n" +
" * @see VisibilityPackage.VpPublic#unknown() Invalid ref: non visible class and visible inner class (non existent method)\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
"----------\n" +
- "12. ERROR in test\\X.java (at line 18)\n" +
+ "13. ERROR in test\\X.java (at line 18)\n" +
" * @see VisibilityPackage.VpPublic#vm_private() Invalid ref: non visible class and visible inner class (non visible method)\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
"----------\n" +
- "13. ERROR in test\\X.java (at line 19)\n" +
+ "14. ERROR in test\\X.java (at line 19)\n" +
" * @see VisibilityPackage.VpPublic#vm_private(boolean, String) Invalid ref: non visible class and visible inner class (non applicable method)\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
"----------\n" +
- "14. ERROR in test\\X.java (at line 20)\n" +
+ "15. ERROR in test\\X.java (at line 20)\n" +
" * @see VisibilityPackage.VpPublic#vm_public() Invalid ref: non visible class and visible inner class (visible method)\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
"----------\n" +
- "15. ERROR in test\\X.java (at line 21)\n" +
+ "16. ERROR in test\\X.java (at line 21)\n" +
" * @see VisibilityPackage.VpPublic#vm_public(Object, float) Invalid ref: non visible class and visible inner class (non applicable visible method)\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Javadoc: The type VisibilityPackage is not visible\n" +
@@ -4678,32 +4698,37 @@
+ " }\n"
+ "}\n" },
"----------\n" +
- "1. ERROR in test\\X.java (at line 7)\n" +
+ "1. WARNING in test\\X.java (at line 2)\n"+
+ " import test.copy.VisibilityPublic;\n"+
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n"+
+ "The import test.copy.VisibilityPublic is never used\n"+
+ "----------\n"+
+ "2. ERROR in test\\X.java (at line 7)\n" +
" * @see VisibilityPublic#vm_private(\"boolean\") Invalid ref: invalid argument declaration\n" +
" ^^^^^^^^^^\n" +
"Javadoc: Invalid parameters declaration\n" +
"----------\n" +
- "2. ERROR in test\\X.java (at line 8)\n" +
+ "3. ERROR in test\\X.java (at line 8)\n" +
" * @see VisibilityPublic#vm_public(long, \"int) Invalid ref: invalid argument definition\n" +
" ^^^^^^^^\n" +
"Javadoc: Invalid parameters declaration\n" +
"----------\n" +
- "3. ERROR in test\\X.java (at line 9)\n" +
+ "4. ERROR in test\\X.java (at line 9)\n" +
" * @see VisibilityPublic.VpPrivate#vm_private(double d()) Invalid ref: invalid argument declaration\n" +
" ^^^^^^^^^^\n" +
"Javadoc: Invalid parameters declaration\n" +
"----------\n" +
- "4. ERROR in test\\X.java (at line 10)\n" +
+ "5. ERROR in test\\X.java (at line 10)\n" +
" * @see VisibilityPublic.VpPrivate#vm_public(\") Invalid ref: invalid argument declaration\n" +
" ^^\n" +
"Javadoc: Invalid parameters declaration\n" +
"----------\n" +
- "5. ERROR in test\\X.java (at line 11)\n" +
+ "6. ERROR in test\\X.java (at line 11)\n" +
" * @see VisibilityPublic.VpPublic#vm_private(d()) Invalid ref: invalid argument declaration\n" +
" ^^^\n" +
"Javadoc: Invalid parameters declaration\n" +
"----------\n" +
- "6. ERROR in test\\X.java (at line 12)\n" +
+ "7. ERROR in test\\X.java (at line 12)\n" +
" * @see VisibilityPublic.VpPublic#vm_public(205) Invalid ref: invalid argument declaration\n" +
" ^^^^\n" +
"Javadoc: Invalid parameters declaration\n" +
@@ -4875,32 +4900,37 @@
+ " }\n"
+ "}\n" },
"----------\n" +
- "1. ERROR in test\\X.java (at line 7)\n" +
+ "1. WARNING in test\\X.java (at line 2)\n"+
+ " import test.copy.VisibilityPublic;\n"+
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n"+
+ "The import test.copy.VisibilityPublic is never used\n"+
+ "----------\n"+
+ "2. ERROR in test\\X.java (at line 7)\n" +
" * @see test.copy.VisibilityPublic#vm_private(\"\") Invalid ref: invalid argument declaration\n" +
" ^^^\n" +
"Javadoc: Invalid parameters declaration\n" +
"----------\n" +
- "2. ERROR in test\\X.java (at line 8)\n" +
+ "3. ERROR in test\\X.java (at line 8)\n" +
" * @see test.copy.VisibilityPublic#vm_public(\"\"\") Invalid ref: invalid argument definition\n" +
" ^^^\n" +
"Javadoc: Invalid parameters declaration\n" +
"----------\n" +
- "3. ERROR in test\\X.java (at line 9)\n" +
+ "4. ERROR in test\\X.java (at line 9)\n" +
" * @see test.copy.VisibilityPublic.VpPrivate#vm_private(String d()) Invalid ref: invalid argument declaration\n" +
" ^^^^^^^^^^\n" +
"Javadoc: Invalid parameters declaration\n" +
"----------\n" +
- "4. ERROR in test\\X.java (at line 10)\n" +
+ "5. ERROR in test\\X.java (at line 10)\n" +
" * @see test.copy.VisibilityPublic.VpPrivate#vm_public([) Invalid ref: invalid argument declaration\n" +
" ^^\n" +
"Javadoc: Invalid parameters declaration\n" +
"----------\n" +
- "5. ERROR in test\\X.java (at line 11)\n" +
+ "6. ERROR in test\\X.java (at line 11)\n" +
" * @see test.copy.VisibilityPublic.VpPublic#vm_private([]) Invalid ref: invalid argument declaration\n" +
" ^^\n" +
"Javadoc: Invalid parameters declaration\n" +
"----------\n" +
- "6. ERROR in test\\X.java (at line 12)\n" +
+ "7. ERROR in test\\X.java (at line 12)\n" +
" * @see test.copy.VisibilityPublic.VpPublic#vm_public(char[], int[],]) Invalid ref: invalid argument declaration\n" +
" ^^^^^^^^^^^^^^^^\n" +
"Javadoc: Invalid parameters declaration\n" +
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java
index 5f0ebcd..253c543 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 GK Software AG and others.
+ * Copyright (c) 2010, 2012 GK Software AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -53,7 +53,7 @@
// Static initializer to specify tests subset using TESTS_* static variables
// All specified tests which do not belong to the class are skipped...
static {
-// TESTS_NAMES = new String[] { "test_missing_default_annotation_03" };
+// TESTS_NAMES = new String[] { "testBug374129" };
// TESTS_NUMBERS = new int[] { 561 };
// TESTS_RANGE = new int[] { 1, 2049 };
}
@@ -3549,4 +3549,116 @@
libs,
true /* shouldFlush*/);
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=374129 - more tests for bug 372011
+// Test whether @NonNullByDefault on a binary package or an enclosing type is respected from enclosed elements.
+public void testBug374129() {
+ String path = this.getCompilerTestsPluginDirectoryPath() + File.separator + "workspace" + File.separator + "Test374129.jar";
+ /* content of Test372129.jar:
+ p1bin/package-info.java:
+ @org.eclipse.jdt.annotation.NonNullByDefault
+ package p1bin;
+ p1bin/C1bin.java:
+ package p1bin;
+ import org.eclipse.jdt.annotation.Nullable;
+ public class C1bin {
+ public String getId(String id, @Nullable String n) {
+ return id;
+ }
+ public static class C1binInner {
+ public String getId(String id, @Nullable String n) {
+ return id;
+ }
+ }
+ }
+ p2bin/C2bin.java:
+ package p2bin;
+ import org.eclipse.jdt.annotation.NonNullByDefault;
+ import org.eclipse.jdt.annotation.Nullable;
+ @NonNullByDefault
+ public class C2bin {
+ public String getId(String id, @Nullable String n) {
+ return id;
+ }
+ @NonNullByDefault(false)
+ public static class C2binInner {
+ public String getId(String id, @Nullable String n) {
+ return id;
+ }
+ }
+ }
+ p2bin/C3bin.java:
+ package p2bin;
+ import org.eclipse.jdt.annotation.NonNullByDefault;
+ import org.eclipse.jdt.annotation.Nullable;
+ public class C3bin {
+ @NonNullByDefault public String getId(String id, @Nullable String n) {
+ return id;
+ }
+ }
+ */
+ String[] libs = new String[this.LIBS.length + 1];
+ System.arraycopy(this.LIBS, 0, libs, 0, this.LIBS.length);
+ libs[this.LIBS.length] = path;
+ runNegativeTest(
+ new String[] {
+ "bug374129/Test.java",
+ "package bug374129;\n" +
+ "\n" +
+ "import org.eclipse.jdt.annotation.NonNull;\n" +
+ "import org.eclipse.jdt.annotation.Nullable;\n" +
+ "\n" +
+ "import p1bin.C1bin;\n" +
+ "import p1bin.C1bin.C1binInner;\n" +
+ "import p2bin.C2bin;\n" +
+ "import p2bin.C2bin.C2binInner;\n" +
+ "import p2bin.C3bin;\n" +
+ "\n" +
+ "public class Test {\n" +
+ " static C1bin c1 = new C1bin();\n" +
+ " static C1binInner c1i = new C1binInner();\n" +
+ " static C2bin c2 = new C2bin();\n" +
+ " static C2binInner c2i = new C2binInner();\n" +
+ " static C3bin c3 = new C3bin();\n" +
+ " \n" +
+ " public static void main(String[] args) {\n" +
+ " @Nullable String n = getN();\n" +
+ " @NonNull String s;\n" +
+ " s = c1.getId(n, n); // error on first arg (package default)\n" +
+ " s = c1i.getId(n, n); // error on first arg (package default propagated into inner)\n" +
+ " s = c2.getId(n, n); // error on first arg (type default)\n" +
+ " s = c2i.getId(n, n); // no arg error (canceled default), return requires unchecked conversion\n" +
+ " s = c3.getId(n, n); // error on first arg (method default)\n" +
+ " }\n" +
+ " static String getN() { return null; }\n" +
+ "}\n" +
+ "\n"},
+ "----------\n" +
+ "1. ERROR in bug374129\\Test.java (at line 22)\n" +
+ " s = c1.getId(n, n); // error on first arg (package default)\n" +
+ " ^\n" +
+ "Null type mismatch: required \'@NonNull String\' but the provided value is specified as @Nullable\n" +
+ "----------\n" +
+ "2. ERROR in bug374129\\Test.java (at line 23)\n" +
+ " s = c1i.getId(n, n); // error on first arg (package default propagated into inner)\n" +
+ " ^\n" +
+ "Null type mismatch: required \'@NonNull String\' but the provided value is specified as @Nullable\n" +
+ "----------\n" +
+ "3. ERROR in bug374129\\Test.java (at line 24)\n" +
+ " s = c2.getId(n, n); // error on first arg (type default)\n" +
+ " ^\n" +
+ "Null type mismatch: required \'@NonNull String\' but the provided value is specified as @Nullable\n" +
+ "----------\n" +
+ "4. WARNING in bug374129\\Test.java (at line 25)\n" +
+ " s = c2i.getId(n, n); // no arg error (canceled default), return requires unchecked conversion\n" +
+ " ^^^^^^^^^^^^^^^\n" +
+ "Null type safety: The expression of type String needs unchecked conversion to conform to \'@NonNull String\'\n" +
+ "----------\n" +
+ "5. ERROR in bug374129\\Test.java (at line 26)\n" +
+ " s = c3.getId(n, n); // error on first arg (method default)\n" +
+ " ^\n" +
+ "Null type mismatch: required \'@NonNull String\' but the provided value is specified as @Nullable\n" +
+ "----------\n",
+ libs,
+ true /* shouldFlush*/);
+}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java
index 1200657..a2d81a4 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java
@@ -1802,12 +1802,7 @@
" ^^^^^^^^^^^^^^^^^^^^\n" +
"The import sample.X.TestEnum.V2 is never used\n" +
"----------\n" +
- "3. WARNING in sample\\X.java (at line 12)\n" +
- " switch (value) {\n" +
- " ^^^^^\n" +
- "The switch on the enum type X.TestEnum should have a default case\n" +
- "----------\n" +
- "4. ERROR in sample\\X.java (at line 22)\n" +
+ "3. ERROR in sample\\X.java (at line 22)\n" +
" i++;\n" +
" ^\n" +
"The local variable i may not have been initialized\n" +
@@ -1848,13 +1843,8 @@
" import static sample.X.TestEnum.*;\n" +
" ^^^^^^^^^^^^^^^^^\n" +
"The import sample.X.TestEnum is never used\n" +
- "----------\n" +
- "2. WARNING in sample\\X.java (at line 11)\n" +
- " switch (value) {\n" +
- " ^^^^^\n" +
- "The switch on the enum type X.TestEnum should have a default case\n" +
"----------\n" +
- "3. ERROR in sample\\X.java (at line 21)\n" +
+ "2. ERROR in sample\\X.java (at line 21)\n" +
" i++;\n" +
" ^\n" +
"The local variable i may not have been initialized\n" +
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java
index f45096e..212d3d3 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Stephan Herrmann - Contribution for bug 374605 - Unreasonable warning for enum-based switch statements
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -15,6 +16,7 @@
import junit.framework.Test;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.ToolFactory;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.core.util.ClassFileBytesDisassembler;
@@ -1028,17 +1030,12 @@
" ^^^\n" +
"Type mismatch: cannot convert from String to int\n" +
"----------\n" +
- "2. WARNING in X.java (at line 9)\n" +
- " switch(Days.Sunday) {\n" +
- " ^^^^^^^^^^^\n" +
- "The switch on the enum type Days should have a default case\n" +
- "----------\n" +
- "3. ERROR in X.java (at line 10)\n" +
+ "2. ERROR in X.java (at line 10)\n" +
" case \"Sunday\": break;\n" +
" ^^^^^^^^\n" +
"Type mismatch: cannot convert from String to Days\n" +
"----------\n" +
- "4. ERROR in X.java (at line 13)\n" +
+ "3. ERROR in X.java (at line 13)\n" +
" case \"0\": break;\n" +
" ^^^\n" +
"Type mismatch: cannot convert from String to Integer\n" +
@@ -2138,6 +2135,35 @@
this.runConformTest(sourceFiles, "DONE");
}
}
+public void testBug374605() {
+ Map options = getCompilerOptions();
+ options.put(JavaCore.COMPILER_PB_SWITCH_MISSING_DEFAULT_CASE, JavaCore.WARNING);
+ this.runNegativeTest(
+ new String[] {
+ "p/X.java",
+ "package p;\n" +
+ "class X {\n" +
+ " void v(int i) {\n" +
+ " switch (i) {\n" +
+ " case 1 :\n" +
+ " break;\n" +
+ " case 2 :\n" +
+ " break;\n" +
+ " }\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING in p\\X.java (at line 4)\n" +
+ " switch (i) {\n" +
+ " ^\n" +
+ "The switch over the type int should have a default case\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+}
public static Class testClass() {
return SwitchTest.class;
}
diff --git a/org.eclipse.jdt.core.tests.compiler/workspace/Test374129.jar b/org.eclipse.jdt.core.tests.compiler/workspace/Test374129.jar
new file mode 100644
index 0000000..93409d6
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/workspace/Test374129.jar
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/.settings/org.eclipse.core.resources.prefs b/org.eclipse.jdt.core.tests.model/.settings/org.eclipse.core.resources.prefs
index e36f4c5..947b88f 100644
--- a/org.eclipse.jdt.core.tests.model/.settings/org.eclipse.core.resources.prefs
+++ b/org.eclipse.jdt.core.tests.model/.settings/org.eclipse.core.resources.prefs
@@ -1,3 +1,3 @@
-#Wed Nov 25 13:03:46 CET 2009
eclipse.preferences.version=1
+encoding//src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java=UTF-8
encoding//workspace/Encoding/src/testUTF8/Test.java=UTF-8
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15JLS4Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15JLS4Test.java
index 9b73eb2..48b71d8 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15JLS4Test.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15JLS4Test.java
@@ -4767,7 +4767,6 @@
" RED, GREEN(), BLUE(17);\n" +
" X() {}\n" +
" X(int i) {}\n" +
- " @SuppressWarnings(\"incomplete-switch\")\n" +
" public static void main(String[] args) {\n" +
" for (X x : X.values()) {\n" +
" switch(x) {\n" +
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java
index dac0e8d..e67367d 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java
@@ -4770,7 +4770,6 @@
" RED, GREEN(), BLUE(17);\n" +
" X() {}\n" +
" X(int i) {}\n" +
- " @SuppressWarnings(\"incomplete-switch\")\n" +
" public static void main(String[] args) {\n" +
" for (X x : X.values()) {\n" +
" switch(x) {\n" +
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CodeCorrectionTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CodeCorrectionTests.java
index 62da35b..972f591 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CodeCorrectionTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CodeCorrectionTests.java
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Stephan Herrmann - Contribution for bug 374605 - Unreasonable warning for enum-based switch statements
*******************************************************************************/
package org.eclipse.jdt.core.tests.model;
@@ -804,7 +805,9 @@
assertEquals("wrong token", "hiding", CorrectionEngine.getWarningToken(IProblem.TypeParameterHidingType));
assertEquals("wrong token", "nls", CorrectionEngine.getWarningToken(IProblem.NonExternalizedStringLiteral));
assertEquals("wrong token", "incomplete-switch", CorrectionEngine.getWarningToken(IProblem.MissingEnumConstantCase));
+ assertEquals("wrong token", "incomplete-switch", CorrectionEngine.getWarningToken(IProblem.MissingEnumConstantCaseDespiteDefault));
assertEquals("wrong token", "incomplete-switch", CorrectionEngine.getWarningToken(IProblem.MissingEnumDefaultCase));
+ assertEquals("wrong token", "incomplete-switch", CorrectionEngine.getWarningToken(IProblem.MissingDefaultCase));
assertEquals("wrong token", "unused", CorrectionEngine.getWarningToken(IProblem.UnusedImport));
assertEquals("wrong token", "unused", CorrectionEngine.getWarningToken(IProblem.LocalVariableIsNeverUsed));
assertEquals("wrong token", "unused", CorrectionEngine.getWarningToken(IProblem.ArgumentIsNeverUsed));
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java
index 758e89a..014fb9a 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -24839,9 +24839,9 @@
" }\n" +
" }" +
"}\n" +
- "public class IZZException extends Exception {\n" +
+ "class IZZException extends Exception {\n" +
"}\n" +
- "public class IZZAException extends IZZException {\n" +
+ "class IZZAException extends IZZException {\n" +
"}\n");
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
@@ -24968,9 +24968,9 @@
" }\n" +
" }" +
"}\n" +
- "public class IZZException extends Exception {\n" +
+ "class IZZException extends Exception {\n" +
"}\n" +
- "public class IZZAException extends IZZException {\n" +
+ "class IZZAException extends IZZException {\n" +
"}\n");
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
@@ -25093,10 +25093,7 @@
requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=350652
-// superclass exception type not allowed in multi-catch
-// Test filtration of supertype from expected types when no prefix before caret (IZZException is expected here because of the
-// throw, yet is not a valid proposal anymore since a child, IZZAException is present in the same multi-catch).
-// types in same CU
+// according to comment 5, supertypes of exceptions should also be proposed
public void testBug350652k() throws JavaModelException {
Map options = COMPLETION_PROJECT.getOptions(true);
Object savedOptionCompliance = options.get(CompilerOptions.OPTION_Compliance);
@@ -25106,7 +25103,7 @@
this.workingCopies = new ICompilationUnit[1];
this.workingCopies[0] = getWorkingCopy(
"/Completion/src/test/Test.java",
- "package test;"+
+ "package test;\n"+
"public class Test {\n" +
" public void foo() {\n" +
" try {\n" +
@@ -25116,19 +25113,20 @@
" }\n" +
" }" +
"}\n" +
- "public class IZZException extends Exception {\n" +
+ "class IZZException extends Exception {\n" +
"}\n" +
- "public class IZZAException extends IZZException {\n" +
+ "class IZZAException extends IZZException {\n" +
"}\n");
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
String str = this.workingCopies[0].getSource();
- String completeBehind = "IZZException |";
+ String completeBehind = "catch (IZZAException |";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "",
+ "Exception[TYPE_REF]{Exception, java.lang, Ljava.lang.Exception;, null, null, " + (R_DEFAULT + R_EXACT_EXPECTED_TYPE + R_RESOLVED + R_UNQUALIFIED + R_EXCEPTION + R_NON_RESTRICTED) + "}\n" +
+ "IZZException[TYPE_REF]{IZZException, test, Ltest.IZZException;, null, null, " + (R_DEFAULT + R_EXACT_EXPECTED_TYPE + R_RESOLVED + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_NON_RESTRICTED) + "}",
requestor.getResults());
} finally {
// Restore compliance settings.
@@ -25137,11 +25135,7 @@
}
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=350652
-// subclass exception type not allowed in multi-catch
-// Test relevance of sub-type from expected types when no prefix before caret (IZZAException is expected here because of the
-// throw, yet is a less relevant proposal since a child, IZZException is present in the same multi-catch).
-// Also, sub-type should not be an expected type.
-// types in same CU
+// according to comment 5, subtypes of exceptions should also be proposed
public void testBug350652l() throws JavaModelException {
Map options = COMPLETION_PROJECT.getOptions(true);
Object savedOptionCompliance = options.get(CompilerOptions.OPTION_Compliance);
@@ -25161,9 +25155,9 @@
" }\n" +
" }" +
"}\n" +
- "public class IZZException extends Exception {\n" +
+ "class IZZException extends Exception {\n" +
"}\n" +
- "public class IZZAException extends IZZException {\n" +
+ "class IZZAException extends IZZException {\n" +
"}\n");
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests2.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests2.java
index 8cf9c88..42c0755 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests2.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests2.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -48,7 +48,7 @@
public class CompletionTests2 extends ModifyingResourceTests implements RelevanceConstants {
static {
-// TESTS_NAMES = new String[]{"testBug340945"};
+// TESTS_NAMES = new String[]{"testBug326610"};
}
public static class CompletionContainerInitializer implements ContainerInitializer.ITestInitializer {
@@ -5852,4 +5852,46 @@
"static void foo() \n",
requestor.getVisibleMethods());
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=326610
+// Test if annotations can be added on package declaration in package-info
+public void testBug326610() throws Exception {
+ try {
+ // create P1
+ IFile f = getFile("/Completion/org.eclipse.jdt.annotation_1.0.0.v20120312-1601.jar");
+ IJavaProject p = this.createJavaProject(
+ "P1",
+ new String[]{"src"},
+ new String[]{"JCL_LIB"},
+ "bin",
+ "1.5");
+
+ this.createFolder("/P1/src/p");
+ this.createFile("/P1/lib.jar", f.getContents());
+ this.addLibraryEntry(p, "/P1/lib.jar", true);
+
+ this.createFile(
+ "/P1/src/p/package-info.java",
+ "@No\n" +
+ "package p;\n");
+
+ waitUntilIndexesReady();
+
+ // do completion
+ CompletionTestsRequestor requestor = new CompletionTestsRequestor();
+ ICompilationUnit cu= getCompilationUnit("P1", "src", "p", "package-info.java");
+
+ String str = cu.getSource();
+ String completeBehind = "@No";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ cu.codeComplete(cursorLocation, requestor);
+
+ assertEquals(
+ "element:NonNullByDefault completion:org.eclipse.jdt.annotation.NonNullByDefault relevance:"+ (R_DEFAULT + R_INTERESTING + R_CASE + R_QUALIFIED + R_EXACT_NAME + R_NON_RESTRICTED + R_ANNOTATION),
+ requestor.getResults());
+
+
+ } finally {
+ this.deleteProject("P1");
+ }
+}
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java
index 6521614..bad7208 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java
@@ -14306,4 +14306,128 @@
"X<T>[TYPE_REF]{, , LX<TT;>;, null, null, replace[116, 116], token[116, 116], 51}",
requestor.getResults());
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=326610
+public void testBug326610() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/test/package-info.java",
+ "package test;\n");
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "package test;";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "import[KEYWORD]{import, null, null, import, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}",
+ requestor.getResults());
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=326610
+public void testBug326610a() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/test/Try.java",
+ "package test;\n");
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "package test;";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "abstract[KEYWORD]{abstract, null, null, abstract, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}\n" +
+ "class[KEYWORD]{class, null, null, class, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}\n" +
+ "enum[KEYWORD]{enum, null, null, enum, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}\n" +
+ "final[KEYWORD]{final, null, null, final, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}\n" +
+ "import[KEYWORD]{import, null, null, import, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}\n" +
+ "interface[KEYWORD]{interface, null, null, interface, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}\n" +
+ "public[KEYWORD]{public, null, null, public, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}",
+ requestor.getResults());
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=326610
+public void testBug326610b() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/test/package-info.java",
+ "/*Complete here*/\n");
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "/*Complete here*/";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "package[KEYWORD]{package, null, null, package, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}",
+ requestor.getResults());
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=326610
+public void testBug326610c() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/test/Try.java",
+ "/*Complete here*/\n");
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "/*Complete here*/";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "abstract[KEYWORD]{abstract, null, null, abstract, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}\n" +
+ "class[KEYWORD]{class, null, null, class, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}\n" +
+ "enum[KEYWORD]{enum, null, null, enum, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}\n" +
+ "final[KEYWORD]{final, null, null, final, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}\n" +
+ "import[KEYWORD]{import, null, null, import, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}\n" +
+ "interface[KEYWORD]{interface, null, null, interface, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}\n" +
+ "package[KEYWORD]{package, null, null, package, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}\n" +
+ "public[KEYWORD]{public, null, null, public, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}",
+ requestor.getResults());
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=326610
+public void testBug326610d() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[2];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/test/package-info.java",
+ "@Non\n" +
+ "package test");
+ this.workingCopies[1] = getWorkingCopy(
+ "/Completion/src/j/NonNull.java",
+ "package j;\n" +
+ "import static java.lang.annotation.ElementType.PACKAGE;\n" +
+ "import java.lang.annotation.Target;\n" +
+ "@Target({PACKAGE})\n" +
+ "public @interface NonNull{}\n");
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "@Non";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "NonNull[TYPE_REF]{j.NonNull, j, Lj.NonNull;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_QUALIFIED + R_EXACT_NAME + R_NON_RESTRICTED + R_ANNOTATION) + "}",
+ requestor.getResults());
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=326610
+public void testBug326610e() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/test/package-info.java",
+ "/*Complete here*/\n" +
+ "package test;");
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "/*Complete here*/";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "",
+ requestor.getResults());
+}
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java
index 0052f7a..cde8aa0 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java
@@ -12,11 +12,13 @@
package org.eclipse.jdt.core.tests.model;
import java.io.IOException;
+import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import junit.framework.Test;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
@@ -37,7 +39,7 @@
}
static {
- //TESTS_NAMES = new String[] {"testBug123836"};
+ //TESTS_NAMES = new String[] {"testBug123836j", "testBug376673"};
}
public static Test suite() {
@@ -481,4 +483,416 @@
deleteProject("P");
}
}
+
+ /**
+ * @bug 376673: DBCS4.2 Can not rename the class names when DBCS (Surrogate e.g. U+20B9F) is in it
+ * @test Search for DBCS type should report the match
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=376673"
+ */
+ public void testBug376673a() throws CoreException {
+ try {
+ IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL17_LIB"}, "bin", "1.7");
+ String content = "package pkg;\n" +
+ "class 𠮟1 {}\n";
+ createFolder("/P/pkg");
+ try {
+ IFile file = createFile("/P/pkg/𠮟1.java", content, "UTF-8");
+ file.setCharset("UTF-8", null);
+ } catch (UnsupportedEncodingException e) {
+ System.out.println("unsupported encoding");
+ }
+ waitUntilIndexesReady();
+ IJavaSearchScope scope = SearchEngine. createJavaSearchScope(
+ new IJavaElement[] { project }, IJavaSearchScope.SOURCES);
+ search("𠮟1", TYPE, DECLARATIONS, EXACT_RULE, scope, this.resultCollector);
+ assertSearchResults("pkg/𠮟1.java pkg.𠮟1 [𠮟1] EXACT_MATCH");
+ } finally {
+ deleteProject("P");
+ }
+ }
+ // Search for DBCS method should report the match
+ public void testBug376673b() throws CoreException {
+ try {
+ IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL17_LIB"}, "bin", "1.7");
+ String content = "package pkg;\n" +
+ "class 𠮟1 {" +
+ " public void 𠮟m() {}\n" +
+ "}\n";
+ createFolder("/P/pkg");
+ try {
+ IFile file = createFile("/P/pkg/𠮟1.java", content, "UTF-8");
+ file.setCharset("UTF-8", null);
+ } catch (UnsupportedEncodingException e) {
+ System.out.println("unsupported encoding");
+ }
+ waitUntilIndexesReady();
+ IJavaSearchScope scope = SearchEngine. createJavaSearchScope(
+ new IJavaElement[] { project }, IJavaSearchScope.SOURCES);
+ search("𠮟m", METHOD, DECLARATIONS, EXACT_RULE, scope, this.resultCollector);
+ assertSearchResults("pkg/𠮟1.java void pkg.𠮟1.𠮟m() [𠮟m] EXACT_MATCH");
+ } finally {
+ deleteProject("P");
+ }
+ }
+ // Search for DBCS constructor should report the match
+ public void testBug376673c() throws CoreException {
+ try {
+ IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL17_LIB"}, "bin", "1.7");
+ String content = "package pkg;\n" +
+ "class 𠮟1 {" +
+ " public 𠮟1() {}\n" +
+ "}\n";
+ createFolder("/P/pkg");
+ try {
+ IFile file = createFile("/P/pkg/𠮟1.java", content, "UTF-8");
+ file.setCharset("UTF-8", null);
+ } catch (UnsupportedEncodingException e) {
+ System.out.println("unsupported encoding");
+ }
+ waitUntilIndexesReady();
+ IJavaSearchScope scope = SearchEngine. createJavaSearchScope(
+ new IJavaElement[] { project }, IJavaSearchScope.SOURCES);
+ search("𠮟1", CONSTRUCTOR, DECLARATIONS, EXACT_RULE, scope, this.resultCollector);
+ assertSearchResults("pkg/𠮟1.java pkg.𠮟1() [𠮟1] EXACT_MATCH");
+ } finally {
+ deleteProject("P");
+ }
+ }
+ // Search for DBCS field should report the match
+ public void testBug376673d() throws CoreException {
+ try {
+ IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL17_LIB"}, "bin", "1.7");
+ String content = "package pkg;\n" +
+ "class 𠮟1 {" +
+ " public int 𠮟f;\n" +
+ "}\n";
+ createFolder("/P/pkg");
+ try {
+ IFile file = createFile("/P/pkg/𠮟1.java", content, "UTF-8");
+ file.setCharset("UTF-8", null);
+ } catch (UnsupportedEncodingException e) {
+ System.out.println("unsupported encoding");
+ }
+ waitUntilIndexesReady();
+ IJavaSearchScope scope = SearchEngine. createJavaSearchScope(
+ new IJavaElement[] { project }, IJavaSearchScope.SOURCES);
+ search("𠮟f", FIELD, DECLARATIONS, EXACT_RULE, scope, this.resultCollector);
+ assertSearchResults("pkg/𠮟1.java pkg.𠮟1.𠮟f [𠮟f] EXACT_MATCH");
+ } finally {
+ deleteProject("P");
+ }
+ }
+ // Search for DBCS package name from a jar also should report the match
+ public void testBug376673e() throws CoreException, IOException {
+ try {
+ IJavaProject p = createJavaProject("P", new String[] {}, new String[] { "/P/lib376673.jar", "JCL17_LIB" }, "", "1.7");
+
+ org.eclipse.jdt.core.tests.util.Util.createJar(
+ new String[] {
+ "p𠮟/i𠮟/Test.java",
+ "package p𠮟.i𠮟;\n" +
+ "public class Test{}\n" },
+ p.getProject().getLocation().append("lib376673.jar").toOSString(),
+ "1.7");
+ refresh(p);
+ waitUntilIndexesReady();
+ int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES;
+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, mask);
+ search("Test", TYPE, DECLARATIONS, scope, this.resultCollector);
+ assertSearchResults("lib376673.jar p𠮟.i𠮟.Test [No source] EXACT_MATCH");
+ } finally {
+ deleteProject("P");
+ }
+ }
+ /**
+ * @bug 357547: [search] Search for method references is returning methods as overriden even if the superclass's method is only package-visible
+ * @test Search for a non-overriden method because of package visibility should not be found
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=357547"
+ */
+ public void testBug357547a() throws CoreException {
+ IJavaProject project = null;
+ try
+ {
+ project = createJavaProject("P");
+ createFolder("/P/p1");
+ createFile("/P/p1/B.java",
+ "package p1;\n" +
+ "import p2.*;\n" +
+ "public class B extends A {\n" +
+ "long k(){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "}\n");
+ createFolder("/P/p2");
+ createFile("/P/p2/A.java",
+ "package p2;\n" +
+ "public class A {\n" +
+ "long k(){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "public long m(){\n"+
+ "return new A().k();\n" +
+ "}\n"+
+ "}\n");
+ IType type = getCompilationUnit("/P/p1/B.java").getType("B");
+ IMethod method = type.getMethod("k", new String[]{});
+ search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector);
+ assertSearchResults("Should not get any results", "", this.resultCollector);
+ } finally {
+ deleteProject(project);
+ }
+ }
+
+ // search for the method name should also not return matches if not-overriden because of package-visible
+ public void testBug357547b() throws CoreException {
+ IJavaProject project = null;
+ try
+ {
+ project = createJavaProject("P");
+ createFolder("/P/p1");
+ createFile("/P/p1/B.java",
+ "package p1;\n" +
+ "import p2.*;\n" +
+ "public class B extends A {\n" +
+ "long k(){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "}\n");
+ createFolder("/P/p2");
+ createFile("/P/p2/A.java",
+ "package p2;\n" +
+ "public class A {\n" +
+ "long k(){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "public long m(){\n"+
+ "return new A().k();\n" +
+ "}\n"+
+ "}\n");
+ waitUntilIndexesReady();
+ // search
+ SearchPattern pattern = SearchPattern.createPattern("p*.B.k()", METHOD, REFERENCES , 0 );
+ search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }), this.resultCollector);
+ assertSearchResults("Should not get any results", "", this.resultCollector);
+ } finally {
+ deleteProject(project);
+ }
+ }
+
+ // search for the method name should return the match if same package
+ public void testBug357547c() throws CoreException {
+ IJavaProject project = null;
+ try
+ {
+ project = createJavaProject("P");
+ createFolder("/P/p2");
+ createFile("/P/p2/B.java",
+ "package p2;\n" +
+ "public class B extends A {\n" +
+ "long k(){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "}\n");
+ createFile("/P/p2/A.java",
+ "package p2;\n" +
+ "public class A {\n" +
+ "long k(){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "public long m(){\n"+
+ "return new A().k();\n" +
+ "}\n"+
+ "}\n");
+ waitUntilIndexesReady();
+ // search
+ SearchPattern pattern = SearchPattern.createPattern("B.k()", METHOD, REFERENCES, EXACT_RULE);
+ search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }), this.resultCollector);
+ assertSearchResults("Wrong results", "p2/A.java long p2.A.m() [k()] EXACT_MATCH", this.resultCollector);
+ } finally {
+ deleteProject(project);
+ }
+ }
+
+
+ public void testBug357547d() throws CoreException {
+ IJavaProject project = null;
+ try
+ {
+ project = createJavaProject("P");
+ createFolder("/P/p1");
+ createFile("/P/p1/B.java",
+ "package p1;\n" +
+ "import p2.*;\n" +
+ "public class B extends A {\n" +
+ "long k(){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "}\n");
+ createFolder("/P/p2");
+ createFile("/P/p2/A.java",
+ "package p2;\n" +
+ "public class A{ \n" +
+ "long k(){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "public long m(){\n"+
+ "return new A().k();\n" +
+ "}\n"+
+ "}\n");
+ createFile("/P/p2/B.java",
+ "package p2;\n" +
+ "public class B {\n" +
+ "}\n");
+ waitUntilIndexesReady();
+ // search
+ SearchPattern pattern = SearchPattern.createPattern("B.k()", METHOD, REFERENCES, EXACT_RULE);
+ search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }), this.resultCollector);
+ assertSearchResults("Should not get any results", "", this.resultCollector);
+ } finally {
+ deleteProject(project);
+ }
+ }
+ // search for the method name should also not return matches if not-overriden because of package-visible
+ // even if they are in jars
+ public void testBug357547e() throws CoreException, IOException {
+ IJavaProject project = null;
+ try
+ {
+ project = createJavaProject("P", new String[] {""}, new String[] { "/P/lib357547.jar", "JCL15_LIB" }, "", "1.5");
+ org.eclipse.jdt.core.tests.util.Util.createJar(new String[] {
+ "p2/A.java",
+ "package p2;\n" +
+ "public class A{}\n" },
+ project.getProject().getLocation().append("libStuff.jar").toOSString(), "1.5");
+
+ org.eclipse.jdt.core.tests.util.Util.createJar(
+ new String[] {
+ "p1/B.java",
+ "package p1;\n"+
+ "import p2.*;\n"+
+ "public class B extends A {\n" +
+ "long k(){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "}\n"},
+ null,
+ project.getProject().getLocation().append("lib357547.jar").toOSString(),
+ new String[] { project.getProject().getLocation().append("libStuff.jar").toOSString() },
+ "1.5");
+ refresh(project);
+ createFolder("/P/p2");
+ createFile("/P/p2/A.java",
+ "package p2;\n" +
+ "public class A {\n" +
+ "long k(){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "public long m(){\n"+
+ "return new A().k();\n" +
+ "}\n"+
+ "}\n");
+ waitUntilIndexesReady();
+ // search
+ SearchPattern pattern = SearchPattern.createPattern("B.k()", METHOD, REFERENCES, EXACT_RULE);
+ search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES), this.resultCollector);
+ assertSearchResults("Wrong results", "", this.resultCollector);
+ } finally {
+ deleteProject(project);
+ }
+ }
+ // search for the method name should also not return matches if not-overriden because of package-visible
+ // even if they are in jars
+ public void testBug357547f() throws CoreException, IOException {
+ IJavaProject project = null;
+ try
+ {
+ project = createJavaProject("P", new String[] {""}, new String[] { "/P/lib357547.jar", "JCL15_LIB" }, "", "1.5");
+ org.eclipse.jdt.core.tests.util.Util.createJar(new String[] {
+ "p2/A.java",
+ "package p2;\n" +
+ "public class A{}\n" },
+ project.getProject().getLocation().append("libStuff.jar").toOSString(), "1.5");
+
+ org.eclipse.jdt.core.tests.util.Util.createJar(
+ new String[] {
+ "p2/B.java",
+ "package p2;\n" +
+ "import p2.*;\n" +
+ "public class B extends A {\n" +
+ "long k(){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "}\n"},
+ null,
+ project.getProject().getLocation().append("lib357547.jar").toOSString(),
+ new String[] { project.getProject().getLocation().append("libStuff.jar").toOSString() },
+ "1.5");
+ refresh(project);
+ createFolder("/P/p2");
+ createFile("/P/p2/A.java",
+ "package p2;\n" +
+ "public class A {\n" +
+ "long k(){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "public long m(){\n"+
+ "return new A().k();\n" +
+ "}\n"+
+ "}\n");
+ waitUntilIndexesReady();
+ // search
+ SearchPattern pattern = SearchPattern.createPattern("B.k()", METHOD, REFERENCES, EXACT_RULE);
+ search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES), this.resultCollector);
+ assertSearchResults("Wrong results", "p2/A.java long p2.A.m() [k()] EXACT_MATCH", this.resultCollector);
+ } finally {
+ deleteProject(project);
+ }
+ }
+
+ // search for declarations also should take care of default
+ public void testBug357547g() throws CoreException {
+ IJavaProject project = null;
+ try
+ {
+ project = createJavaProject("P");
+ createFolder("/P/p1");
+ createFile("/P/p1/B.java",
+ "package p1;\n" +
+ "import p2.*;\n" +
+ "public class B extends A {\n" +
+ "long k(int a){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "}\n");
+ createFile("/P/p1/C.java",
+ "package p1;\n" +
+ "public class C extends B {\n" +
+ "long k(int a){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "}\n");
+ createFolder("/P/p2");
+ createFile("/P/p2/A.java",
+ "package p2;\n" +
+ "public class A{ \n" +
+ "long k(int a){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "public long m(){\n"+
+ "return new A().k(0);\n" +
+ "}\n"+
+ "}\n");
+ createFile("/P/p2/B.java",
+ "package p2;\n" +
+ "public class B {\n" +
+ "}\n");
+ waitUntilIndexesReady();
+ // search
+ SearchPattern pattern = SearchPattern.createPattern("A.k(int)", METHOD, DECLARATIONS, EXACT_RULE);
+ search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }), this.resultCollector);
+ assertSearchResults("Wrong results", "p2/A.java long p2.A.k(int) [k] EXACT_MATCH", this.resultCollector);
+ } finally {
+ deleteProject(project);
+ }
+ }
}
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 3919526..774c9c2 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
@@ -17,6 +17,7 @@
* bug 295551 - Add option to automatically promote all warnings to errors
* bug 359721 - [options] add command line option for new warning token "resource"
* bug 365208 - [compiler][batch] command line options for annotation based null analysis
+ * bug 374605 - Unreasonable warning for enum-based switch statements
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.batch;
@@ -3486,10 +3487,26 @@
}
break;
case 'e' :
- if (token.equals("enumSwitch") //$NON-NLS-1$
- || token.equals("incomplete-switch")) { //$NON-NLS-1$
+ if (token.equals("enumSwitch")) { //$NON-NLS-1$
setSeverity(CompilerOptions.OPTION_ReportIncompleteEnumSwitch, severity, isEnabling);
return;
+ } else if (token.equals("enumSwitchPedantic")) { //$NON-NLS-1$
+ if (isEnabling) {
+ switch (severity) {
+ case ProblemSeverities.Error:
+ setSeverity(CompilerOptions.OPTION_ReportIncompleteEnumSwitch, severity, isEnabling);
+ break;
+ case ProblemSeverities.Warning:
+ if (CompilerOptions.IGNORE.equals(this.options.get(CompilerOptions.OPTION_ReportIncompleteEnumSwitch))) {
+ setSeverity(CompilerOptions.OPTION_ReportIncompleteEnumSwitch, severity, isEnabling);
+ }
+ break;
+ default: // no severity update
+ }
+ }
+ this.options.put(CompilerOptions.OPTION_ReportMissingEnumCaseDespiteDefault,
+ isEnabling ? CompilerOptions.ENABLED : CompilerOptions.DISABLED);
+ return;
} else if (token.equals("emptyBlock")) {//$NON-NLS-1$
setSeverity(CompilerOptions.OPTION_ReportUndocumentedEmptyBlock, severity, isEnabling);
return;
@@ -3743,6 +3760,9 @@
} else if (token.equals("static-method")) { //$NON-NLS-1$
setSeverity(CompilerOptions.OPTION_ReportMethodCanBeStatic, severity, isEnabling);
return;
+ } else if (token.equals("switchDefault")) { //$NON-NLS-1$
+ setSeverity(CompilerOptions.OPTION_ReportMissingDefaultCase, severity, isEnabling);
+ return;
}
break;
case 't' :
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 e9e9e16..2333687 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
@@ -13,6 +13,7 @@
# bug 295551 - Add option to automatically promote all warnings to errors
# bug 359721 - [options] add command line option for new warning token "resource"
# bug 365208 - [compiler][batch] command line options for annotation based null analysis
+# bug 374605 - Unreasonable warning for enum-based switch statements
###############################################################################
### JavaBatchCompiler messages.
@@ -20,8 +21,8 @@
#Format: compiler.name = word1 word2 word3
compiler.name = Eclipse Compiler for Java(TM)
#Format: compiler.version = 0.XXX[, other words (don't forget the comma if adding other words)]
-compiler.version = 0.C44, 3.8.0 M7
-compiler.copyright = Copyright IBM Corp 2000, 2011. All rights reserved.
+compiler.version = 0.C49, 3.8.0 M7
+compiler.copyright = Copyright IBM Corp 2000, 2012. All rights reserved.
###{ObjectTeams:
otdtc.name = Extension for Object Teams
@@ -321,6 +322,8 @@
\ emptyBlock undocumented empty block\n\
\ enumIdentifier ''enum'' used as identifier\n\
\ enumSwitch incomplete enum switch\n\
+\ enumSwitchPedantic + report missing enum switch cases even\n\
+\ in the presence of a default case\n\
\ exceptioninguard + guard predicate throwing checked exception\n\
\ fallthrough possible fall-through case\n\
\ fieldHiding field hiding another variable\n\
@@ -370,6 +373,7 @@
\ suppress + enable @SuppressWarnings\n\
\ When used with -err:, it can also silent optional\n\
\ errors and warnings\n\
+\ switchDefault + switch statement lacking a default case\n\
\ syncOverride missing synchronized in synchr. method override\n\
\ syntheticAccess synthetic access for innerclass\n\
\ tasks(<tags separated by |>) tasks identified by tags inside comments\n\
diff --git a/org.eclipse.jdt.core/buildnotes_jdt-core.html b/org.eclipse.jdt.core/buildnotes_jdt-core.html
index cfdcfd5..2b1cab1 100644
--- a/org.eclipse.jdt.core/buildnotes_jdt-core.html
+++ b/org.eclipse.jdt.core/buildnotes_jdt-core.html
@@ -42,20 +42,165 @@
</td>
</tr>
</table>
+<a name="v_C49"></a>
+<hr><h1>
+Eclipse Platform Build Notes<br>
+Java development tools core</h1>
+Eclipse SDK 3.8.0 - %date% - 3.8.0 M7
+<br>Project org.eclipse.jdt.core v_C49
+(<a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.core/?only_with_tag=v_C49">cvs</a>).
+<h2>What's new in this drop</h2>
+
+<h3>Problem Reports Fixed</h3>
+<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=371832">371832</a>
+The preference "Suppress optional errors with '@SuppressWarnings'" ends up silencing warnings it shouldn't
+
+<a name="v_C48"></a>
+<hr><h1>
+Eclipse Platform Build Notes<br>
+Java development tools core</h1>
+Eclipse SDK 3.8.0 - April 27, 2012
+<br>Project org.eclipse.jdt.core v_C48
+(<a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.core/?only_with_tag=v_C48">cvs</a>).
+<h2>What's new in this drop</h2>
+
+<h3>Problem Reports Fixed</h3>
+<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=377806">377806</a>
+ExternalFoldersManager standalone regression
+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=322977">322977</a>
+Documentation about use of "SearchPattern.R_REGEXP_MATCH" is wrong
+
+<a name="v_C47"></a>
+<hr><h1>
+Eclipse Platform Build Notes<br>
+Java development tools core</h1>
+Eclipse SDK 3.8.0 - April 26, 2012
+<br>
+<h2>What's new in this drop</h2>
+
+<h3>Problem Reports Fixed</h3>
+<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=376724">376724</a>
+ExternalFoldersManager still has synchronization gaps
+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=374129">374129</a>
+more tests for bug 372011
+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=365710">365710</a>
+FUP of bug 363293: Fix the incorrect added resource close
+
+<a name="v_C46"></a>
+<hr><h1>
+Eclipse Platform Build Notes<br>
+Java development tools core</h1>
+Eclipse SDK 3.8.0 - April 24, 2012 - April 10, 2012
+<br>
+<h2>What's new in this drop</h2>
+<ul>
+<li>New/changed options in JavaCore to control warnings relating to incomplete switch statements:
+<pre>
+ /**
+ * Compiler option ID: Reporting Incomplete Enum Switch.
+ * When enabled, the compiler will issue an error or a warning
+ * regarding each enum constant for which a corresponding case label is lacking.
+ * Reporting is further controlled by the option {@link #COMPILER_PB_MISSING_ENUM_CASE_DESPITE_DEFAULT}.
+ *
+ * Option id:"org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch"
+ * Possible values:{ "error", "warning", "ignore" }
+ * Default:"warning"
+ *
+ * @since 3.1
+ * @category CompilerOptionID
+ */
+ public static final String COMPILER_PB_INCOMPLETE_ENUM_SWITCH = PLUGIN_ID + ".compiler.problem.incompleteEnumSwitch"; //$NON-NLS-1$
+ /**
+ * Compiler option ID: Reporting Missing Enum Case In Switch Despite An Existing Default Case.
+ * This option further controls the option {@link #COMPILER_PB_INCOMPLETE_ENUM_SWITCH}:
+ *
+ * - If enabled the compiler will report problems about missing enum constants even if a default case exists
+ * in the same switch statement.
+ * - If disabled existence of a default case is considered as sufficient to make a switch statement complete.
+ *
+ * This option has no effect if {@link #COMPILER_PB_INCOMPLETE_ENUM_SWITCH} is set to "ignore".
+ *
+ * Option id:"org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault"
+ * Possible values:{ "enabled", "disabled" }
+ * Default:"disabled"
+ *
+ * @since 3.8
+ * @category CompilerOptionID
+ */
+ public static final String COMPILER_PB_MISSING_ENUM_CASE_DESPITE_DEFAULT = PLUGIN_ID + ".compiler.problem.missingEnumCaseDespiteDefault"; //$NON-NLS-1$
+ /**
+ * Compiler option ID: Reporting Missing Default Case In Switch.
+ * When enabled, the compiler will issue an error or a warning
+ * against each switch statement that lacks a default case.
+ *
+ * Option id:"org.eclipse.jdt.core.compiler.problem.missingDefaultCase"
+ * Possible values:{ "error", "warning", "ignore" }
+ * Default:"ignore"
+ *
+ * @since 3.8
+ * @category CompilerOptionID
+ */
+ public static final String COMPILER_PB_SWITCH_MISSING_DEFAULT_CASE = PLUGIN_ID + ".compiler.problem.missingDefaultCase"; //$NON-NLS-1$
+</pre>
+</li>
+<li> New IProblems relating to incomplete switch statements.
+<pre>
+ /** @since 3.8 */
+ int MissingEnumDefaultCase = Internal + 766;
+ /** @since 3.8 */
+ int MissingDefaultCase = Internal + 767;
+ /** @since 3.8 */
+ int MissingEnumConstantCaseDespiteDefault = FieldRelated + 768;
+ /** @since 3.8 */
+ int UninitializedLocalVariableHintMissingDefault = Internal + 769;
+ /** @since 3.8 */
+ int UninitializedBlankFinalFieldHintMissingDefault = FieldRelated + 770;
+ /** @since 3.8 */
+ int ShouldReturnValueHintMissingDefault = MethodRelated + 771;
+</pre>
+</li>
+
+<h3>Problem Reports Fixed</h3>
+<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=377401">377401</a>
+FuP of bug 372418: "The type ... cannot be resolved" error when there is a $ in the class name.
+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=376429">376429</a>
+AIOOBE when trying to create AST for invalid annotation declaration
+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=376673">376673</a>
+DBCS4.2 Can not rename the class names when DBCS (Surrogate e.g. U+20B9F) is in it
+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=374605">374605</a>
+Unreasonable warning for enum-based switch statements
+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=372694">372694</a>
+Adjust parser generator tools
+
+<a name="v_C45"></a>
+<hr><h1>
+Eclipse Platform Build Notes<br>
+Java development tools core</h1>
+Eclipse SDK 3.8.0 - April 17, 2012
+<br>
+<h2>What's new in this drop</h2>
+
+<h3>Problem Reports Fixed</h3>
+<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=326610">326610</a>
+[content assist] code assist for package-info.java
+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=376465">376465</a>
+Mixed line delimiters in org.eclipse.jdt.internal.compiler.parser.Parser.consumeRule(int)
+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=376837">376837</a>
+[warning] Resource leak warning in FileManagerTest
+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=375394">375394</a>
+Incorrect type checking for parameterized types
+
<a name="v_C44"></a>
<hr><h1>
Eclipse Platform Build Notes<br>
Java development tools core</h1>
-Eclipse SDK 3.8.0 - April 10, 2012 - 3.8.0 M7
-<br>Project org.eclipse.jdt.core v_C44
-(<a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.core/?only_with_tag=v_C44">cvs</a>).
+Eclipse SDK 3.8.0
+<br>
<h2>What's new in this drop</h2>
<h3>Problem Reports Fixed</h3>
<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=351697">351697</a>
ClassCastException while copying a .class file to wrong source package
-<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=375394">375394</a>
-Incorrect type checking for parameterized types
<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=375326">375326</a>
try-with-resources assignment in statement produces stack map exception
@@ -64,8 +209,7 @@
Eclipse Platform Build Notes<br>
Java development tools core</h1>
Eclipse SDK 3.8.0 - April 3, 2012
-<br>Project org.eclipse.jdt.core v_C43
-(<a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.core/?only_with_tag=v_C43">cvs</a>).
+<br>
<h2>What's new in this drop</h2>
<h3>Problem Reports Fixed</h3>
@@ -105,8 +249,7 @@
Eclipse Platform Build Notes<br>
Java development tools core</h1>
Eclipse SDK 3.8.0 - March 13, 2012 - 3.8.0 M6
-<br>Project org.eclipse.jdt.core v_C40
-(<a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.core/?only_with_tag=v_C40">cvs</a>).
+<br>
<h2>What's new in this drop</h2>
<h3>Problem Reports Fixed</h3>
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java
index 9f905c6..dba5e64 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -1900,7 +1900,7 @@
if(!this.requestor.isIgnored(CompletionProposal.KEYWORD)) {
setSourceAndTokenRange(importReference.sourceStart, importReference.sourceEnd);
CompletionOnKeyword keyword = (CompletionOnKeyword)importReference;
- findKeywords(keyword.getToken(), keyword.getPossibleKeywords(), false, false);
+ findKeywords(keyword.getToken(), keyword.getPossibleKeywords(), true, false, parsedUnit.currentPackage != null);
}
if(this.noProposal && this.problem != null) {
this.requestor.completionFailure(this.problem);
@@ -2509,7 +2509,7 @@
private void completionOnKeyword(ASTNode astNode) {
if (!this.requestor.isIgnored(CompletionProposal.KEYWORD)) {
CompletionOnKeyword keyword = (CompletionOnKeyword)astNode;
- findKeywords(keyword.getToken(), keyword.getPossibleKeywords(), keyword.canCompleteEmptyToken(), false);
+ findKeywords(keyword.getToken(), keyword.getPossibleKeywords(), keyword.canCompleteEmptyToken(), false, false);
}
}
@@ -2658,7 +2658,7 @@
} else {
if (!access.isInsideAnnotation) {
if (!this.requestor.isIgnored(CompletionProposal.KEYWORD)) {
- findKeywords(this.completionToken, new char[][]{Keywords.NEW}, false, false);
+ findKeywords(this.completionToken, new char[][]{Keywords.NEW}, false, false, false);
}
ObjectVector fieldsFound = new ObjectVector();
@@ -3317,7 +3317,7 @@
findTypesAndPackages(this.completionToken, scope, true, false, new ObjectVector());
if (!this.requestor.isIgnored(CompletionProposal.KEYWORD)) {
if (this.completionToken != null && this.completionToken.length != 0) {
- findKeywords(this.completionToken, singleNameReference.possibleKeywords, false, false);
+ findKeywords(this.completionToken, singleNameReference.possibleKeywords, false, false, false);
} else {
findTrueOrFalseKeywords(singleNameReference.possibleKeywords);
}
@@ -8397,7 +8397,7 @@
// what about onDemand types? Ignore them since it does not happen!
// import p1.p2.A.*;
- private void findKeywords(char[] keyword, char[][] choices, boolean canCompleteEmptyToken, boolean staticFieldsAndMethodOnly) {
+ private void findKeywords(char[] keyword, char[][] choices, boolean canCompleteEmptyToken, boolean staticFieldsAndMethodOnly, boolean ignorePackageKeyword) {
if(choices == null || choices.length == 0) return;
int length = keyword.length;
@@ -8406,6 +8406,8 @@
if (length <= choices[i].length
&& CharOperation.prefixEquals(keyword, choices[i], false /* ignore case */
)){
+ if (ignorePackageKeyword && CharOperation.equals(choices[i], Keywords.PACKAGE))
+ continue;
int relevance = computeBaseRelevance();
relevance += computeRelevanceForResolution();
relevance += computeRelevanceForInterestingProposal();
@@ -8422,8 +8424,8 @@
InternalCompletionProposal proposal = createProposal(CompletionProposal.KEYWORD, this.actualCompletionPosition);
proposal.setName(choices[i]);
proposal.setCompletion(choices[i]);
- proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
- proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
+ proposal.setReplaceRange((canCompleteEmptyToken && (this.startPosition < 0)) ? 0 : this.startPosition - this.offset, this.endPosition - this.offset);
+ proposal.setTokenRange((canCompleteEmptyToken && (this.tokenStart < 0)) ? 0 : this.tokenStart - this.offset, this.tokenEnd - this.offset);
proposal.setRelevance(relevance);
this.requestor.accept(proposal);
if(DEBUG) {
@@ -8538,7 +8540,7 @@
}
System.arraycopy(keywords, 0, keywords = new char[count][], 0, count);
- findKeywords(token, keywords, false, false);
+ findKeywords(token, keywords, false, false, false);
}
private void findLabels(char[] label, char[][] choices) {
if(choices == null || choices.length == 0) return;
@@ -9672,7 +9674,7 @@
((scope instanceof MethodScope && !((MethodScope)scope).isStatic)
|| ((methodScope = scope.enclosingMethodScope()) != null && !methodScope.isStatic))) {
if (token.length > 0) {
- findKeywords(token, new char[][]{Keywords.THIS}, false, true);
+ findKeywords(token, new char[][]{Keywords.THIS}, false, true, false);
} else {
int relevance = computeBaseRelevance();
relevance += computeRelevanceForResolution();
@@ -11228,9 +11230,9 @@
if (this.assistNodeInJavadoc == 0 || (this.assistNodeInJavadoc & CompletionOnJavadoc.BASE_TYPES) != 0) {
if (proposeBaseTypes) {
if (proposeVoidType) {
- findKeywords(token, BASE_TYPE_NAMES, false, false);
+ findKeywords(token, BASE_TYPE_NAMES, false, false, false);
} else {
- findKeywords(token, BASE_TYPE_NAMES_WITHOUT_VOID, false, false);
+ findKeywords(token, BASE_TYPE_NAMES_WITHOUT_VOID, false, false, false);
}
}
}
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 b0ce28e..c38f86d 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
@@ -1469,6 +1469,7 @@
char[][] keywords = new char[Keywords.COUNT][];
int count = 0;
if(unit.typeCount == 0
+ && (!this.compilationUnit.isPackageInfo() || this.compilationUnit.currentPackage != null)
&& this.lastModifiers == ClassFileConstants.AccDefault) {
keywords[count++] = Keywords.IMPORT;
}
@@ -1478,39 +1479,41 @@
&& this.compilationUnit.currentPackage == null) {
keywords[count++] = Keywords.PACKAGE;
}
- if((this.lastModifiers & ClassFileConstants.AccPublic) == 0) {
- boolean hasNoPublicType = true;
- for (int i = 0; i < unit.typeCount; i++) {
- if((unit.types[i].typeDeclaration.modifiers & ClassFileConstants.AccPublic) != 0) {
- hasNoPublicType = false;
+ if (!this.compilationUnit.isPackageInfo()) {
+ if((this.lastModifiers & ClassFileConstants.AccPublic) == 0) {
+ boolean hasNoPublicType = true;
+ for (int i = 0; i < unit.typeCount; i++) {
+ if((unit.types[i].typeDeclaration.modifiers & ClassFileConstants.AccPublic) != 0) {
+ hasNoPublicType = false;
+ }
+ }
+ if(hasNoPublicType) {
+ keywords[count++] = Keywords.PUBLIC;
}
}
- if(hasNoPublicType) {
- keywords[count++] = Keywords.PUBLIC;
+ if((this.lastModifiers & ClassFileConstants.AccAbstract) == 0
+ && (this.lastModifiers & ClassFileConstants.AccFinal) == 0) {
+ keywords[count++] = Keywords.ABSTRACT;
}
- }
- if((this.lastModifiers & ClassFileConstants.AccAbstract) == 0
- && (this.lastModifiers & ClassFileConstants.AccFinal) == 0) {
- keywords[count++] = Keywords.ABSTRACT;
- }
- if((this.lastModifiers & ClassFileConstants.AccAbstract) == 0
- && (this.lastModifiers & ClassFileConstants.AccFinal) == 0) {
- keywords[count++] = Keywords.FINAL;
- }
-
+ if((this.lastModifiers & ClassFileConstants.AccAbstract) == 0
+ && (this.lastModifiers & ClassFileConstants.AccFinal) == 0) {
+ keywords[count++] = Keywords.FINAL;
+ }
+
//{ObjectTeams: consider team class
- if (CharOperation.prefixEquals(this.identifierStack[ptr], Keywords.TEAM))
- {
- keywords[count++] = Keywords.TEAM;
- }
+ if (CharOperation.prefixEquals(this.identifierStack[ptr], Keywords.TEAM))
+ {
+ keywords[count++] = Keywords.TEAM;
+ }
//gbr}
- keywords[count++] = Keywords.CLASS;
- if (this.options.complianceLevel >= ClassFileConstants.JDK1_5) {
- keywords[count++] = Keywords.ENUM;
- }
-
- if((this.lastModifiers & ClassFileConstants.AccFinal) == 0) {
- keywords[count++] = Keywords.INTERFACE;
+ keywords[count++] = Keywords.CLASS;
+ if (this.options.complianceLevel >= ClassFileConstants.JDK1_5) {
+ keywords[count++] = Keywords.ENUM;
+ }
+
+ if((this.lastModifiers & ClassFileConstants.AccFinal) == 0) {
+ keywords[count++] = Keywords.INTERFACE;
+ }
}
if(count != 0) {
System.arraycopy(keywords, 0, keywords = new char[count][], 0, count);
@@ -2468,9 +2471,6 @@
arg.annotations = new Annotation[length],
0,
length);
- RecoveredType currentRecoveryType = this.currentRecoveryType();
- if (currentRecoveryType != null)
- currentRecoveryType.annotationsConsumed(arg.annotations);
}
arg.isCatchArgument = topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_BETWEEN_CATCH_AND_RIGHT_PAREN;
@@ -2962,6 +2962,9 @@
arg.annotations = new Annotation[length],
0,
length);
+ RecoveredType currentRecoveryType = this.currentRecoveryType();
+ if (currentRecoveryType != null)
+ currentRecoveryType.annotationsConsumed(arg.annotations);
}
arg.isCatchArgument = topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_BETWEEN_CATCH_AND_RIGHT_PAREN;
@@ -5271,30 +5274,6 @@
this.sourceEnds = new HashtableOfObjectToInt();
}
}
-
-/*
- * To find out if the given stack has an instanceof expression
- * at the given startIndex or at one prior to that
- */
-private boolean stackHasInstanceOfExpression(Object[] stackToSearch, int startIndex) {
- int indexInstanceOf = startIndex;
- while (indexInstanceOf >= 0) {
- if (stackToSearch[indexInstanceOf] instanceof InstanceOfExpression) {
- return true;
- }
- indexInstanceOf--;
- }
- return false;
-}
-
-// https://bugs.eclipse.org/bugs/show_bug.cgi?id=292087
-protected boolean isInsideArrayInitializer(){
- int i = this.elementPtr;
- if (i > -1 && this.elementKindStack[i] == K_ARRAY_INITIALIZER) {
- return true;
- }
- return false;
-}
/*
* Reset internal state after completion is over
*/
@@ -5443,6 +5422,30 @@
}
}
+/*
+ * To find out if the given stack has an instanceof expression
+ * at the given startIndex or at one prior to that
+ */
+private boolean stackHasInstanceOfExpression(Object[] stackToSearch, int startIndex) {
+ int indexInstanceOf = startIndex;
+ while (indexInstanceOf >= 0) {
+ if (stackToSearch[indexInstanceOf] instanceof InstanceOfExpression) {
+ return true;
+ }
+ indexInstanceOf--;
+ }
+ return false;
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=292087
+protected boolean isInsideArrayInitializer(){
+ int i = this.elementPtr;
+ if (i > -1 && this.elementKindStack[i] == K_ARRAY_INITIALIZER) {
+ return true;
+ }
+ return false;
+}
+
//{ObjectTeams: OT completion
@Override
protected LiftingTypeReference completeLiftingTypeReference(int dims) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java
index 0183e52..6b15a72 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java
@@ -147,6 +147,11 @@
* RedundantNullCheckOnSpecdNonNullLocalVariable
* SpecdNonNullLocalVariableComparisonYieldsFalse
* RequiredNonNullButProvidedSpecdNullable
+ * MissingDefaultCase
+ * MissingEnumConstantCaseDespiteDefault
+ * UninitializedLocalVariableHintMissingDefault
+ * UninitializedBlankFinalFieldHintMissingDefault
+ * ShouldReturnValueHintMissingDefault
*******************************************************************************/
package org.eclipse.jdt.core.compiler;
@@ -1353,6 +1358,16 @@
int AbstractMethodInEnum = MethodRelated + 765;
/** @since 3.8 */
int MissingEnumDefaultCase = Internal + 766;
+ /** @since 3.8 */
+ int MissingDefaultCase = Internal + 767;
+ /** @since 3.8 */
+ int MissingEnumConstantCaseDespiteDefault = FieldRelated + 768;
+ /** @since 3.8 */
+ int UninitializedLocalVariableHintMissingDefault = Internal + 769;
+ /** @since 3.8 */
+ int UninitializedBlankFinalFieldHintMissingDefault = FieldRelated + 770;
+ /** @since 3.8 */
+ int ShouldReturnValueHintMissingDefault = MethodRelated + 771;
/**
* Var args
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/CompilationResult.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/CompilationResult.java
index 5f2fa61..9f632a6 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/CompilationResult.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/CompilationResult.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -95,6 +95,7 @@
public char[][] packageName;
public boolean checkSecondaryTypes = false; // check for secondary types which were created after the initial buildTypeBindings call
private int numberOfErrors;
+ private boolean hasMandatoryErrors;
//{ObjectTeams: separate handling of teams and their roles:
/** mark the end of real source when adding synthetic positions for SMAP support */
@@ -373,6 +374,10 @@
return this.numberOfErrors != 0;
}
+public boolean hasMandatoryErrors() {
+ return this.hasMandatoryErrors;
+}
+
public boolean hasProblems() {
return this.problemCount != 0;
}
@@ -423,6 +428,11 @@
}
public void record(CategorizedProblem newProblem, ReferenceContext referenceContext) {
+ record(newProblem, referenceContext, true);
+ return;
+}
+
+public void record(CategorizedProblem newProblem, ReferenceContext referenceContext, boolean mandatoryError) {
//new Exception("VERBOSE PROBLEM REPORTING").printStackTrace();
if(newProblem.getID() == IProblem.Task) {
recordTask(newProblem);
@@ -442,6 +452,7 @@
}
if (newProblem.isError()) {
this.numberOfErrors++;
+ if (mandatoryError) this.hasMandatoryErrors = true;
if ((newProblem.getID() & IProblem.Syntax) != 0) {
this.hasSyntaxError = true;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java
index 215ae07..5b62b2a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -664,7 +664,7 @@
0, // source end
0, // line number
0),// column number
- unit);
+ unit, true);
/* hand back the compilation result */
if (!result.hasBeenAccepted) {
@@ -726,7 +726,7 @@
if (distantProblem instanceof DefaultProblem) { // fixup filename TODO (philippe) should improve API to make this official
((DefaultProblem) distantProblem).setOriginatingFileName(result.getFileName());
}
- result.record(distantProblem, unit);
+ result.record(distantProblem, unit, true);
}
} else {
/* distant internal exception which could not be reported back there */
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
index 054a837..f9b4f3d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
@@ -15,6 +15,7 @@
* bug 185682 - Increment/decrement operators mark local variables as read
* bug 186342 - [compiler][null] Using annotations for null checking
* bug 365519 - editorial cleanup after bug 186342 and bug 365387
+ * bug 374605 - Unreasonable warning for enum-based switch statements
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
@@ -145,6 +146,7 @@
public static final int IsReachable = Bit32;
public static final int LabelUsed = Bit7;
public static final int DocumentedFallthrough = Bit30; // switch statement
+ public static final int DocumentedCasesOmitted = Bit31; // switch statement
// local decls
public static final int IsLocalDeclarationReachable = Bit31;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java
index 4ad9647..fec1e09 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java
@@ -138,7 +138,7 @@
*/
public void analyseCode() {
//{ObjectTeams: postponed from resolve() to also catch import usage from late statement generators.
- if (!this.compilationResult.hasErrors())
+ if (!this.compilationResult.hasMandatoryErrors())
checkUnusedImports();
// SH}
if (this.ignoreFurtherInvestigation)
@@ -680,7 +680,7 @@
}
//{ObjectTeams: postponed to analyseCode():
/* orig:
- if (!this.compilationResult.hasErrors()) checkUnusedImports();
+ if (!this.compilationResult.hasMandatoryErrors()) checkUnusedImports();
:giro */
if (!isRoleUnit())
// SH}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java
index 576e200..0a2f27e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java
@@ -11,6 +11,7 @@
* bug 319201 - [null] no warning when unboxing SingleNameReference causes NPE
* bug 349326 - [1.7] new warning for missing try-with-resources
* bug 265744 - Enum switch should warn about missing default
+ * bug 374605 - Unreasonable warning for enum-based switch statements
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
@@ -451,6 +452,7 @@
boolean isEnumSwitch = false;
boolean isStringSwitch = false;
TypeBinding expressionType = this.expression.resolveType(upperScope);
+ CompilerOptions compilerOptions = upperScope.compilerOptions();
if (expressionType != null) {
this.expression.computeConversion(upperScope, expressionType, expressionType);
checkType: {
@@ -464,14 +466,14 @@
break checkType;
} else if (expressionType.isEnum()) {
isEnumSwitch = true;
- if (upperScope.compilerOptions().complianceLevel < ClassFileConstants.JDK1_5) {
+ if (compilerOptions.complianceLevel < ClassFileConstants.JDK1_5) {
upperScope.problemReporter().incorrectSwitchType(this.expression, expressionType); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=360317
}
break checkType;
} else if (upperScope.isBoxingCompatibleWith(expressionType, TypeBinding.INT)) {
this.expression.computeConversion(upperScope, TypeBinding.INT, expressionType);
break checkType;
- } else if (upperScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_7 && expressionType.id == TypeIds.T_JavaLangString) {
+ } else if (compilerOptions.complianceLevel >= ClassFileConstants.JDK1_7 && expressionType.id == TypeIds.T_JavaLangString) {
isStringSwitch = true;
break checkType;
}
@@ -536,28 +538,37 @@
upperScope.problemReporter().undocumentedEmptyBlock(this.blockStart, this.sourceEnd);
}
}
- // for enum switch, check if all constants are accounted for (if no default)
- if (isEnumSwitch && this.defaultCase == null
- && upperScope.compilerOptions().getSeverity(CompilerOptions.IncompleteEnumSwitch) != ProblemSeverities.Ignore) {
- // JLS recommends a default case for every enum switch
- if (upperScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_5) { // report only if enum is legal in the first place
- upperScope.problemReporter().missingEnumDefaultCase(this, expressionType);
+ // check default case for all kinds of switch:
+ if (this.defaultCase == null) {
+ if (compilerOptions.getSeverity(CompilerOptions.MissingDefaultCase) == ProblemSeverities.Ignore) {
+ if (isEnumSwitch) {
+ upperScope.methodScope().hasMissingSwitchDefault = true;
+ }
+ } else {
+ upperScope.problemReporter().missingDefaultCase(this, isEnumSwitch, expressionType);
}
-
- int constantCount = this.constants == null ? 0 : this.constants.length; // could be null if no case statement
- if (constantCount == this.caseCount
- && this.caseCount != ((ReferenceBinding)expressionType).enumConstantCount()) {
- FieldBinding[] enumFields = ((ReferenceBinding)expressionType.erasure()).fields();
- for (int i = 0, max = enumFields.length; i <max; i++) {
- FieldBinding enumConstant = enumFields[i];
- if ((enumConstant.modifiers & ClassFileConstants.AccEnum) == 0) continue;
- findConstant : {
- for (int j = 0; j < this.caseCount; j++) {
- if ((enumConstant.id + 1) == this.constants[j]) // zero should not be returned see bug 141810
- break findConstant;
+ }
+ // for enum switch, check if all constants are accounted for (perhaps depending on existence of a default case)
+ if (isEnumSwitch && compilerOptions.complianceLevel >= ClassFileConstants.JDK1_5) {
+ if (this.defaultCase == null || compilerOptions.reportMissingEnumCaseDespiteDefault) {
+ int constantCount = this.constants == null ? 0 : this.constants.length; // could be null if no case statement
+ if (constantCount == this.caseCount
+ && this.caseCount != ((ReferenceBinding)expressionType).enumConstantCount()) {
+ FieldBinding[] enumFields = ((ReferenceBinding)expressionType.erasure()).fields();
+ for (int i = 0, max = enumFields.length; i <max; i++) {
+ FieldBinding enumConstant = enumFields[i];
+ if ((enumConstant.modifiers & ClassFileConstants.AccEnum) == 0) continue;
+ findConstant : {
+ for (int j = 0; j < this.caseCount; j++) {
+ if ((enumConstant.id + 1) == this.constants[j]) // zero should not be returned see bug 141810
+ break findConstant;
+ }
+ // enum constant did not get referenced from switch
+ boolean suppress = (this.defaultCase != null && (this.defaultCase.bits & DocumentedCasesOmitted) != 0);
+ if (!suppress) {
+ upperScope.problemReporter().missingEnumConstantCase(this, enumConstant);
+ }
}
- // enum constant did not get referenced from switch
- upperScope.problemReporter().missingEnumConstantCase(this, enumConstant);
}
}
}
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 c994e36..1399319 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
@@ -17,6 +17,7 @@
* bug 186342 - [compiler][null] Using annotations for null checking
* bug 370639 - [compiler][resource] restore the default for resource leak warnings
* bug 366063 - Compiler should not add synthetic @NonNull annotations
+ * bug 374605 - Unreasonable warning for enum-based switch statements
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.impl;
@@ -126,6 +127,8 @@
public static final String OPTION_ReportMissingOverrideAnnotationForInterfaceMethodImplementation = "org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation"; //$NON-NLS-1$
public static final String OPTION_ReportMissingDeprecatedAnnotation = "org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation"; //$NON-NLS-1$
public static final String OPTION_ReportIncompleteEnumSwitch = "org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch"; //$NON-NLS-1$
+ public static final String OPTION_ReportMissingEnumCaseDespiteDefault = "org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault"; //$NON-NLS-1$
+ public static final String OPTION_ReportMissingDefaultCase = "org.eclipse.jdt.core.compiler.problem.missingDefaultCase"; //$NON-NLS-1$
public static final String OPTION_ReportForbiddenReference = "org.eclipse.jdt.core.compiler.problem.forbiddenReference"; //$NON-NLS-1$
public static final String OPTION_ReportDiscouragedReference = "org.eclipse.jdt.core.compiler.problem.discouragedReference"; //$NON-NLS-1$
public static final String OPTION_SuppressWarnings = "org.eclipse.jdt.core.compiler.problem.suppressWarnings"; //$NON-NLS-1$
@@ -313,7 +316,7 @@
public static final int AnnotationSuperInterface = IrritantSet.GROUP1 | ASTNode.Bit10;
public static final int TypeHiding = IrritantSet.GROUP1 | ASTNode.Bit11;
public static final int MissingOverrideAnnotation = IrritantSet.GROUP1 | ASTNode.Bit12;
- public static final int IncompleteEnumSwitch = IrritantSet.GROUP1 | ASTNode.Bit13;
+ public static final int MissingEnumConstantCase = IrritantSet.GROUP1 | ASTNode.Bit13;
public static final int MissingDeprecatedAnnotation = IrritantSet.GROUP1 | ASTNode.Bit14;
public static final int DiscouragedReference = IrritantSet.GROUP1 | ASTNode.Bit15;
public static final int UnhandledWarningToken = IrritantSet.GROUP1 | ASTNode.Bit16;
@@ -347,6 +350,7 @@
public static final int NullUncheckedConversion = IrritantSet.GROUP2 | ASTNode.Bit13;
public static final int RedundantNullAnnotation = IrritantSet.GROUP2 | ASTNode.Bit14;
public static final int MissingNonNullByDefaultAnnotation = IrritantSet.GROUP2 | ASTNode.Bit15;
+ public static final int MissingDefaultCase = IrritantSet.GROUP2 | ASTNode.Bit16;
//{ObjectTeams: OT/J specific problems/irritants:
public static final int OTJFlag = IrritantSet.GROUP3;
@@ -520,6 +524,8 @@
public long intendedDefaultNonNullness; // 0 or TagBits#AnnotationNonNull
/** Should resources (objects of type Closeable) be analysed for matching calls to close()? */
public boolean analyseResourceLeaks;
+ /** Should missing enum cases be reported even if a default case exists in the same switch? */
+ public boolean reportMissingEnumCaseDespiteDefault;
// keep in sync with warningTokenToIrritant and warningTokenFromIrritant
public final static String[] warningTokens = {
@@ -690,8 +696,10 @@
return OPTION_ReportTypeParameterHiding;
case MissingOverrideAnnotation :
return OPTION_ReportMissingOverrideAnnotation;
- case IncompleteEnumSwitch :
+ case MissingEnumConstantCase :
return OPTION_ReportIncompleteEnumSwitch;
+ case MissingDefaultCase :
+ return OPTION_ReportMissingDefaultCase;
case MissingDeprecatedAnnotation :
return OPTION_ReportMissingDeprecatedAnnotation;
case DiscouragedReference :
@@ -891,7 +899,9 @@
OPTION_ReportForbiddenReference,
OPTION_ReportHiddenCatchBlock,
OPTION_ReportIncompatibleNonInheritedInterfaceMethod,
+ OPTION_ReportMissingDefaultCase,
OPTION_ReportIncompleteEnumSwitch,
+ OPTION_ReportMissingEnumCaseDespiteDefault,
OPTION_ReportIndirectStaticAccess,
OPTION_ReportInvalidJavadoc,
OPTION_ReportInvalidJavadocTags,
@@ -1030,7 +1040,8 @@
return "boxing"; //$NON-NLS-1$
case TypeHiding :
return "hiding"; //$NON-NLS-1$
- case IncompleteEnumSwitch :
+ case MissingEnumConstantCase :
+ case MissingDefaultCase :
return "incomplete-switch"; //$NON-NLS-1$
case MissingDeprecatedAnnotation :
return "dep-ann"; //$NON-NLS-1$
@@ -1301,7 +1312,9 @@
optionsMap.put(OPTION_ReportUnnecessaryElse, getSeverityString(UnnecessaryElse));
optionsMap.put(OPTION_ReportAutoboxing, getSeverityString(AutoBoxing));
optionsMap.put(OPTION_ReportAnnotationSuperInterface, getSeverityString(AnnotationSuperInterface));
- optionsMap.put(OPTION_ReportIncompleteEnumSwitch, getSeverityString(IncompleteEnumSwitch));
+ optionsMap.put(OPTION_ReportIncompleteEnumSwitch, getSeverityString(MissingEnumConstantCase));
+ optionsMap.put(OPTION_ReportMissingEnumCaseDespiteDefault, this.reportMissingEnumCaseDespiteDefault ? ENABLED : DISABLED);
+ optionsMap.put(OPTION_ReportMissingDefaultCase, getSeverityString(MissingDefaultCase));
optionsMap.put(OPTION_ReportInvalidJavadoc, getSeverityString(InvalidJavadoc));
optionsMap.put(OPTION_ReportInvalidJavadocTagsVisibility, getVisibilityString(this.reportInvalidJavadocTagsVisibility));
optionsMap.put(OPTION_ReportInvalidJavadocTags, this.reportInvalidJavadocTags ? ENABLED : DISABLED);
@@ -1332,7 +1345,6 @@
optionsMap.put(OPTION_ReportMissingOverrideAnnotation, getSeverityString(MissingOverrideAnnotation));
optionsMap.put(OPTION_ReportMissingOverrideAnnotationForInterfaceMethodImplementation, this.reportMissingOverrideAnnotationForInterfaceMethodImplementation ? ENABLED : DISABLED);
optionsMap.put(OPTION_ReportMissingDeprecatedAnnotation, getSeverityString(MissingDeprecatedAnnotation));
- optionsMap.put(OPTION_ReportIncompleteEnumSwitch, getSeverityString(IncompleteEnumSwitch));
optionsMap.put(OPTION_ReportUnusedLabel, getSeverityString(UnusedLabel));
optionsMap.put(OPTION_ReportUnusedTypeArgumentsForMethodInvocation, getSeverityString(UnusedTypeArguments));
optionsMap.put(OPTION_Compliance, versionFromJdkLevel(this.complianceLevel));
@@ -1579,6 +1591,8 @@
this.intendedDefaultNonNullness = 0;
this.analyseResourceLeaks = true;
+
+ this.reportMissingEnumCaseDespiteDefault = false;
}
public void set(Map optionsMap) {
@@ -1841,7 +1855,15 @@
if ((optionValue = optionsMap.get(OPTION_ReportAnnotationSuperInterface)) != null) updateSeverity(AnnotationSuperInterface, optionValue);
if ((optionValue = optionsMap.get(OPTION_ReportMissingOverrideAnnotation)) != null) updateSeverity(MissingOverrideAnnotation, optionValue);
if ((optionValue = optionsMap.get(OPTION_ReportMissingDeprecatedAnnotation)) != null) updateSeverity(MissingDeprecatedAnnotation, optionValue);
- if ((optionValue = optionsMap.get(OPTION_ReportIncompleteEnumSwitch)) != null) updateSeverity(IncompleteEnumSwitch, optionValue);
+ if ((optionValue = optionsMap.get(OPTION_ReportIncompleteEnumSwitch)) != null) updateSeverity(MissingEnumConstantCase, optionValue);
+ if ((optionValue = optionsMap.get(OPTION_ReportMissingEnumCaseDespiteDefault)) != null) {
+ if (ENABLED.equals(optionValue)) {
+ this.reportMissingEnumCaseDespiteDefault = true;
+ } else if (DISABLED.equals(optionValue)) {
+ this.reportMissingEnumCaseDespiteDefault = false;
+ }
+ }
+ if ((optionValue = optionsMap.get(OPTION_ReportMissingDefaultCase)) != null) updateSeverity(MissingDefaultCase, optionValue);
if ((optionValue = optionsMap.get(OPTION_ReportUnhandledWarningToken)) != null) updateSeverity(UnhandledWarningToken, optionValue);
if ((optionValue = optionsMap.get(OPTION_ReportUnusedWarningToken)) != null) updateSeverity(UnusedWarningToken, optionValue);
if ((optionValue = optionsMap.get(OPTION_ReportUnusedLabel)) != null) updateSeverity(UnusedLabel, optionValue);
@@ -2136,7 +2158,7 @@
buf.append("\n\t- missing @Override annotation: ").append(getSeverityString(MissingOverrideAnnotation)); //$NON-NLS-1$
buf.append("\n\t- missing @Override annotation for interface method implementation: ").append(this.reportMissingOverrideAnnotationForInterfaceMethodImplementation ? ENABLED : DISABLED); //$NON-NLS-1$
buf.append("\n\t- missing @Deprecated annotation: ").append(getSeverityString(MissingDeprecatedAnnotation)); //$NON-NLS-1$
- buf.append("\n\t- incomplete enum switch: ").append(getSeverityString(IncompleteEnumSwitch)); //$NON-NLS-1$
+ buf.append("\n\t- incomplete enum switch: ").append(getSeverityString(MissingEnumConstantCase)); //$NON-NLS-1$
buf.append("\n\t- raise null related warnings for variables tainted in assert statements: ").append(this.includeNullInfoFromAsserts ? ENABLED : DISABLED); //$NON-NLS-1$
buf.append("\n\t- suppress warnings: ").append(this.suppressWarnings ? ENABLED : DISABLED); //$NON-NLS-1$
buf.append("\n\t- suppress optional errors: ").append(this.suppressOptionalErrors ? ENABLED : DISABLED); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java
index 9dbc97b..96bf024 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java
@@ -13,6 +13,7 @@
* bug 186342 - [compiler][null] Using annotations for null checking
* bug 370639 - [compiler][resource] restore the default for resource leak warnings
* bug 265744 - Enum switch should warn about missing default
+ * bug 374605 - Unreasonable warning for enum-based switch statements
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.impl;
@@ -60,7 +61,7 @@
public static final IrritantSet FALLTHROUGH = new IrritantSet(CompilerOptions.FallthroughCase);
public static final IrritantSet FINALLY = new IrritantSet(CompilerOptions.FinallyBlockNotCompleting);
public static final IrritantSet HIDING = new IrritantSet(CompilerOptions.MaskedCatchBlock);
- public static final IrritantSet INCOMPLETE_SWITCH = new IrritantSet(CompilerOptions.IncompleteEnumSwitch);
+ public static final IrritantSet INCOMPLETE_SWITCH = new IrritantSet(CompilerOptions.MissingEnumConstantCase);
public static final IrritantSet NLS = new IrritantSet(CompilerOptions.NonExternalizedString);
public static final IrritantSet NULL = new IrritantSet(CompilerOptions.NullReference);
public static final IrritantSet RAW = new IrritantSet(CompilerOptions.RawTypeReference);
@@ -178,7 +179,7 @@
| CompilerOptions.UnusedTypeArguments
| CompilerOptions.UnusedWarningToken
| CompilerOptions.ComparingIdentical
- | CompilerOptions.IncompleteEnumSwitch)
+ | CompilerOptions.MissingEnumConstantCase)
// group-2 warnings enabled by default
.set(
CompilerOptions.DeadCode
@@ -222,6 +223,7 @@
RESOURCE
.set(CompilerOptions.PotentiallyUnclosedCloseable)
.set(CompilerOptions.ExplicitlyClosedAutoCloseable);
+ INCOMPLETE_SWITCH.set(CompilerOptions.MissingDefaultCase);
String suppressRawWhenUnchecked = System.getProperty("suppressRawWhenUnchecked"); //$NON-NLS-1$
if (suppressRawWhenUnchecked != null && "true".equalsIgnoreCase(suppressRawWhenUnchecked)) { //$NON-NLS-1$
UNCHECKED.set(CompilerOptions.RawTypeReference);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java
index 437695e..336f502 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -187,8 +187,9 @@
firstIsSynthetic = true;
}
// ensure the package annotations are copied over before resolution
- if (this.referenceContext.currentPackage != null)
+ if (this.referenceContext.currentPackage != null && this.referenceContext.currentPackage.annotations != null) {
this.referenceContext.types[0].annotations = this.referenceContext.currentPackage.annotations;
+ }
}
recordQualifiedReference(this.currentPackageName); // always dependent on your own package
// :giro
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodScope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodScope.java
index a3b522b..d1f2cd7 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodScope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodScope.java
@@ -8,9 +8,11 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
- * Stephan Herrmann - Contribution for bug 349326 - [1.7] new warning for missing try-with-resources
* Fraunhofer FIRST - extended API and implementation
* Technical University Berlin - extended API and implementation
+ * Stephan Herrmann - Contributions for
+ * bug 349326 - [1.7] new warning for missing try-with-resources
+ * bug 374605 - Unreasonable warning for enum-based switch statements
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
@@ -77,6 +79,9 @@
// inner-emulation
public SyntheticArgumentBinding[] extraSyntheticArguments;
+ // remember suppressed warning re missing 'default:' to give hints on possibly related flow problems
+ public boolean hasMissingSwitchDefault; // TODO(stephan): combine flags to a bitset?
+
public MethodScope(ClassScope parent, ReferenceContext context, boolean isStatic) {
super(METHOD_SCOPE, parent);
this.locals = new LocalVariableBinding[5];
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java
index 4b79be2..8531ba8 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java
@@ -115,11 +115,10 @@
TypeBinding substitute = methodSubstitute.typeArguments[i]; // retain for diagnostics
/* https://bugs.eclipse.org/bugs/show_bug.cgi?id=375394, To avoid spurious bounds check failures due to circularity in formal bounds,
we should eliminate only the lingering embedded type variable references after substitution, not alien type variable references
- that constitute the inference per se. Also short circuit this step, if the substitution has no type variables in the first place
- (as it is effectively a nop.)
+ that constitute the inference per se.
*/
TypeBinding substituteForChecks;
- if (substitute instanceof TypeVariableBinding || ((substitute.tagBits & TagBits.HasTypeVariable) == 0)) {
+ if (substitute instanceof TypeVariableBinding) {
substituteForChecks = substitute;
} else {
substituteForChecks = Scope.substitute(new LingeringTypeVariableEliminator(typeVariables, null, scope), substitute); // while using this for bounds check
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
index cc7ee0a..9fa5312 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
@@ -1071,21 +1071,6 @@
this.tagBits |= TagBits.AreFieldsComplete;
return this.fields;
}
-
-public void tagIndirectlyAccessibleMembers() {
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=328281
- for (int i = 0; i < this.fields.length; i++) {
- if (!this.fields[i].isPrivate())
- this.fields[i].modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
- }
- for (int i = 0; i < this.memberTypes.length; i++) {
- if (!this.memberTypes[i].isPrivate())
- this.memberTypes[i].modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
- }
- if (this.superclass.isPrivate())
- if (this.superclass instanceof SourceTypeBinding) // should always be true because private super type can only be accessed in same CU
- ((SourceTypeBinding) this.superclass).tagIndirectlyAccessibleMembers();
-}
/**
* @see org.eclipse.jdt.internal.compiler.lookup.TypeBinding#genericTypeSignature()
*/
@@ -1759,6 +1744,11 @@
for (int i = 0; i < this.methods.length; i++) {
int length = this.methods.length;
// SH}
+ if ((this.tagBits & TagBits.AreMethodsComplete) != 0) {
+ // recursive call to methods() from resolveTypesFor(..) resolved the methods
+ return this.methods;
+ }
+
if (resolveTypesFor(this.methods[i]) == null) {
// do not alter original method array until resolution is over, due to reentrance (143259)
if (resolvedMethods == this.methods) {
@@ -1942,6 +1932,10 @@
}
}
} finally {
+ if ((this.tagBits & TagBits.AreMethodsComplete) != 0) {
+ // recursive call to methods() from resolveTypesFor(..) resolved the methods
+ return this.methods;
+ }
if (failed > 0) {
int newSize = resolvedMethods.length - failed;
if (newSize == 0) {
@@ -2949,13 +2943,29 @@
public FieldBinding[] unResolvedFields() {
return this.fields;
}
+
+public void tagIndirectlyAccessibleMembers() {
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=328281
+ for (int i = 0; i < this.fields.length; i++) {
+ if (!this.fields[i].isPrivate())
+ this.fields[i].modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
+ }
+ for (int i = 0; i < this.memberTypes.length; i++) {
+ if (!this.memberTypes[i].isPrivate())
+ this.memberTypes[i].modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
+ }
+ if (this.superclass.isPrivate())
+ if (this.superclass instanceof SourceTypeBinding) // should always be true because private super type can only be accessed in same CU
+ ((SourceTypeBinding) this.superclass).tagIndirectlyAccessibleMembers();
+}
+
//{ObjectTeams: in state final we lost the scope, cannot use some code.
private boolean isStateFinal() {
- if (this.roleModel != null)
- return this.roleModel.getState() == ITranslationStates.STATE_FINAL;
- if (this._teamModel != null)
- return this._teamModel.getState() == ITranslationStates.STATE_FINAL;
- return (this.scope == null);
+ if (this.roleModel != null)
+ return this.roleModel.getState() == ITranslationStates.STATE_FINAL;
+ if (this._teamModel != null)
+ return this._teamModel.getState() == ITranslationStates.STATE_FINAL;
+ return (this.scope == null);
}
//SH}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
index a542af5..c1b95b3 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
@@ -10,7 +10,9 @@
* Tom Tromey - patch for readTable(String) as described in http://bugs.eclipse.org/bugs/show_bug.cgi?id=32196
* Fraunhofer FIRST - extended API and implementation
* Technical University Berlin - extended API and implementation
- * Stephan Herrmann - Contribution for Bug 366003 - CCE in ASTNode.resolveAnnotations(ASTNode.java:639)
+ * Stephan Herrmann - Contributions for
+ * bug 366003 - CCE in ASTNode.resolveAnnotations(ASTNode.java:639)
+ * bug 374605 - Unreasonable warning for enum-based switch statements
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.parser;
@@ -19,9 +21,7 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
+import java.util.Properties;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.compiler.InvalidInputException;
@@ -90,6 +90,7 @@
protected static final int THIS_CALL = ExplicitConstructorCall.This;
protected static final int SUPER_CALL = ExplicitConstructorCall.Super;
public static final char[] FALL_THROUGH_TAG = "$FALL-THROUGH$".toCharArray(); //$NON-NLS-1$
+ public static final char[] CASES_OMITTED_TAG = "$CASES-OMITTED$".toCharArray(); //$NON-NLS-1$
//{ObjectTeams: new constants for tsuper
protected static final int TSUPER_CALL = ExplicitConstructorCall.Tsuper;
@@ -125,8 +126,7 @@
public static char nasr[] = null;
public static char non_terminal_index[] = null;
private final static String READABLE_NAMES_FILE = "readableNames"; //$NON-NLS-1$
- private final static String READABLE_NAMES_FILE_NAME =
- "org.eclipse.jdt.internal.compiler.parser." + READABLE_NAMES_FILE; //$NON-NLS-1$
+
public static String readableName[] = null;
public static byte rhs[] = null;
@@ -563,7 +563,7 @@
}
buildFileForCompliance(prefix + (++i) + ".rsc", newRhs.length, tokens);//$NON-NLS-1$
- buildFileForReadableName(READABLE_NAMES_FILE+".properties", newLhs, newNonTerminalIndex, newName, tokens);//$NON-NLS-1$
+ buildFileForReadableName(READABLE_NAMES_FILE+".props", newLhs, newNonTerminalIndex, newName, tokens);//$NON-NLS-1$
buildFilesForRecoveryTemplates(
prefix + (++i) + ".rsc", //$NON-NLS-1$
@@ -649,7 +649,7 @@
rules_compliance = readLongTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
- readableName = readReadableNameTable(READABLE_NAMES_FILE_NAME);
+ readableName = readReadableNameTable(READABLE_NAMES_FILE + ".props"); //$NON-NLS-1$
reverse_index = computeReverseTable(terminal_index, non_terminal_index, name);
@@ -750,28 +750,25 @@
return result;
}
- protected static String[] readReadableNameTable(String filename) {
+ protected static String[] readReadableNameTable(String filename){
String[] result = new String[name.length];
-
- ResourceBundle bundle;
+
+ InputStream is = Parser.class.getResourceAsStream(filename);
+ Properties props = new Properties();
try {
- bundle = ResourceBundle.getBundle(filename, Locale.getDefault());
- } catch(MissingResourceException e) {
- System.out.println("Missing resource : " + filename.replace('.', '/') + ".properties for locale " + Locale.getDefault()); //$NON-NLS-1$//$NON-NLS-2$
- throw e;
+ props.load(is);
+ } catch (IOException e) {
+ result = name;
+ return result;
}
for (int i = 0; i < NT_OFFSET + 1; i++) {
result[i] = name[i];
}
for (int i = NT_OFFSET; i < name.length; i++) {
- try {
- String n = bundle.getString(name[i]);
- if(n != null && n.length() > 0) {
- result[i] = n;
- } else {
- result[i] = name[i];
- }
- } catch(MissingResourceException e) {
+ String n = props.getProperty(name[i]);
+ if (n != null && n.length() > 0) {
+ result[i] = n;
+ } else {
result[i] = name[i];
}
}
@@ -3736,10 +3733,13 @@
protected void consumeDefaultLabel() {
// SwitchLabel ::= 'default' ':'
CaseStatement defaultStatement = new CaseStatement(null, this.intStack[this.intPtr--], this.intStack[this.intPtr--]);
- // Look for $fall-through$ tag in leading comment for case statement
+ // Look for $fall-through$ and $CASES-OMITTED$ tags in leading comment for case statement
if (hasLeadingTagComment(FALL_THROUGH_TAG, defaultStatement.sourceStart)) {
defaultStatement.bits |= ASTNode.DocumentedFallthrough;
- }
+ }
+ if (hasLeadingTagComment(CASES_OMITTED_TAG, defaultStatement.sourceStart)) {
+ defaultStatement.bits |= ASTNode.DocumentedCasesOmitted;
+ }
pushOnAstStack(defaultStatement);
}
protected void consumeDefaultModifiers() {
@@ -11692,8 +11692,14 @@
}
}
for (int iTag = 0, length = commentPrefixTag.length; iTag < length; iTag++, charPos++) {
- if (charPos >= rangeEnd) return false; // comment is too small to host tag
- if (source[charPos] != commentPrefixTag[iTag]) return false;
+ if (charPos >= rangeEnd // comment is too small to host tag
+ || source[charPos] != commentPrefixTag[iTag]) {
+ if (iTag == 0) {
+ return false; // didn't even match leading '$' -> not a tag comment
+ } else {
+ continue previousComment; // accept as tag comment -> skip it and keep searching backwards
+ }
+ }
}
return true;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredElement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredElement.java
index d81e2d6..207fd41 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredElement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredElement.java
@@ -1,361 +1,360 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- * $Id: RecoveredElement.java 23404 2010-02-03 14:10:22Z stephan $
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
+/*******************************************************************************
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
* Fraunhofer FIRST - extended API and implementation
* Technical University Berlin - extended API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.compiler.parser;
-
-/**
- * Internal structure for parsing recovery
- */
-import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.ASTNode;
-import org.eclipse.jdt.internal.compiler.ast.Block;
-import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.ImportReference;
-import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.Statement;
-import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
-import org.eclipse.jdt.internal.compiler.util.Util;
-import org.eclipse.objectteams.otdt.internal.core.compiler.ast.AbstractMethodMappingDeclaration;
-
-public class RecoveredElement {
-
- public RecoveredElement parent;
- public int bracketBalance;
- public boolean foundOpeningBrace;
- protected Parser recoveringParser;
-public RecoveredElement(RecoveredElement parent, int bracketBalance){
- this(parent, bracketBalance, null);
-}
-public RecoveredElement(RecoveredElement parent, int bracketBalance, Parser parser){
- this.parent = parent;
- this.bracketBalance = bracketBalance;
- this.recoveringParser = parser;
-}
-public RecoveredElement addAnnotationName(int identifierPtr, int identifierLengthPtr, int annotationStart, int bracketBalanceValue) {
- /* default behavior is to delegate recording to parent if any */
- resetPendingModifiers();
- if (this.parent == null) return this; // ignore
- this.updateSourceEndIfNecessary(previousAvailableLineEnd(annotationStart - 1));
- return this.parent.addAnnotationName(identifierPtr, identifierLengthPtr, annotationStart, bracketBalanceValue);
-}
-/*
- * Record a method declaration
- */
-public RecoveredElement add(AbstractMethodDeclaration methodDeclaration, int bracketBalanceValue) {
-
- /* default behavior is to delegate recording to parent if any */
- resetPendingModifiers();
- if (this.parent == null) return this; // ignore
- this.updateSourceEndIfNecessary(previousAvailableLineEnd(methodDeclaration.declarationSourceStart - 1));
- return this.parent.add(methodDeclaration, bracketBalanceValue);
-}
-/*
- * Record a nested block declaration
- */
-public RecoveredElement add(Block nestedBlockDeclaration, int bracketBalanceValue) {
-
- /* default behavior is to delegate recording to parent if any */
- resetPendingModifiers();
- if (this.parent == null) return this; // ignore
- this.updateSourceEndIfNecessary(previousAvailableLineEnd(nestedBlockDeclaration.sourceStart - 1));
- return this.parent.add(nestedBlockDeclaration, bracketBalanceValue);
-}
-//{ObjectTeams: MethodMapping:
-public RecoveredElement add(AbstractMethodMappingDeclaration methodMapping, int bracketBalanceValue) {
-
- /* default behavior is to delegate recording to parent if any */
- if (this.parent == null) return this; // ignore
- this.updateSourceEndIfNecessary(previousAvailableLineEnd(methodMapping.declarationSourceStart - 1));
- return this.parent.add(methodMapping, bracketBalanceValue);
-}
-// SH}
-/*
- * Record a field declaration
- */
-public RecoveredElement add(FieldDeclaration fieldDeclaration, int bracketBalanceValue) {
-
- /* default behavior is to delegate recording to parent if any */
- resetPendingModifiers();
- if (this.parent == null) return this; // ignore
- this.updateSourceEndIfNecessary(previousAvailableLineEnd(fieldDeclaration.declarationSourceStart - 1));
- return this.parent.add(fieldDeclaration, bracketBalanceValue);
-}
-/*
- * Record an import reference
- */
-public RecoveredElement add(ImportReference importReference, int bracketBalanceValue){
-
- /* default behavior is to delegate recording to parent if any */
- resetPendingModifiers();
- if (this.parent == null) return this; // ignore
- this.updateSourceEndIfNecessary(previousAvailableLineEnd(importReference.declarationSourceStart - 1));
- return this.parent.add(importReference, bracketBalanceValue);
-}
-/*
- * Record a local declaration
- */
-public RecoveredElement add(LocalDeclaration localDeclaration, int bracketBalanceValue) {
-
- /* default behavior is to delegate recording to parent if any */
- resetPendingModifiers();
- if (this.parent == null) return this; // ignore
- this.updateSourceEndIfNecessary(previousAvailableLineEnd(localDeclaration.declarationSourceStart - 1));
- return this.parent.add(localDeclaration, bracketBalanceValue);
-}
-/*
- * Record a statement
- */
-public RecoveredElement add(Statement statement, int bracketBalanceValue) {
-
- /* default behavior is to delegate recording to parent if any */
- resetPendingModifiers();
- if (this.parent == null) return this; // ignore
- if (this instanceof RecoveredType) {
- TypeDeclaration typeDeclaration = ((RecoveredType) this).typeDeclaration;
- if (typeDeclaration != null && (typeDeclaration.bits & ASTNode.IsAnonymousType) != 0) {
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=291040, new X(<SelectOnMessageSend:zoo()>) { ???
- if (statement.sourceStart > typeDeclaration.sourceStart && statement.sourceEnd < typeDeclaration.sourceEnd) {
- return this;
- }
- }
- }
- this.updateSourceEndIfNecessary(previousAvailableLineEnd(statement.sourceStart - 1));
- return this.parent.add(statement, bracketBalanceValue);
-}
-/*
- * Record a type declaration
- */
-public RecoveredElement add(TypeDeclaration typeDeclaration, int bracketBalanceValue){
-
- /* default behavior is to delegate recording to parent if any */
- resetPendingModifiers();
- if (this.parent == null) return this; // ignore
- this.updateSourceEndIfNecessary(previousAvailableLineEnd(typeDeclaration.declarationSourceStart - 1));
- return this.parent.add(typeDeclaration, bracketBalanceValue);
-}
-protected void addBlockStatement(RecoveredBlock recoveredBlock) {
- Block block = recoveredBlock.blockDeclaration;
- if(block.statements != null) {
- Statement[] statements = block.statements;
- for (int i = 0; i < statements.length; i++) {
- recoveredBlock.add(statements[i], 0);
- }
- }
-}
-public void addModifier(int flag, int modifiersSourceStart) {
- // default implementation: do nothing
-}
-/*
- * Answer the depth of this element, considering the parent link.
- */
-public int depth(){
- int depth = 0;
- RecoveredElement current = this;
- while ((current = current.parent) != null) depth++;
- return depth;
-}
-/*
- * Answer the enclosing method node, or null if none
- */
-public RecoveredInitializer enclosingInitializer(){
- RecoveredElement current = this;
- while (current != null){
- if (current instanceof RecoveredInitializer){
- return (RecoveredInitializer) current;
- }
- current = current.parent;
- }
- return null;
-}
-/*
- * Answer the enclosing method node, or null if none
- */
-public RecoveredMethod enclosingMethod(){
- RecoveredElement current = this;
- while (current != null){
- if (current instanceof RecoveredMethod){
- return (RecoveredMethod) current;
- }
- current = current.parent;
- }
- return null;
-}
-/*
- * Answer the enclosing type node, or null if none
- */
-public RecoveredType enclosingType(){
- RecoveredElement current = this;
- while (current != null){
- if (current instanceof RecoveredType){
- return (RecoveredType) current;
- }
- current = current.parent;
- }
- return null;
-}
-/*
- * Answer the closest specified parser
- */
-public Parser parser(){
- RecoveredElement current = this;
- while (current != null){
- if (current.recoveringParser != null){
- return current.recoveringParser;
- }
- current = current.parent;
- }
- return null;
-}
-/*
- * Answer the associated parsed structure
- */
-public ASTNode parseTree(){
- return null;
-}
-public void resetPendingModifiers() {
- // default implementation: do nothing
- // recovered elements which have pending modifiers must override this method
-}
-/*
- * Iterate the enclosing blocks and tag them so as to preserve their content
- */
-public void preserveEnclosingBlocks(){
- RecoveredElement current = this;
- while (current != null){
- if (current instanceof RecoveredBlock){
- ((RecoveredBlock)current).preserveContent = true;
- }
- if (current instanceof RecoveredType){ // for anonymous types
- ((RecoveredType)current).preserveContent = true;
- }
- current = current.parent;
- }
-}
-/*
- * Answer the position of the previous line end if
- * there is nothing but spaces in between it and the
- * line end. Used to trim spaces on unclosed elements.
- */
-public int previousAvailableLineEnd(int position){
-
- Parser parser = parser();
- if (parser == null) return position;
-
- Scanner scanner = parser.scanner;
- if (scanner.lineEnds == null) return position;
-
- int index = Util.getLineNumber(position, scanner.lineEnds, 0, scanner.linePtr);
- if (index < 2) return position;
- int previousLineEnd = scanner.lineEnds[index-2];
-
- char[] source = scanner.source;
- for (int i = previousLineEnd+1; i < position; i++){
- if (!(source[i] == ' ' || source[i] == '\t')) return position;
- }
- return previousLineEnd;
-}
-/*
- * Answer the very source end of the corresponding parse node
- */
-public int sourceEnd(){
- return 0;
-}
-protected String tabString(int tab) {
- StringBuffer result = new StringBuffer();
- for (int i = tab; i > 0; i--) {
- result.append(" "); //$NON-NLS-1$
- }
- return result.toString();
-}
-/*
- * Answer the top node
- */
-public RecoveredElement topElement(){
- RecoveredElement current = this;
- while (current.parent != null){
- current = current.parent;
- }
- return current;
-}
-public String toString() {
- return toString(0);
-}
-public String toString(int tab) {
- return super.toString();
-}
-/*
- * Answer the enclosing type node, or null if none
- */
-public RecoveredType type(){
- RecoveredElement current = this;
- while (current != null){
- if (current instanceof RecoveredType){
- return (RecoveredType) current;
- }
- current = current.parent;
- }
- return null;
-}
-/*
- * Update the bodyStart of the corresponding parse node
- */
-public void updateBodyStart(int bodyStart){
- this.foundOpeningBrace = true;
-}
-/*
- * Update the corresponding parse node from parser state which
- * is about to disappear because of restarting recovery
- */
-public void updateFromParserState(){
- // default implementation: do nothing
-}
-/*
- * A closing brace got consumed, might have closed the current element,
- * in which case both the currentElement is exited
- */
-public RecoveredElement updateOnClosingBrace(int braceStart, int braceEnd){
- if ((--this.bracketBalance <= 0) && (this.parent != null)){
- this.updateSourceEndIfNecessary(braceStart, braceEnd);
- return this.parent;
- }
- return this;
-}
-/*
- * An opening brace got consumed, might be the expected opening one of the current element,
- * in which case the bodyStart is updated.
- */
-/*public RecoveredElement updateOnOpeningBrace(int braceEnd){return null;}*/
-public RecoveredElement updateOnOpeningBrace(int braceStart, int braceEnd){
-
- if (this.bracketBalance++ == 0){
- updateBodyStart(braceEnd + 1);
- return this;
- }
- return null; // no update is necessary
-}
-/*
- * Final update the corresponding parse node
- */
-public void updateParseTree(){
- // default implementation: do nothing
-}
-/*
- * Update the declarationSourceEnd of the corresponding parse node
- */
-public void updateSourceEndIfNecessary(int braceStart, int braceEnd){
- // default implementation: do nothing
-}
-public void updateSourceEndIfNecessary(int sourceEnd){
- this.updateSourceEndIfNecessary(sourceEnd + 1, sourceEnd);
-}
-}
+ *******************************************************************************/
+package org.eclipse.jdt.internal.compiler.parser;
+
+/**
+ * Internal structure for parsing recovery
+ */
+import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.ASTNode;
+import org.eclipse.jdt.internal.compiler.ast.Block;
+import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.ImportReference;
+import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.Statement;
+import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
+import org.eclipse.jdt.internal.compiler.util.Util;
+import org.eclipse.objectteams.otdt.internal.core.compiler.ast.AbstractMethodMappingDeclaration;
+
+public class RecoveredElement {
+
+ public RecoveredElement parent;
+ public int bracketBalance;
+ public boolean foundOpeningBrace;
+ protected Parser recoveringParser;
+public RecoveredElement(RecoveredElement parent, int bracketBalance){
+ this(parent, bracketBalance, null);
+}
+public RecoveredElement(RecoveredElement parent, int bracketBalance, Parser parser){
+ this.parent = parent;
+ this.bracketBalance = bracketBalance;
+ this.recoveringParser = parser;
+}
+public RecoveredElement addAnnotationName(int identifierPtr, int identifierLengthPtr, int annotationStart, int bracketBalanceValue) {
+ /* default behavior is to delegate recording to parent if any */
+ resetPendingModifiers();
+ if (this.parent == null) return this; // ignore
+ this.updateSourceEndIfNecessary(previousAvailableLineEnd(annotationStart - 1));
+ return this.parent.addAnnotationName(identifierPtr, identifierLengthPtr, annotationStart, bracketBalanceValue);
+}
+/*
+ * Record a method declaration
+ */
+public RecoveredElement add(AbstractMethodDeclaration methodDeclaration, int bracketBalanceValue) {
+
+ /* default behavior is to delegate recording to parent if any */
+ resetPendingModifiers();
+ if (this.parent == null) return this; // ignore
+ this.updateSourceEndIfNecessary(previousAvailableLineEnd(methodDeclaration.declarationSourceStart - 1));
+ return this.parent.add(methodDeclaration, bracketBalanceValue);
+}
+/*
+ * Record a nested block declaration
+ */
+public RecoveredElement add(Block nestedBlockDeclaration, int bracketBalanceValue) {
+
+ /* default behavior is to delegate recording to parent if any */
+ resetPendingModifiers();
+ if (this.parent == null) return this; // ignore
+ this.updateSourceEndIfNecessary(previousAvailableLineEnd(nestedBlockDeclaration.sourceStart - 1));
+ return this.parent.add(nestedBlockDeclaration, bracketBalanceValue);
+}
+//{ObjectTeams: MethodMapping:
+public RecoveredElement add(AbstractMethodMappingDeclaration methodMapping, int bracketBalanceValue) {
+
+ /* default behavior is to delegate recording to parent if any */
+ if (this.parent == null) return this; // ignore
+ this.updateSourceEndIfNecessary(previousAvailableLineEnd(methodMapping.declarationSourceStart - 1));
+ return this.parent.add(methodMapping, bracketBalanceValue);
+}
+//SH}
+/*
+ * Record a field declaration
+ */
+public RecoveredElement add(FieldDeclaration fieldDeclaration, int bracketBalanceValue) {
+
+ /* default behavior is to delegate recording to parent if any */
+ resetPendingModifiers();
+ if (this.parent == null) return this; // ignore
+ this.updateSourceEndIfNecessary(previousAvailableLineEnd(fieldDeclaration.declarationSourceStart - 1));
+ return this.parent.add(fieldDeclaration, bracketBalanceValue);
+}
+/*
+ * Record an import reference
+ */
+public RecoveredElement add(ImportReference importReference, int bracketBalanceValue){
+
+ /* default behavior is to delegate recording to parent if any */
+ resetPendingModifiers();
+ if (this.parent == null) return this; // ignore
+ this.updateSourceEndIfNecessary(previousAvailableLineEnd(importReference.declarationSourceStart - 1));
+ return this.parent.add(importReference, bracketBalanceValue);
+}
+/*
+ * Record a local declaration
+ */
+public RecoveredElement add(LocalDeclaration localDeclaration, int bracketBalanceValue) {
+
+ /* default behavior is to delegate recording to parent if any */
+ resetPendingModifiers();
+ if (this.parent == null) return this; // ignore
+ this.updateSourceEndIfNecessary(previousAvailableLineEnd(localDeclaration.declarationSourceStart - 1));
+ return this.parent.add(localDeclaration, bracketBalanceValue);
+}
+/*
+ * Record a statement
+ */
+public RecoveredElement add(Statement statement, int bracketBalanceValue) {
+
+ /* default behavior is to delegate recording to parent if any */
+ resetPendingModifiers();
+ if (this.parent == null) return this; // ignore
+ if (this instanceof RecoveredType) {
+ TypeDeclaration typeDeclaration = ((RecoveredType) this).typeDeclaration;
+ if (typeDeclaration != null && (typeDeclaration.bits & ASTNode.IsAnonymousType) != 0) {
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=291040, new X(<SelectOnMessageSend:zoo()>) { ???
+ if (statement.sourceStart > typeDeclaration.sourceStart && statement.sourceEnd < typeDeclaration.sourceEnd) {
+ return this;
+ }
+ }
+ }
+ this.updateSourceEndIfNecessary(previousAvailableLineEnd(statement.sourceStart - 1));
+ return this.parent.add(statement, bracketBalanceValue);
+}
+/*
+ * Record a type declaration
+ */
+public RecoveredElement add(TypeDeclaration typeDeclaration, int bracketBalanceValue){
+
+ /* default behavior is to delegate recording to parent if any */
+ resetPendingModifiers();
+ if (this.parent == null) return this; // ignore
+ this.updateSourceEndIfNecessary(previousAvailableLineEnd(typeDeclaration.declarationSourceStart - 1));
+ return this.parent.add(typeDeclaration, bracketBalanceValue);
+}
+protected void addBlockStatement(RecoveredBlock recoveredBlock) {
+ Block block = recoveredBlock.blockDeclaration;
+ if(block.statements != null) {
+ Statement[] statements = block.statements;
+ for (int i = 0; i < statements.length; i++) {
+ recoveredBlock.add(statements[i], 0);
+ }
+ }
+}
+public void addModifier(int flag, int modifiersSourceStart) {
+ // default implementation: do nothing
+}
+/*
+ * Answer the depth of this element, considering the parent link.
+ */
+public int depth(){
+ int depth = 0;
+ RecoveredElement current = this;
+ while ((current = current.parent) != null) depth++;
+ return depth;
+}
+/*
+ * Answer the enclosing method node, or null if none
+ */
+public RecoveredInitializer enclosingInitializer(){
+ RecoveredElement current = this;
+ while (current != null){
+ if (current instanceof RecoveredInitializer){
+ return (RecoveredInitializer) current;
+ }
+ current = current.parent;
+ }
+ return null;
+}
+/*
+ * Answer the enclosing method node, or null if none
+ */
+public RecoveredMethod enclosingMethod(){
+ RecoveredElement current = this;
+ while (current != null){
+ if (current instanceof RecoveredMethod){
+ return (RecoveredMethod) current;
+ }
+ current = current.parent;
+ }
+ return null;
+}
+/*
+ * Answer the enclosing type node, or null if none
+ */
+public RecoveredType enclosingType(){
+ RecoveredElement current = this;
+ while (current != null){
+ if (current instanceof RecoveredType){
+ return (RecoveredType) current;
+ }
+ current = current.parent;
+ }
+ return null;
+}
+/*
+ * Answer the closest specified parser
+ */
+public Parser parser(){
+ RecoveredElement current = this;
+ while (current != null){
+ if (current.recoveringParser != null){
+ return current.recoveringParser;
+ }
+ current = current.parent;
+ }
+ return null;
+}
+/*
+ * Answer the associated parsed structure
+ */
+public ASTNode parseTree(){
+ return null;
+}
+public void resetPendingModifiers() {
+ // default implementation: do nothing
+ // recovered elements which have pending modifiers must override this method
+}
+/*
+ * Iterate the enclosing blocks and tag them so as to preserve their content
+ */
+public void preserveEnclosingBlocks(){
+ RecoveredElement current = this;
+ while (current != null){
+ if (current instanceof RecoveredBlock){
+ ((RecoveredBlock)current).preserveContent = true;
+ }
+ if (current instanceof RecoveredType){ // for anonymous types
+ ((RecoveredType)current).preserveContent = true;
+ }
+ current = current.parent;
+ }
+}
+/*
+ * Answer the position of the previous line end if
+ * there is nothing but spaces in between it and the
+ * line end. Used to trim spaces on unclosed elements.
+ */
+public int previousAvailableLineEnd(int position){
+
+ Parser parser = parser();
+ if (parser == null) return position;
+
+ Scanner scanner = parser.scanner;
+ if (scanner.lineEnds == null) return position;
+
+ int index = Util.getLineNumber(position, scanner.lineEnds, 0, scanner.linePtr);
+ if (index < 2) return position;
+ int previousLineEnd = scanner.lineEnds[index-2];
+
+ char[] source = scanner.source;
+ for (int i = previousLineEnd+1; i < position; i++){
+ if (!(source[i] == ' ' || source[i] == '\t')) return position;
+ }
+ return previousLineEnd;
+}
+/*
+ * Answer the very source end of the corresponding parse node
+ */
+public int sourceEnd(){
+ return 0;
+}
+protected String tabString(int tab) {
+ StringBuffer result = new StringBuffer();
+ for (int i = tab; i > 0; i--) {
+ result.append(" "); //$NON-NLS-1$
+ }
+ return result.toString();
+}
+/*
+ * Answer the top node
+ */
+public RecoveredElement topElement(){
+ RecoveredElement current = this;
+ while (current.parent != null){
+ current = current.parent;
+ }
+ return current;
+}
+public String toString() {
+ return toString(0);
+}
+public String toString(int tab) {
+ return super.toString();
+}
+/*
+ * Answer the enclosing type node, or null if none
+ */
+public RecoveredType type(){
+ RecoveredElement current = this;
+ while (current != null){
+ if (current instanceof RecoveredType){
+ return (RecoveredType) current;
+ }
+ current = current.parent;
+ }
+ return null;
+}
+/*
+ * Update the bodyStart of the corresponding parse node
+ */
+public void updateBodyStart(int bodyStart){
+ this.foundOpeningBrace = true;
+}
+/*
+ * Update the corresponding parse node from parser state which
+ * is about to disappear because of restarting recovery
+ */
+public void updateFromParserState(){
+ // default implementation: do nothing
+}
+/*
+ * A closing brace got consumed, might have closed the current element,
+ * in which case both the currentElement is exited
+ */
+public RecoveredElement updateOnClosingBrace(int braceStart, int braceEnd){
+ if ((--this.bracketBalance <= 0) && (this.parent != null)){
+ this.updateSourceEndIfNecessary(braceStart, braceEnd);
+ return this.parent;
+ }
+ return this;
+}
+/*
+ * An opening brace got consumed, might be the expected opening one of the current element,
+ * in which case the bodyStart is updated.
+ */
+/*public RecoveredElement updateOnOpeningBrace(int braceEnd){return null;}*/
+public RecoveredElement updateOnOpeningBrace(int braceStart, int braceEnd){
+
+ if (this.bracketBalance++ == 0){
+ updateBodyStart(braceEnd + 1);
+ return this;
+ }
+ return null; // no update is necessary
+}
+/*
+ * Final update the corresponding parse node
+ */
+public void updateParseTree(){
+ // default implementation: do nothing
+}
+/*
+ * Update the declarationSourceEnd of the corresponding parse node
+ */
+public void updateSourceEndIfNecessary(int braceStart, int braceEnd){
+ // default implementation: do nothing
+}
+public void updateSourceEndIfNecessary(int sourceEnd){
+ this.updateSourceEndIfNecessary(sourceEnd + 1, sourceEnd);
+}
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/readableNames.properties b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/readableNames.props
similarity index 99%
rename from org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/readableNames.properties
rename to org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/readableNames.props
index f94e949..cc0035b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/readableNames.properties
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/readableNames.props
@@ -9,7 +9,7 @@
# IBM Corporation - initial API and implementation
###############################################################################
,opt=,
-\;opt=;
+;opt=;
AbstractMethodDeclaration=MethodDeclaration
AdditionalBound1=AdditionalBound1
AdditionalBound=AdditionalBound
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java
index ac5c295..0606fcb 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java
@@ -282,10 +282,11 @@
switch (severity & ProblemSeverities.Error) {
case ProblemSeverities.Error :
- record(problem, unitResult, referenceContext);
+ boolean mandatory = ((severity & ProblemSeverities.Optional) == 0);
+ record(problem, unitResult, referenceContext, mandatory);
if ((severity & ProblemSeverities.Fatal) != 0) {
// don't abort or tag as error if the error is suppressed
- if (!referenceContext.hasErrors() && (severity & ProblemSeverities.Optional) != 0 && this.options.suppressOptionalErrors) {
+ if (!referenceContext.hasErrors() && !mandatory && this.options.suppressOptionalErrors) {
CompilationUnitDeclaration unitDecl = referenceContext.getCompilationUnitDeclaration();
if (unitDecl != null && unitDecl.isSuppressed(problem)) {
return;
@@ -303,7 +304,7 @@
}
break;
case ProblemSeverities.Warning :
- record(problem, unitResult, referenceContext);
+ record(problem, unitResult, referenceContext, false);
break;
}
}
@@ -331,7 +332,7 @@
referenceContext,
unitResult);
}
-public void record(CategorizedProblem problem, CompilationResult unitResult, ReferenceContext referenceContext) {
- unitResult.record(problem, referenceContext);
+public void record(CategorizedProblem problem, CompilationResult unitResult, ReferenceContext referenceContext, boolean optionalError) {
+ unitResult.record(problem, referenceContext, optionalError);
}
}
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 7aaf4f1..baa1a36 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
@@ -20,6 +20,7 @@
* bug 365662 - [compiler][null] warn on contradictory and redundant null annotations
* bug 365531 - [compiler][null] investigate alternative strategy for internally encoding nullness defaults
* bug 365859 - [compiler][null] distinguish warnings based on flow analysis vs. null annotations
+ * bug 374605 - Unreasonable warning for enum-based switch statements
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.problem;
@@ -111,6 +112,7 @@
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
import org.eclipse.jdt.internal.compiler.lookup.MemberTypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
+import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
import org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding;
import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding;
@@ -396,8 +398,12 @@
return CompilerOptions.AutoBoxing;
case IProblem.MissingEnumConstantCase :
+ case IProblem.MissingEnumConstantCaseDespiteDefault : // this one is further protected by CompilerOptions.reportMissingEnumCaseDespiteDefault
+ return CompilerOptions.MissingEnumConstantCase;
+
+ case IProblem.MissingDefaultCase :
case IProblem.MissingEnumDefaultCase :
- return CompilerOptions.IncompleteEnumSwitch;
+ return CompilerOptions.MissingDefaultCase;
case IProblem.AnnotationTypeUsedAsSuperInterface :
return CompilerOptions.AnnotationSuperInterface;
@@ -683,7 +689,8 @@
case CompilerOptions.NullReference :
case CompilerOptions.PotentialNullReference :
case CompilerOptions.RedundantNullCheck :
- case CompilerOptions.IncompleteEnumSwitch :
+ case CompilerOptions.MissingEnumConstantCase :
+ case CompilerOptions.MissingDefaultCase :
case CompilerOptions.FallthroughCase :
case CompilerOptions.OverridingMethodWithoutSuperInvocation :
case CompilerOptions.ComparingIdentical :
@@ -5984,20 +5991,21 @@
}
public void missingEnumConstantCase(SwitchStatement switchStatement, FieldBinding enumConstant) {
this.handle(
- IProblem.MissingEnumConstantCase,
+ switchStatement.defaultCase == null ? IProblem.MissingEnumConstantCase : IProblem.MissingEnumConstantCaseDespiteDefault,
new String[] {new String(enumConstant.declaringClass.readableName()), new String(enumConstant.name) },
new String[] {new String(enumConstant.declaringClass.shortReadableName()), new String(enumConstant.name) },
switchStatement.expression.sourceStart,
switchStatement.expression.sourceEnd);
}
-public void missingEnumDefaultCase(SwitchStatement switchStatement, TypeBinding enumType) {
+public void missingDefaultCase(SwitchStatement switchStatement, boolean isEnumSwitch, TypeBinding expressionType) {
this.handle(
- IProblem.MissingEnumDefaultCase,
- new String[] {new String(enumType.readableName())},
- new String[] {new String(enumType.shortReadableName())},
+ isEnumSwitch ? IProblem.MissingEnumDefaultCase : IProblem.MissingDefaultCase,
+ new String[] {new String(expressionType.readableName())},
+ new String[] {new String(expressionType.shortReadableName())},
switchStatement.expression.sourceStart,
switchStatement.expression.sourceEnd);
-}public void missingOverrideAnnotation(AbstractMethodDeclaration method) {
+}
+public void missingOverrideAnnotation(AbstractMethodDeclaration method) {
//{ObjectTeams: don't report for generated method:
if (method.isGenerated)
return;
@@ -7288,7 +7296,7 @@
}
public void shouldReturn(TypeBinding returnType, ASTNode location) {
this.handle(
- IProblem.ShouldReturnValue,
+ methodHasMissingSwitchDefault() ? IProblem.ShouldReturnValueHintMissingDefault : IProblem.ShouldReturnValue,
new String[] { new String (returnType.readableName())},
new String[] { new String (returnType.shortReadableName())},
location.sourceStart,
@@ -7912,7 +7920,7 @@
// SH}
String[] arguments = new String[] {new String(field.readableName())};
this.handle(
- IProblem.UninitializedBlankFinalField,
+ methodHasMissingSwitchDefault() ? IProblem.UninitializedBlankFinalFieldHintMissingDefault : IProblem.UninitializedBlankFinalField,
arguments,
arguments,
nodeSourceStart(field, location),
@@ -7922,12 +7930,21 @@
binding.tagBits |= TagBits.NotInitialized;
String[] arguments = new String[] {new String(binding.readableName())};
this.handle(
- IProblem.UninitializedLocalVariable,
+ methodHasMissingSwitchDefault() ? IProblem.UninitializedLocalVariableHintMissingDefault : IProblem.UninitializedLocalVariable,
arguments,
arguments,
nodeSourceStart(binding, location),
nodeSourceEnd(binding, location));
}
+private boolean methodHasMissingSwitchDefault() {
+ MethodScope methodScope = null;
+ if (this.referenceContext instanceof Block) {
+ methodScope = ((Block)this.referenceContext).scope.methodScope();
+ } else if (this.referenceContext instanceof AbstractMethodDeclaration) {
+ methodScope = ((AbstractMethodDeclaration)this.referenceContext).scope;
+ }
+ return methodScope != null && methodScope.hasMissingSwitchDefault;
+}
public void unmatchedBracket(int position, ReferenceContext context, CompilationResult compilationResult) {
this.handle(
IProblem.UnmatchedBracket,
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
index 7e7e822..5f90cc0 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2011 IBM Corporation and others.
+# Copyright (c) 2000, 2012 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@@ -17,6 +17,7 @@
# bug 365662 - [compiler][null] warn on contradictory and redundant null annotations
# bug 365531 - [compiler][null] investigate alternative strategy for internally encoding nullness defaults
# bug 365859 - [compiler][null] distinguish warnings based on flow analysis vs. null annotations
+# bug 374605 - Unreasonable warning for enum-based switch statements
###############################################################################
0 = {0}
1 = super cannot be used in java.lang.Object
@@ -614,7 +615,12 @@
763 = The enum constant {2} must implement the abstract method {0}({1})
764 = The enum constant {0} cannot define abstract methods
765 = The method {1} cannot be abstract in the enum constant {0}
-766 = The switch on the enum type {0} should have a default case
+766 = The switch over the enum type {0} should have a default case
+767 = The switch over the type {0} should have a default case
+768 = The enum constant {1} should have a corresponding case label in this enum switch on {0}. To suppress this problem, add a comment //$CASES-OMITTED$ on the line above the ''default:''
+769 = The local variable {0} may not have been initialized. Note that a problem regarding missing ''default:'' on ''switch'' has been suppressed, which is perhaps related to this problem
+770 = The blank final field {0} may not have been initialized. Note that a problem regarding missing ''default:'' on ''switch'' has been suppressed, which is perhaps related to this problem
+771 = This method must return a result of type {0}. Note that a problem regarding missing ''default:'' on ''switch'' has been suppressed, which is perhaps related to this problem
### VARARGS
800 = Extended dimensions are illegal for a variable argument
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 a4c694a..e7165a3 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
@@ -96,6 +96,8 @@
* COMPILER_PB_NULL_SPECIFICATION_VIOLATION
* COMPILER_PB_POTENTIAL_NULL_SPECIFICATION_VIOLATION
* COMPILER_PB_NULL_SPECIFICATION_INSUFFICIENT_INFO
+ * COMPILER_PB_MISSING_ENUM_CASE_DESPITE_DEFAULT
+ * COMPILER_PB_SWITCH_MISSING_DEFAULT_CASE
*******************************************************************************/
package org.eclipse.jdt.core;
@@ -1087,10 +1089,9 @@
public static final String COMPILER_PB_DEAD_CODE_IN_TRIVIAL_IF_STATEMENT = PLUGIN_ID + ".compiler.problem.deadCodeInTrivialIfStatement"; //$NON-NLS-1$
/**
* Compiler option ID: Reporting Incomplete Enum Switch.
- * <p>When enabled, the compiler will issue an error or a warning whenever
- * an enum switch statement lacks a default case.
- * If no default case is given, additionally one error or warning is issued
- * regarding each enum constant for which a corresponding case label is lacking.
+ * <p>When enabled, the compiler will issue an error or a warning
+ * regarding each enum constant for which a corresponding case label is lacking.
+ * Reporting is further controlled by the option {@link #COMPILER_PB_MISSING_ENUM_CASE_DESPITE_DEFAULT}.
* <dl>
* <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch"</code></dd>
* <dt>Possible values:</dt><dd><code>{ "error", "warning", "ignore" }</code></dd>
@@ -1101,6 +1102,37 @@
*/
public static final String COMPILER_PB_INCOMPLETE_ENUM_SWITCH = PLUGIN_ID + ".compiler.problem.incompleteEnumSwitch"; //$NON-NLS-1$
/**
+ * Compiler option ID: Reporting Missing Enum Case In Switch Despite An Existing Default Case.
+ * <p>This option further controls the option {@link #COMPILER_PB_INCOMPLETE_ENUM_SWITCH}:
+ * <ul>
+ * <li>If enabled the compiler will report problems about missing enum constants even if a default case exists
+ * in the same switch statement.</li>
+ * <li>If disabled existence of a default case is considered as sufficient to make a switch statement complete.</li>
+ * </ul>
+ * This option has no effect if {@link #COMPILER_PB_INCOMPLETE_ENUM_SWITCH} is set to <code>"ignore"</code>.
+ * <dl>
+ * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault"</code></dd>
+ * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd>
+ * <dt>Default:</dt><dd><code>"disabled"</code></dd>
+ * </dl>
+ * @since 3.8
+ * @category CompilerOptionID
+ */
+ public static final String COMPILER_PB_MISSING_ENUM_CASE_DESPITE_DEFAULT = PLUGIN_ID + ".compiler.problem.missingEnumCaseDespiteDefault"; //$NON-NLS-1$
+ /**
+ * Compiler option ID: Reporting Missing Default Case In Switch.
+ * <p>When enabled, the compiler will issue an error or a warning
+ * against each switch statement that lacks a default case.
+ * <dl>
+ * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.missingDefaultCase"</code></dd>
+ * <dt>Possible values:</dt><dd><code>{ "error", "warning", "ignore" }</code></dd>
+ * <dt>Default:</dt><dd><code>"ignore"</code></dd>
+ * </dl>
+ * @since 3.8
+ * @category CompilerOptionID
+ */
+ public static final String COMPILER_PB_SWITCH_MISSING_DEFAULT_CASE = PLUGIN_ID + ".compiler.problem.missingDefaultCase"; //$NON-NLS-1$
+ /**
* @since 3.1
* @deprecated Use {@link #COMPILER_PB_NULL_REFERENCE} instead.
* @category DeprecatedOptionID
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementParser.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementParser.java
index 44c2d98..0a5dced 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementParser.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementParser.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -90,7 +90,7 @@
DefaultErrorHandlingPolicies.exitAfterAllProblems(),
options,
problemFactory) {
- public void record(CategorizedProblem problem, CompilationResult unitResult, ReferenceContext context) {
+ public void record(CategorizedProblem problem, CompilationResult unitResult, ReferenceContext context, boolean mandatoryError) {
//{ObjectTeams: filter recording (cf. CompilationUnitProblemFinder):
if (context instanceof AbstractMethodDeclaration) {
AbstractMethodDeclaration method = (AbstractMethodDeclaration)context;
@@ -103,7 +103,7 @@
}
}
// SH}
- unitResult.record(problem, context); // TODO (jerome) clients are trapping problems either through factory or requestor... is result storing needed?
+ unitResult.record(problem, context, mandatoryError); // TODO (jerome) clients are trapping problems either through factory or requestor... is result storing needed?
SourceElementParser.this.requestor.acceptProblem(problem);
}
};
@@ -859,7 +859,6 @@
return null;
}
}
-
public TypeReference getTypeReference(int dim) {
/* build a Reference on a variable that may be qualified or not
* This variable is a type reference and dim will be its dimensions
@@ -1051,7 +1050,6 @@
protected SingleNameReference newSingleNameReference(char[] source, long positions) {
return new SingleNameReference(source, positions);
}
-
public CompilationUnitDeclaration parseCompilationUnit(
ICompilationUnit unit,
boolean fullParse,
@@ -1102,7 +1100,6 @@
}
}
}
-
private void reset() {
this.sourceEnds = new HashtableOfObjectToInt();
this.nodesToCategories = new HashMap();
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitProblemFinder.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitProblemFinder.java
index 4a1d8ba..4dd3cc2 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitProblemFinder.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitProblemFinder.java
@@ -312,7 +312,7 @@
this.problemReporter.options,
this.problemReporter.problemFactory)
{
- public void record(CategorizedProblem problem, CompilationResult unitResult, ReferenceContext context) {
+ public void record(CategorizedProblem problem, CompilationResult unitResult, ReferenceContext context, boolean mandatoryError) {
//filter recording:
if (context instanceof AbstractMethodDeclaration) {
AbstractMethodDeclaration method = (AbstractMethodDeclaration)context;
@@ -324,7 +324,7 @@
}
}
}
- super.record(problem, unitResult, context);
+ super.record(problem, unitResult, context, mandatoryError);
}
};
// SH}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ExternalFoldersManager.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ExternalFoldersManager.java
index 9ad73c8..4dde5e3 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ExternalFoldersManager.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ExternalFoldersManager.java
@@ -36,6 +36,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jdt.core.IClasspathEntry;
@@ -51,13 +52,20 @@
private Set pendingFolders; // subset of keys of 'folders', for which linked folders haven't been created yet.
private int counter = 0;
/* Singleton instance */
- private static ExternalFoldersManager MANAGER = new ExternalFoldersManager();
+ private static ExternalFoldersManager MANAGER;
private ExternalFoldersManager() {
// Prevent instantiation
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=377806
+ if (Platform.isRunning()) {
+ getFolders();
+ }
}
- public static ExternalFoldersManager getExternalFoldersManager() {
+ public static synchronized ExternalFoldersManager getExternalFoldersManager() {
+ if (MANAGER == null) {
+ MANAGER = new ExternalFoldersManager();
+ }
return MANAGER;
}
@@ -123,8 +131,10 @@
result = externalFoldersProject.getFolder(LINKED_FOLDER_NAME + this.counter++);
} while (result.exists());
if (scheduleForCreation) {
- if (this.pendingFolders == null)
- this.pendingFolders = Collections.synchronizedSet(new HashSet());
+ synchronized(this) {
+ if (this.pendingFolders == null)
+ this.pendingFolders = Collections.synchronizedSet(new HashSet());
+ }
this.pendingFolders.add(externalFolderPath);
}
knownFolders.put(externalFolderPath, result);
@@ -136,7 +146,7 @@
* @param externalPath to link to
* @return true if the argument was found in the list of pending folders and could be removed from it.
*/
- public boolean removePendingFolder(Object externalPath) {
+ public synchronized boolean removePendingFolder(Object externalPath) {
if (this.pendingFolders == null)
return false;
return this.pendingFolders.remove(externalPath);
@@ -195,7 +205,9 @@
}
public void createPendingFolders(IProgressMonitor monitor) throws JavaModelException{
- if (this.pendingFolders == null || this.pendingFolders.isEmpty()) return;
+ synchronized (this) {
+ if (this.pendingFolders == null || this.pendingFolders.isEmpty()) return;
+ }
IProject externalFoldersProject = null;
try {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java
index e61387b..537f3e7 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java
@@ -3607,7 +3607,10 @@
}
/*
* Puts the infos in the given map (keys are IJavaElements and values are JavaElementInfos)
- * in the Java model cache in an atomic way.
+ * in the Java model cache in an atomic way if the info is not already present in the cache.
+ * If the info is already present in the cache, it depends upon the forceAdd parameter.
+ * If forceAdd is false it just returns the existing info and if true, this element and it's children are closed and then
+ * this particular info is added to the cache.
*/
protected synchronized Object putInfos(IJavaElement openedElement, Object newInfo, boolean forceAdd, Map newElements) {
// remove existing children as the are replaced with the new children contained in newElements
@@ -3615,8 +3618,9 @@
if (existingInfo != null && !forceAdd) {
// If forceAdd is false, then it could mean that the particular element
// wasn't in cache at that point of time, but would have got added through
- // another thread. In that case, we better use the other thread's info
- // rather than removing it's children and creating one another.
+ // another thread. In that case, removing the children could remove it's own
+ // children. So, we should not remove the children but return the already existing
+ // info.
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=372687
return existingInfo;
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/NameEnvironment.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/NameEnvironment.java
index 0dc9550..7547997 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/NameEnvironment.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/NameEnvironment.java
@@ -275,12 +275,16 @@
// if we answer X.java & it no longer defines Y then the binary type looking for Y will think the class path is wrong
// let the recompile loop fix up dependents when the secondary type Y has been deleted from X.java
// Only enclosing type names are present in the additional units table, so strip off inner class specifications
- // when doing the lookup (https://bugs.eclipse.org/372418)
- String enclosingTypeName = qualifiedTypeName;
- int index = enclosingTypeName.indexOf('$');
- if (index > 0)
- enclosingTypeName = enclosingTypeName.substring(0, index);
- SourceFile unit = (SourceFile) this.additionalUnits.get(enclosingTypeName); // doesn't have file extension
+ // when doing the lookup (https://bugs.eclipse.org/372418).
+ // Also take care of $ in the name of the class (https://bugs.eclipse.org/Bug 377401)
+ int index = qualifiedTypeName.indexOf('$');
+ if (index > 0) {
+ String enclosingTypeName = qualifiedTypeName.substring(0, index);
+ SourceFile unit = (SourceFile) this.additionalUnits.get(enclosingTypeName); // doesn't have file extension
+ if (unit != null)
+ return new NameEnvironmentAnswer(unit, null /*no access restriction*/);
+ }
+ SourceFile unit = (SourceFile) this.additionalUnits.get(qualifiedTypeName); // doesn't have file extension
if (unit != null)
return new NameEnvironmentAnswer(unit, null /*no access restriction*/);
}
diff --git a/org.eclipse.jdt.core/scripts/binary/META-INF/MANIFEST.MF b/org.eclipse.jdt.core/scripts/binary/META-INF/MANIFEST.MF
index 2fda856..e609e12 100644
--- a/org.eclipse.jdt.core/scripts/binary/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.core/scripts/binary/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: Eclipse Compiler for Java(TM)
Bundle-SymbolicName: org.eclipse.jdt.core.compiler.batch
-Bundle-Version: 3.7.0.qualifier
+Bundle-Version: 3.8.0.qualifier
Bundle-ClassPath: .
Bundle-Vendor: Eclipse.org
Export-Package: org.eclipse.jdt.core,
diff --git a/org.eclipse.jdt.core/scripts/generateOTParser.sh b/org.eclipse.jdt.core/scripts/generateOTParser.sh
index 4dc1bf4..211c8e4 100755
--- a/org.eclipse.jdt.core/scripts/generateOTParser.sh
+++ b/org.eclipse.jdt.core/scripts/generateOTParser.sh
@@ -71,6 +71,9 @@
exit
fi
+scriptDir=`dirname "$0"`
+pluginDir=`readlink -f ${scriptDir}/..`
+
echo "Initiales Aufräumen"
if test -d output
then
@@ -276,12 +279,12 @@
exit
fi
fi
-echo "Verwende jdtcore.jar aus ${JDTCORE_JAR}"
+echo "Verwende JDT/Core aus ${pluginDir}/bin"
#cp ${JDTCORE_JAR} .
echo "UpdateParserFiles kompilieren"
-javac -classpath ${JDTCORE_JAR} UpdateParserFiles.java
+javac -classpath ${pluginDir}/bin UpdateParserFiles.java
echo "Ressourcendateien erzeugen (*.rsc)"
-java -classpath .:${JDTCORE_JAR} UpdateParserFiles javadcl.java javahdr.java
+java -classpath ${pluginDir}/bin:. UpdateParserFiles javadcl.java javahdr.java
cd ..
@@ -309,8 +312,8 @@
cp output/ParserBasicInformation.java $SOURCE/compiler/org/eclipse/jdt/internal/compiler/parser
cp output/parser*.rsc $SOURCE/compiler/org/eclipse/jdt/internal/compiler/parser
cp output/parser*.rsc $SOURCE/bin/org/eclipse/jdt/internal/compiler/parser
-cp output/readableNames.properties $SOURCE/compiler/org/eclipse/jdt/internal/compiler/parser
-cp output/readableNames.properties $SOURCE/bin/org/eclipse/jdt/internal/compiler/parser
+cp output/readableNames.props $SOURCE/compiler/org/eclipse/jdt/internal/compiler/parser
+cp output/readableNames.props $SOURCE/bin/org/eclipse/jdt/internal/compiler/parser
############################################################################################################################################################
#echo "Eclipse Build ausfhren mit Optionen build -os linux -ws motif"
#cd $SOURCE
diff --git a/org.eclipse.jdt.core/scripts/source/META-INF/MANIFEST.MF b/org.eclipse.jdt.core/scripts/source/META-INF/MANIFEST.MF
index a2344e0..21614ca 100644
--- a/org.eclipse.jdt.core/scripts/source/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.core/scripts/source/META-INF/MANIFEST.MF
@@ -2,6 +2,6 @@
Bundle-ManifestVersion: 2
Bundle-Name: Source of Eclipse Compiler for Java(TM)
Bundle-SymbolicName: org.eclipse.jdt.core.compiler.batch.source
-Bundle-Version: 3.7.0.qualifier
+Bundle-Version: 3.8.0.qualifier
Bundle-Vendor: Eclipse.org
-Eclipse-SourceBundle: org.eclipse.jdt.core.compiler.batch;version="3.7.0.qualifier";roots:="."
+Eclipse-SourceBundle: org.eclipse.jdt.core.compiler.batch;version="3.8.0.qualifier";roots:="."
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchPattern.java
index cb27404..900cfa5 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchPattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchPattern.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -41,15 +41,15 @@
* to create a search pattern.
* <p>
* Search patterns are used during the search phase to decode index entries that were added during the indexing phase
- * (see {@link SearchDocument#addIndexEntry(char[], char[])}). When an index is queried, the
+ * (see {@link SearchDocument#addIndexEntry(char[], char[])}). When an index is queried, the
* index categories and keys to consider are retrieved from the search pattern using {@link #getIndexCategories()} and
* {@link #getIndexKey()}, as well as the match rule (see {@link #getMatchRule()}). A blank pattern is
* then created (see {@link #getBlankPattern()}). This blank pattern is used as a record as follows.
- * For each index entry in the given index categories and that starts with the given key, the blank pattern is fed using
+ * For each index entry in the given index categories and that starts with the given key, the blank pattern is fed using
* {@link #decodeIndexKey(char[])}. The original pattern is then asked if it matches the decoded key using
* {@link #matchesDecodedKey(SearchPattern)}. If it matches, a search document is created for this index entry
* using {@link SearchParticipant#getDocument(String)}.
- *
+ *
* </p><p>
* This class is intended to be sub-classed by clients. A default behavior is provided for each of the methods above, that
* clients can override if they wish.
@@ -73,7 +73,7 @@
public static final int R_PREFIX_MATCH = 0x0001;
/**
- * Match rule: The search pattern contains one or more wild cards ('*' or '?').
+ * Match rule: The search pattern contains one or more wild cards ('*' or '?').
* A '*' wild-card can replace 0 or more characters in the search result.
* A '?' wild-card replaces exactly 1 character in the search result.
*/
@@ -81,6 +81,7 @@
/**
* Match rule: The search pattern contains a regular expression.
+ * <p><b>Warning:</b> The support for this rule is <b>not yet implemented</b></p>
*/
public static final int R_REGEXP_MATCH = 0x0004;
@@ -172,7 +173,7 @@
* <p>
* @see #camelCaseMatch(String, String) for a detailed explanation of Camel
* Case matching.
- *
+ *
* @since 3.2
*/
public static final int R_CAMELCASE_MATCH = 0x0080;
@@ -204,15 +205,15 @@
public static final int R_CAMELCASE_SAME_PART_COUNT_MATCH = 0x0100;
private static final int MODE_MASK = R_EXACT_MATCH
- | R_PREFIX_MATCH
- | R_PATTERN_MATCH
- | R_REGEXP_MATCH
+ | R_PREFIX_MATCH
+ | R_PATTERN_MATCH
+ | R_REGEXP_MATCH
| R_CAMELCASE_MATCH
| R_CAMELCASE_SAME_PART_COUNT_MATCH;
private int matchRule;
-/**
+ /**
* The focus element (used for reference patterns)
* @noreference This field is not intended to be referenced by clients.
*/
@@ -229,10 +230,10 @@
public boolean mustResolve = true;
/**
- * Creates a search pattern with the rule to apply for matching index keys.
+ * Creates a search pattern with the rule to apply for matching index keys.
* It can be exact match, prefix match, pattern match or regexp match.
* Rule can also be combined with a case sensitivity flag.
- *
+ *
* @param matchRule one of following match rule
* <ul>
* <li>{@link #R_EXACT_MATCH}</li>
@@ -373,10 +374,10 @@
* name = "HatMapper"
* result => true</li>
* </ol></pre>
- *
+ *
* @see #camelCaseMatch(String, int, int, String, int, int, boolean) for algorithm
* implementation
- *
+ *
* @param pattern the given pattern
* @param name the given name
* @return true if the pattern matches the given name, false otherwise
@@ -440,10 +441,10 @@
* name = "HashMapEntry"
* result => (samePartCount == false)</li>
* </ol></pre>
- *
+ *
* @see #camelCaseMatch(String, int, int, String, int, int, boolean) for algorithm
* implementation
- *
+ *
* @param pattern the given pattern
* @param name the given name
* @param samePartCount flag telling whether the pattern and the name should
@@ -470,7 +471,7 @@
/**
* Answers true if a sub-pattern matches the sub-part of the given name using
* CamelCase rules, or false otherwise. char[] CamelCase matching does NOT
- * accept explicit wild-cards '*' and '?' and is inherently case sensitive.
+ * accept explicit wild-cards '*' and '?' and is inherently case sensitive.
* Can match only subset of name/pattern, considering end positions as non-inclusive.
* The sub-pattern is defined by the patternStart and patternEnd positions.
* <p>
@@ -561,7 +562,7 @@
* nameEnd = 9
* result => true</li>
* </ol></pre>
- *
+ *
* @param pattern the given pattern
* @param patternStart the start index of the pattern, inclusive
* @param patternEnd the end index of the pattern, exclusive
@@ -576,9 +577,9 @@
}
/**
- * Answers true if a sub-pattern matches the sub-part of the given name using
+ * Answers true if a sub-pattern matches the sub-part of the given name using
* CamelCase rules, or false otherwise. char[] CamelCase matching does NOT
- * accept explicit wild-cards '*' and '?' and is inherently case sensitive.
+ * accept explicit wild-cards '*' and '?' and is inherently case sensitive.
* Can match only subset of name/pattern, considering end positions as
* non-inclusive. The sub-pattern is defined by the patternStart and patternEnd
* positions.
@@ -660,10 +661,10 @@
* nameEnd = 12
* result => (samePartCount == false)</li>
* </ol></pre>
- *
+ *
* @see CharOperation#camelCaseMatch(char[], int, int, char[], int, int, boolean)
* from which algorithm implementation has been entirely copied.
- *
+ *
* @param pattern the given pattern
* @param patternStart the start index of the pattern, inclusive
* @param patternEnd the end index of the pattern, exclusive
@@ -684,7 +685,7 @@
*/
public static final boolean camelCaseMatch(String pattern, int patternStart, int patternEnd, String name, int nameStart, int nameEnd, boolean samePartCount) {
return StringOperation.getCamelCaseMatchingRegions(pattern, patternStart, patternEnd, name, nameStart, nameEnd, samePartCount) != null;
- }
+}
/**
* Answers all the regions in a given name matching a given pattern using
@@ -797,30 +798,30 @@
final int nameLength = name.length();
if (pattern == null) {
return new int[] { 0, nameLength };
- }
+ }
final int patternLength = pattern.length();
boolean countMatch = false;
switch (matchRule) {
case SearchPattern.R_EXACT_MATCH:
if (patternLength == nameLength && pattern.equalsIgnoreCase(name)) {
return new int[] { 0, patternLength };
- }
+ }
break;
case SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE:
if (patternLength == nameLength && pattern.equals(name)) {
return new int[] { 0, patternLength };
}
- break;
+ break;
case SearchPattern.R_PREFIX_MATCH:
if (patternLength <= nameLength && name.substring(0, patternLength).equalsIgnoreCase(pattern)) {
return new int[] { 0, patternLength };
- }
+ }
break;
case SearchPattern.R_PREFIX_MATCH | SearchPattern.R_CASE_SENSITIVE:
if (name.startsWith(pattern)) {
return new int[] { 0, patternLength };
}
- break;
+ break;
case SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH:
countMatch = true;
//$FALL-THROUGH$
@@ -830,8 +831,8 @@
if (regions != null) return regions;
if (name.substring(0, patternLength).equalsIgnoreCase(pattern)) {
return new int[] { 0, patternLength };
+ }
}
- }
break;
case SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH | SearchPattern.R_CASE_SENSITIVE:
countMatch = true;
@@ -847,7 +848,7 @@
return StringOperation.getPatternMatchingRegions(pattern, 0, patternLength, name, 0, nameLength, true);
}
return null;
-}
+}
/**
* Returns a search pattern that combines the given two patterns into an
@@ -866,13 +867,14 @@
}
private static SearchPattern createFieldPattern(String patternString, int limitTo, int matchRule) {
-
- Scanner scanner = new Scanner(false /*comment*/, true /*whitespace*/, false /*nls*/, ClassFileConstants.JDK1_3/*sourceLevel*/, null /*taskTags*/, null/*taskPriorities*/, true/*taskCaseSensitive*/);
+ // use 1.7 as the source level as there are more valid tokens in 1.7 mode
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=376673
+ Scanner scanner = new Scanner(false /*comment*/, true /*whitespace*/, false /*nls*/, ClassFileConstants.JDK1_7/*sourceLevel*/, null /*taskTags*/, null/*taskPriorities*/, true/*taskCaseSensitive*/);
scanner.setSource(patternString.toCharArray());
final int InsideDeclaringPart = 1;
final int InsideType = 2;
int lastToken = -1;
-
+
String declaringType = null, fieldName = null;
String type = null;
int mode = InsideDeclaringPart;
@@ -908,7 +910,7 @@
fieldName += scanner.getCurrentTokenString();
}
break;
- // read type
+ // read type
case InsideType:
switch (token) {
case TerminalTokens.TokenNameWHITESPACE:
@@ -932,7 +934,7 @@
char[] fieldNameChars = fieldName.toCharArray();
if (fieldNameChars.length == 1 && fieldNameChars[0] == '*') fieldNameChars = null;
-
+
char[] declaringTypeQualification = null, declaringTypeSimpleName = null;
char[] typeQualification = null, typeSimpleName = null;
@@ -982,15 +984,16 @@
}
private static SearchPattern createMethodOrConstructorPattern(String patternString, int limitTo, int matchRule, boolean isConstructor) {
-
- Scanner scanner = new Scanner(false /*comment*/, true /*whitespace*/, false /*nls*/, ClassFileConstants.JDK1_3/*sourceLevel*/, null /*taskTags*/, null/*taskPriorities*/, true/*taskCaseSensitive*/);
+ // use 1.7 as the source level as there are more valid tokens in 1.7 mode
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=376673
+ Scanner scanner = new Scanner(false /*comment*/, true /*whitespace*/, false /*nls*/, ClassFileConstants.JDK1_7/*sourceLevel*/, null /*taskTags*/, null/*taskPriorities*/, true/*taskCaseSensitive*/);
scanner.setSource(patternString.toCharArray());
final int InsideSelector = 1;
final int InsideTypeArguments = 2;
final int InsideParameter = 3;
final int InsideReturnType = 4;
int lastToken = -1;
-
+
String declaringType = null, selector = null, parameterType = null;
String[] parameterTypes = null;
char[][] typeArguments = null;
@@ -1208,7 +1211,7 @@
if (selectorChars.length == 1 && selectorChars[0] == '*')
selectorChars = null;
}
-
+
char[] declaringTypeQualification = null, declaringTypeSimpleName = null;
char[] returnTypeQualification = null, returnTypeSimpleName = null;
char[][] parameterTypeQualifications = null, parameterTypeSimpleNames = null;
@@ -1284,7 +1287,7 @@
if (parameterTypeSimpleNames[i].length == 1 && parameterTypeSimpleNames[i][0] == '*')
parameterTypeSimpleNames[i] = null;
}
- }
+ }
// extract return type infos
if (returnType != null) {
// get return type part and signature
@@ -1309,7 +1312,7 @@
} else {
// because of an import
returnTypeQualification = CharOperation.concat(IIndexConstants.ONE_STAR, returnTypeQualification);
- }
+ }
returnTypeSimpleName = CharOperation.subarray(returnTypePart, lastDotPosition+1, returnTypePart.length);
} else {
returnTypeSimpleName = returnTypePart;
@@ -1320,10 +1323,10 @@
// Create method/constructor pattern
if (isConstructor) {
return new ConstructorPattern(
- declaringTypeSimpleName,
+ declaringTypeSimpleName,
declaringTypeQualification,
declaringTypeSignature,
- parameterTypeQualifications,
+ parameterTypeQualifications,
parameterTypeSimpleNames,
parameterTypeSignatures,
typeArguments,
@@ -1553,7 +1556,6 @@
* <li>{@link #R_EXACT_MATCH}</li>
* <li>{@link #R_PREFIX_MATCH}</li>
* <li>{@link #R_PATTERN_MATCH}</li>
- * <li>{@link #R_REGEXP_MATCH}</li>
* <li>{@link #R_CAMELCASE_MATCH}</li>
* <li>{@link #R_CAMELCASE_SAME_PART_COUNT_MATCH}</li>
* </ul>
@@ -1617,7 +1619,7 @@
}
/**
- * Returns a search pattern based on a given Java element.
+ * Returns a search pattern based on a given Java element.
* The pattern is used to trigger the appropriate search.
* <br>
* Note that for generic searches, the returned pattern consider {@link #R_ERASURE_MATCH} matches.
@@ -1733,7 +1735,7 @@
}
/**
- * Returns a search pattern based on a given Java element.
+ * Returns a search pattern based on a given Java element.
* The pattern is used to trigger the appropriate search, and can be parameterized as follows:
*
* @param element the Java element the search pattern is based on
@@ -1840,7 +1842,6 @@
* <li>{@link #R_EXACT_MATCH}</li>
* <li>{@link #R_PREFIX_MATCH}</li>
* <li>{@link #R_PATTERN_MATCH}</li>
- * <li>{@link #R_REGEXP_MATCH}</li>
* <li>{@link #R_CAMELCASE_MATCH}</li>
* <li>{@link #R_CAMELCASE_SAME_PART_COUNT_MATCH}</li>
* </ul>
@@ -1885,7 +1886,7 @@
// SH}
switch (element.getElementType()) {
case IJavaElement.FIELD :
- IField field = (IField) element;
+ IField field = (IField) element;
if (!ignoreDeclaringType) {
IType declaringClass = field.getDeclaringType();
declaringSimpleName = declaringClass.getElementName().toCharArray();
@@ -1920,12 +1921,12 @@
}
}
// Create field pattern
- searchPattern =
+ searchPattern =
new FieldPattern(
- name,
- declaringQualification,
- declaringSimpleName,
- typeQualification,
+ name,
+ declaringQualification,
+ declaringSimpleName,
+ typeQualification,
typeSimpleName,
typeSignature,
limitTo,
@@ -1939,7 +1940,7 @@
if (importDecl.isOnDemand()) {
searchPattern = createPackagePattern(elementName.substring(0, lastDot), maskedLimitTo, matchRule);
} else {
- searchPattern =
+ searchPattern =
createTypePattern(
elementName.substring(lastDot+1).toCharArray(),
elementName.substring(0, lastDot).toCharArray(),
@@ -1966,7 +1967,7 @@
findParamDeclarations = false;
break;
}
- searchPattern =
+ searchPattern =
new TypeParameterPattern(
findParamDeclarations,
findParamReferences,
@@ -2065,9 +2066,9 @@
if (isConstructor) {
searchPattern =
new ConstructorPattern(
- declaringSimpleName,
- declaringQualification,
- parameterQualifications,
+ declaringSimpleName,
+ declaringQualification,
+ parameterQualifications,
parameterSimpleNames,
parameterSignatures,
method,
@@ -2076,13 +2077,13 @@
} else {
searchPattern =
new MethodPattern(
- selector,
- declaringQualification,
- declaringSimpleName,
- returnQualification,
- returnSimpleName,
+ selector,
+ declaringQualification,
+ declaringSimpleName,
+ returnQualification,
+ returnSimpleName,
returnSignature,
- parameterQualifications,
+ parameterQualifications,
parameterSimpleNames,
parameterSignatures,
method,
@@ -2100,7 +2101,7 @@
case IJavaElement.TYPE :
IType type = (IType)element;
searchPattern = createTypePattern(
- type.getElementName().toCharArray(),
+ type.getElementName().toCharArray(),
type.getPackageFragment().getElementName().toCharArray(),
ignoreDeclaringType ? null : enclosingTypeNames(type),
null,
@@ -2122,27 +2123,27 @@
switch (limitTo) {
case IJavaSearchConstants.DECLARATIONS :
return new TypeDeclarationPattern(
- packageName,
- enclosingTypeNames,
- simpleName,
+ packageName,
+ enclosingTypeNames,
+ simpleName,
IIndexConstants.TYPE_SUFFIX,
matchRule);
case IJavaSearchConstants.REFERENCES :
if (type != null) {
return new TypeReferencePattern(
- CharOperation.concatWith(packageName, enclosingTypeNames, '.'),
+ CharOperation.concatWith(packageName, enclosingTypeNames, '.'),
simpleName,
type,
matchRule);
}
return new TypeReferencePattern(
- CharOperation.concatWith(packageName, enclosingTypeNames, '.'),
+ CharOperation.concatWith(packageName, enclosingTypeNames, '.'),
simpleName,
typeSignature,
matchRule);
- case IJavaSearchConstants.IMPLEMENTORS :
+ case IJavaSearchConstants.IMPLEMENTORS :
return new SuperTypeReferencePattern(
- CharOperation.concatWith(packageName, enclosingTypeNames, '.'),
+ CharOperation.concatWith(packageName, enclosingTypeNames, '.'),
simpleName,
SuperTypeReferencePattern.ONLY_SUPER_INTERFACES,
matchRule);
@@ -2157,19 +2158,19 @@
case IJavaSearchConstants.ALL_OCCURRENCES :
return new OrPattern(
new TypeDeclarationPattern(
- packageName,
- enclosingTypeNames,
- simpleName,
+ packageName,
+ enclosingTypeNames,
+ simpleName,
IIndexConstants.TYPE_SUFFIX,
- matchRule),
+ matchRule),
(type != null)
? new TypeReferencePattern(
- CharOperation.concatWith(packageName, enclosingTypeNames, '.'),
+ CharOperation.concatWith(packageName, enclosingTypeNames, '.'),
simpleName,
type,
matchRule)
: new TypeReferencePattern(
- CharOperation.concatWith(packageName, enclosingTypeNames, '.'),
+ CharOperation.concatWith(packageName, enclosingTypeNames, '.'),
simpleName,
typeSignature,
matchRule)
@@ -2177,7 +2178,7 @@
default:
if (type != null) {
return new TypeReferencePattern(
- CharOperation.concatWith(packageName, enclosingTypeNames, '.'),
+ CharOperation.concatWith(packageName, enclosingTypeNames, '.'),
simpleName,
type,
limitTo,
@@ -2188,8 +2189,9 @@
}
private static SearchPattern createTypePattern(String patternString, int limitTo, int matchRule, char indexSuffix) {
-
- Scanner scanner = new Scanner(false /*comment*/, true /*whitespace*/, false /*nls*/, ClassFileConstants.JDK1_3/*sourceLevel*/, null /*taskTags*/, null/*taskPriorities*/, true/*taskCaseSensitive*/);
+ // use 1.7 as the source level as there are more valid tokens in 1.7 mode
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=376673
+ Scanner scanner = new Scanner(false /*comment*/, true /*whitespace*/, false /*nls*/, ClassFileConstants.JDK1_7/*sourceLevel*/, null /*taskTags*/, null/*taskPriorities*/, true/*taskCaseSensitive*/);
scanner.setSource(patternString.toCharArray());
String type = null;
int token;
@@ -2296,7 +2298,7 @@
IType declaringType = type.getDeclaringType();
if (declaringType == null) return CharOperation.NO_CHAR_CHAR;
return CharOperation.arrayConcat(
- enclosingTypeNames(declaringType),
+ enclosingTypeNames(declaringType),
declaringType.getElementName().toCharArray());
case IJavaElement.COMPILATION_UNIT:
return CharOperation.NO_CHAR_CHAR;
@@ -2309,7 +2311,7 @@
new char[][] {declaringClass.getElementName().toCharArray(), IIndexConstants.ONE_STAR});
case IJavaElement.TYPE:
return CharOperation.arrayConcat(
- enclosingTypeNames((IType)parent),
+ enclosingTypeNames((IType)parent),
parent.getElementName().toCharArray());
default:
return null;
@@ -2317,13 +2319,13 @@
}
/**
- * Decode the given index key in this pattern. The decoded index key is used by
- * {@link #matchesDecodedKey(SearchPattern)} to find out if the corresponding index entry
+ * Decode the given index key in this pattern. The decoded index key is used by
+ * {@link #matchesDecodedKey(SearchPattern)} to find out if the corresponding index entry
* should be considered.
* <p>
* This method should be re-implemented in subclasses that need to decode an index key.
* </p>
- *
+ *
* @param key the given index key
*/
public void decodeIndexKey(char[] key) {
@@ -2368,7 +2370,7 @@
* Implementors of this method should return a new search pattern that is going to be used
* to decode index keys.
* </p>
- *
+ *
* @return a new blank pattern
* @see #decodeIndexKey(char[])
*/
@@ -2382,7 +2384,7 @@
* This method should be re-implemented in subclasses that need to narrow down the
* index query.
* </p>
- *
+ *
* @return an index key from this pattern, or <code>null</code> if all index entries are matched.
*/
public char[] getIndexKey() {
@@ -2397,7 +2399,7 @@
* This method should be re-implemented in subclasses that need to narrow down the
* index query.
* </p>
- *
+ *
* @return an array of index categories
*/
public char[][] getIndexCategories() {
@@ -2406,7 +2408,7 @@
/**
* Returns the rule to apply for matching index keys. Can be exact match, prefix match, pattern match or regexp match.
* Rule can also be combined with a case sensitivity flag.
- *
+ *
* @return one of R_EXACT_MATCH, R_PREFIX_MATCH, R_PATTERN_MATCH, R_REGEXP_MATCH combined with R_CASE_SENSITIVE,
* e.g. R_EXACT_MATCH | R_CASE_SENSITIVE if an exact and case sensitive match is requested,
* or R_PREFIX_MATCH if a prefix non case sensitive match is requested.
@@ -2427,7 +2429,7 @@
* This method should be re-implemented in subclasses that need to narrow down the
* index query.
* </p>
- *
+ *
* @param decodedPattern a pattern representing a decoded index key
* @return whether this pattern matches the given pattern
*/
@@ -2441,7 +2443,7 @@
* This method should be re-implemented in subclasses that need to define how
* a name matches a pattern.
* </p>
- *
+ *
* @param pattern the given pattern, or <code>null</code> to represent "*"
* @param name the given name
* @return whether the given name matches the given pattern
@@ -2516,7 +2518,7 @@
* {@link #R_CAMELCASE_SAME_PART_COUNT_MATCH} flags are reset</b>
* if they are tentatively combined.
* </li>
- * <li>when the {@link #R_CAMELCASE_MATCH} flag is set, then <b>other
+ * <li>when the {@link #R_CAMELCASE_MATCH} flag is set, then <b>other
* {@link #R_PREFIX_MATCH} or {@link #R_CAMELCASE_SAME_PART_COUNT_MATCH}
* flags are reset</b> if they are tentatively combined.<br>
* Reversely, if the string pattern cannot be a camel case pattern (i.e. contains
@@ -2548,7 +2550,7 @@
// Verify Regexp match rule
if ((matchRule & R_REGEXP_MATCH) != 0) {
- if ((matchRule & R_PATTERN_MATCH) != 0 || (matchRule & R_PREFIX_MATCH) != 0 ||
+ if ((matchRule & R_PATTERN_MATCH) != 0 || (matchRule & R_PREFIX_MATCH) != 0 ||
(matchRule & R_CAMELCASE_MATCH) != 0 || (matchRule & R_CAMELCASE_SAME_PART_COUNT_MATCH) != 0) {
// regexp is not supported yet
return -1;
@@ -2588,7 +2590,7 @@
}
return matchRule;
}
-
+
// Verify Camel Case with same count of parts
if ((matchRule & R_CAMELCASE_SAME_PART_COUNT_MATCH) != 0) {
// reset other incompatible flags
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java
index d0b5403..c4ff21d 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -253,11 +253,25 @@
return super.getJobFamily();
return this.containerPath.toOSString(); // external jar
}
+ private boolean isIdentifier() throws InvalidInputException {
+ switch(this.scanner.scanIdentifier()) {
+ // assert and enum will not be recognized as java identifiers
+ // in 1.7 mode, which are in 1.3.
+ case TerminalTokens.TokenNameIdentifier:
+ case TerminalTokens.TokenNameassert:
+ case TerminalTokens.TokenNameenum:
+ return true;
+ default:
+ return false;
+ }
+ }
private boolean isValidPackageNameForClass(String className) {
char[] classNameArray = className.toCharArray();
+ // use 1.7 as the source level as there are more valid identifiers in 1.7 mode
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=376673
if (this.scanner == null)
this.scanner = new Scanner(false /* comment */, true /* whitespace */, false /* nls */,
- ClassFileConstants.JDK1_3/* sourceLevel */, null/* taskTag */, null/* taskPriorities */, true /* taskCaseSensitive */);
+ ClassFileConstants.JDK1_7/* sourceLevel */, null/* taskTag */, null/* taskPriorities */, true /* taskCaseSensitive */);
//{ObjectTeams: don't exclude OT keywords appearing as package names:
this.scanner.forceBaseIsIdentifier();
this.scanner.parsePureJavaOnly = true;
@@ -266,14 +280,12 @@
this.scanner.setSource(classNameArray);
this.scanner.eofPosition = classNameArray.length - SuffixConstants.SUFFIX_CLASS.length;
try {
- if (this.scanner.scanIdentifier() == TerminalTokens.TokenNameIdentifier) {
+ if (isIdentifier()) {
while (this.scanner.eofPosition > this.scanner.currentPosition) {
if (this.scanner.getNextChar() != '/' || this.scanner.eofPosition <= this.scanner.currentPosition) {
return false;
}
- if (this.scanner.scanIdentifier() != TerminalTokens.TokenNameIdentifier) {
- return false;
- }
+ if (!isIdentifier()) return false;
}
return true;
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java
index 446b231..5b9256a 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java
@@ -9,6 +9,9 @@
* IBM Corporation - initial API and implementation
* Fraunhofer FIRST - extended API and implementation
* Technical University Berlin - extended API and implementation
+ * Samrat Dhillon samrat.dhillon@gmail.com - Search for method references is
+ * returning methods as overriden even if the superclass's method is
+ * only package-visible - https://bugs.eclipse.org/357547
*******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
@@ -83,10 +86,18 @@
//extra reference info
public char[][][] allSuperDeclaringTypeNames;
+// This is set only if focus is null. In these cases
+// it will be hard to determine if the super class is of the same package
+// at a latter point. Hence, this array is created with all the super class
+// names of the same package name as of the matching class name.
+// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=357547
+private char[][][] samePkgSuperDeclaringTypeNames;
+
private MatchLocator matchLocator;
//method declarations which parameters verification fail
private HashMap methodDeclarationsWithInvalidParam = new HashMap();
+
public MethodLocator(MethodPattern pattern) {
super(pattern);
@@ -127,14 +138,16 @@
start = System.currentTimeMillis();
}
try {
- this.allSuperDeclaringTypeNames =
+ SuperTypeNamesCollector namesCollector =
new SuperTypeNamesCollector(
this.pattern,
this.pattern.declaringSimpleName,
this.pattern.declaringQualification,
locator,
this.pattern.declaringType,
- locator.progressMonitor).collect();
+ locator.progressMonitor);
+ this.allSuperDeclaringTypeNames = namesCollector.collect();
+ this.samePkgSuperDeclaringTypeNames = namesCollector.getSamePackageSuperTypeNames();
this.matchLocator = locator;
} catch (JavaModelException e) {
// inaccurate matches will be found
@@ -165,7 +178,7 @@
*/
protected boolean isVirtualInvoke(MethodBinding method, MessageSend messageSend) {
return !method.isStatic() &&
-//ObjectTeams: private role methods are visible in the implicit sub roles (???1.2.1. (e))
+//ObjectTeams: private role methods are visible in the implicit sub roles (OTJLD 1.2.1. (e))
(
// orig:
!method.isPrivate()
@@ -173,7 +186,9 @@
|| (method.declaringClass.isRole() && messageSend.receiver.isImplicitThis()))
&& !(messageSend instanceof TSuperMessageSend) // similar to "super" but for codegen it's a "this"
//jsv}
- && !messageSend.isSuperAccess();
+ && !messageSend.isSuperAccess()
+ && !(method.isDefault() && this.pattern.focus != null
+ && !CharOperation.equals(this.pattern.declaringQualification, method.declaringClass.qualifiedPackageName()));
}
public int match(ASTNode node, MatchingNodeSet nodeSet) {
int declarationsLevel = IMPOSSIBLE_MATCH;
@@ -675,14 +690,14 @@
// Report match for binary
if (type.isBinary()) {
- IMethod method = null;
+ IMethod method = null;
//{ObjectTeams: for callin methods use the retrenched parameters:
/* orig:
- TypeBinding[] parameters = methodBinding.original().parameters;
+ TypeBinding[] parameters = methodBinding.original().parameters;
:giro */
- TypeBinding[] parameters = methodBinding.original().getSourceParameters();
+ TypeBinding[] parameters = methodBinding.original().getSourceParameters();
// SH}
- int parameterLength = parameters.length;
+ int parameterLength = parameters.length;
char[][] parameterTypes = new char[parameterLength][];
for (int i = 0; i<parameterLength; i++) {
char[] typeName = parameters[i].qualifiedSourceName();
@@ -823,7 +838,7 @@
subType = CharOperation.compareWith(this.pattern.declaringQualification, method.declaringClass.fPackage.shortReadableName()) == 0;
}
int declaringLevel = subType
- ? resolveLevelAsSubtype(this.pattern.declaringSimpleName, this.pattern.declaringQualification, method.declaringClass, method.selector, null)
+ ? resolveLevelAsSubtype(this.pattern.declaringSimpleName, this.pattern.declaringQualification, method.declaringClass, method.selector, null, method.declaringClass.qualifiedPackageName(), method.isDefault())
: resolveLevelForType(this.pattern.declaringSimpleName, this.pattern.declaringQualification, method.declaringClass);
return (methodLevel & MATCH_LEVEL_MASK) > (declaringLevel & MATCH_LEVEL_MASK) ? declaringLevel : methodLevel; // return the weaker match
}
@@ -856,14 +871,15 @@
int declaringLevel;
if (isVirtualInvoke(method, messageSend) && (messageSend.actualReceiverType instanceof ReferenceBinding)) {
ReferenceBinding methodReceiverType = (ReferenceBinding) messageSend.actualReceiverType;
- declaringLevel = resolveLevelAsSubtype(this.pattern.declaringSimpleName, this.pattern.declaringQualification, methodReceiverType, method.selector, method.parameters);
+ declaringLevel = resolveLevelAsSubtype(this.pattern.declaringSimpleName, this.pattern.declaringQualification, methodReceiverType, method.selector, method.parameters, methodReceiverType.qualifiedPackageName(), method.isDefault());
if (declaringLevel == IMPOSSIBLE_MATCH) {
if (method.declaringClass == null || this.allSuperDeclaringTypeNames == null) {
declaringLevel = INACCURATE_MATCH;
} else {
- if (resolveLevelAsSuperInvocation(methodReceiverType, method.parameters, true)) {
- declaringLevel = methodLevel // since this is an ACCURATE_MATCH so return the possibly weaker match
- | SUPER_INVOCATION_FLAVOR; // this is an overridden method => add flavor to returned level
+ char[][][] superTypeNames = (method.isDefault() && this.pattern.focus == null) ? this.samePkgSuperDeclaringTypeNames: this.allSuperDeclaringTypeNames;
+ if (superTypeNames != null && resolveLevelAsSuperInvocation(methodReceiverType, method.parameters, superTypeNames, true)) {
+ declaringLevel = methodLevel // since this is an ACCURATE_MATCH so return the possibly weaker match
+ | SUPER_INVOCATION_FLAVOR; // this is an overridden method => add flavor to returned level
}
}
}
@@ -890,7 +906,7 @@
* Returns INACCURATE_MATCH if resolve fails
* Returns IMPOSSIBLE_MATCH if it doesn't.
*/
-protected int resolveLevelAsSubtype(char[] simplePattern, char[] qualifiedPattern, ReferenceBinding type, char[] methodName, TypeBinding[] argumentTypes) {
+protected int resolveLevelAsSubtype(char[] simplePattern, char[] qualifiedPattern, ReferenceBinding type, char[] methodName, TypeBinding[] argumentTypes, char[] packageName, boolean isDefault) {
if (type == null) return INACCURATE_MATCH;
int level = resolveLevelForType(simplePattern, qualifiedPattern, type);
@@ -901,6 +917,9 @@
}
// SH}
if (level != IMPOSSIBLE_MATCH) {
+ if (isDefault && !CharOperation.equals(packageName, type.qualifiedPackageName())) {
+ return IMPOSSIBLE_MATCH;
+ }
MethodBinding method = argumentTypes == null ? null : getMethodBinding(type, methodName, argumentTypes);
if (((method != null && !method.isAbstract()) || !type.isAbstract()) && !type.isInterface()) { // if concrete, then method is overridden
level |= OVERRIDDEN_METHOD_FLAVOR;
@@ -910,7 +929,7 @@
// matches superclass
if (!type.isInterface() && !CharOperation.equals(type.compoundName, TypeConstants.JAVA_LANG_OBJECT)) {
- level = resolveLevelAsSubtype(simplePattern, qualifiedPattern, type.superclass(), methodName, argumentTypes);
+ level = resolveLevelAsSubtype(simplePattern, qualifiedPattern, type.superclass(), methodName, argumentTypes, packageName, isDefault);
if (level != IMPOSSIBLE_MATCH) {
if (argumentTypes != null) {
// need to verify if method may be overridden
@@ -935,7 +954,7 @@
if (type.roleModel != null) {
ReferenceBinding[] tsuperTypes = roleModel.getTSuperRoleBindings();
for (int t = tsuperTypes.length-1; t>=0; t--) { // check highest prio first (which comes last in the array)
- level = resolveLevelAsSubtype(simplePattern, qualifiedPattern, tsuperTypes[t], methodName, argumentTypes);
+ level = resolveLevelAsSubtype(simplePattern, qualifiedPattern, tsuperTypes[t], methodName, argumentTypes, packageName, isDefault);
// OT_COPY_PASTE from above "matches superclass":
if (level != IMPOSSIBLE_MATCH) {
if (argumentTypes != null) {
@@ -980,7 +999,7 @@
ReferenceBinding[] interfaces = type.superInterfaces();
if (interfaces == null) return INACCURATE_MATCH;
for (int i = 0; i < interfaces.length; i++) {
- level = resolveLevelAsSubtype(simplePattern, qualifiedPattern, interfaces[i], methodName, null);
+ level = resolveLevelAsSubtype(simplePattern, qualifiedPattern, interfaces[i], methodName, null, packageName, isDefault);
if (level != IMPOSSIBLE_MATCH) {
if (!type.isAbstract() && !type.isInterface()) { // if concrete class, then method is overridden
level |= OVERRIDDEN_METHOD_FLAVOR;
@@ -995,10 +1014,10 @@
* Return whether the given type binding or one of its possible super interfaces
* matches a type in the declaring type names hierarchy.
*/
-private boolean resolveLevelAsSuperInvocation(ReferenceBinding type, TypeBinding[] argumentTypes, boolean methodAlreadyVerified) {
+private boolean resolveLevelAsSuperInvocation(ReferenceBinding type, TypeBinding[] argumentTypes, char[][][] superTypeNames, boolean methodAlreadyVerified) {
char[][] compoundName = type.compoundName;
- for (int i = 0, max = this.allSuperDeclaringTypeNames.length; i < max; i++) {
- if (CharOperation.equals(this.allSuperDeclaringTypeNames[i], compoundName)) {
+ for (int i = 0, max = superTypeNames.length; i < max; i++) {
+ if (CharOperation.equals(superTypeNames[i], compoundName)) {
// need to verify if the type implements the pattern method
if (methodAlreadyVerified) return true; // already verified before enter into this method (see resolveLevel(MessageSend))
MethodBinding[] methods = type.getMethods(this.pattern.selector);
@@ -1030,7 +1049,7 @@
ReferenceBinding[] interfaces = type.superInterfaces();
if (interfaces == null) return false;
for (int i = 0; i < interfaces.length; i++) {
- if (resolveLevelAsSuperInvocation(interfaces[i], argumentTypes, false)) {
+ if (resolveLevelAsSuperInvocation(interfaces[i], argumentTypes, superTypeNames, false)) {
return true;
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeNamesCollector.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeNamesCollector.java
index fd53a9b..e9cd9ca 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeNamesCollector.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeNamesCollector.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -49,19 +49,19 @@
public boolean visit(TypeDeclaration typeDeclaration, BlockScope scope) {
ReferenceBinding binding = typeDeclaration.binding;
if (SuperTypeNamesCollector.this.matches(binding))
- collectSuperTypeNames(binding);
+ collectSuperTypeNames(binding, binding.compoundName);
return true;
}
public boolean visit(TypeDeclaration typeDeclaration, CompilationUnitScope scope) {
ReferenceBinding binding = typeDeclaration.binding;
if (SuperTypeNamesCollector.this.matches(binding))
- collectSuperTypeNames(binding);
+ collectSuperTypeNames(binding, binding.compoundName);
return true;
}
public boolean visit(TypeDeclaration memberTypeDeclaration, ClassScope scope) {
ReferenceBinding binding = memberTypeDeclaration.binding;
if (SuperTypeNamesCollector.this.matches(binding))
- collectSuperTypeNames(binding);
+ collectSuperTypeNames(binding, binding.compoundName);
return true;
}
public boolean visit(FieldDeclaration fieldDeclaration, MethodScope scope) {
@@ -81,17 +81,20 @@
char[] typeSimpleName;
char[] typeQualification;
MatchLocator locator;
-IType type;
+IType type;
IProgressMonitor progressMonitor;
char[][][] result;
int resultIndex;
+char[][][] samePackageSuperTypeName; // set only if focus is null
+int samePackageIndex;
+
public SuperTypeNamesCollector(
SearchPattern pattern,
char[] typeSimpleName,
char[] typeQualification,
MatchLocator locator,
- IType type,
+ IType type,
IProgressMonitor progressMonitor) {
this.pattern = pattern;
@@ -102,6 +105,21 @@
this.progressMonitor = progressMonitor;
}
+private boolean addIfSamePackage(char[][] compoundName, char[][] path) {
+ if (compoundName.length != path.length) return false;
+ int resultLength = this.samePackageSuperTypeName.length;
+ for (int i = 0; i < resultLength; i++)
+ if (CharOperation.equals(this.samePackageSuperTypeName[i], compoundName)) return false; // already known
+
+ for (int i = 0, length = compoundName.length - 1; i < length; i ++) {
+ if (!CharOperation.equals(compoundName[i], path[i])) return false;
+ }
+ if (resultLength == this.samePackageIndex)
+ System.arraycopy(this.samePackageSuperTypeName, 0, this.samePackageSuperTypeName = new char[resultLength*2][][], 0, resultLength);
+ this.samePackageSuperTypeName[this.samePackageIndex++] = compoundName;
+ return true;
+}
+
protected void addToResult(char[][] compoundName) {
int resultLength = this.result.length;
for (int i = 0; i < resultLength; i++)
@@ -111,6 +129,7 @@
System.arraycopy(this.result, 0, this.result = new char[resultLength*2][][], 0, resultLength);
this.result[this.resultIndex++] = compoundName;
}
+
/*
* Parse the given compiation unit and build its type bindings.
*/
@@ -119,7 +138,7 @@
org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit = (org.eclipse.jdt.internal.compiler.env.ICompilationUnit) compilationUnit;
CompilationResult compilationResult = new CompilationResult(sourceUnit, 1, 1, 0);
- CompilationUnitDeclaration unit =
+ CompilationUnitDeclaration unit =
isTopLevelOrMember ?
this.locator.basicParser().dietParse(sourceUnit, compilationResult) :
this.locator.basicParser().parse(sourceUnit, compilationResult);
@@ -157,7 +176,7 @@
if (this.type.isBinary()) {
BinaryTypeBinding binding = this.locator.cacheBinaryType(this.type, null);
if (binding != null)
- collectSuperTypeNames(binding);
+ collectSuperTypeNames(binding, null);
} else {
ICompilationUnit unit = this.type.getCompilationUnit();
SourceType sourceType = (SourceType) this.type;
@@ -165,8 +184,8 @@
CompilationUnitDeclaration parsedUnit = buildBindings(unit, isTopLevelOrMember);
if (parsedUnit != null) {
TypeDeclaration typeDecl = new ASTNodeFinder(parsedUnit).findType(this.type);
- if (typeDecl != null && typeDecl.binding != null)
- collectSuperTypeNames(typeDecl.binding);
+ if (typeDecl != null && typeDecl.binding != null)
+ collectSuperTypeNames(typeDecl.binding, null);
}
}
} catch (AbortCompilation e) {
@@ -182,11 +201,12 @@
String[] paths = getPathsOfDeclaringType();
if (paths == null) return null;
- // Create bindings from source types and binary types and collect super type names of the type declaration
+ // Create bindings from source types and binary types and collect super type names of the type declaration
// that match the given declaring type
Util.sort(paths); // sort by projects
JavaProject previousProject = null;
this.result = new char[1][][];
+ this.samePackageSuperTypeName = new char[1][][];
this.resultIndex = 0;
for (int i = 0, length = paths.length; i < length; i++) {
try {
@@ -207,7 +227,7 @@
IClassFile classFile = (IClassFile) openable;
BinaryTypeBinding binding = this.locator.cacheBinaryType(classFile.getType(), null);
if (matches(binding))
- collectSuperTypeNames(binding);
+ collectSuperTypeNames(binding, binding.compoundName);
}
} catch (AbortCompilation e) {
// ignore: continue with next element
@@ -222,11 +242,15 @@
/**
* Collects the names of all the supertypes of the given type.
*/
-protected void collectSuperTypeNames(ReferenceBinding binding) {
+protected void collectSuperTypeNames(ReferenceBinding binding, char[][] path) {
ReferenceBinding superclass = binding.superclass();
+ if (path != null) {
+ boolean samePackage = addIfSamePackage(superclass.compoundName, path);
+ if (!samePackage) path = null;
+ }
if (superclass != null) {
addToResult(superclass.compoundName);
- collectSuperTypeNames(superclass);
+ collectSuperTypeNames(superclass, null);
}
ReferenceBinding[] interfaces = binding.superInterfaces();
@@ -234,7 +258,7 @@
for (int i = 0; i < interfaces.length; i++) {
ReferenceBinding interfaceBinding = interfaces[i];
addToResult(interfaceBinding.compoundName);
- collectSuperTypeNames(interfaceBinding);
+ collectSuperTypeNames(interfaceBinding, null);
}
}
}
@@ -257,19 +281,22 @@
pathCollector.acceptIndexMatch(documentPath, indexRecord, participant, access);
}
return true;
- }
- };
+ }
+ };
indexManager.performConcurrentJob(
new PatternSearchJob(
- searchPattern,
+ searchPattern,
new JavaSearchParticipant(),
- scope,
+ scope,
searchRequestor),
IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
this.progressMonitor == null ? null : new SubProgressMonitor(this.progressMonitor, 100));
return pathCollector.getPaths();
}
+public char[][][] getSamePackageSuperTypeNames() {
+ return this.samePackageSuperTypeName;
+}
protected boolean matches(char[][] compoundName) {
int length = compoundName.length;
if (length == 0) return false;
@@ -289,7 +316,7 @@
int dollar = CharOperation.indexOf('$', simpleName);
if (dollar == -1) return false;
compoundName[last] = CharOperation.subarray(simpleName, 0, dollar);
- compoundName[length] = CharOperation.subarray(simpleName, dollar+1, simpleName.length);
+ compoundName[length] = CharOperation.subarray(simpleName, dollar+1, simpleName.length);
return this.matches(compoundName);
}
protected boolean matches(ReferenceBinding binding) {