Update jdt.core to I20161005-1430
diff --git a/org.eclipse.jdt.core.tests.compiler/.classpath b/org.eclipse.jdt.core.tests.compiler/.classpath
index b277a8a..01836c4 100644
--- a/org.eclipse.jdt.core.tests.compiler/.classpath
+++ b/org.eclipse.jdt.core.tests.compiler/.classpath
@@ -2,6 +2,6 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/org.eclipse.jdt.core.tests.compiler/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.jdt.core.tests.compiler/.settings/org.eclipse.jdt.core.prefs
index 1c33923..9426fc4 100644
--- a/org.eclipse.jdt.core.tests.compiler/.settings/org.eclipse.jdt.core.prefs
+++ b/org.eclipse.jdt.core.tests.compiler/.settings/org.eclipse.jdt.core.prefs
@@ -15,9 +15,9 @@
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
@@ -120,6 +120,6 @@
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.7
+org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.incompatibleJDKLevel=ignore
org.eclipse.jdt.core.incompleteClasspath=error
diff --git a/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF b/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF
index dc40e8b..e99046e 100644
--- a/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF
@@ -24,7 +24,7 @@
org.eclipse.jdt.annotation;bundle-version="[2.0.0,3.0.0)";resolution:=optional,
org.eclipse.objectteams.otdt
Import-Package: org.eclipse.jdt.internal.compiler.apt.dispatch
-Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Eclipse-BundleShape: dir
Bundle-Activator: org.eclipse.jdt.core.tests.compiler.Activator
Bundle-ActivationPolicy: lazy
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest18.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest18.java
index 852c395..01472ff 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest18.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionParserTest18.java
@@ -17,6 +17,7 @@
public class SelectionParserTest18 extends AbstractSelectionTest {
static {
// TESTS_NUMBERS = new int[] { 53 };
+// TESTS_NAMES = new String[] { "test495912" };
}
public static Test suite() {
return buildMinimalComplianceTestSuite(SelectionParserTest18.class, F_1_8);
@@ -249,4 +250,207 @@
expectedReplacedSource,
testName);
}
+public void test495912() {
+ String string =
+ "package xy;\n" +
+ "public class Test {\n" +
+ " {\n" +
+ " Runnable r = () -> {\n" +
+ " Integer i= 1;\n" +
+ " byte b= i.byteValue();\n" +
+ " if (true) {\n" +
+ " if (false) {\n" +
+ " }\n" +
+ " }\n" +
+ " String s= new String();\n" +
+ " };\n" +
+ " }\n" +
+ " public void foo(Runnable r) {\n" +
+ " }\n" +
+ "}";
+
+ String expectedCompletionNodeToString = "<SelectOnMessageSend:i.byteValue()>";
+
+ String completionIdentifier = "byteValue";
+ String expectedUnitDisplayString =
+ "package xy;\n" +
+ "public class Test {\n" +
+ " {\n" +
+ " Runnable r = () -> {\n" +
+ " Integer i;\n" +
+ " byte b = <SelectOnMessageSend:i.byteValue()>;\n" +
+ " if (true)\n" +
+ " {\n" +
+ " if (false)\n" +
+ " {\n" +
+ " }\n" +
+ " }\n" +
+ " String s;\n" +
+ " };\n" +
+ " }\n" +
+ " public Test() {\n" +
+ " }\n" +
+ " public void foo(Runnable r) {\n" +
+ " }\n" +
+ "}\n";
+ String expectedReplacedSource = "i.byteValue()";
+ String testName = "<select>";
+
+ int selectionStart = string.indexOf("byteValue");
+ int selectionEnd = selectionStart + completionIdentifier.length() - 1;
+
+ this.checkMethodParse(
+ string.toCharArray(),
+ selectionStart,
+ selectionEnd,
+ expectedCompletionNodeToString,
+ expectedUnitDisplayString,
+ completionIdentifier,
+ expectedReplacedSource,
+ testName);
+}
+public void test495912a() {
+ String string =
+ "package xy;\n" +
+ "public class Test {\n" +
+ " {\n" +
+ " Runnable r = () -> {\n" +
+ " Integer i= 1;\n" +
+ " byte b= i.byteValue();\n" +
+ " if (true) {\n" +
+ " if (false) {\n" +
+ " }\n" +
+ " }\n" +
+ " for (int i1 = 0; i1 < 42; i1++) {\n" +
+ " }\n" +
+ " };\n" +
+ " }\n" +
+ " public void foo(Runnable r) {\n" +
+ " }\n" +
+ "}";
+
+ String expectedCompletionNodeToString = "<SelectOnMessageSend:i.byteValue()>";
+
+ String completionIdentifier = "byteValue";
+ String expectedUnitDisplayString =
+ "package xy;\n" +
+ "public class Test {\n" +
+ " {\n" +
+ " Runnable r = () -> {\n" +
+ " Integer i;\n" +
+ " byte b = <SelectOnMessageSend:i.byteValue()>;\n" +
+ " if (true)\n" +
+ " {\n" +
+ " if (false)\n" +
+ " {\n" +
+ " }\n" +
+ " }\n" +
+ " for (int i1;; (i1 < 42); i1 ++) \n" +
+ " {\n" +
+ " }\n" +
+ " };\n" +
+ " }\n" +
+ " public Test() {\n" +
+ " }\n" +
+ " public void foo(Runnable r) {\n" +
+ " }\n" +
+ "}\n";
+ String expectedReplacedSource = "i.byteValue()";
+ String testName = "<select>";
+
+ int selectionStart = string.indexOf("byteValue");
+ int selectionEnd = selectionStart + completionIdentifier.length() - 1;
+
+ this.checkMethodParse(
+ string.toCharArray(),
+ selectionStart,
+ selectionEnd,
+ expectedCompletionNodeToString,
+ expectedUnitDisplayString,
+ completionIdentifier,
+ expectedReplacedSource,
+ testName);
+}
+public void test495912b() {
+ String string =
+ "package xy;\n" +
+ "import org.eclipse.e4.ui.internal.workbench.PartServiceImpl;\n" +
+ "import org.eclipse.e4.ui.model.application.ui.basic.MPart;\n" +
+ "import org.eclipse.swt.widgets.Table;\n" +
+ "import org.eclipse.ui.IWorkbenchWindow;\n" +
+ "public abstract class CycleViewHandler extends CycleBaseHandler {\n" +
+ " @Override\n" +
+ " protected void addItems(Table table, WorkbenchPage page) {\n" +
+ " List<MPart> parts = null;\n" +
+ " parts.stream().sorted((firstPart, secondPart) -> {\n" +
+ " Long firstPartActivationTime = (Long) firstPart.getTransientData()\n" +
+ " .getOrDefault(PartServiceImpl.PART_ACTIVATION_TIME, Long.MIN_VALUE);\n" +
+ " Long secondPartActivationTime = (Long) secondPart.getTransientData()\n" +
+ " .getOrDefault(PartServiceImpl.PART_ACTIVATION_TIME, Long.MIN_VALUE);\n" +
+ " return 0;\n" +
+ " }).forEach(part -> {\n" +
+ " if (true) {\n" +
+ " if (true) {\n" +
+ " }\n" +
+ " } \n" +
+ " else {\n" +
+ " IWorkbenchWindow iwbw = page.getWorkbenchWindow();\n" +
+ " if (true){\n" +
+ " }\n" +
+ " }\n" +
+ " });\n" +
+ " }\n" +
+ "}";
+
+ String expectedSelectionNodeToString = "<SelectOnMessageSend:firstPart.getTransientData()>";
+
+ String selectionIdentifier = "getTransientData";
+ String expectedUnitDisplayString =
+ "package xy;\n" +
+ "import org.eclipse.e4.ui.internal.workbench.PartServiceImpl;\n" +
+ "import org.eclipse.e4.ui.model.application.ui.basic.MPart;\n" +
+ "import org.eclipse.swt.widgets.Table;\n" +
+ "import org.eclipse.ui.IWorkbenchWindow;\n" +
+ "public abstract class CycleViewHandler extends CycleBaseHandler {\n" +
+ " public CycleViewHandler() {\n" +
+ " }\n" +
+ " protected @Override void addItems(Table table, WorkbenchPage page) {\n" +
+ " List<MPart> parts;\n" + // this is the missing part without the fix in RecoveredMethod#add(Block....)
+ " parts.stream().sorted((<no type> firstPart, <no type> secondPart) -> {\n" +
+ " Long firstPartActivationTime = (Long) <SelectOnMessageSend:firstPart.getTransientData()>.getOrDefault(PartServiceImpl.PART_ACTIVATION_TIME, Long.MIN_VALUE);\n" +
+ " Long secondPartActivationTime;\n" +
+ " return 0;\n" +
+ "}).forEach((<no type> part) -> {\n" +
+ " if (true)\n" +
+ " {\n" +
+ " if (true)\n" +
+ " {\n" +
+ " }\n" +
+ " }\n" +
+ " else\n" +
+ " {\n" +
+ " IWorkbenchWindow iwbw;\n" +
+ " if (true)\n" +
+ " {\n" +
+ " }\n" +
+ " }\n" +
+ "});\n" +
+ " }\n" +
+ "}\n";
+ String expectedReplacedSource = "firstPart.getTransientData()";
+ String testName = "<select>";
+
+ int selectionStart = string.indexOf("getTransientData");
+ int selectionEnd = selectionStart + selectionIdentifier.length() - 1;
+
+ this.checkMethodParse(
+ string.toCharArray(),
+ selectionStart,
+ selectionEnd,
+ expectedSelectionNodeToString,
+ expectedUnitDisplayString,
+ selectionIdentifier,
+ expectedReplacedSource,
+ testName);
+}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
index 28b58aa..fb9c9a2 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
@@ -395,7 +395,11 @@
}
} : null,
EclipseBug177715 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=177715
- new EclipseHasABug(MismatchType.JavacErrorsEclipseNone) : null,
+ new EclipseHasABug(MismatchType.JavacErrorsEclipseNone) {
+ Excuse excuseFor(JavacCompiler compiler) {
+ return compiler.compliance < ClassFileConstants.JDK1_8 ? this : null; // in 1.8 rejected by both compilers
+ }
+ } : null,
EclipseBug207935 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=207935
new EclipseHasABug(MismatchType.EclipseErrorsJavacNone | MismatchType.EclipseWarningsJavacNone) : null,
EclipseBug216558 = RUN_JAVAC ? // https://bugs.eclipse.org/bugs/show_bug.cgi?id=216558
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java
index 7b65b81..41f359c 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java
@@ -4362,24 +4362,29 @@
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=321485
public void test087() {
- this.runNegativeTest(
- new String[] {
- "X.java",
- "import java.util.Collection;\n" +
- "import java.util.List;\n" +
- "public class X {\n" +
- " public static <T> List<T> with(List<? extends T> p) { return null; } \n" +
- " public static <T> Collection<T> with(Collection<T> p) { return null; }\n" +
- " static { with(null); }\n" +
- "} \n"
- },
- "----------\n" +
- "1. ERROR in X.java (at line 6)\n" +
- " static { with(null); }\n" +
- " ^^^^\n" +
- "The method with(List<? extends Object>) is ambiguous for the type X\n" +
- "----------\n"
- );
+ String source =
+ "import java.util.Collection;\n" +
+ "import java.util.List;\n" +
+ "public class X {\n" +
+ " public static <T> List<T> with(List<? extends T> p) { return null; } \n" +
+ " public static <T> Collection<T> with(Collection<T> p) { return null; }\n" +
+ " static { with(null); }\n" +
+ "} \n";
+ if (this.complianceLevel < ClassFileConstants.JDK1_8) {
+ this.runNegativeTest( // FIXME: Eclipse has a bug
+ new String[] { "X.java", source },
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " static { with(null); }\n" +
+ " ^^^^\n" +
+ "The method with(List<? extends Object>) is ambiguous for the type X\n" +
+ "----------\n"
+ );
+ } else {
+ this.runConformTest(
+ new String[] { "X.java", source }
+ );
+ }
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=354579
public void test088a() {
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
index 0d715ee..ceba32c 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
@@ -29841,6 +29841,9 @@
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=127583
public void test0910() {
+ int[] capIds = this.complianceLevel < ClassFileConstants.JDK1_8
+ ? new int[]{ 1, 3, 4, 6, 13}
+ : new int[]{ 1, 2, 3, 4, 8};
this.runNegativeTest(
new String[] {
"X.java",
@@ -29893,12 +29896,12 @@
"4. ERROR in X.java (at line 13)\n" +
" lc1 = lc3; //2 ko\n" +
" ^^^\n" +
- "Type mismatch: cannot convert from List<capture#1-of ? extends Collection<?>> to List<Collection>\n" +
+ "Type mismatch: cannot convert from List<capture#"+capIds[0]+"-of ? extends Collection<?>> to List<Collection>\n" +
"----------\n" +
"5. ERROR in X.java (at line 14)\n" +
" lc1 = lc4; //3 ko\n" +
" ^^^\n" +
- "Type mismatch: cannot convert from List<capture#3-of ? extends Collection> to List<Collection>\n" +
+ "Type mismatch: cannot convert from List<capture#"+capIds[1]+"-of ? extends Collection> to List<Collection>\n" +
"----------\n" +
"6. ERROR in X.java (at line 15)\n" +
" lc2 = lc1; //4 ko\n" +
@@ -29908,12 +29911,12 @@
"7. ERROR in X.java (at line 16)\n" +
" lc2 = lc3; //5 ko\n" +
" ^^^\n" +
- "Type mismatch: cannot convert from List<capture#4-of ? extends Collection<?>> to List<Collection<?>>\n" +
+ "Type mismatch: cannot convert from List<capture#"+capIds[2]+"-of ? extends Collection<?>> to List<Collection<?>>\n" +
"----------\n" +
"8. ERROR in X.java (at line 17)\n" +
" lc2 = lc4; //6 ko\n" +
" ^^^\n" +
- "Type mismatch: cannot convert from List<capture#6-of ? extends Collection> to List<Collection<?>>\n" +
+ "Type mismatch: cannot convert from List<capture#"+capIds[3]+"-of ? extends Collection> to List<Collection<?>>\n" +
"----------\n" +
"9. ERROR in X.java (at line 18)\n" +
" lc3 = lc1; //7 ko\n" +
@@ -29923,7 +29926,7 @@
"10. ERROR in X.java (at line 20)\n" +
" lc3 = lc4; //9 ko\n" +
" ^^^\n" +
- "Type mismatch: cannot convert from List<capture#13-of ? extends Collection> to List<? extends Collection<?>>\n" +
+ "Type mismatch: cannot convert from List<capture#"+capIds[4]+"-of ? extends Collection> to List<? extends Collection<?>>\n" +
"----------\n" +
"11. WARNING in X.java (at line 25)\n" +
" private final List<Collection> aList = new ArrayList<Collection>();\n" +
@@ -38756,11 +38759,7 @@
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=177715
public void test1118() {
- runConformTest(
- // test directory preparation
- new String[] { /* test files */
- "X.java",
- "import java.util.List;\n" +
+ String source = "import java.util.List;\n" +
"\n" +
"public class X {\n" +
" X() {\n" +
@@ -38771,10 +38770,21 @@
" <I, T extends List<I>> T foo(Class<T> pClass) {\n" +
" return null;\n" +
" }\n" +
- "}\n", // =================
- },
- // javac options
- JavacTestOptions.EclipseHasABug.EclipseBug177715 /* javac test options */);
+ "}\n";
+ if (this.complianceLevel < ClassFileConstants.JDK1_8) {
+ runConformTest(
+ new String[] { "X.java", source },
+ JavacTestOptions.EclipseHasABug.EclipseBug177715 /* javac test options */);
+ } else {
+ runNegativeTest(
+ new String[] { "X.java", source },
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " foo(cls);\n" +
+ " ^^^\n" +
+ "The method foo(Class<T>) in the type X is not applicable for the arguments (Class<capture#1-of ? extends List<?>>)\n" +
+ "----------\n");
+ }
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=169728
public void test1119() {
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 80a24af..8375b7b 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
@@ -5921,5 +5921,97 @@
"}\n"
});
}
+public void testBug499126() {
+ runConformTest(
+ new String[] {
+ "bug_ise_immutablelist/$Immutable.java",
+ "package bug_ise_immutablelist;\n" +
+ "\n" +
+ "public class $Immutable<T> {\n" +
+ "}\n" +
+ "",
+ "bug_ise_immutablelist/Test.java",
+ "package bug_ise_immutablelist;\n" +
+ "\n" +
+ "public class Test {\n" +
+ " public static $Immutable<Object> f;\n" +
+ "}\n" +
+ "",
+ }
+ );
+ runConformTest(
+ false,
+ new String[] {
+ "Usage.java",
+ "public class Usage {\n" +
+ " Object f() {return bug_ise_immutablelist.Test.f;}\n" +
+ "}\n" +
+ "",
+ },
+ null,
+ null,
+ null,
+ null
+ );
+}
+public void testBug441905() {
+ runConformTest(
+ new String[] {
+ "EclipseJava8Generics.java",
+ "import java.util.List;\n" +
+ "\n" +
+ "public class EclipseJava8Generics {\n" +
+ "\n" +
+ " public interface Foo<V> {\n" +
+ " }\n" +
+ "\n" +
+ " public static class FooBar<V, T extends Foo<V>> {\n" +
+ " }\n" +
+ "\n" +
+ " protected void doFoos(List<FooBar<?, ? extends Foo<?>>> fooBars) {\n" +
+ " FooBar<?, ? extends Foo<?>> fooBar = fooBars.iterator().next();\n" +
+ " doFoo(fooBar);\n" +
+ " }\n" +
+ "\n" +
+ " protected static <F> void doFoo(FooBar<F, ? extends Foo<F>> fooBar) {\n" +
+ " }\n" +
+ "\n" +
+ "}\n"
+ });
+}
+public void testBug469297() {
+ String source = " import java.util.List;\n" +
+ " \n" +
+ " public class Test {\n" +
+ " \n" +
+ " static final void a(Class<? extends List<?>> type) {\n" +
+ " b(newList(type));\n" +
+ " }\n" +
+ " \n" +
+ " static final <T> List<T> b(List<T> list) {\n" +
+ " return list;\n" +
+ " }\n" +
+ " \n" +
+ " static final <L extends List<?>> L newList(Class<L> type) {\n" +
+ " try {\n" +
+ " return type.newInstance();\n" +
+ " }\n" +
+ " catch (Exception e) {\n" +
+ " throw new RuntimeException(e);\n" +
+ " }\n" +
+ " }\n" +
+ " }\n";
+ if (this.complianceLevel < ClassFileConstants.JDK1_8) {
+ runConformTest(new String[] { "Test.java", source });
+ } else {
+ runNegativeTest(new String[] { "Test.java", source },
+ "----------\n" +
+ "1. ERROR in Test.java (at line 6)\n" +
+ " b(newList(type));\n" +
+ " ^\n" +
+ "The method b(List<T>) in the type Test is not applicable for the arguments (capture#1-of ? extends List<?>)\n" +
+ "----------\n");
+ }
+}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java
index f25e40f..e53c451 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java
@@ -6886,4 +6886,73 @@
}
);
}
+public void testBug472851() {
+ runNegativeTest(
+ new String[] {
+ "Test.java",
+ "import java.util.*;\n" +
+ "\n" +
+ "public class Test {\n" +
+ " public static void main(String... arg) {\n" +
+ " List<Integer> l1=Arrays.asList(0, 1, 2);\n" +
+ " List<String> l2=Arrays.asList(\"0\", \"1\", \"2\");\n" +
+ " a(Arrays.asList(l1, l2));\n" +
+ "}\n" +
+ "static final void a(List<? extends List<?>> type) {\n" +
+ " test(type);\n" +
+ "}\n" +
+ "static final <Y,L extends List<Y>> void test(List<L> type) {\n" +
+ " L l1=type.get(0), l2=type.get(1);\n" +
+ " l2.set(0, l1.get(0));\n" +
+ "}\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in Test.java (at line 10)\n" +
+ " test(type);\n" +
+ " ^^^^\n" +
+ "The method test(List<L>) in the type Test is not applicable for the arguments (List<capture#1-of ? extends List<?>>)\n" +
+ "----------\n");
+}
+public void testBug502350() {
+ runNegativeTest(
+ new String[] {
+ "makeCompilerFreeze/EclipseJava8Bug.java",
+ "package makeCompilerFreeze;\n" +
+ "\n" +
+ "interface Comparable<E> {} \n" +
+ "\n" +
+ "interface Comparator<A> {\n" +
+ " public static <B extends Comparable<B>> Comparator<B> naturalOrder() {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n" +
+ "\n" +
+ "\n" +
+ "class Stuff {\n" +
+ " public static <T, S extends T> Object func(Comparator<T> comparator) {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n" +
+ "\n" +
+ "public class EclipseJava8Bug {\n" +
+ " static final Object BORKED =\n" +
+ " Stuff.func(Comparator.naturalOrder());\n" +
+ "}\n" +
+ "\n" +
+ "",
+ },
+ "----------\n" +
+ "1. ERROR in makeCompilerFreeze\\EclipseJava8Bug.java (at line 20)\n" +
+ " Stuff.func(Comparator.naturalOrder());\n" +
+ " ^^^^\n" +
+ "The method func(Comparator<T>) in the type Stuff is not applicable for the arguments (Comparator<Comparable<Comparable<B>>>)\n" +
+ "----------\n" +
+ "2. ERROR in makeCompilerFreeze\\EclipseJava8Bug.java (at line 20)\n" +
+ " Stuff.func(Comparator.naturalOrder());\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Type mismatch: cannot convert from Comparator<Comparable<Comparable<B>>> to Comparator<T>\n" +
+ "----------\n"
+ );
+}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LambdaExpressionsTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LambdaExpressionsTest.java
index 98d0c5f..74b2de1 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LambdaExpressionsTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LambdaExpressionsTest.java
@@ -6182,6 +6182,111 @@
"private static java.lang.reflect.Method Test.lambda$0(java.lang.Void)\n" +
"private java.lang.reflect.Method AnotherClass.lambda$0(java.lang.Void)");
}
+public void testBug499258() {
+ runConformTest(
+ new String[] {
+ "bug499258/ShellTab.java",
+ "package bug499258;\n" +
+ "class Controller {\n" +
+ " public void newTerminal(Object... path) {\n" +
+ " }\n" +
+ "}\n" +
+ "\n" +
+ "interface EventHandler {\n" +
+ " void handle();\n" +
+ "}\n" +
+ "\n" +
+ "public class ShellTab {\n" +
+ " private final Controller controller;\n" +
+ "\n" +
+ " public ShellTab(Controller controller) {\n" +
+ " this.controller = controller;\n" +
+ " EventHandler h = this.controller::newTerminal;\n" +
+ " }\n" +
+ "}\n" +
+ "",
+ }
+ );
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=500374 Using a method reference to a generic method in a Base class gives me NoSuchMethodError
+public void test500374() {
+ this.runConformTest(
+ new String[] {
+ "client/Client.java",
+ "package client;\n" +
+ "import lib.Sub;\n" +
+ "public class Client {\n" +
+ " public static void main(String[] args) throws Throwable {\n" +
+ " Sub s1 = new Sub();\n" +
+ " doSomething(() -> s1.m());\n" +
+ " doSomething(s1::m);\n" +
+ " }\n" +
+ " interface Aaa {\n" +
+ " Object f() throws Throwable;\n" +
+ " }\n" +
+ " public static void doSomething(Aaa a) throws Throwable {\n" +
+ " System.out.println(\"Done\");\n" +
+ " }\n" +
+ "}\n",
+ "lib/Sub.java",
+ "package lib;\n" +
+ "public class Sub extends Base<Sub> {}",
+ "lib/Base.java",
+ "package lib;\n" +
+ "class Base<T> {\n" +
+ " public T m() {\n" +
+ " System.out.println(\"m\");\n" +
+ " return thisInstance();\n" +
+ " }\n" +
+ " @SuppressWarnings(\"unchecked\")\n" +
+ " T thisInstance() {\n" +
+ " return (T) this;\n" +
+ " }\n" +
+ "}"
+ },
+ "Done\n" +
+ "Done");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=500374 Using a method reference to a generic method in a Base class gives me NoSuchMethodError
+public void test500374a() {
+ this.runConformTest(
+ new String[] {
+ "client/Client.java",
+ "package client;\n" +
+ "import java.lang.invoke.MethodHandle;\n" +
+ "import java.lang.invoke.MethodHandles;\n" +
+ "import java.lang.invoke.MethodType;\n" +
+ "import lib.Sub;\n" +
+ "public class Client {\n" +
+ " public static void main(String[] args) throws Throwable {\n" +
+ " MethodHandle mh = MethodHandles.lookup().findVirtual(Sub.class, \"m\", MethodType.methodType(Object.class));\n" +
+ " doSomething(mh::invoke);\n" +
+ " }\n" +
+ " interface Aaa {\n" +
+ " Object f() throws Throwable;\n" +
+ " }\n" +
+ " public static void doSomething(Aaa a) throws Throwable {\n" +
+ " System.out.println(\"Done\");\n" +
+ " }\n" +
+ "}\n",
+ "lib/Sub.java",
+ "package lib;\n" +
+ "public class Sub extends Base<Sub> {}",
+ "lib/Base.java",
+ "package lib;\n" +
+ "class Base<T> {\n" +
+ " public T m() {\n" +
+ " System.out.println(\"m\");\n" +
+ " return thisInstance();\n" +
+ " }\n" +
+ " @SuppressWarnings(\"unchecked\")\n" +
+ " T thisInstance() {\n" +
+ " return (T) this;\n" +
+ " }\n" +
+ "}"
+ },
+ "Done");
+}
public static Class testClass() {
return LambdaExpressionsTest.class;
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java
index 4f090c0..9e52dad 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java
@@ -14300,4 +14300,31 @@
},
compilerOptions);
}
+public void testBug500673() {
+ runNegativeTest(
+ new String[] {
+ "mfi.java",
+ "interface mfi {\n" +
+ " public transient void a(Throwable throwable);\n" +
+ "}\n",
+ "mfa.java",
+ "final class mfa implements mfi {\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in mfi.java (at line 2)\n" +
+ " public transient void a(Throwable throwable);\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^\n" +
+ (this.complianceLevel < ClassFileConstants.JDK1_8
+ ? "Illegal modifier for the interface method a; only public & abstract are permitted\n"
+ : "Illegal modifier for the interface method a; only public, abstract, default, static and strictfp are permitted\n"
+ ) +
+ "----------\n" +
+ "----------\n" +
+ "1. ERROR in mfa.java (at line 1)\n" +
+ " final class mfa implements mfi {\n" +
+ " ^^^\n" +
+ "The type mfa must implement the inherited abstract method mfi.a(Throwable)\n" +
+ "----------\n");
+}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java
index 14d4d19..d2c8891 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java
@@ -17974,4 +17974,181 @@
"----------\n"
);
}
+public void testBug447695() {
+ runConformTest(
+ new String[] {
+ "test/Test447695.java",
+ "package test;\n" +
+ "\n" +
+ "public class Test447695 {\n" +
+ " public static void f() {\n" +
+ " int[] array = null;\n" +
+ " (array = new int[1])[0] = 42;\n" +
+ " }\n" +
+ " public static int g() {\n" +
+ " int[] array = null;\n" +
+ " return (array = new int[1])[0];\n" +
+ " }\n" +
+ "}\n"
+ }
+ );
+}
+public void testBug447695b() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5) return; // uses foreach
+ runConformTest(
+ new String[] {
+ "X.java",
+ "import java.util.*;\n" +
+ "public class X {\n" +
+ " void test(String[] ss) {\n" +
+ " List<String> strings = null;\n" +
+ " for (String s : (strings = Arrays.asList(ss)))\n" +
+ " System.out.println(s);\n" +
+ " }\n" +
+ "}\n"
+ });
+}
+public void testBug447695c() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5) return; // uses autoboxing
+ runConformTest(
+ new String[] {
+ "test/Test447695.java",
+ "package test;\n" +
+ "\n" +
+ "public class Test447695 {\n" +
+ " void f() {\n" +
+ " Integer l1 = null;\n" +
+ " Integer l2 = null;\n" +
+ " int b = (l1 = new Integer(2)) + (l2 = new Integer(1));\n" +
+ " }\n" +
+ "}\n"
+ }
+ );
+}
+public void testBug447695d() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_8) return; // uses reference expression
+ runConformTest(
+ new String[] {
+ "test/Test447695.java",
+ "package test;\n" +
+ "\n" +
+ "import java.util.function.Supplier;\n" +
+ "\n" +
+ "public class Test447695 {\n" +
+ " void f() {\n" +
+ " String s = null;\n" +
+ " Supplier<String> l = (s = \"\")::toString;\n" +
+ " }\n" +
+ "}\n"
+ }
+ );
+}
+public void testBug447695e() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5) return; // uses autoboxing
+ runConformTest(
+ new String[] {
+ "test/Test447695.java",
+ "package test;\n" +
+ "\n" +
+ "public class Test447695 {\n" +
+ " void f() {\n" +
+ " Integer i = null;\n" +
+ " int j = -(i = new Integer(1));\n" +
+ " Boolean b1 = null;\n" +
+ " boolean b = !(b1 = new Boolean(false));\n" +
+ " }\n" +
+ "}\n"
+ }
+ );
+}
+public void testBug447695f() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5) return; // uses autoboxing
+ runConformTest(
+ new String[] {
+ "test/Test447695.java",
+ "package test;\n" +
+ "\n" +
+ "public class Test447695 {\n" +
+ " void f() {\n" +
+ " int i = 0;\n" +
+ " Integer i1 = null;\n" +
+ " Integer i2 = null;\n" +
+ " Integer i3 = null;\n" +
+ " int j = (i1 = new Integer(1)) \n" +
+ " + (i2 = new Integer(1)) \n" +
+ " + i + i + i + i + i + i + i + i + i + i + i + i + i + i + i + i + i + i + i \n" +
+ " + (i3 = new Integer(2)) + i;\n" +
+ " }\n" +
+ "}\n"
+ }
+ );
+}
+public void testBug447695g() {
+ runNegativeTest(
+ new String[] {
+ "test/Test447695.java",
+ "package test;\n" +
+ "\n" +
+ "class X {\n" +
+ " int i;\n" +
+ "}\n" +
+ "\n" +
+ "public class Test447695 {\n" +
+ " void f() {\n" +
+ " X x1 = null;\n" +
+ " X x2 = null;\n" +
+ " X x3 = null;\n" +
+ " X x4 = null;\n" +
+ " X x5 = null;\n" +
+ " X x6 = null;\n" +
+ " X x7 = null;\n" +
+ " X x8 = null;\n" +
+ " X x9 = null;\n" +
+ " X x10 = null;\n" +
+ " X x11 = null;\n" +
+ " x1.i = 1; // error 1 expected\n" +
+ " x2.i += 1; // error 2 expected\n" +
+ " (x3).i = 1; // error 3 expected\n" +
+ " (x4).i += 1; // error 4 expected\n" +
+ " (x5 = new X()).i = (x6 = new X()).i;\n" +
+ " (x7 = new X()).i += (x8 = new X()).i;\n" +
+ " int i1 = x9.i; // error 5 expected\n" +
+ " int i2 = (x10).i; // error 6 expected\n" +
+ " int i3 = (x11 = new X()).i;\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in test\\Test447695.java (at line 20)\n" +
+ " x1.i = 1; // error 1 expected\n" +
+ " ^^\n" +
+ "Null pointer access: The variable x1 can only be null at this location\n" +
+ "----------\n" +
+ "2. ERROR in test\\Test447695.java (at line 21)\n" +
+ " x2.i += 1; // error 2 expected\n" +
+ " ^^\n" +
+ "Null pointer access: The variable x2 can only be null at this location\n" +
+ "----------\n" +
+ "3. ERROR in test\\Test447695.java (at line 22)\n" +
+ " (x3).i = 1; // error 3 expected\n" +
+ " ^^^^\n" +
+ "Null pointer access: The variable x3 can only be null at this location\n" +
+ "----------\n" +
+ "4. ERROR in test\\Test447695.java (at line 23)\n" +
+ " (x4).i += 1; // error 4 expected\n" +
+ " ^^^^\n" +
+ "Null pointer access: The variable x4 can only be null at this location\n" +
+ "----------\n" +
+ "5. ERROR in test\\Test447695.java (at line 26)\n" +
+ " int i1 = x9.i; // error 5 expected\n" +
+ " ^^\n" +
+ "Null pointer access: The variable x9 can only be null at this location\n" +
+ "----------\n" +
+ "6. ERROR in test\\Test447695.java (at line 27)\n" +
+ " int i2 = (x10).i; // error 6 expected\n" +
+ " ^^^^^\n" +
+ "Null pointer access: The variable x10 can only be null at this location\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/NullTypeAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java
index 5db5078..4cb5285 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java
@@ -12226,6 +12226,101 @@
"----------\n"
);
}
+public void testBug489674() {
+ Map options = new HashMap<>(getCompilerOptions());
+ options.put(JavaCore.COMPILER_NONNULL_ANNOTATION_SECONDARY_NAMES, "org.foo.NonNull");
+ options.put(JavaCore.COMPILER_NULLABLE_ANNOTATION_SECONDARY_NAMES, "org.foo.Nullable");
+ runConformTest(
+ new String[] {
+ "org/foo/Nullable.java",
+ "package org.foo;\n" +
+ "import java.lang.annotation.*;\n" +
+ "import static java.lang.annotation.ElementType.*;\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target({ FIELD, METHOD, PARAMETER, LOCAL_VARIABLE })\n" +
+ "public @interface Nullable {}\n",
+ "org/foo/NonNull.java",
+ "package org.foo;\n" +
+ "import java.lang.annotation.*;\n" +
+ "import static java.lang.annotation.ElementType.*;\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target({ FIELD, METHOD, PARAMETER, LOCAL_VARIABLE })\n" +
+ "public @interface NonNull {}\n",
+ "}"
+ },
+ options);
+ runConformTestWithLibs(
+ new String[] {
+ "with_other_nullable/P1.java",
+ "package with_other_nullable;\n" +
+ "\n" +
+ "import org.foo.Nullable;\n" +
+ "\n" +
+ "public class P1 {\n" +
+ " public static @Nullable String f0() {\n" +
+ " return null;\n" +
+ " }\n" +
+ "\n" +
+ " public static <T> T check(T t) {\n" +
+ " return t;\n" +
+ " }\n" +
+ "}\n" +
+ "",
+ "with_other_nullable/P2.java",
+ "package with_other_nullable;\n" +
+ "\n" +
+ "import org.foo.NonNull;\n" +
+ "\n" +
+ "public class P2 {\n" +
+ " public static void f(@NonNull String s) {\n" +
+ " }\n" +
+ "\n" +
+ " public static <T> T check(T t) {\n" +
+ " return t;\n" +
+ " }\n" +
+ "}\n" +
+ "",
+ },
+ options,
+ ""
+ );
+ runNegativeTestWithLibs(
+ new String[] {
+ "test/Test4.java",
+ "package test;\n" +
+ "\n" +
+ "import org.eclipse.jdt.annotation.NonNullByDefault;\n" +
+ "\n" +
+ "import with_other_nullable.P1;\n" +
+ "import with_other_nullable.P2;\n" +
+ "\n" +
+ "@NonNullByDefault\n" +
+ "public class Test4 {\n" +
+ " void m1(String s) {\n" +
+ " P1.f0().hashCode();\n" +
+ " s = P1.check(s);\n" +
+ " }\n" +
+ " void m2(String s) {\n" +
+ " P2.f(null);\n" +
+ " s = P2.check(s);\n" +
+ " }\n" +
+ "}\n" +
+ "",
+ },
+ options,
+ "----------\n" +
+ "1. ERROR in test\\Test4.java (at line 11)\n" +
+ " P1.f0().hashCode();\n" +
+ " ^^^^^^^\n" +
+ "Potential null pointer access: The method f0() may return null\n" +
+ "----------\n" +
+ "2. ERROR in test\\Test4.java (at line 15)\n" +
+ " P2.f(null);\n" +
+ " ^^^^\n" +
+ "Null type mismatch: required \'String\' but the provided value is null\n" +
+ "----------\n"
+ );
+}
public void testBug492327() {
runConformTestWithLibs(
new String[] {
@@ -12651,4 +12746,166 @@
""
);
}
+public void testBug499862a() {
+ runConformTestWithLibs(
+ new String[] {
+ "Test.java",
+ "import org.eclipse.jdt.annotation.*;\n" +
+ "import java.util.*;\n" +
+ "public class Test {\n" +
+ " static void printChecked(Collection<? extends @Nullable String> collection) {\n" +
+ " for(String s : collection)\n" +
+ " if (s != null)\n" +
+ " System.out.println(s.toString());\n" +
+ " else\n" +
+ " System.out.println(\"NULL\");\n" +
+ " }\n" +
+ "}\n"
+ },
+ getCompilerOptions(),
+ "");
+}
+public void testBug499862b() {
+ runNegativeTestWithLibs(
+ new String[] {
+ "Test.java",
+ "import org.eclipse.jdt.annotation.*;\n" +
+ "import java.util.*;\n" +
+ "public class Test {\n" +
+ " static void printChecked(Collection<? extends @Nullable String> collection) {\n" +
+ " for(String s : collection)\n" +
+ " System.out.println(s.toString());\n" +
+ " }\n" +
+ "}\n"
+ },
+ getCompilerOptions(),
+ "----------\n" +
+ "1. ERROR in Test.java (at line 6)\n" +
+ " System.out.println(s.toString());\n" +
+ " ^\n" +
+ "Potential null pointer access: The variable s may be null at this location\n" +
+ "----------\n");
+}
+public void testBug499862c() {
+ runNegativeTestWithLibs(
+ new String[] {
+ "Test.java",
+ "import java.util.*;\n" +
+ "public class Test {\n" +
+ " static <T> void printUnchecked(Collection<T> collection) {\n" +
+ " for(T t : collection)\n" +
+ " System.out.println(t.toString());\n" +
+ " }\n" +
+ "}\n"
+ },
+ getCompilerOptions(),
+ "----------\n" +
+ "1. ERROR in Test.java (at line 5)\n" +
+ " System.out.println(t.toString());\n" +
+ " ^\n" +
+ "Potential null pointer access: this expression has type \'T\', a free type variable that may represent a \'@Nullable\' type\n" +
+ "----------\n");
+}
+public void testBug499597simplified() {
+ runConformTestWithLibs(
+ new String[] {
+ "Foo2.java",
+ "import org.eclipse.jdt.annotation.NonNull;\n" +
+ "import org.eclipse.jdt.annotation.NonNullByDefault;\n" +
+ "\n" +
+ "@NonNullByDefault\n" +
+ "class Foo2 {\n" +
+ " static <T> T of(T t) {\n" +
+ " return t;\n" +
+ " }\n" +
+ "\n" +
+ " static String foo() {\n" +
+ " return Foo2.<String>of(\"\"); // <-- warning here\n" +
+ " }\n" +
+ "\n" +
+ " static String bar() {\n" +
+ " return Foo2.<@NonNull String>of(\"\"); // <-- no warning\n" +
+ " }\n" +
+ "}\n" +
+ "",
+ },
+ getCompilerOptions(),
+ ""
+ );
+}
+public void testBug499597original() {
+ runNegativeTestWithLibs(
+ new String[] {
+ "Foo.java",
+ "import static org.eclipse.jdt.annotation.DefaultLocation.*;\n" +
+ "import org.eclipse.jdt.annotation.*;\n" +
+ "\n" +
+ "import java.util.Collection;\n" +
+ "import java.util.Collections;\n" +
+ "\n" +
+ "class Foo {\n" +
+ " static @NonNull String @NonNull [] X = { \"A\" };\n" +
+ "\n" +
+ " @NonNullByDefault({ PARAMETER, RETURN_TYPE, FIELD, TYPE_PARAMETER, TYPE_BOUND, TYPE_ARGUMENT, ARRAY_CONTENTS })\n" +
+ " @SafeVarargs\n" +
+ " static <T> Collection<T> of(@NonNull T @NonNull... elements) {\n" +
+ " return Collections.singleton(elements[0]);\n" +
+ " }\n" +
+ "\n" +
+ " @NonNullByDefault({ PARAMETER, RETURN_TYPE, FIELD, TYPE_PARAMETER, TYPE_BOUND, TYPE_ARGUMENT, ARRAY_CONTENTS })\n" +
+ " static Collection<String[]> foo() {\n" +
+ " return Foo.<String[]>of(X); // <-- warning here\n" +
+ " }\n" +
+ "\n" +
+ " @NonNullByDefault({ PARAMETER, RETURN_TYPE, FIELD, TYPE_PARAMETER, TYPE_BOUND, TYPE_ARGUMENT, ARRAY_CONTENTS })\n" +
+ " static Collection<String[]> bar() {\n" +
+ " return Foo.<String @NonNull []>of(X); // <-- no warning\n" +
+ " }\n" +
+ "}\n" +
+ "",
+ },
+ getCompilerOptions(),
+ "----------\n" +
+ "1. WARNING in Foo.java (at line 12)\n" +
+ " static <T> Collection<T> of(@NonNull T @NonNull... elements) {\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The nullness annotation is redundant with a default that applies to this location\n" +
+ "----------\n" +
+ "2. WARNING in Foo.java (at line 13)\n" +
+ " return Collections.singleton(elements[0]);\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Null type safety (type annotations): The expression of type \'Set<T>\' needs unchecked conversion to conform to \'@NonNull Collection<T>\', corresponding supertype is \'Collection<T>\'\n" +
+ "----------\n"
+ );
+}
+public void testBug501449() {
+ runNegativeTestWithLibs(
+ new String[] {
+ "Test.java",
+ "import org.eclipse.jdt.annotation.Nullable;\n" +
+ "\n" +
+ "public class Test {\n" +
+ " <T, S extends T> void f(T[] objects, @Nullable T nullableValue, T value, S subclassValue) {\n" +
+ " objects[0] = null;\n" +
+ " objects[1] = nullableValue;\n" +
+ " objects[2] = value;\n" +
+ " objects[3] = subclassValue;\n" +
+ " }\n" +
+ "}\n" +
+ "",
+ },
+ getCompilerOptions(),
+ "----------\n" +
+ "1. ERROR in Test.java (at line 5)\n" +
+ " objects[0] = null;\n" +
+ " ^^^^^^^^^^\n" +
+ "Null type mismatch (type annotations): \'null\' is not compatible to the free type variable \'T\'\n" +
+ "----------\n" +
+ "2. ERROR in Test.java (at line 6)\n" +
+ " objects[1] = nullableValue;\n" +
+ " ^^^^^^^^^^\n" +
+ "Null type mismatch (type annotations): required \'T\' but this expression has type \'@Nullable T\', where \'T\' is a free type variable\n" +
+ "----------\n"
+ );
+}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PackageBindingTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PackageBindingTest.java
index 827e53d..f848e19 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PackageBindingTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PackageBindingTest.java
@@ -29,8 +29,9 @@
/**
* This test checks if it is searched for packages before searching for types.
* The search for packages is much faster than searching for types, therefore it should get executed before searching for types.
+ * Commented since reverted to original behaviour as per bug 495598
*/
- public void test01() {
+ public void _test01() {
NameEnvironmentDummy nameEnv = new NameEnvironmentDummy(true);
PackageBinding packageBinding = new PackageBinding(new LookupEnvironment(null, new CompilerOptions(), null, nameEnv));
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SerializableLambdaTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SerializableLambdaTest.java
index 18e554d..30541d6 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SerializableLambdaTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SerializableLambdaTest.java
@@ -2158,6 +2158,47 @@
null,true,
new String[]{"-Ddummy"});
}
+ public void testbug503118() {
+ this.runConformTest(
+ new String[]{
+ "lambdabug/App.java",
+ "package lambdabug;\n" +
+ "import java.io.ByteArrayInputStream;\n" +
+ "import java.io.ByteArrayOutputStream;\n" +
+ "import java.io.ObjectInputStream;\n" +
+ "import java.io.ObjectOutputStream;\n" +
+ "import java.io.Serializable;\n" +
+ "import java.util.function.Function;\n" +
+ "public class App {\n" +
+ " public static interface SerialFunction<T, R> extends Function<T, R>, Serializable {\n" +
+ " }\n" +
+ " public static interface TestInterface extends Serializable {\n" +
+ " public Integer method(Integer i);\n" +
+ " }\n" +
+ " public static class TestClass implements TestInterface {\n" +
+ " private static final long serialVersionUID = 1L;\n" +
+ " @Override\n" +
+ " public Integer method(Integer i) {\n" +
+ " return i;\n" +
+ " }\n" +
+ " }\n" +
+ " public static void main(String[] args) throws Exception {\n" +
+ " TestInterface testService = getService();\n" +
+ " SerialFunction<Integer, Integer> sf = testService::method;\n" +
+ " ByteArrayOutputStream bos = new ByteArrayOutputStream();\n" +
+ " new ObjectOutputStream(bos).writeObject(sf);\n" +
+ " Object o = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray())).readObject();\n" +
+ " System.out.println(o.getClass().getInterfaces()[0]);\n" +
+ " }\n" +
+ " private static TestInterface getService() {\n" +
+ " return new TestClass();\n" +
+ " }\n" +
+ "}\n"
+ },
+ "interface lambdabug.App$SerialFunction",
+ null,true,
+ new String[]{"-Ddummy"});
+ }
// ---
private void checkExpected(String expected, String actual) {
diff --git a/org.eclipse.jdt.core.tests.model/.classpath b/org.eclipse.jdt.core.tests.model/.classpath
index f4a5c79..0035118 100644
--- a/org.eclipse.jdt.core.tests.model/.classpath
+++ b/org.eclipse.jdt.core.tests.model/.classpath
@@ -1,6 +1,6 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/org.eclipse.jdt.core.tests.model/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.jdt.core.tests.model/.settings/org.eclipse.jdt.core.prefs
index 69354e7..0f72841 100644
--- a/org.eclipse.jdt.core.tests.model/.settings/org.eclipse.jdt.core.prefs
+++ b/org.eclipse.jdt.core.tests.model/.settings/org.eclipse.jdt.core.prefs
@@ -15,9 +15,9 @@
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
@@ -119,6 +119,6 @@
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.7
+org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.incompatibleJDKLevel=ignore
org.eclipse.jdt.core.incompleteClasspath=error
diff --git a/org.eclipse.jdt.core.tests.model/META-INF/MANIFEST.MF b/org.eclipse.jdt.core.tests.model/META-INF/MANIFEST.MF
index 1752649..7a26b38 100644
--- a/org.eclipse.jdt.core.tests.model/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.core.tests.model/META-INF/MANIFEST.MF
@@ -25,7 +25,7 @@
org.eclipse.core.filesystem;bundle-version="[1.2.0,2.0.0)",
org.eclipse.jdt.annotation;bundle-version="[1.1.0,2.0.0)";resolution:=optional,
org.eclipse.jdt.annotation;bundle-version="[2.0.0,3.0.0)";resolution:=optional
-Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Eclipse-BundleShape: dir
Bundle-Activator: org.eclipse.jdt.core.tests.Activator
Bundle-ActivationPolicy: lazy
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/Activator.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/Activator.java
index defb6d0..2d22199 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/Activator.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/Activator.java
@@ -16,21 +16,20 @@
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
-/**
- * Make the PackageAdmin service accessible to tests.
- *
- * @deprecated uses deprecated class PackageAdmin.
- */
@SuppressWarnings({"rawtypes", "unchecked"})
public class Activator extends Plugin {
private static final String PLUGIN_ID = "org.eclipse.jdt.core.tests.model";
+ /**
+ * @deprecated uses deprecated class PackageAdmin.
+ */
static org.osgi.service.packageadmin.PackageAdmin packageAdmin = null;
static Plugin instance;
+ @SuppressWarnings("deprecation")
public void start(BundleContext context) throws Exception {
ServiceReference ref= context.getServiceReference(org.osgi.service.packageadmin.PackageAdmin.class.getName());
@@ -46,6 +45,11 @@
// nothing
}
+ /**
+ * Make the PackageAdmin service accessible to tests.
+ *
+ * @deprecated uses deprecated class PackageAdmin.
+ */
public static org.osgi.service.packageadmin.PackageAdmin getPackageAdmin() {
return packageAdmin;
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/APIDocumentationTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/APIDocumentationTests.java
index d59474a..25368a3 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/APIDocumentationTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/APIDocumentationTests.java
@@ -141,7 +141,7 @@
// fetch JavaCore source file
// 1. attempt: workspace relative location in project org.eclipse.jdt.core:
- @SuppressWarnings("deprecation")Bundle bundle = org.eclipse.jdt.core.tests.Activator.getInstance().getBundle();
+ Bundle bundle = org.eclipse.jdt.core.tests.Activator.getInstance().getBundle();
URL url = bundle.getEntry("/");
IPath path = new Path(FileLocator.toFileURL(url).getPath());
path = path.removeLastSegments(1).append(ORG_ECLIPSE_JDT_CORE);
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
index bf98fb7..c0b797c 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
@@ -12499,4 +12499,124 @@
"}";
formatSource(source);
}
+/**
+ * https://bugs.eclipse.org/500443 - [formatter] NPE on block comment before 'force-wrap' element
+ */
+public void testBug500443() {
+ this.formatterPrefs.alignment_for_enum_constants = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE;
+ this.formatterPrefs.alignment_for_superclass_in_type_declaration = Alignment.M_ONE_PER_LINE_SPLIT + Alignment.M_FORCE;
+ String source =
+ "public class SomeClass\n" +
+ " /* */ extends\n" +
+ " Object {\n" +
+ " enum MyEnum {\n" +
+ " /* 1 */ ONE\n" +
+ " }\n" +
+ "}";
+ formatSource(source);
+}
+/**
+ * https://bugs.eclipse.org/500092 - [formatter] Blank lines at beginning of method body doesn't work in constructors
+ */
+public void testBug500092() {
+ this.formatterPrefs.blank_lines_at_beginning_of_method_body = 1;
+ String source =
+ "public class Test {\n" +
+ " public Test() { int a; }\n" +
+ "}";
+ formatSource(source,
+ "public class Test {\n" +
+ " public Test() {\n" +
+ "\n" +
+ " int a;\n" +
+ " }\n" +
+ "}"
+ );
+}
+/**
+ * https://bugs.eclipse.org/500135 - [formatter] 'Parenthesis positions' ignores single member annotations
+ */
+public void testBug500135() {
+ this.formatterPrefs.parenthesis_positions_in_annotation = DefaultCodeFormatterConstants.SEPARATE_LINES;
+ String source =
+ "@SomeAnnotation(\n" +
+ " \"some value\"\n" +
+ ")\n" +
+ "public class Test {\n" +
+ "}";
+ formatSource(source);
+}
+/**
+ * https://bugs.eclipse.org/500096 - [formatter] Indent declarations within enum declaration doesn't affect enum constants
+ */
+public void testBug500096a() {
+ this.formatterPrefs.indent_body_declarations_compare_to_enum_declaration_header = false;
+ String source =
+ "public enum Test {\n" +
+ "AAA, BBB;\n" +
+ "Test() {\n" +
+ "}\n" +
+ "}";
+ formatSource(source);
+}
+/**
+ * https://bugs.eclipse.org/500096 - [formatter] Indent declarations within enum declaration doesn't affect enum constants
+ */
+public void testBug500096b() {
+ this.formatterPrefs.indent_body_declarations_compare_to_enum_declaration_header = false;
+ this.formatterPrefs.alignment_for_enum_constants = Alignment.M_COMPACT_SPLIT + Alignment.M_INDENT_BY_ONE;
+ String source =
+ "public enum Test {\n" +
+ " AAA, BBB;\n" +
+ "Test() {\n" +
+ "}\n" +
+ "}";
+ formatSource(source);
+}
+/**
+ * https://bugs.eclipse.org/500093 - [formatter] AssertionError with 'Next line on wrap' for array initializers
+ */
+public void testBug500093() {
+ this.formatterPrefs.brace_position_for_array_initializer = DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP;
+ this.formatterPrefs.page_width = 60;
+ this.formatterPrefs.use_tabs_only_for_leading_indentations = true;
+ String source =
+ "public class SomeClass {\n" +
+ " void foo() {\n" +
+ " Arrays.asList(new String[] { \"ddd\", \"eee\", \"fff\" });\n" +
+ " Arrays.asList(new String[] { \"a\", \"b\", \"c\" },\n" +
+ " new String[]\n" +
+ " { \"a\", \"b\", \"c\", });\n" +
+ " Arrays.asList(//\n" +
+ " new String[]\n" +
+ " { \"ddd\", \"eee\", \"fff\" });\n" +
+ " Arrays.asList(\n" +
+ " new String[]\n" +
+ " { \"eedd\", \"eee\", \"fff\" });\n" +
+ " Arrays.asList(\n" +
+ " new String[]\n" +
+ " { \"aa\", \"bb\", \"cc\", \"dd\", \"ee\", \"ff\", \"gg\",\n" +
+ " \"hh\", \"ii\" });\n" +
+ " String[][] test = { { \"aaaaaa\", \"bbbbb\", \"ccccc\" },\n" +
+ " { \"aaaa\", \"bb\", \"ccc\" } };\n" +
+ " test[123456 //\n" +
+ " * (234567 + 345678 + 456789 - 567890\n" +
+ " - 678901)] = new String[]\n" +
+ " { \"a\", \"b\", \"c\" };\n" +
+ " }\n" +
+ "}";
+ formatSource(source);
+}
+/**
+ * https://bugs.eclipse.org/500853 - [Formatter] java code formatter doesn't honour new parentheses settings
+ */
+public void testBug500853() {
+ this.formatterPrefs.parenthesis_positions_in_method_declaration = new String(DefaultCodeFormatterConstants.PRESERVE_POSITIONS);
+ String source =
+ "public class SomeClass {\n" +
+ " void foo() {\n" +
+ " }\n" +
+ "}";
+ formatSource(source);
+}
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java
index b67a696..9edcdc6 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java
@@ -76,20 +76,6 @@
super.setUpSuite();
}
-/**
- * Reset the jar placeholder and delete project.
- */
-public void tearDownSuite() throws Exception {
- if (ALL_TEST_SUITES == null) {
- deleteProject(JAVA_PROJECT); //$NON-NLS-1$
- } else {
- ALL_TEST_SUITES.remove(getClass());
- if (ALL_TEST_SUITES.size() == 0) {
- deleteProject(JAVA_PROJECT); //$NON-NLS-1$
- }
- }
-}
-
void compareFormattedSource(ICompilationUnit compilationUnit) throws JavaModelException {
DefaultCodeFormatter codeFormatter = codeFormatter();
String source = compilationUnit.getSource();
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java
index a04e279..2659d99 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -32,11 +32,13 @@
import org.eclipse.jdt.internal.core.ClasspathEntry;
import org.eclipse.jdt.internal.core.JavaCorePreferenceInitializer;
import org.eclipse.jdt.internal.core.JavaElement;
+import org.eclipse.jdt.internal.core.JavaElementDelta;
import org.eclipse.jdt.internal.core.JavaModelManager;
import org.eclipse.jdt.internal.core.JavaProject;
import org.eclipse.jdt.internal.core.NameLookup;
import org.eclipse.jdt.internal.core.ResolvedSourceMethod;
import org.eclipse.jdt.internal.core.ResolvedSourceType;
+import org.eclipse.jdt.internal.core.nd.indexer.Indexer;
import org.eclipse.jdt.internal.core.search.BasicSearchEngine;
import org.eclipse.jdt.internal.core.util.Util;
@@ -238,10 +240,17 @@
public synchronized String stackTraces() {
return this.stackTraces.toString();
}
+
public synchronized String toString() {
- StringBuffer buffer = new StringBuffer();
- for (int i=0, length= this.deltas.length; i<length; i++) {
+ StringBuilder buffer = new StringBuilder();
+ for (int i = 0, length= this.deltas.length; i < length; i++) {
IJavaElementDelta delta = this.deltas[i];
+ if (((JavaElementDelta) delta).ignoreFromTests) {
+ continue;
+ }
+ if (buffer.length() != 0) {
+ buffer.append("\n\n");
+ }
IJavaElementDelta[] children = delta.getAffectedChildren();
int childrenLength=children.length;
IResourceDelta[] resourceDeltas = delta.getResourceDeltas();
@@ -250,28 +259,23 @@
buffer.append(delta);
} else {
sortDeltas(children);
- for (int j=0; j<childrenLength; j++) {
- buffer.append(children[j]);
- if (j != childrenLength-1) {
- buffer.append("\n");
+ for (int j = 0; j < childrenLength; j++) {
+ if (buffer.length() != 0 && buffer.charAt(buffer.length() - 1) != '\n') {
+ buffer.append('\n');
}
+ buffer.append(children[j]);
}
- for (int j=0; j<resourceDeltasLength; j++) {
- if (j == 0 && buffer.length() != 0) {
- buffer.append("\n");
+ for (int j = 0; j < resourceDeltasLength; j++) {
+ if (buffer.length() != 0 && buffer.charAt(buffer.length() - 1) != '\n') {
+ buffer.append('\n');
}
buffer.append(resourceDeltas[j]);
- if (j != resourceDeltasLength-1) {
- buffer.append("\n");
- }
}
}
- if (i != length-1) {
- buffer.append("\n\n");
- }
}
return buffer.toString();
}
+
public void waitForResourceDelta() {
long start = System.currentTimeMillis();
while (!this.gotResourceDelta) {
@@ -2422,6 +2426,7 @@
protected void refreshExternalArchives(IJavaProject p) throws JavaModelException {
waitForAutoBuild(); // ensure that the auto-build job doesn't interfere with external jar refreshing
getJavaModel().refreshExternalArchives(new IJavaElement[] {p}, null);
+ Indexer.getInstance().waitForIndex(null);
}
protected void removeJavaNature(String projectName) throws CoreException {
@@ -3139,6 +3144,7 @@
do {
try {
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
+ Indexer.getInstance().waitForIndex(null);
wasInterrupted = false;
} catch (OperationCanceledException e) {
e.printStackTrace();
@@ -3153,6 +3159,7 @@
do {
try {
Job.getJobManager().join(ResourcesPlugin.FAMILY_MANUAL_REFRESH, null);
+ Indexer.getInstance().waitForIndex(null);
wasInterrupted = false;
} catch (OperationCanceledException e) {
e.printStackTrace();
@@ -3167,6 +3174,7 @@
SearchEngine engine = new SearchEngine();
IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
try {
+ Indexer.getInstance().waitForIndex(null);
engine.searchAllTypeNames(
null,
SearchPattern.R_EXACT_MATCH,
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java
index 6c82e92..24aaeee 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -16,6 +16,7 @@
import java.lang.reflect.Method;
import org.eclipse.jdt.core.tests.junit.extension.TestCase;
+import org.eclipse.jdt.core.tests.nd.RunIndexTests;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -57,6 +58,9 @@
// Java search tests
RunJavaSearchTests.class,
+ // Testss for the new index
+ RunIndexTests.class,
+
// Working copy tests
WorkingCopyTests.class,
WorkingCopyNotInClasspathTests.class,
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java
index 9376aa6..203b2bc 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -260,20 +260,7 @@
try {
IClasspathEntry[] entries = this.project.getRawClasspath();
savedEntries = entries.clone();
- IResource resource = this.project.getProject().findMember("/doc.zip"); //$NON-NLS-1$
- assertNotNull("doc folder cannot be null", resource); //$NON-NLS-1$
- URI locationURI = resource.getLocationURI();
- assertNotNull("doc folder cannot be null", locationURI); //$NON-NLS-1$
- URL docUrl = null;
- try {
- docUrl = locationURI.toURL();
- } catch (MalformedURLException e) {
- assertTrue("Should not happen", false); //$NON-NLS-1$
- } catch(IllegalArgumentException e) {
- assertTrue("Should not happen", false); //$NON-NLS-1$
- }
- final String path = "jar:" + docUrl.toExternalForm() + "!/doc"; //$NON-NLS-1$ //$NON-NLS-2$
- //final String path = "jar:" + "platform:/resource/AttachedJavadocProject/doc.zip" + "!/doc";
+ final String path = "jar:" + "platform:/resource/AttachedJavadocProject/doc.zip" + "!/doc";
IClasspathAttribute attribute = JavaCore.newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, path);
for (int i = 0, max = entries.length; i < max; i++) {
final IClasspathEntry entry = entries[i];
@@ -1315,5 +1302,27 @@
assertTrue("Should not happen", false);
}
}
+ public void testBug499196() throws JavaModelException {
+ try {
+ IClasspathAttribute attribute =
+ JavaCore.newClasspathAttribute(
+ IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME,
+ "jar:platform:/resource/AttachedJavadocProject/bug499196_doc.zip!/");
+ IClasspathEntry newEntry = JavaCore.newLibraryEntry(new Path("/AttachedJavadocProject/bug499196.jar"), null, null, null, new IClasspathAttribute[] {attribute}, true);
+ this.project.setRawClasspath(new IClasspathEntry[]{newEntry}, null);
+ this.project.getResolvedClasspath(false);
+
+ IPackageFragmentRoot jarRoot = this.project.getPackageFragmentRoot(getFile("/AttachedJavadocProject/bug499196.jar"));
+ final IType type = jarRoot.getPackageFragment("p1.p2").getClassFile("Bug499196.class").getType();
+ assertNotNull(type);
+ IMethod method = type.getMethod("Bug499196", new String[] {}); //$NON-NLS-1$
+ assertNotNull("Constructor should not be null", method);
+ assertTrue(method.exists());
+ String javadoc = method.getAttachedJavadoc(new NullProgressMonitor()); //$NON-NLS-1$
+ assertNotNull("Should have a javadoc", javadoc); //$NON-NLS-1$
+ } catch (IndexOutOfBoundsException e) {
+ assertTrue("Should not happen", false);
+ }
+ }
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java
index 2a52510..3c431dd 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -2580,6 +2580,34 @@
typeParameters[0].getBoundsSignatures());
}
-
-
+public void testBug495598_001() throws CoreException {
+ try {
+ createFolder("/P/src/a/b/C");
+ createFile("/P/src/a/b/C/readme.txt", "This is not a Java file");
+
+ createFile(
+ "/P/src/a/b/C.java",
+ "package a.b;\n" +
+ "public class C{};\n"
+ );
+
+ createFile("/P/src/X.java",
+ "import a.b.C;\n" +
+ "public class X {}\n");
+ ICompilationUnit cuD = getCompilationUnit("/P/src/X.java");
+
+ ASTParser parser = ASTParser.newParser(AST.JLS8);
+ parser.setProject(this.testProject);
+ parser.setSource(cuD);
+ parser.setResolveBindings(true);
+ org.eclipse.jdt.core.dom.CompilationUnit cuAST = (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(null);
+ IProblem[] problems = cuAST.getProblems();
+ assertEquals("Should have 1 problem", 1, problems.length);
+ assertEquals("Should have only an unused warning", "The import a.b.C is never used", problems[0].getMessage());
+ } finally {
+ deleteFile("/P/src/X.java");
+ deleteFile("/P/src/a/b/C.java");
+ deleteFolder("/P/src/a");
+ }
+}
}
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 2be5e05..7a5ecda 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
@@ -20676,11 +20676,11 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
// In the absence of the fix, it would have been:
- // "IBar[TYPE_REF]{IBar, test, Ltest.IBar;, null, 44}\n" +
- // "IFoo[TYPE_REF]{IFoo, test, Ltest.IFoo;, null, 44}"
+ // "IBar[TYPE_REF]{IBar, test, Ltest.IBar;, null, " + (R_DEFAULT + 39) + "}\n" +
+ // "IFoo[TYPE_REF]{IFoo, test, Ltest.IFoo;, null, " + (R_DEFAULT + 39) + "}"
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "IBar[TYPE_REF]{IBar, test, Ltest.IBar;, null, 44}",
+ "IBar[TYPE_REF]{IBar, test, Ltest.IBar;, null, " + (R_DEFAULT + 39) + "}",
requestor.getResults());
}
@@ -20712,8 +20712,8 @@
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
// In the absence of the fix, it would also complete to Interface1:
- //"Interface1[TYPE_REF]{Interface1, test, Ltest.Interface1;, null, 44}\n"+
- "Interface2[TYPE_REF]{Interface2, test, Ltest.Interface2;, null, 44}",
+ //"Interface1[TYPE_REF]{Interface1, test, Ltest.Interface1;, null, " + (R_DEFAULT + 39) + "}\n"+
+ "Interface2[TYPE_REF]{Interface2, test, Ltest.Interface2;, null, " + (R_DEFAULT + 39) + "}",
requestor.getResults());
}
@@ -20743,7 +20743,7 @@
assertResults(
// In the absence of the fix, it would suggest both p.Enclosing.Interface2, and
// p.Enclosing.Interface1 while it should have suppressed the latter which is in use.
- "Enclosing.Interface2[TYPE_REF]{p.Enclosing.Interface2, p, Lp.Enclosing$Interface2;, null, 44}",
+ "Enclosing.Interface2[TYPE_REF]{p.Enclosing.Interface2, p, Lp.Enclosing$Interface2;, null, " + (R_DEFAULT + 39) + "}",
requestor.getResults());
}
@@ -20778,8 +20778,8 @@
assertResults(
// In the absence of the fix, it would suggest only p.Enclosing.Interface2, as it
// was wrongly suppressing p.Enclosing.Interface1 confusing it with p.Interface1.
- "Enclosing.Interface1[TYPE_REF]{p.Enclosing.Interface1, p, Lp.Enclosing$Interface1;, null, 44}\n" +
- "Enclosing.Interface2[TYPE_REF]{p.Enclosing.Interface2, p, Lp.Enclosing$Interface2;, null, 44}",
+ "Enclosing.Interface1[TYPE_REF]{p.Enclosing.Interface1, p, Lp.Enclosing$Interface1;, null, " + (R_DEFAULT + 39) + "}\n" +
+ "Enclosing.Interface2[TYPE_REF]{p.Enclosing.Interface2, p, Lp.Enclosing$Interface2;, null, " + (R_DEFAULT + 39) + "}",
requestor.getResults());
}
@@ -21182,9 +21182,9 @@
assertResults(
// without the fix no proposals obtained.
- "Tr[POTENTIAL_METHOD_DECLARATION]{Tr, Ltest.Try;, ()V, Tr, null, 14}\n" +
- "transient[KEYWORD]{transient, null, null, transient, null, 14}\n" +
- "Try[TYPE_REF]{Try, test, Ltest.Try;, null, null, 27}",
+ "Tr[POTENTIAL_METHOD_DECLARATION]{Tr, Ltest.Try;, ()V, Tr, null, " + (R_DEFAULT + 9) + "}\n" +
+ "transient[KEYWORD]{transient, null, null, transient, null, " + (R_DEFAULT + 9) + "}\n" +
+ "Try[TYPE_REF]{Try, test, Ltest.Try;, null, null, " + (R_DEFAULT + 22) + "}",
requestor.getResults());
}
@@ -21220,10 +21220,10 @@
assertResults(
// without the fix no proposals obtained.
- "Error[TYPE_REF]{Error, java.lang, Ljava.lang.Error;, null, null, 17}\n" +
- "Exception[TYPE_REF]{Exception, java.lang, Ljava.lang.Exception;, null, null, 17}\n" +
- "equals[METHOD_REF]{Try.this.equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), 24}\n" +
- "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), 27}",
+ "Error[TYPE_REF]{Error, java.lang, Ljava.lang.Error;, null, null, " + (R_DEFAULT + 12) + "}\n" +
+ "Exception[TYPE_REF]{Exception, java.lang, Ljava.lang.Exception;, null, null, " + (R_DEFAULT + 12) + "}\n" +
+ "equals[METHOD_REF]{Try.this.equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), " + (R_DEFAULT + 19) + "}\n" +
+ "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), " + (R_DEFAULT + 22) + "}",
requestor.getResults());
}
@@ -21322,7 +21322,7 @@
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "AClass[TYPE_REF]{AClass, test, Ltest.AClass;, null, null, 27}",
+ "AClass[TYPE_REF]{AClass, test, Ltest.AClass;, null, null, " + (R_DEFAULT + 22) + "}",
requestor.getResults());
}
@@ -21366,7 +21366,7 @@
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "AClass[TYPE_REF]{AClass, test, Ltest.AClass;, null, null, 27}",
+ "AClass[TYPE_REF]{AClass, test, Ltest.AClass;, null, null, " + (R_DEFAULT + 22) + "}",
requestor.getResults());
}
@@ -21396,10 +21396,10 @@
assertResults(
// without the fix no proposals obtained.
- "Inn.Inn2[TYPE_REF]{test.Inn.Inn2, test, Ltest.Inn$Inn2;, null, null, 44}\n" +
- "ABC.ABCInterface[TYPE_REF]{ABCInterface, test, Ltest.ABC$ABCInterface;, null, null, 47}\n" +
- "In[TYPE_REF]{In, test, Ltest.In;, null, null, 47}\n" +
- "Inn[TYPE_REF]{Inn, test, Ltest.Inn;, null, null, 47}",
+ "Inn.Inn2[TYPE_REF]{test.Inn.Inn2, test, Ltest.Inn$Inn2;, null, null, " + (R_DEFAULT + 39) + "}\n" +
+ "ABC.ABCInterface[TYPE_REF]{ABCInterface, test, Ltest.ABC$ABCInterface;, null, null, " + (R_DEFAULT + 42) + "}\n" +
+ "In[TYPE_REF]{In, test, Ltest.In;, null, null, " + (R_DEFAULT + 42) + "}\n" +
+ "Inn[TYPE_REF]{Inn, test, Ltest.Inn;, null, null, " + (R_DEFAULT + 42) + "}",
requestor.getResults());
}
@@ -21430,11 +21430,11 @@
assertResults(
// without the fix no proposals obtained.
- "Inn.Inn2[TYPE_REF]{test.Inn.Inn2, test, Ltest.Inn$Inn2;, null, null, 44}\n" +
- "Inn.Inn2.Inn3[TYPE_REF]{test.Inn.Inn2.Inn3, test, Ltest.Inn$Inn2$Inn3;, null, null, 44}\n" +
- "ABC[TYPE_REF]{ABC, test, Ltest.ABC;, null, null, 47}\n" +
- "In[TYPE_REF]{In, test, Ltest.In;, null, null, 47}\n" +
- "Inn[TYPE_REF]{Inn, test, Ltest.Inn;, null, null, 47}",
+ "Inn.Inn2[TYPE_REF]{test.Inn.Inn2, test, Ltest.Inn$Inn2;, null, null, " + (R_DEFAULT + 39) + "}\n" +
+ "Inn.Inn2.Inn3[TYPE_REF]{test.Inn.Inn2.Inn3, test, Ltest.Inn$Inn2$Inn3;, null, null, " + (R_DEFAULT + 39) + "}\n" +
+ "ABC[TYPE_REF]{ABC, test, Ltest.ABC;, null, null, " + (R_DEFAULT + 42) + "}\n" +
+ "In[TYPE_REF]{In, test, Ltest.In;, null, null, " + (R_DEFAULT + 42) + "}\n" +
+ "Inn[TYPE_REF]{Inn, test, Ltest.Inn;, null, null, " + (R_DEFAULT + 42) + "}",
requestor.getResults());
}
@@ -21463,9 +21463,9 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- int relevance1 = R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_EXACT_EXPECTED_TYPE;
- int relevance2 = R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC;
- int relevance3 = R_RESOLVED + R_CASE + R_NON_STATIC;
+ int relevance1 = R_DEFAULT + 52;
+ int relevance2 = R_DEFAULT + 22;
+ int relevance3 = R_DEFAULT + 17;
int start1 = str.lastIndexOf("/**/") + "".length();
int end1 = start1 + "/**/".length();
assertResults(
@@ -21620,7 +21620,7 @@
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "myVar1[LOCAL_VARIABLE_REF]{myVar1, null, I, myVar1, null, 57}",
+ "myVar1[LOCAL_VARIABLE_REF]{myVar1, null, I, myVar1, null, " + (R_DEFAULT + 52) + "}",
requestor.getResults());
}
@@ -21942,10 +21942,10 @@
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "MyClass[TYPE_REF]{mypackage.MyClass, mypackage, Lmypackage.MyClass;, null, null, " + (R_NON_STATIC + R_UNQUALIFIED) + "}\n" +
- "mypackage[PACKAGE_REF]{mypackage, mypackage, null, null, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE) + "}\n" +
- "myString[FIELD_REF]{myString, Ltest.X;, Ljava.lang.String;, myString, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE + R_NON_RESTRICTED) + "}\n" +
- "myString2[FIELD_REF]{myString2, Ltest.X;, Ljava.lang.String;, myString2, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE + R_NON_RESTRICTED) + "}",
+ "MyClass[TYPE_REF]{mypackage.MyClass, mypackage, Lmypackage.MyClass;, null, null, " + (R_DEFAULT + 9) + "}\n" +
+ "mypackage[PACKAGE_REF]{mypackage, mypackage, null, null, null, " + (R_DEFAULT + 19) + "}\n" +
+ "myString[FIELD_REF]{myString, Ltest.X;, Ljava.lang.String;, myString, null, " + (R_DEFAULT + 22) + "}\n" +
+ "myString2[FIELD_REF]{myString2, Ltest.X;, Ljava.lang.String;, myString2, null, " + (R_DEFAULT + 22) + "}",
requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=312603
@@ -21969,9 +21969,9 @@
this.wcOwner);
assertResults(
- "MyClass[TYPE_REF]{mypackage.MyClass, mypackage, Lmypackage.MyClass;, null, null, 14}\n" +
- "mypackage[PACKAGE_REF]{mypackage, mypackage, null, null, null, 24}\n" +
- "myString[FIELD_REF]{myString, Ltest.X;, Ljava.lang.String;, myString, null, 57}",
+ "MyClass[TYPE_REF]{mypackage.MyClass, mypackage, Lmypackage.MyClass;, null, null, " + (R_DEFAULT + 9) + "}\n" +
+ "mypackage[PACKAGE_REF]{mypackage, mypackage, null, null, null, " + (R_DEFAULT + 19) + "}\n" +
+ "myString[FIELD_REF]{myString, Ltest.X;, Ljava.lang.String;, myString, null, " + (R_DEFAULT + 52) + "}",
requestor.getResults());
}
@@ -22001,10 +22001,10 @@
this.wcOwner);
assertResults(
- "MyClass[TYPE_REF]{mypackage.MyClass, mypackage, Lmypackage.MyClass;, null, null, " + (R_NON_STATIC + R_UNQUALIFIED) + "}\n" +
- "mypackage[PACKAGE_REF]{mypackage, mypackage, null, null, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE) + "}\n" +
- "myString[LOCAL_VARIABLE_REF]{myString, null, Ljava.lang.String;, myString, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}\n" +
- "myString2[LOCAL_VARIABLE_REF]{myString2, null, Ljava.lang.String;, myString2, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}",
+ "MyClass[TYPE_REF]{mypackage.MyClass, mypackage, Lmypackage.MyClass;, null, null, " + (R_DEFAULT + 9) + "}\n" +
+ "mypackage[PACKAGE_REF]{mypackage, mypackage, null, null, null, " + (R_DEFAULT + 19) + "}\n" +
+ "myString[LOCAL_VARIABLE_REF]{myString, null, Ljava.lang.String;, myString, null, " + (R_DEFAULT + 52) + "}\n" +
+ "myString2[LOCAL_VARIABLE_REF]{myString2, null, Ljava.lang.String;, myString2, null, " + (R_DEFAULT + 52) + "}",
requestor.getResults());
}
@@ -22034,10 +22034,10 @@
this.wcOwner);
assertResults(
- "MyClass[TYPE_REF]{mypackage.MyClass, mypackage, Lmypackage.MyClass;, null, null, " + (R_NON_STATIC + R_UNQUALIFIED) + "}\n" +
- "mypackage[PACKAGE_REF]{mypackage, mypackage, null, null, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE) + "}\n" +
- "myString[LOCAL_VARIABLE_REF]{myString, null, Ljava.lang.String;, myString, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}\n" +
- "myString1[LOCAL_VARIABLE_REF]{myString1, null, Ljava.lang.String;, myString1, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}",
+ "MyClass[TYPE_REF]{mypackage.MyClass, mypackage, Lmypackage.MyClass;, null, null, " + (R_DEFAULT + 9) + "}\n" +
+ "mypackage[PACKAGE_REF]{mypackage, mypackage, null, null, null, " + (R_DEFAULT + 19) + "}\n" +
+ "myString[LOCAL_VARIABLE_REF]{myString, null, Ljava.lang.String;, myString, null, " + (R_DEFAULT + 52) + "}\n" +
+ "myString1[LOCAL_VARIABLE_REF]{myString1, null, Ljava.lang.String;, myString1, null, " + (R_DEFAULT + 52) + "}",
requestor.getResults());
}
@@ -22058,7 +22058,7 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
cu.codeComplete(cursorLocation, requestor);
- int relevance = R_INTERFACE + R_UNQUALIFIED + R_NON_RESTRICTED;
+ int relevance = R_DEFAULT + 21;
assumeEquals(
"should have two completions",
"element:ADD_CUSTOM_ATTRIBUTES completion:ADD_CUSTOM_ATTRIBUTES relevance:" + relevance +"\n" +
@@ -23979,7 +23979,7 @@
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "def[POTENTIAL_METHOD_DECLARATION]{def, Ltest.P;, ()V, def, null, 14}\n" + "default[KEYWORD]{default, null, null, default, null, 24}" ,
+ "def[POTENTIAL_METHOD_DECLARATION]{def, Ltest.P;, ()V, def, null, " + (R_DEFAULT + 9) + "}\n" + "default[KEYWORD]{default, null, null, default, null, " + (R_DEFAULT + 19) + "}" ,
requestor.getResults());
} finally {
// Restore compliance settings.
@@ -24043,7 +24043,7 @@
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "def[POTENTIAL_METHOD_DECLARATION]{def, Ltest.P;, ()V, def, null, 14}" ,
+ "def[POTENTIAL_METHOD_DECLARATION]{def, Ltest.P;, ()V, def, null, " + (R_DEFAULT + 9) + "}" ,
requestor.getResults());
} finally {
// Restore compliance settings.
@@ -24109,7 +24109,7 @@
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "def[POTENTIAL_METHOD_DECLARATION]{def, Ltest.ZZ$I;, ()V, def, null, 14}\n" + "default[KEYWORD]{default, null, null, default, null, 24}" ,
+ "def[POTENTIAL_METHOD_DECLARATION]{def, Ltest.ZZ$I;, ()V, def, null, " + (R_DEFAULT + 9) + "}\n" + "default[KEYWORD]{default, null, null, default, null, " + (R_DEFAULT + 19) + "}" ,
requestor.getResults());
} finally {
// Restore compliance settings.
@@ -24573,10 +24573,10 @@
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
assertResults(
- "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<TT;>;, (Ljava.lang.String;Ljava.lang.String;)V, TXYU, (s, s2), 30}\n" +
- " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, 30}\n" +
- "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<TT;>;, (TT;)V, TXYU, (t), 30}\n" +
- " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, 30}",
+ "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<TT;>;, (Ljava.lang.String;Ljava.lang.String;)V, TXYU, (s, s2), " + (R_DEFAULT + 25) + "}\n" +
+ " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, " + (R_DEFAULT + 25) + "}\n" +
+ "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<TT;>;, (TT;)V, TXYU, (t), " + (R_DEFAULT + 25) + "}\n" +
+ " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, " + (R_DEFAULT + 25) + "}",
requestor.getResults());
assertEquals(true,
requestor.canUseDiamond(0));
@@ -24616,10 +24616,10 @@
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
assertResults(
- "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<TT;>;, (Ljava.lang.String;Ljava.lang.String;)V, TXYU, (s, s2), 30}\n" +
- " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, 30}\n" +
- "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<TT;>;, (TT;)V, TXYU, (t), 30}\n" +
- " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, 30}",
+ "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<TT;>;, (Ljava.lang.String;Ljava.lang.String;)V, TXYU, (s, s2), " + (R_DEFAULT + 25) + "}\n" +
+ " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, " + (R_DEFAULT + 25) + "}\n" +
+ "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<TT;>;, (TT;)V, TXYU, (t), " + (R_DEFAULT + 25) + "}\n" +
+ " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, " + (R_DEFAULT + 25) + "}",
requestor.getResults());
assertEquals(false,
requestor.canUseDiamond(1));
@@ -24662,10 +24662,10 @@
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
assertResults(
- "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.Test<Ljava.lang.Object;>.TXYU;, (Ljava.lang.String;Ljava.lang.String;)V, TXYU, (s, s2), 30}\n" +
- " Test.TXYU[TYPE_REF]{TXYU, test, Ltest.Test$TXYU;, null, null, 30}\n" +
- "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.Test<Ljava.lang.Object;>.TXYU;, (TT;)V, TXYU, (t), 30}\n" +
- " Test.TXYU[TYPE_REF]{TXYU, test, Ltest.Test$TXYU;, null, null, 30}",
+ "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.Test<Ljava.lang.Object;>.TXYU;, (Ljava.lang.String;Ljava.lang.String;)V, TXYU, (s, s2), " + (R_DEFAULT + 25) + "}\n" +
+ " Test.TXYU[TYPE_REF]{TXYU, test, Ltest.Test$TXYU;, null, null, " + (R_DEFAULT + 25) + "}\n" +
+ "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.Test<Ljava.lang.Object;>.TXYU;, (TT;)V, TXYU, (t), " + (R_DEFAULT + 25) + "}\n" +
+ " Test.TXYU[TYPE_REF]{TXYU, test, Ltest.Test$TXYU;, null, null, " + (R_DEFAULT + 25) + "}",
requestor.getResults());
assertEquals(true,
requestor.canUseDiamond(0));
@@ -24708,10 +24708,10 @@
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
assertResults(
- "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.Test<Ljava.lang.Object;>.TXYU;, (Ljava.lang.String;Ljava.lang.String;)V, TXYU, (s, s2), 30}\n" +
- " Test.TXYU[TYPE_REF]{TXYU, test, Ltest.Test$TXYU;, null, null, 30}\n" +
- "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.Test<Ljava.lang.Object;>.TXYU;, (TT;)V, TXYU, (t), 30}\n" +
- " Test.TXYU[TYPE_REF]{TXYU, test, Ltest.Test$TXYU;, null, null, 30}",
+ "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.Test<Ljava.lang.Object;>.TXYU;, (Ljava.lang.String;Ljava.lang.String;)V, TXYU, (s, s2), " + (R_DEFAULT + 25) + "}\n" +
+ " Test.TXYU[TYPE_REF]{TXYU, test, Ltest.Test$TXYU;, null, null, " + (R_DEFAULT + 25) + "}\n" +
+ "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.Test<Ljava.lang.Object;>.TXYU;, (TT;)V, TXYU, (t), " + (R_DEFAULT + 25) + "}\n" +
+ " Test.TXYU[TYPE_REF]{TXYU, test, Ltest.Test$TXYU;, null, null, " + (R_DEFAULT + 25) + "}",
requestor.getResults());
assertEquals(false,
requestor.canUseDiamond(1));
@@ -24757,10 +24757,10 @@
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
assertResults(
- "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<LNumber;>;, (LNumber;)V, TXYU, (t), 60}\n" +
- " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, 60}\n" +
- "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<LNumber;>;, (Ljava.lang.String;Ljava.lang.String;)V, TXYU, (s, s2), 60}\n" +
- " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, 60}",
+ "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<LNumber;>;, (LNumber;)V, TXYU, (t), " + (R_DEFAULT + 55) + "}\n" +
+ " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, " + (R_DEFAULT + 55) + "}\n" +
+ "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<LNumber;>;, (Ljava.lang.String;Ljava.lang.String;)V, TXYU, (s, s2), " + (R_DEFAULT + 55) + "}\n" +
+ " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, " + (R_DEFAULT + 55) + "}",
requestor.getResults());
assertEquals(false,
requestor.canUseDiamond(0));
@@ -24806,10 +24806,10 @@
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
assertResults(
- "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<LNumber;>;, (LNumber;)V, TXYU, (t), 60}\n" +
- " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, 60}\n" +
- "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<LNumber;>;, (Ljava.lang.String;Ljava.lang.String;)V, TXYU, (s, s2), 60}\n" +
- " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, 60}",
+ "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<LNumber;>;, (LNumber;)V, TXYU, (t), " + (R_DEFAULT + 55) + "}\n" +
+ " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, " + (R_DEFAULT + 55) + "}\n" +
+ "TXYU[CONSTRUCTOR_INVOCATION]{(), Ltest.TXYU<LNumber;>;, (Ljava.lang.String;Ljava.lang.String;)V, TXYU, (s, s2), " + (R_DEFAULT + 55) + "}\n" +
+ " TXYU[TYPE_REF]{TXYU, test, Ltest.TXYU;, null, null, " + (R_DEFAULT + 55) + "}",
requestor.getResults());
assertEquals(true,
requestor.canUseDiamond(1));
@@ -24850,11 +24850,11 @@
"expectedTypesKeys={Ltest/Try~MyClass;}",
requestor.getContext());
assertResults(
- "mypackage[PACKAGE_REF]{mypackage, mypackage, null, null, null, " + (R_NON_STATIC + R_UNQUALIFIED) + "}\n" +
- "MyClass[TYPE_REF]{mypackage.MyClass, mypackage, Lmypackage.MyClass;, null, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE) + "}\n" +
- "MyClass[TYPE_REF]{MyClass, test, Ltest.MyClass;, null, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}\n" +
- "MyClassField[FIELD_REF]{MyClassField, Ltest.Try;, Ltest.MyClass;, MyClassField, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}\n" +
- "MyClassMethod[METHOD_REF]{MyClassMethod(), Ltest.Try;, ()Ltest.MyClass;, MyClassMethod, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}",
+ "mypackage[PACKAGE_REF]{mypackage, mypackage, null, null, null, " + (R_DEFAULT + 9) + "}\n" +
+ "MyClass[TYPE_REF]{mypackage.MyClass, mypackage, Lmypackage.MyClass;, null, null, " + (R_DEFAULT + 19) + "}\n" +
+ "MyClass[TYPE_REF]{MyClass, test, Ltest.MyClass;, null, null, " + (R_DEFAULT + 52) + "}\n" +
+ "MyClassField[FIELD_REF]{MyClassField, Ltest.Try;, Ltest.MyClass;, MyClassField, null, " + (R_DEFAULT + 52) + "}\n" +
+ "MyClassMethod[METHOD_REF]{MyClassMethod(), Ltest.Try;, ()Ltest.MyClass;, MyClassMethod, null, " + (R_DEFAULT + 52) + "}",
requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=292087
@@ -24888,21 +24888,21 @@
"expectedTypesKeys={Ltest/Try~MyClass;}",
requestor.getContext());
assertResults(
- "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_VOID) + "}\n" +
- "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_VOID) + "}\n" +
- "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_VOID) + "}\n" +
- "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_VOID) + "}\n" +
- "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_VOID) + "}\n" +
- "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_VOID) + "}\n" +
- "Try[TYPE_REF]{Try, test, Ltest.Try;, null, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS) + "}\n" +
- "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS) + "}\n" +
- "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS) + "}\n" +
- "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class;, getClass, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS) + "}\n" +
- "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS) + "}\n" +
- "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS) + "}\n" +
- "MyClass[TYPE_REF]{MyClass, test, Ltest.MyClass;, null, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_EXACT_EXPECTED_TYPE) + "}\n" +
- "MyClassField[FIELD_REF]{MyClassField, Ltest.Try;, Ltest.MyClass;, MyClassField, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_EXACT_EXPECTED_TYPE) + "}\n" +
- "MyClassMethod[METHOD_REF]{MyClassMethod(), Ltest.Try;, ()Ltest.MyClass;, MyClassMethod, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_EXACT_EXPECTED_TYPE) + "}",
+ "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, " + (R_DEFAULT + 17) + "}\n" +
+ "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, " + (R_DEFAULT + 17) + "}\n" +
+ "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, " + (R_DEFAULT + 17) + "}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, " + (R_DEFAULT + 17) + "}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), " + (R_DEFAULT + 17) + "}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), " + (R_DEFAULT + 17) + "}\n" +
+ "Try[TYPE_REF]{Try, test, Ltest.Try;, null, null, " + (R_DEFAULT + 22) + "}\n" +
+ "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, " + (R_DEFAULT + 22) + "}\n" +
+ "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), " + (R_DEFAULT + 22) + "}\n" +
+ "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class;, getClass, null, " + (R_DEFAULT + 22) + "}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, " + (R_DEFAULT + 22) + "}\n" +
+ "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, " + (R_DEFAULT + 22) + "}\n" +
+ "MyClass[TYPE_REF]{MyClass, test, Ltest.MyClass;, null, null, " + (R_DEFAULT + 52) + "}\n" +
+ "MyClassField[FIELD_REF]{MyClassField, Ltest.Try;, Ltest.MyClass;, MyClassField, null, " + (R_DEFAULT + 52) + "}\n" +
+ "MyClassMethod[METHOD_REF]{MyClassMethod(), Ltest.Try;, ()Ltest.MyClass;, MyClassMethod, null, " + (R_DEFAULT + 52) + "}",
requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=292087
@@ -24938,21 +24938,21 @@
"expectedTypesKeys={Ltest/Try~MyClass;}",
requestor.getContext());
assertResults(
- "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_VOID) + "}\n" +
- "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_VOID) + "}\n" +
- "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_VOID) + "}\n" +
- "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_VOID) + "}\n" +
- "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_VOID) + "}\n" +
- "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_VOID) + "}\n" +
- "Try[TYPE_REF]{Try, test, Ltest.Try;, null, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS) + "}\n" +
- "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS) + "}\n" +
- "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS) + "}\n" +
- "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class;, getClass, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS) + "}\n" +
- "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS) + "}\n" +
- "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS) + "}\n" +
- "MyClass[TYPE_REF]{MyClass, test, Ltest.MyClass;, null, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_EXACT_EXPECTED_TYPE) + "}\n" +
- "MyClassField[FIELD_REF]{MyClassField, Ltest.Try;, Ltest.MyClass;, MyClassField, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_EXACT_EXPECTED_TYPE) + "}\n" +
- "MyClassMethod[METHOD_REF]{MyClassMethod(), Ltest.Try;, ()Ltest.MyClass;, MyClassMethod, null, " + (R_RESOLVED + R_NON_STATIC + R_NAME_LESS_NEW_CHARACTERS + R_EXACT_EXPECTED_TYPE) + "}",
+ "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, " + (R_DEFAULT + 17) + "}\n" +
+ "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, " + (R_DEFAULT + 17) + "}\n" +
+ "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, " + (R_DEFAULT + 17) + "}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, " + (R_DEFAULT + 17) + "}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), " + (R_DEFAULT + 17) + "}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), " + (R_DEFAULT + 17) + "}\n" +
+ "Try[TYPE_REF]{Try, test, Ltest.Try;, null, null, " + (R_DEFAULT + 22) + "}\n" +
+ "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, " + (R_DEFAULT + 22) + "}\n" +
+ "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), " + (R_DEFAULT + 22) + "}\n" +
+ "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class;, getClass, null, " + (R_DEFAULT + 22) + "}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, " + (R_DEFAULT + 22) + "}\n" +
+ "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, " + (R_DEFAULT + 22) + "}\n" +
+ "MyClass[TYPE_REF]{MyClass, test, Ltest.MyClass;, null, null, " + (R_DEFAULT + 52) + "}\n" +
+ "MyClassField[FIELD_REF]{MyClassField, Ltest.Try;, Ltest.MyClass;, MyClassField, null, " + (R_DEFAULT + 52) + "}\n" +
+ "MyClassMethod[METHOD_REF]{MyClassMethod(), Ltest.Try;, ()Ltest.MyClass;, MyClassMethod, null, " + (R_DEFAULT + 52) + "}",
requestor.getResults());
}
@@ -25181,15 +25181,15 @@
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
assertResults(
- "IT_MAY_BE_DUE_TO_MIXING_PERHAPS[FIELD_REF]{IT_MAY_BE_DUE_TO_MIXING_PERHAPS, Ltest.ExampleEnumNoAutocomplete;, Ltest.ExampleEnumNoAutocomplete;, IT_MAY_BE_DUE_TO_MIXING_PERHAPS, null, 26}\n" +
- "MORE_STUFF[FIELD_REF]{MORE_STUFF, Ltest.ExampleEnumNoAutocomplete;, Ltest.ExampleEnumNoAutocomplete;, MORE_STUFF, null, 26}\n" +
- "OTHER[FIELD_REF]{OTHER, Ltest.ExampleEnumNoAutocomplete;, Ltest.ExampleEnumNoAutocomplete;, OTHER, null, 26}\n" +
- "STILL_OTHER[FIELD_REF]{STILL_OTHER, Ltest.ExampleEnumNoAutocomplete;, Ltest.ExampleEnumNoAutocomplete;, STILL_OTHER, null, 26}\n" +
- "STUFF[FIELD_REF]{STUFF, Ltest.ExampleEnumNoAutocomplete;, Ltest.ExampleEnumNoAutocomplete;, STUFF, null, 26}\n" +
- "THINGS[FIELD_REF]{THINGS, Ltest.ExampleEnumNoAutocomplete;, Ltest.ExampleEnumNoAutocomplete;, THINGS, null, 26}\n" +
- "class[FIELD_REF]{class, null, Ljava.lang.Class<Ltest.ExampleEnumNoAutocomplete;>;, class, null, 26}\n" +
- "valueOf[METHOD_REF]{valueOf(), Ltest.ExampleEnumNoAutocomplete;, (Ljava.lang.String;)Ltest.ExampleEnumNoAutocomplete;, valueOf, (arg0), 26}\n" +
- "values[METHOD_REF]{values(), Ltest.ExampleEnumNoAutocomplete;, ()[Ltest.ExampleEnumNoAutocomplete;, values, null, 26}",
+ "IT_MAY_BE_DUE_TO_MIXING_PERHAPS[FIELD_REF]{IT_MAY_BE_DUE_TO_MIXING_PERHAPS, Ltest.ExampleEnumNoAutocomplete;, Ltest.ExampleEnumNoAutocomplete;, IT_MAY_BE_DUE_TO_MIXING_PERHAPS, null, " + (R_DEFAULT + 21) + "}\n" +
+ "MORE_STUFF[FIELD_REF]{MORE_STUFF, Ltest.ExampleEnumNoAutocomplete;, Ltest.ExampleEnumNoAutocomplete;, MORE_STUFF, null, " + (R_DEFAULT + 21) + "}\n" +
+ "OTHER[FIELD_REF]{OTHER, Ltest.ExampleEnumNoAutocomplete;, Ltest.ExampleEnumNoAutocomplete;, OTHER, null, " + (R_DEFAULT + 21) + "}\n" +
+ "STILL_OTHER[FIELD_REF]{STILL_OTHER, Ltest.ExampleEnumNoAutocomplete;, Ltest.ExampleEnumNoAutocomplete;, STILL_OTHER, null, " + (R_DEFAULT + 21) + "}\n" +
+ "STUFF[FIELD_REF]{STUFF, Ltest.ExampleEnumNoAutocomplete;, Ltest.ExampleEnumNoAutocomplete;, STUFF, null, " + (R_DEFAULT + 21) + "}\n" +
+ "THINGS[FIELD_REF]{THINGS, Ltest.ExampleEnumNoAutocomplete;, Ltest.ExampleEnumNoAutocomplete;, THINGS, null, " + (R_DEFAULT + 21) + "}\n" +
+ "class[FIELD_REF]{class, null, Ljava.lang.Class<Ltest.ExampleEnumNoAutocomplete;>;, class, null, " + (R_DEFAULT + 21) + "}\n" +
+ "valueOf[METHOD_REF]{valueOf(), Ltest.ExampleEnumNoAutocomplete;, (Ljava.lang.String;)Ltest.ExampleEnumNoAutocomplete;, valueOf, (arg0), " + (R_DEFAULT + 21) + "}\n" +
+ "values[METHOD_REF]{values(), Ltest.ExampleEnumNoAutocomplete;, ()[Ltest.ExampleEnumNoAutocomplete;, values, null, " + (R_DEFAULT + 21) + "}",
requestor.getResults());
assertEquals(false,
requestor.canUseDiamond(0));
@@ -25242,7 +25242,7 @@
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
assertResults(
- "staticMethod[METHOD_REF]{staticMethod(), Ltest.Test;, ()V, staticMethod, null, 27}",
+ "staticMethod[METHOD_REF]{staticMethod(), Ltest.Test;, ()V, staticMethod, null, " + (R_DEFAULT + 22) + "}",
requestor.getResults());
} finally {
deleteProject("P");
@@ -25297,7 +25297,7 @@
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
assertResults(
- "staticMethod[METHOD_REF]{staticMethod(), Ltest.I;, ()V, staticMethod, null, 26}",
+ "staticMethod[METHOD_REF]{staticMethod(), Ltest.I;, ()V, staticMethod, null, " + (R_DEFAULT + 21) + "}",
requestor.getResults());
} finally {
deleteProject("P");
@@ -25353,7 +25353,7 @@
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
assertResults(
- "defaultMethod[METHOD_REF]{defaultMethod(), Ltest.I;, ()V, defaultMethod, null, 35}",
+ "defaultMethod[METHOD_REF]{defaultMethod(), Ltest.I;, ()V, defaultMethod, null, " + (R_DEFAULT + 30) + "}",
requestor.getResults());
} finally {
deleteProject("P");
@@ -25408,7 +25408,7 @@
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
assertResults(
- "defaultMethod[METHOD_REF]{defaultMethod(), Ltest.I;, ()V, defaultMethod, null, 27}",
+ "defaultMethod[METHOD_REF]{defaultMethod(), Ltest.I;, ()V, defaultMethod, null, " + (R_DEFAULT + 22) + "}",
requestor.getResults());
} finally {
deleteProject("P");
@@ -25452,7 +25452,7 @@
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
assertResults(
- "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, 65}",
+ "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, " + (R_DEFAULT + 60) + "}",
requestor.getResults());
assertEquals(false,
requestor.canUseDiamond(0));
@@ -25492,12 +25492,12 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "I[TYPE_REF]{I, test, Ltest.I;, null, null, 27}\n" +
- "X[TYPE_REF]{X, test, Ltest.X;, null, null, 27}\n" +
- "args[LOCAL_VARIABLE_REF]{args, null, [Ljava.lang.String;, args, null, 27}\n" +
- "i[LOCAL_VARIABLE_REF]{i, null, Ltest.I;, i, null, 27}\n" +
- "main[METHOD_REF]{main(), Ltest.X;, ([Ljava.lang.String;)V, main, (args), 27}\n" +
- "x[LOCAL_VARIABLE_REF]{x, null, [[[Ltest.X;, x, null, 27}",
+ "I[TYPE_REF]{I, test, Ltest.I;, null, null, " + (R_DEFAULT + 22) + "}\n" +
+ "X[TYPE_REF]{X, test, Ltest.X;, null, null, " + (R_DEFAULT + 22) + "}\n" +
+ "args[LOCAL_VARIABLE_REF]{args, null, [Ljava.lang.String;, args, null, " + (R_DEFAULT + 22) + "}\n" +
+ "i[LOCAL_VARIABLE_REF]{i, null, Ltest.I;, i, null, " + (R_DEFAULT + 22) + "}\n" +
+ "main[METHOD_REF]{main(), Ltest.X;, ([Ljava.lang.String;)V, main, (args), " + (R_DEFAULT + 22) + "}\n" +
+ "x[LOCAL_VARIABLE_REF]{x, null, [[[Ltest.X;, x, null, " + (R_DEFAULT + 22) + "}",
requestor.getResults());
} finally {
// Restore compliance settings.
@@ -25534,13 +25534,13 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "I[TYPE_REF]{I, test, Ltest.I;, null, null, 27}\n" +
- "S[TYPE_REF]{S, null, TS;, null, null, 27}\n" +
- "X<S>[TYPE_REF]{X, test, Ltest.X<TS;>;, null, null, 27}\n" +
- "args[LOCAL_VARIABLE_REF]{args, null, [Ljava.lang.String;, args, null, 27}\n" +
- "i[LOCAL_VARIABLE_REF]{i, null, Ltest.I;, i, null, 27}\n" +
- "main[METHOD_REF]{main(), Ltest.X<TS;>;, ([Ljava.lang.String;)V, main, (args), 27}\n" +
- "x[LOCAL_VARIABLE_REF]{x, null, Ltest.X;, x, null, 27}",
+ "I[TYPE_REF]{I, test, Ltest.I;, null, null, " + (R_DEFAULT + 22) + "}\n" +
+ "S[TYPE_REF]{S, null, TS;, null, null, " + (R_DEFAULT + 22) + "}\n" +
+ "X<S>[TYPE_REF]{X, test, Ltest.X<TS;>;, null, null, " + (R_DEFAULT + 22) + "}\n" +
+ "args[LOCAL_VARIABLE_REF]{args, null, [Ljava.lang.String;, args, null, " + (R_DEFAULT + 22) + "}\n" +
+ "i[LOCAL_VARIABLE_REF]{i, null, Ltest.I;, i, null, " + (R_DEFAULT + 22) + "}\n" +
+ "main[METHOD_REF]{main(), Ltest.X<TS;>;, ([Ljava.lang.String;)V, main, (args), " + (R_DEFAULT + 22) + "}\n" +
+ "x[LOCAL_VARIABLE_REF]{x, null, Ltest.X;, x, null, " + (R_DEFAULT + 22) + "}",
requestor.getResults());
} finally {
// Restore compliance settings.
@@ -25694,7 +25694,7 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "pqrqwerty[LOCAL_VARIABLE_REF]{pqrqwerty, null, I, pqrqwerty, null, 27}",
+ "pqrqwerty[LOCAL_VARIABLE_REF]{pqrqwerty, null, I, pqrqwerty, null, " + (R_DEFAULT + 22) + "}",
requestor.getResults());
} finally {
// Restore compliance settings.
@@ -25739,7 +25739,7 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "pqrqwerty[LOCAL_VARIABLE_REF]{pqrqwerty, null, I, pqrqwerty, null, 27}",
+ "pqrqwerty[LOCAL_VARIABLE_REF]{pqrqwerty, null, I, pqrqwerty, null, " + (R_DEFAULT + 22) + "}",
requestor.getResults());
} finally {
// Restore compliance settings.
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests18.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests18.java
index 9002b44..7056054 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests18.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests18.java
@@ -26,7 +26,7 @@
public class CompletionTests18 extends AbstractJavaModelCompletionTests {
static {
-// TESTS_NAMES = new String[] {"test001"};
+// TESTS_NAMES = new String[] {"test001"};
}
public CompletionTests18(String name) {
@@ -63,7 +63,7 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "first[LOCAL_VARIABLE_REF]{first, null, I, first, null, 27}",
+ "first[LOCAL_VARIABLE_REF]{first, null, I, first, null, " + (R_DEFAULT + 22) + "}",
requestor.getResults());
}
public void test002() throws JavaModelException {
@@ -86,7 +86,7 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "first[LOCAL_VARIABLE_REF]{first, null, I, first, null, 27}",
+ "first[LOCAL_VARIABLE_REF]{first, null, I, first, null, " + (R_DEFAULT + 22) + "}",
requestor.getResults());
}
public void test003() throws JavaModelException {
@@ -118,22 +118,22 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "CASE_INSENSITIVE_ORDER[FIELD_REF]{CASE_INSENSITIVE_ORDER, Ljava.lang.String;, Ljava.util.Comparator<Ljava.lang.String;>;, CASE_INSENSITIVE_ORDER, null, 14}\n" +
- "copyValueOf[METHOD_REF]{copyValueOf(), Ljava.lang.String;, ([C)Ljava.lang.String;, copyValueOf, (arg0), 24}\n" +
- "copyValueOf[METHOD_REF]{copyValueOf(), Ljava.lang.String;, ([CII)Ljava.lang.String;, copyValueOf, (arg0, arg1, arg2), 24}\n" +
- "charAt[METHOD_REF]{charAt(), Ljava.lang.String;, (I)C, charAt, (arg0), 35}\n" +
- "chars[METHOD_REF]{chars(), Ljava.lang.CharSequence;, ()Ljava.util.stream.IntStream;, chars, null, 35}\n" +
- "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, 35}\n" +
- "codePointAt[METHOD_REF]{codePointAt(), Ljava.lang.String;, (I)I, codePointAt, (arg0), 35}\n" +
- "codePointBefore[METHOD_REF]{codePointBefore(), Ljava.lang.String;, (I)I, codePointBefore, (arg0), 35}\n" +
- "codePointCount[METHOD_REF]{codePointCount(), Ljava.lang.String;, (II)I, codePointCount, (arg0, arg1), 35}\n" +
- "codePoints[METHOD_REF]{codePoints(), Ljava.lang.CharSequence;, ()Ljava.util.stream.IntStream;, codePoints, null, 35}\n" +
- "compareTo[METHOD_REF]{compareTo(), Ljava.lang.String;, (Ljava.lang.String;)I, compareTo, (arg0), 35}\n" +
- "compareToIgnoreCase[METHOD_REF]{compareToIgnoreCase(), Ljava.lang.String;, (Ljava.lang.String;)I, compareToIgnoreCase, (arg0), 35}\n" +
- "concat[METHOD_REF]{concat(), Ljava.lang.String;, (Ljava.lang.String;)Ljava.lang.String;, concat, (arg0), 35}\n" +
- "contains[METHOD_REF]{contains(), Ljava.lang.String;, (Ljava.lang.CharSequence;)Z, contains, (arg0), 35}\n" +
- "contentEquals[METHOD_REF]{contentEquals(), Ljava.lang.String;, (Ljava.lang.CharSequence;)Z, contentEquals, (arg0), 35}\n" +
- "contentEquals[METHOD_REF]{contentEquals(), Ljava.lang.String;, (Ljava.lang.StringBuffer;)Z, contentEquals, (arg0), 35}",
+ "CASE_INSENSITIVE_ORDER[FIELD_REF]{CASE_INSENSITIVE_ORDER, Ljava.lang.String;, Ljava.util.Comparator<Ljava.lang.String;>;, CASE_INSENSITIVE_ORDER, null, " + (R_DEFAULT + 9) + "}\n" +
+ "copyValueOf[METHOD_REF]{copyValueOf(), Ljava.lang.String;, ([C)Ljava.lang.String;, copyValueOf, (arg0), " + (R_DEFAULT + 19) + "}\n" +
+ "copyValueOf[METHOD_REF]{copyValueOf(), Ljava.lang.String;, ([CII)Ljava.lang.String;, copyValueOf, (arg0, arg1, arg2), " + (R_DEFAULT + 19) + "}\n" +
+ "charAt[METHOD_REF]{charAt(), Ljava.lang.String;, (I)C, charAt, (arg0), " + (R_DEFAULT + 30) + "}\n" +
+ "chars[METHOD_REF]{chars(), Ljava.lang.CharSequence;, ()Ljava.util.stream.IntStream;, chars, null, " + (R_DEFAULT + 30) + "}\n" +
+ "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, " + (R_DEFAULT + 30) + "}\n" +
+ "codePointAt[METHOD_REF]{codePointAt(), Ljava.lang.String;, (I)I, codePointAt, (arg0), " + (R_DEFAULT + 30) + "}\n" +
+ "codePointBefore[METHOD_REF]{codePointBefore(), Ljava.lang.String;, (I)I, codePointBefore, (arg0), " + (R_DEFAULT + 30) + "}\n" +
+ "codePointCount[METHOD_REF]{codePointCount(), Ljava.lang.String;, (II)I, codePointCount, (arg0, arg1), " + (R_DEFAULT + 30) + "}\n" +
+ "codePoints[METHOD_REF]{codePoints(), Ljava.lang.CharSequence;, ()Ljava.util.stream.IntStream;, codePoints, null, " + (R_DEFAULT + 30) + "}\n" +
+ "compareTo[METHOD_REF]{compareTo(), Ljava.lang.String;, (Ljava.lang.String;)I, compareTo, (arg0), " + (R_DEFAULT + 30) + "}\n" +
+ "compareToIgnoreCase[METHOD_REF]{compareToIgnoreCase(), Ljava.lang.String;, (Ljava.lang.String;)I, compareToIgnoreCase, (arg0), " + (R_DEFAULT + 30) + "}\n" +
+ "concat[METHOD_REF]{concat(), Ljava.lang.String;, (Ljava.lang.String;)Ljava.lang.String;, concat, (arg0), " + (R_DEFAULT + 30) + "}\n" +
+ "contains[METHOD_REF]{contains(), Ljava.lang.String;, (Ljava.lang.CharSequence;)Z, contains, (arg0), " + (R_DEFAULT + 30) + "}\n" +
+ "contentEquals[METHOD_REF]{contentEquals(), Ljava.lang.String;, (Ljava.lang.CharSequence;)Z, contentEquals, (arg0), " + (R_DEFAULT + 30) + "}\n" +
+ "contentEquals[METHOD_REF]{contentEquals(), Ljava.lang.String;, (Ljava.lang.StringBuffer;)Z, contentEquals, (arg0), " + (R_DEFAULT + 30) + "}",
requestor.getResults());
}
public void test004() throws JavaModelException {
@@ -154,8 +154,8 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "lpx5[LOCAL_VARIABLE_REF]{lpx5, null, I, lpx5, null, 27}\n" +
- "lpx6[LOCAL_VARIABLE_REF]{lpx6, null, I, lpx6, null, 27}",
+ "lpx5[LOCAL_VARIABLE_REF]{lpx5, null, I, lpx5, null, " + (R_DEFAULT + 22) + "}\n" +
+ "lpx6[LOCAL_VARIABLE_REF]{lpx6, null, I, lpx6, null, " + (R_DEFAULT + 22) + "}",
requestor.getResults());
}
@@ -183,7 +183,7 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "argument[LOCAL_VARIABLE_REF]{argument, null, I, argument, null, 57}",
+ "argument[LOCAL_VARIABLE_REF]{argument, null, I, argument, null, " + (R_DEFAULT + 52) + "}",
requestor.getResults());
}
public void test006() throws JavaModelException {
@@ -208,7 +208,7 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "argument[LOCAL_VARIABLE_REF]{argument, null, I, argument, null, 27}",
+ "argument[LOCAL_VARIABLE_REF]{argument, null, I, argument, null, " + (R_DEFAULT + 22) + "}",
requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=405126, [1.8][code assist] Lambda parameters incorrectly recovered as fields.
@@ -236,10 +236,10 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "class[FIELD_REF]{class, null, Ljava.lang.Class<LX;>;, class, null, 26}\n" +
- "f[FIELD_REF]{f, LX;, LFoo;, f, null, 26}\n" +
- "this[KEYWORD]{this, null, null, this, null, 26}\n" +
- "x1[FIELD_REF]{x1, LX;, I, x1, null, 56}",
+ "class[FIELD_REF]{class, null, Ljava.lang.Class<LX;>;, class, null, " + (R_DEFAULT + 21) + "}\n" +
+ "f[FIELD_REF]{f, LX;, LFoo;, f, null, " + (R_DEFAULT + 21) + "}\n" +
+ "this[KEYWORD]{this, null, null, this, null, " + (R_DEFAULT + 21) + "}\n" +
+ "x1[FIELD_REF]{x1, LX;, I, x1, null, " + (R_DEFAULT + 51) + "}",
requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=422107, [1.8][code assist] Invoking code assist just before and after a variable initialized using lambda gives different result
@@ -265,35 +265,35 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "[POTENTIAL_METHOD_DECLARATION]{, LX;, ()V, , null, 14}\n" +
- "abstract[KEYWORD]{abstract, null, null, abstract, null, 24}\n" +
+ "[POTENTIAL_METHOD_DECLARATION]{, LX;, ()V, , null, " + (R_DEFAULT + 9) + "}\n" +
+ "abstract[KEYWORD]{abstract, null, null, abstract, null, " + (R_DEFAULT + 19) + "}\n" +
//{ObjectTeams:
- "callin[KEYWORD]{callin, null, null, callin, null, 24}\n" +
+ "callin[KEYWORD]{callin, null, null, callin, null, " + (R_DEFAULT + 19) + "}\n" +
// SH}
- "class[KEYWORD]{class, null, null, class, null, 24}\n" +
- "enum[KEYWORD]{enum, null, null, enum, null, 24}\n" +
- "final[KEYWORD]{final, null, null, final, null, 24}\n" +
- "interface[KEYWORD]{interface, null, null, interface, null, 24}\n" +
- "native[KEYWORD]{native, null, null, native, null, 24}\n" +
- "private[KEYWORD]{private, null, null, private, null, 24}\n" +
- "protected[KEYWORD]{protected, null, null, protected, null, 24}\n" +
- "public[KEYWORD]{public, null, null, public, null, 24}\n" +
- "static[KEYWORD]{static, null, null, static, null, 24}\n" +
- "strictfp[KEYWORD]{strictfp, null, null, strictfp, null, 24}\n" +
- "synchronized[KEYWORD]{synchronized, null, null, synchronized, null, 24}\n" +
+ "class[KEYWORD]{class, null, null, class, null, " + (R_DEFAULT + 19) + "}\n" +
+ "enum[KEYWORD]{enum, null, null, enum, null, " + (R_DEFAULT + 19) + "}\n" +
+ "final[KEYWORD]{final, null, null, final, null, " + (R_DEFAULT + 19) + "}\n" +
+ "interface[KEYWORD]{interface, null, null, interface, null, " + (R_DEFAULT + 19) + "}\n" +
+ "native[KEYWORD]{native, null, null, native, null, " + (R_DEFAULT + 19) + "}\n" +
+ "private[KEYWORD]{private, null, null, private, null, " + (R_DEFAULT + 19) + "}\n" +
+ "protected[KEYWORD]{protected, null, null, protected, null, " + (R_DEFAULT + 19) + "}\n" +
+ "public[KEYWORD]{public, null, null, public, null, " + (R_DEFAULT + 19) + "}\n" +
+ "static[KEYWORD]{static, null, null, static, null, " + (R_DEFAULT + 19) + "}\n" +
+ "strictfp[KEYWORD]{strictfp, null, null, strictfp, null, " + (R_DEFAULT + 19) + "}\n" +
+ "synchronized[KEYWORD]{synchronized, null, null, synchronized, null, " + (R_DEFAULT + 19) + "}\n" +
//{ObjectTeams:
- "team[KEYWORD]{team, null, null, team, null, 24}\n" +
+ "team[KEYWORD]{team, null, null, team, null, " + (R_DEFAULT + 19) + "}\n" +
// SH}
- "transient[KEYWORD]{transient, null, null, transient, null, 24}\n" +
- "volatile[KEYWORD]{volatile, null, null, volatile, null, 24}\n" +
- "I[TYPE_REF]{I, , LI;, null, null, 27}\n" +
- "J[TYPE_REF]{J, , LJ;, null, null, 27}\n" +
- "X[TYPE_REF]{X, , LX;, null, null, 27}\n" +
- "clone[METHOD_DECLARATION]{protected Object clone() throws CloneNotSupportedException, Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, 27}\n" +
- "equals[METHOD_DECLARATION]{public boolean equals(Object obj), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), 27}\n" +
- "finalize[METHOD_DECLARATION]{protected void finalize() throws Throwable, Ljava.lang.Object;, ()V, finalize, null, 27}\n" +
- "hashCode[METHOD_DECLARATION]{public int hashCode(), Ljava.lang.Object;, ()I, hashCode, null, 27}\n" +
- "toString[METHOD_DECLARATION]{public String toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, 27}",
+ "transient[KEYWORD]{transient, null, null, transient, null, " + (R_DEFAULT + 19) + "}\n" +
+ "volatile[KEYWORD]{volatile, null, null, volatile, null, " + (R_DEFAULT + 19) + "}\n" +
+ "I[TYPE_REF]{I, , LI;, null, null, " + (R_DEFAULT + 22) + "}\n" +
+ "J[TYPE_REF]{J, , LJ;, null, null, " + (R_DEFAULT + 22) + "}\n" +
+ "X[TYPE_REF]{X, , LX;, null, null, " + (R_DEFAULT + 22) + "}\n" +
+ "clone[METHOD_DECLARATION]{protected Object clone() throws CloneNotSupportedException, Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, " + (R_DEFAULT + 22) + "}\n" +
+ "equals[METHOD_DECLARATION]{public boolean equals(Object obj), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), " + (R_DEFAULT + 22) + "}\n" +
+ "finalize[METHOD_DECLARATION]{protected void finalize() throws Throwable, Ljava.lang.Object;, ()V, finalize, null, " + (R_DEFAULT + 22) + "}\n" +
+ "hashCode[METHOD_DECLARATION]{public int hashCode(), Ljava.lang.Object;, ()I, hashCode, null, " + (R_DEFAULT + 22) + "}\n" +
+ "toString[METHOD_DECLARATION]{public String toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, " + (R_DEFAULT + 22) + "}",
requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=422107, [1.8][code assist] Invoking code assist just before and after a variable initialized using lambda gives different result
@@ -319,35 +319,35 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "[POTENTIAL_METHOD_DECLARATION]{, LX;, ()V, , null, 14}\n" +
- "abstract[KEYWORD]{abstract, null, null, abstract, null, 24}\n" +
+ "[POTENTIAL_METHOD_DECLARATION]{, LX;, ()V, , null, " + (R_DEFAULT + 9) + "}\n" +
+ "abstract[KEYWORD]{abstract, null, null, abstract, null, " + (R_DEFAULT + 19) + "}\n" +
//{ObjectTeams:
- "callin[KEYWORD]{callin, null, null, callin, null, 24}\n" +
+ "callin[KEYWORD]{callin, null, null, callin, null, " + (R_DEFAULT + 9) + "}\n" +
// SH}
- "class[KEYWORD]{class, null, null, class, null, 24}\n" +
- "enum[KEYWORD]{enum, null, null, enum, null, 24}\n" +
- "final[KEYWORD]{final, null, null, final, null, 24}\n" +
- "interface[KEYWORD]{interface, null, null, interface, null, 24}\n" +
- "native[KEYWORD]{native, null, null, native, null, 24}\n" +
- "private[KEYWORD]{private, null, null, private, null, 24}\n" +
- "protected[KEYWORD]{protected, null, null, protected, null, 24}\n" +
- "public[KEYWORD]{public, null, null, public, null, 24}\n" +
- "static[KEYWORD]{static, null, null, static, null, 24}\n" +
- "strictfp[KEYWORD]{strictfp, null, null, strictfp, null, 24}\n" +
- "synchronized[KEYWORD]{synchronized, null, null, synchronized, null, 24}\n" +
+ "class[KEYWORD]{class, null, null, class, null, " + (R_DEFAULT + 19) + "}\n" +
+ "enum[KEYWORD]{enum, null, null, enum, null, " + (R_DEFAULT + 19) + "}\n" +
+ "final[KEYWORD]{final, null, null, final, null, " + (R_DEFAULT + 19) + "}\n" +
+ "interface[KEYWORD]{interface, null, null, interface, null, " + (R_DEFAULT + 19) + "}\n" +
+ "native[KEYWORD]{native, null, null, native, null, " + (R_DEFAULT + 19) + "}\n" +
+ "private[KEYWORD]{private, null, null, private, null, " + (R_DEFAULT + 19) + "}\n" +
+ "protected[KEYWORD]{protected, null, null, protected, null, " + (R_DEFAULT + 19) + "}\n" +
+ "public[KEYWORD]{public, null, null, public, null, " + (R_DEFAULT + 19) + "}\n" +
+ "static[KEYWORD]{static, null, null, static, null, " + (R_DEFAULT + 19) + "}\n" +
+ "strictfp[KEYWORD]{strictfp, null, null, strictfp, null, " + (R_DEFAULT + 19) + "}\n" +
+ "synchronized[KEYWORD]{synchronized, null, null, synchronized, null, " + (R_DEFAULT + 19) + "}\n" +
//{ObjectTeams:
- "team[KEYWORD]{team, null, null, team, null, 24}\n" +
+ "team[KEYWORD]{team, null, null, team, null, " + (R_DEFAULT + 9) + "}\n" +
// SH}
- "transient[KEYWORD]{transient, null, null, transient, null, 24}\n" +
- "volatile[KEYWORD]{volatile, null, null, volatile, null, 24}\n" +
- "I[TYPE_REF]{I, , LI;, null, null, 27}\n" +
- "J[TYPE_REF]{J, , LJ;, null, null, 27}\n" +
- "X[TYPE_REF]{X, , LX;, null, null, 27}\n" +
- "clone[METHOD_DECLARATION]{protected Object clone() throws CloneNotSupportedException, Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, 27}\n" +
- "equals[METHOD_DECLARATION]{public boolean equals(Object obj), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), 27}\n" +
- "finalize[METHOD_DECLARATION]{protected void finalize() throws Throwable, Ljava.lang.Object;, ()V, finalize, null, 27}\n" +
- "hashCode[METHOD_DECLARATION]{public int hashCode(), Ljava.lang.Object;, ()I, hashCode, null, 27}\n" +
- "toString[METHOD_DECLARATION]{public String toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, 27}",
+ "transient[KEYWORD]{transient, null, null, transient, null, " + (R_DEFAULT + 19) + "}\n" +
+ "volatile[KEYWORD]{volatile, null, null, volatile, null, " + (R_DEFAULT + 19) + "}\n" +
+ "I[TYPE_REF]{I, , LI;, null, null, " + (R_DEFAULT + 22) + "}\n" +
+ "J[TYPE_REF]{J, , LJ;, null, null, " + (R_DEFAULT + 22) + "}\n" +
+ "X[TYPE_REF]{X, , LX;, null, null, " + (R_DEFAULT + 22) + "}\n" +
+ "clone[METHOD_DECLARATION]{protected Object clone() throws CloneNotSupportedException, Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, " + (R_DEFAULT + 22) + "}\n" +
+ "equals[METHOD_DECLARATION]{public boolean equals(Object obj), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), " + (R_DEFAULT + 22) + "}\n" +
+ "finalize[METHOD_DECLARATION]{protected void finalize() throws Throwable, Ljava.lang.Object;, ()V, finalize, null, " + (R_DEFAULT + 22) + "}\n" +
+ "hashCode[METHOD_DECLARATION]{public int hashCode(), Ljava.lang.Object;, ()I, hashCode, null, " + (R_DEFAULT + 22) + "}\n" +
+ "toString[METHOD_DECLARATION]{public String toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, " + (R_DEFAULT + 22) + "}",
requestor.getResults());
}
public void test010() throws JavaModelException {
@@ -377,20 +377,20 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "goo[METHOD_REF]{goo(), LX;, (LI;)V, goo, (i), 24}\n" +
- "goo[METHOD_REF]{goo(), LX;, (Ljava.lang.String;)V, goo, (s), 24}\n" +
- "main[METHOD_REF]{main(), LX;, ([Ljava.lang.String;)V, main, (args), 24}\n" +
- "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, 35}\n" +
- "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), 35}\n" +
- "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, 35}\n" +
- "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, getClass, null, 35}\n" +
- "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, 35}\n" +
- "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, 35}\n" +
- "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, 35}\n" +
- "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, 35}\n" +
- "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, 35}\n" +
- "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), 35}\n" +
- "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), 35}",
+ "goo[METHOD_REF]{goo(), LX;, (LI;)V, goo, (i), " + (R_DEFAULT + 19) + "}\n" +
+ "goo[METHOD_REF]{goo(), LX;, (Ljava.lang.String;)V, goo, (s), " + (R_DEFAULT + 19) + "}\n" +
+ "main[METHOD_REF]{main(), LX;, ([Ljava.lang.String;)V, main, (args), " + (R_DEFAULT + 19) + "}\n" +
+ "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, " + (R_DEFAULT + 30) + "}\n" +
+ "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), " + (R_DEFAULT + 30) + "}\n" +
+ "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, " + (R_DEFAULT + 30) + "}\n" +
+ "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, getClass, null, " + (R_DEFAULT + 30) + "}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, " + (R_DEFAULT + 30) + "}\n" +
+ "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, " + (R_DEFAULT + 30) + "}\n" +
+ "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, " + (R_DEFAULT + 30) + "}\n" +
+ "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, " + (R_DEFAULT + 30) + "}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, " + (R_DEFAULT + 30) + "}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), " + (R_DEFAULT + 30) + "}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), " + (R_DEFAULT + 30) + "}",
requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=422901, [1.8][code assist] Code assistant sensitive to scope.referenceContext type identity.
@@ -509,8 +509,8 @@
String completeBehind = "arrayO";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("arrayOfStrings[LOCAL_VARIABLE_REF]{arrayOfStrings, null, [Ljava.lang.String;, null, null, arrayOfStrings, null, [168, 174], 27}\n" +
- "arrayOfInts[LOCAL_VARIABLE_REF]{arrayOfInts, null, [I, null, null, arrayOfInts, null, [168, 174], 57}", requestor.getResults());
+ assertResults("arrayOfStrings[LOCAL_VARIABLE_REF]{arrayOfStrings, null, [Ljava.lang.String;, null, null, arrayOfStrings, null, [168, 174], " + (R_DEFAULT + 22) + "}\n" +
+ "arrayOfInts[LOCAL_VARIABLE_REF]{arrayOfInts, null, [I, null, null, arrayOfInts, null, [168, 174], " + (R_DEFAULT + 52) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=422901, [1.8][code assist] Code assistant sensitive to scope.referenceContext type identity.
public void test015() throws JavaModelException { // ensure higher relevance for matching return type.
@@ -537,7 +537,7 @@
String completeBehind = "xyz";
int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("xyzAfter[LOCAL_VARIABLE_REF]{xyzAfter, null, Ljava.lang.Object;, null, null, xyzAfter, null, [132, 135], 26}", requestor.getResults());
+ assertResults("xyzAfter[LOCAL_VARIABLE_REF]{xyzAfter, null, Ljava.lang.Object;, null, null, xyzAfter, null, [132, 135], " + (R_DEFAULT + 21) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=422901, [1.8][code assist] Code assistant sensitive to scope.referenceContext type identity.
public void test016() throws JavaModelException { // ensure higher relevance for matching return type.
@@ -564,7 +564,7 @@
String completeBehind = "xyz";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("xyzBefore[LOCAL_VARIABLE_REF]{xyzBefore, null, Ljava.lang.Object;, null, null, xyzBefore, null, [163, 166], 26}", requestor.getResults());
+ assertResults("xyzBefore[LOCAL_VARIABLE_REF]{xyzBefore, null, Ljava.lang.Object;, null, null, xyzBefore, null, [163, 166], " + (R_DEFAULT + 21) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=422901, [1.8][code assist] Code assistant sensitive to scope.referenceContext type identity.
public void test017() throws JavaModelException { // ensure higher relevance for matching return type.
@@ -732,20 +732,20 @@
String completeBehind = "Stri";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("StringBufferInputStream[TYPE_REF]{java.io.StringBufferInputStream, java.io, Ljava.io.StringBufferInputStream;, null, null, null, null, [155, 159], 24}\n" +
- "StringCharBuffer[TYPE_REF]{java.nio.StringCharBuffer, java.nio, Ljava.nio.StringCharBuffer;, null, null, null, null, [155, 159], 24}\n" +
- "StringCharacterIterator[TYPE_REF]{java.text.StringCharacterIterator, java.text, Ljava.text.StringCharacterIterator;, null, null, null, null, [155, 159], 24}\n" +
- "StringJoiner[TYPE_REF]{java.util.StringJoiner, java.util, Ljava.util.StringJoiner;, null, null, null, null, [155, 159], 24}\n" +
- "StringReader[TYPE_REF]{java.io.StringReader, java.io, Ljava.io.StringReader;, null, null, null, null, [155, 159], 24}\n" +
- "StringTokenizer[TYPE_REF]{java.util.StringTokenizer, java.util, Ljava.util.StringTokenizer;, null, null, null, null, [155, 159], 24}\n" +
- "StringWriter[TYPE_REF]{java.io.StringWriter, java.io, Ljava.io.StringWriter;, null, null, null, null, [155, 159], 24}\n" +
- "StrictMath[TYPE_REF]{StrictMath, java.lang, Ljava.lang.StrictMath;, null, null, null, null, [155, 159], 27}\n" +
- "String[TYPE_REF]{String, java.lang, Ljava.lang.String;, null, null, null, null, [155, 159], 27}\n" +
- "StringBuffer[TYPE_REF]{StringBuffer, java.lang, Ljava.lang.StringBuffer;, null, null, null, null, [155, 159], 27}\n" +
- "StringBuilder[TYPE_REF]{StringBuilder, java.lang, Ljava.lang.StringBuilder;, null, null, null, null, [155, 159], 27}\n" +
- "StringCoding[TYPE_REF]{StringCoding, java.lang, Ljava.lang.StringCoding;, null, null, null, null, [155, 159], 27}\n" +
- "StringIndexOutOfBoundsException[TYPE_REF]{StringIndexOutOfBoundsException, java.lang, Ljava.lang.StringIndexOutOfBoundsException;, null, null, null, null, [155, 159], 27}\n" +
- "StringParameter[LOCAL_VARIABLE_REF]{StringParameter, null, LX;, null, null, StringParameter, null, [155, 159], 27}", requestor.getResults());
+ assertResults("StringBufferInputStream[TYPE_REF]{java.io.StringBufferInputStream, java.io, Ljava.io.StringBufferInputStream;, null, null, null, null, [155, 159], " + (R_DEFAULT + 19) + "}\n" +
+ "StringCharBuffer[TYPE_REF]{java.nio.StringCharBuffer, java.nio, Ljava.nio.StringCharBuffer;, null, null, null, null, [155, 159], " + (R_DEFAULT + 19) + "}\n" +
+ "StringCharacterIterator[TYPE_REF]{java.text.StringCharacterIterator, java.text, Ljava.text.StringCharacterIterator;, null, null, null, null, [155, 159], " + (R_DEFAULT + 19) + "}\n" +
+ "StringJoiner[TYPE_REF]{java.util.StringJoiner, java.util, Ljava.util.StringJoiner;, null, null, null, null, [155, 159], " + (R_DEFAULT + 19) + "}\n" +
+ "StringReader[TYPE_REF]{java.io.StringReader, java.io, Ljava.io.StringReader;, null, null, null, null, [155, 159], " + (R_DEFAULT + 19) + "}\n" +
+ "StringTokenizer[TYPE_REF]{java.util.StringTokenizer, java.util, Ljava.util.StringTokenizer;, null, null, null, null, [155, 159], " + (R_DEFAULT + 19) + "}\n" +
+ "StringWriter[TYPE_REF]{java.io.StringWriter, java.io, Ljava.io.StringWriter;, null, null, null, null, [155, 159], " + (R_DEFAULT + 19) + "}\n" +
+ "StrictMath[TYPE_REF]{StrictMath, java.lang, Ljava.lang.StrictMath;, null, null, null, null, [155, 159], " + (R_DEFAULT + 22) + "}\n" +
+ "String[TYPE_REF]{String, java.lang, Ljava.lang.String;, null, null, null, null, [155, 159], " + (R_DEFAULT + 22) + "}\n" +
+ "StringBuffer[TYPE_REF]{StringBuffer, java.lang, Ljava.lang.StringBuffer;, null, null, null, null, [155, 159], " + (R_DEFAULT + 22) + "}\n" +
+ "StringBuilder[TYPE_REF]{StringBuilder, java.lang, Ljava.lang.StringBuilder;, null, null, null, null, [155, 159], " + (R_DEFAULT + 22) + "}\n" +
+ "StringCoding[TYPE_REF]{StringCoding, java.lang, Ljava.lang.StringCoding;, null, null, null, null, [155, 159], " + (R_DEFAULT + 22) + "}\n" +
+ "StringIndexOutOfBoundsException[TYPE_REF]{StringIndexOutOfBoundsException, java.lang, Ljava.lang.StringIndexOutOfBoundsException;, null, null, null, null, [155, 159], " + (R_DEFAULT + 22) + "}\n" +
+ "StringParameter[LOCAL_VARIABLE_REF]{StringParameter, null, LX;, null, null, StringParameter, null, [155, 159], " + (R_DEFAULT + 22) + "}", requestor.getResults());
}
public void testBrokenMethodCall() throws JavaModelException { // ensure completion works when the containing call is not terminated properly.
this.workingCopies = new ICompilationUnit[1];
@@ -770,7 +770,7 @@
String completeBehind = "StringP";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("StringParameter[LOCAL_VARIABLE_REF]{StringParameter, null, LX;, null, null, StringParameter, null, [155, 162], 27}", requestor.getResults());
+ assertResults("StringParameter[LOCAL_VARIABLE_REF]{StringParameter, null, LX;, null, null, StringParameter, null, [155, 162], " + (R_DEFAULT + 22) + "}", requestor.getResults());
}
public void testExpressionBody() throws JavaModelException {
this.workingCopies = new ICompilationUnit[1];
@@ -795,21 +795,21 @@
String completeBehind = "xyz.";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("goo[METHOD_REF]{goo(), LX;, (LI;)V, null, null, goo, (i), [173, 173], 24}\n" +
- "main[METHOD_REF]{main(), LX;, ([Ljava.lang.String;)V, null, null, main, (args), [173, 173], 24}\n" +
- "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, null, null, clone, null, [173, 173], 35}\n" +
- "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, null, null, equals, (obj), [173, 173], 35}\n" +
- "field[FIELD_REF]{field, LX;, I, null, null, field, null, [173, 173], 35}\n" +
- "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, null, null, finalize, null, [173, 173], 35}\n" +
- "foo[METHOD_REF]{foo(), LX;, ()V, null, null, foo, null, [173, 173], 35}\n" +
- "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [173, 173], 35}\n" +
- "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, null, null, hashCode, null, [173, 173], 35}\n" +
- "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, null, null, notify, null, [173, 173], 35}\n" +
- "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, null, null, notifyAll, null, [173, 173], 35}\n" +
- "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, null, null, toString, null, [173, 173], 35}\n" +
- "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, null, null, wait, null, [173, 173], 35}\n" +
- "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, null, null, wait, (millis), [173, 173], 35}\n" +
- "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, null, null, wait, (millis, nanos), [173, 173], 35}", requestor.getResults());
+ assertResults("goo[METHOD_REF]{goo(), LX;, (LI;)V, null, null, goo, (i), [173, 173], " + (R_DEFAULT + 19) + "}\n" +
+ "main[METHOD_REF]{main(), LX;, ([Ljava.lang.String;)V, null, null, main, (args), [173, 173], " + (R_DEFAULT + 19) + "}\n" +
+ "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, null, null, clone, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" +
+ "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, null, null, equals, (obj), [173, 173], " + (R_DEFAULT + 30) + "}\n" +
+ "field[FIELD_REF]{field, LX;, I, null, null, field, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" +
+ "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, null, null, finalize, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" +
+ "foo[METHOD_REF]{foo(), LX;, ()V, null, null, foo, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" +
+ "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, null, null, hashCode, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" +
+ "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, null, null, notify, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" +
+ "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, null, null, notifyAll, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" +
+ "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, null, null, toString, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, null, null, wait, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, null, null, wait, (millis), [173, 173], " + (R_DEFAULT + 30) + "}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, null, null, wait, (millis, nanos), [173, 173], " + (R_DEFAULT + 30) + "}", requestor.getResults());
}
public void testExpressionBody2() throws JavaModelException {
this.workingCopies = new ICompilationUnit[1];
@@ -834,21 +834,21 @@
String completeBehind = "xyz.";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("goo[METHOD_REF]{goo(), LX;, (LI;)V, null, null, goo, (i), [173, 173], 24}\n" +
- "main[METHOD_REF]{main(), LX;, ([Ljava.lang.String;)V, null, null, main, (args), [173, 173], 24}\n" +
- "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, null, null, clone, null, [173, 173], 35}\n" +
- "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, null, null, equals, (obj), [173, 173], 35}\n" +
- "field[FIELD_REF]{field, LX;, I, null, null, field, null, [173, 173], 35}\n" +
- "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, null, null, finalize, null, [173, 173], 35}\n" +
- "foo[METHOD_REF]{foo(), LX;, ()V, null, null, foo, null, [173, 173], 35}\n" +
- "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [173, 173], 35}\n" +
- "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, null, null, hashCode, null, [173, 173], 35}\n" +
- "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, null, null, notify, null, [173, 173], 35}\n" +
- "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, null, null, notifyAll, null, [173, 173], 35}\n" +
- "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, null, null, toString, null, [173, 173], 35}\n" +
- "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, null, null, wait, null, [173, 173], 35}\n" +
- "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, null, null, wait, (millis), [173, 173], 35}\n" +
- "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, null, null, wait, (millis, nanos), [173, 173], 35}", requestor.getResults());
+ assertResults("goo[METHOD_REF]{goo(), LX;, (LI;)V, null, null, goo, (i), [173, 173], " + (R_DEFAULT + 19) + "}\n" +
+ "main[METHOD_REF]{main(), LX;, ([Ljava.lang.String;)V, null, null, main, (args), [173, 173], " + (R_DEFAULT + 19) + "}\n" +
+ "clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, null, null, clone, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" +
+ "equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, null, null, equals, (obj), [173, 173], " + (R_DEFAULT + 30) + "}\n" +
+ "field[FIELD_REF]{field, LX;, I, null, null, field, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" +
+ "finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, null, null, finalize, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" +
+ "foo[METHOD_REF]{foo(), LX;, ()V, null, null, foo, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" +
+ "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, null, null, hashCode, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" +
+ "notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, null, null, notify, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" +
+ "notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, null, null, notifyAll, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" +
+ "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, null, null, toString, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, null, null, wait, null, [173, 173], " + (R_DEFAULT + 30) + "}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, null, null, wait, (millis), [173, 173], " + (R_DEFAULT + 30) + "}\n" +
+ "wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, null, null, wait, (millis, nanos), [173, 173], " + (R_DEFAULT + 30) + "}", requestor.getResults());
}
// Bug 405125 - [1.8][code assist] static members of an interface appearing after the declaration of a static member lambda expression are not being suggested.
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=405125
@@ -877,7 +877,7 @@
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "bars[METHOD_REF]{bars(), LB;, ()I, bars, null, 27}",
+ "bars[METHOD_REF]{bars(), LB;, ()I, bars, null, " + (R_DEFAULT + 22) + "}",
requestor.getResults());
}
public void testBug405125b() throws JavaModelException {
@@ -905,7 +905,7 @@
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "another[FIELD_REF]{another, LB;, I, another, null, 27}",
+ "another[FIELD_REF]{another, LB;, I, another, null, " + (R_DEFAULT + 22) + "}",
requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=425084, [1.8][completion] Eclipse freeze while autocompleting try block in lambda.
@@ -932,8 +932,8 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "tryit[LOCAL_VARIABLE_REF]{tryit, null, I, null, null, tryit, null, [99, 102], 27}\n" +
- "try[KEYWORD]{try, null, null, null, null, try, null, [99, 102], 28}",
+ "tryit[LOCAL_VARIABLE_REF]{tryit, null, I, null, null, tryit, null, [99, 102], " + (R_DEFAULT + 22) + "}\n" +
+ "try[KEYWORD]{try, null, null, null, null, try, null, [99, 102], " + (R_DEFAULT + 23) + "}",
requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=422901, [1.8][code assist] Code assistant sensitive to scope.referenceContext type identity.
@@ -1017,7 +1017,7 @@
String completeBehind = "Ty";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("TypeUse[TYPE_REF]{TypeUse, , LTypeUse;, null, null, null, null, [131, 133], 52}", requestor.getResults());
+ assertResults("TypeUse[TYPE_REF]{TypeUse, , LTypeUse;, null, null, null, null, [131, 133], " + (R_DEFAULT + 47) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=427532, [1.8][code assist] Completion engine does not like intersection casts
public void test427532() throws JavaModelException {
@@ -1136,7 +1136,7 @@
String completeBehind = "@Ann";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("Annotation[TYPE_REF]{Annotation, , LAnnotation;, null, null, null, null, [138, 141], 47}", requestor.getResults());
+ assertResults("Annotation[TYPE_REF]{Annotation, , LAnnotation;, null, null, null, null, [138, 141], " + (R_DEFAULT + 42) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=428735, [1.8][assist] Missing completion proposals inside lambda body expression - other than first token
public void test428735() throws JavaModelException {
@@ -1159,8 +1159,8 @@
String completeBehind = "p.get";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [186, 189], 35}\n" +
- "getLastName[METHOD_REF]{getLastName(), LPerson;, ()Ljava.lang.String;, null, null, getLastName, null, [186, 189], 35}", requestor.getResults());
+ assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [186, 189], " + (R_DEFAULT + 30) + "}\n" +
+ "getLastName[METHOD_REF]{getLastName(), LPerson;, ()Ljava.lang.String;, null, null, getLastName, null, [186, 189], " + (R_DEFAULT + 30) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=428735, [1.8][assist] Missing completion proposals inside lambda body expression - other than first token
public void test428735a() throws JavaModelException {
@@ -1186,8 +1186,8 @@
String completeBehind = "x.get";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [267, 270], 35}\n" +
- "getLastName[METHOD_REF]{getLastName(), LPerson;, ()Ljava.lang.String;, null, null, getLastName, null, [267, 270], 35}", requestor.getResults());
+ assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [267, 270], " + (R_DEFAULT + 30) + "}\n" +
+ "getLastName[METHOD_REF]{getLastName(), LPerson;, ()Ljava.lang.String;, null, null, getLastName, null, [267, 270], " + (R_DEFAULT + 30) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=428735, [1.8][assist] Missing completion proposals inside lambda body expression - other than first token
public void test428735b() throws JavaModelException {
@@ -1213,8 +1213,8 @@
String completeBehind = "y.get";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [293, 296], 35}\n" +
- "getLastName[METHOD_REF]{getLastName(), LPerson;, ()Ljava.lang.String;, null, null, getLastName, null, [293, 296], 35}", requestor.getResults());
+ assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [293, 296], " + (R_DEFAULT + 30) + "}\n" +
+ "getLastName[METHOD_REF]{getLastName(), LPerson;, ()Ljava.lang.String;, null, null, getLastName, null, [293, 296], " + (R_DEFAULT + 30) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=428735, [1.8][assist] Missing completion proposals inside lambda body expression - other than first token
public void test428735c() throws JavaModelException {
@@ -1240,8 +1240,8 @@
String completeBehind = "y.get";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [285, 288], 35}\n" +
- "getLastName[METHOD_REF]{getLastName(), LPerson;, ()Ljava.lang.String;, null, null, getLastName, null, [285, 288], 65}", requestor.getResults());
+ assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [285, 288], " + (R_DEFAULT + 30) + "}\n" +
+ "getLastName[METHOD_REF]{getLastName(), LPerson;, ()Ljava.lang.String;, null, null, getLastName, null, [285, 288], " + (R_DEFAULT + 60) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=428735, [1.8][assist] Missing completion proposals inside lambda body expression - other than first token
public void test428735d() throws JavaModelException {
@@ -1267,8 +1267,8 @@
String completeBehind = "x.get";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [272, 275], 35}\n" +
- "getLastName[METHOD_REF]{getLastName(), LPerson;, ()Ljava.lang.String;, null, null, getLastName, null, [272, 275], 65}", requestor.getResults());
+ assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [272, 275], " + (R_DEFAULT + 30) + "}\n" +
+ "getLastName[METHOD_REF]{getLastName(), LPerson;, ()Ljava.lang.String;, null, null, getLastName, null, [272, 275], " + (R_DEFAULT + 60) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=428735, [1.8][assist] Missing completion proposals inside lambda body expression - other than first token
public void test428735e() throws JavaModelException {
@@ -1293,8 +1293,8 @@
String completeBehind = "x.get";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [203, 206], 35}\n" +
- "getLastName[METHOD_REF]{getLastName(), LPerson;, ()Ljava.lang.String;, null, null, getLastName, null, [203, 206], 65}", requestor.getResults());
+ assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [203, 206], " + (R_DEFAULT + 30) + "}\n" +
+ "getLastName[METHOD_REF]{getLastName(), LPerson;, ()Ljava.lang.String;, null, null, getLastName, null, [203, 206], " + (R_DEFAULT + 60) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=402081, [1.8][code complete] No proposals while completing at method/constructor references
public void test402081() throws JavaModelException {
@@ -1321,7 +1321,7 @@
String completeBehind = "long";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("longMethodName[METHOD_NAME_REFERENCE]{longMethodName, LX;, (Ljava.lang.String;)Ljava.lang.String;, null, null, longMethodName, (x), [183, 187], 35}", requestor.getResults());
+ assertResults("longMethodName[METHOD_NAME_REFERENCE]{longMethodName, LX;, (Ljava.lang.String;)Ljava.lang.String;, null, null, longMethodName, (x), [183, 187], " + (R_DEFAULT + 30) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=402081, [1.8][code complete] No proposals while completing at method/constructor references
public void test402081a() throws JavaModelException {
@@ -1351,7 +1351,7 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "longMethodName[METHOD_NAME_REFERENCE]{longMethodName, Ltest.X;, (Ljava.lang.String;)Ljava.lang.String;, longMethodName, (x), 35}",
+ "longMethodName[METHOD_NAME_REFERENCE]{longMethodName, Ltest.X;, (Ljava.lang.String;)Ljava.lang.String;, longMethodName, (x), " + (R_DEFAULT + 30) + "}",
requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=402081, [1.8][code complete] No proposals while completing at method/constructor references
@@ -1377,7 +1377,7 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "longMethodName[METHOD_NAME_REFERENCE]{longMethodName, Ltest.X<Ljava.lang.String;>;, (Ljava.lang.String;)Ljava.lang.String;, longMethodName, (x), 35}",
+ "longMethodName[METHOD_NAME_REFERENCE]{longMethodName, Ltest.X<Ljava.lang.String;>;, (Ljava.lang.String;)Ljava.lang.String;, longMethodName, (x), " + (R_DEFAULT + 30) + "}",
requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=402081, [1.8][code complete] No proposals while completing at method/constructor references
@@ -1406,7 +1406,7 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "longMethodName[METHOD_NAME_REFERENCE]{longMethodName, Ltest.Y;, (Ljava.lang.String;)Ljava.lang.String;, longMethodName, (x), 35}",
+ "longMethodName[METHOD_NAME_REFERENCE]{longMethodName, Ltest.Y;, (Ljava.lang.String;)Ljava.lang.String;, longMethodName, (x), " + (R_DEFAULT + 30) + "}",
requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=402081, [1.8][code complete] No proposals while completing at method/constructor references
@@ -1435,7 +1435,7 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "longMethodName[METHOD_NAME_REFERENCE]{longMethodName, Ltest.Y;, (Ljava.lang.String;)Ljava.lang.String;, longMethodName, (x), 35}",
+ "longMethodName[METHOD_NAME_REFERENCE]{longMethodName, Ltest.Y;, (Ljava.lang.String;)Ljava.lang.String;, longMethodName, (x), " + (R_DEFAULT + 30) + "}",
requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=431402, [assist] NPE in AssistParser.triggerRecoveryUponLambdaClosure:483 using Content Assist
@@ -1462,7 +1462,7 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "asList[LOCAL_VARIABLE_REF]{asList, null, Ljava.lang.Object;, asList, null, 47}",
+ "asList[LOCAL_VARIABLE_REF]{asList, null, Ljava.lang.Object;, asList, null, " + (R_DEFAULT + 42) + "}",
requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=432527, Content Assist crashes sometimes using JDK8
@@ -1532,7 +1532,7 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "removeNodeFromGraph[METHOD_REF]{removeNodeFromGraph(), Ltest.X;, (Ltest.X$Node;)V, removeNodeFromGraph, (node), 27}",
+ "removeNodeFromGraph[METHOD_REF]{removeNodeFromGraph(), Ltest.X;, (Ltest.X$Node;)V, removeNodeFromGraph, (node), " + (R_DEFAULT + 22) + "}",
requestor.getResults());
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=430441, [compiler] NPE in ImplicitNullAnnotationVerifier.collectOverriddenMethods from Content Assist in a .jpage file
@@ -1579,8 +1579,8 @@
int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "getClass[METHOD_NAME_REFERENCE]{getClass, Ljava.lang.Object;, ()Ljava.lang.Class<*>;, getClass, null, 35}\n" +
- "getLastName[METHOD_NAME_REFERENCE]{getLastName, Ltest.Person;, ()Ljava.lang.String;, getLastName, null, 35}",
+ "getClass[METHOD_NAME_REFERENCE]{getClass, Ljava.lang.Object;, ()Ljava.lang.Class<*>;, getClass, null, " + (R_DEFAULT + 30) + "}\n" +
+ "getLastName[METHOD_NAME_REFERENCE]{getLastName, Ltest.Person;, ()Ljava.lang.String;, getLastName, null, " + (R_DEFAULT + 30) + "}",
requestor.getResults());
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=433178
@@ -1656,7 +1656,7 @@
String completeBehind = "System.o";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("out[FIELD_REF]{out, Ljava.lang.System;, Ljava.io.PrintStream;, null, null, out, null, [83, 84], 26}", requestor.getResults());
+ assertResults("out[FIELD_REF]{out, Ljava.lang.System;, Ljava.io.PrintStream;, null, null, out, null, [83, 84], " + (R_DEFAULT + 21) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=435219, [1.8][content assist] No proposals for some closure cases
public void test435219a() throws JavaModelException {
@@ -1675,27 +1675,27 @@
String completeBehind = "System.out.p";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("print[METHOD_REF]{print(), Ljava.io.PrintStream;, (C)V, null, null, print, (arg0), [87, 88], 35}\n" +
- "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (D)V, null, null, print, (arg0), [87, 88], 35}\n" +
- "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (F)V, null, null, print, (arg0), [87, 88], 35}\n" +
- "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (I)V, null, null, print, (arg0), [87, 88], 35}\n" +
- "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (J)V, null, null, print, (arg0), [87, 88], 35}\n" +
- "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (Ljava.lang.Object;)V, null, null, print, (arg0), [87, 88], 35}\n" +
- "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (Ljava.lang.String;)V, null, null, print, (arg0), [87, 88], 35}\n" +
- "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (Z)V, null, null, print, (arg0), [87, 88], 35}\n" +
- "print[METHOD_REF]{print(), Ljava.io.PrintStream;, ([C)V, null, null, print, (arg0), [87, 88], 35}\n" +
- "printf[METHOD_REF]{printf(), Ljava.io.PrintStream;, (Ljava.lang.String;[Ljava.lang.Object;)Ljava.io.PrintStream;, null, null, printf, (arg0, arg1), [87, 88], 35}\n" +
- "printf[METHOD_REF]{printf(), Ljava.io.PrintStream;, (Ljava.util.Locale;Ljava.lang.String;[Ljava.lang.Object;)Ljava.io.PrintStream;, null, null, printf, (arg0, arg1, arg2), [87, 88], 35}\n" +
- "println[METHOD_REF]{println(), Ljava.io.PrintStream;, ()V, null, null, println, null, [87, 88], 35}\n" +
- "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (C)V, null, null, println, (arg0), [87, 88], 35}\n" +
- "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (D)V, null, null, println, (arg0), [87, 88], 35}\n" +
- "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (F)V, null, null, println, (arg0), [87, 88], 35}\n" +
- "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (I)V, null, null, println, (arg0), [87, 88], 35}\n" +
- "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (J)V, null, null, println, (arg0), [87, 88], 35}\n" +
- "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (Ljava.lang.Object;)V, null, null, println, (arg0), [87, 88], 35}\n" +
- "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (Ljava.lang.String;)V, null, null, println, (arg0), [87, 88], 35}\n" +
- "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (Z)V, null, null, println, (arg0), [87, 88], 35}\n" +
- "println[METHOD_REF]{println(), Ljava.io.PrintStream;, ([C)V, null, null, println, (arg0), [87, 88], 35}", requestor.getResults());
+ assertResults("print[METHOD_REF]{print(), Ljava.io.PrintStream;, (C)V, null, null, print, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" +
+ "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (D)V, null, null, print, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" +
+ "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (F)V, null, null, print, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" +
+ "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (I)V, null, null, print, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" +
+ "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (J)V, null, null, print, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" +
+ "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (Ljava.lang.Object;)V, null, null, print, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" +
+ "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (Ljava.lang.String;)V, null, null, print, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" +
+ "print[METHOD_REF]{print(), Ljava.io.PrintStream;, (Z)V, null, null, print, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" +
+ "print[METHOD_REF]{print(), Ljava.io.PrintStream;, ([C)V, null, null, print, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" +
+ "printf[METHOD_REF]{printf(), Ljava.io.PrintStream;, (Ljava.lang.String;[Ljava.lang.Object;)Ljava.io.PrintStream;, null, null, printf, (arg0, arg1), [87, 88], " + (R_DEFAULT + 30) + "}\n" +
+ "printf[METHOD_REF]{printf(), Ljava.io.PrintStream;, (Ljava.util.Locale;Ljava.lang.String;[Ljava.lang.Object;)Ljava.io.PrintStream;, null, null, printf, (arg0, arg1, arg2), [87, 88], " + (R_DEFAULT + 30) + "}\n" +
+ "println[METHOD_REF]{println(), Ljava.io.PrintStream;, ()V, null, null, println, null, [87, 88], " + (R_DEFAULT + 30) + "}\n" +
+ "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (C)V, null, null, println, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" +
+ "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (D)V, null, null, println, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" +
+ "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (F)V, null, null, println, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" +
+ "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (I)V, null, null, println, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" +
+ "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (J)V, null, null, println, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" +
+ "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (Ljava.lang.Object;)V, null, null, println, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" +
+ "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (Ljava.lang.String;)V, null, null, println, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" +
+ "println[METHOD_REF]{println(), Ljava.io.PrintStream;, (Z)V, null, null, println, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}\n" +
+ "println[METHOD_REF]{println(), Ljava.io.PrintStream;, ([C)V, null, null, println, (arg0), [87, 88], " + (R_DEFAULT + 30) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=435219, [1.8][content assist] No proposals for some closure cases
public void test435219b() throws JavaModelException {
@@ -1714,9 +1714,9 @@
String completeBehind = "st";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("start[METHOD_REF]{start(), Ljava.lang.Thread;, ()V, null, null, start, null, [103, 105], 35}\n" +
- "stop[METHOD_REF]{stop(), Ljava.lang.Thread;, ()V, null, null, stop, null, [103, 105], 35}\n" +
- "stop[METHOD_REF]{stop(), Ljava.lang.Thread;, (Ljava.lang.Throwable;)V, null, null, stop, (arg0), [103, 105], 35}", requestor.getResults());
+ assertResults("start[METHOD_REF]{start(), Ljava.lang.Thread;, ()V, null, null, start, null, [103, 105], " + (R_DEFAULT + 30) + "}\n" +
+ "stop[METHOD_REF]{stop(), Ljava.lang.Thread;, ()V, null, null, stop, null, [103, 105], " + (R_DEFAULT + 30) + "}\n" +
+ "stop[METHOD_REF]{stop(), Ljava.lang.Thread;, (Ljava.lang.Throwable;)V, null, null, stop, (arg0), [103, 105], " + (R_DEFAULT + 30) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=435219, [1.8][content assist] No proposals for some closure cases
public void test435219c() throws JavaModelException {
@@ -1738,9 +1738,9 @@
String completeBehind = "x.h";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("hashCode[METHOD_REF]{hashCode(), Ljava.lang.Integer;, (I)I, null, null, hashCode, (arg0), [187, 188], 54}\n" +
- "highestOneBit[METHOD_REF]{highestOneBit(), Ljava.lang.Integer;, (I)I, null, null, highestOneBit, (arg0), [187, 188], 54}\n" +
- "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Integer;, ()I, null, null, hashCode, null, [187, 188], 65}", requestor.getResults());
+ assertResults("hashCode[METHOD_REF]{hashCode(), Ljava.lang.Integer;, (I)I, null, null, hashCode, (arg0), [187, 188], " + (R_DEFAULT + 49) + "}\n" +
+ "highestOneBit[METHOD_REF]{highestOneBit(), Ljava.lang.Integer;, (I)I, null, null, highestOneBit, (arg0), [187, 188], " + (R_DEFAULT + 49) + "}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Integer;, ()I, null, null, hashCode, null, [187, 188], " + (R_DEFAULT + 60) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=435219, [1.8][content assist] No proposals for some closure cases
public void test435219d() throws JavaModelException {
@@ -1762,27 +1762,27 @@
String completeBehind = "pri";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (C)V, null, null, print, null, [219, 222], 30}\n" +
- "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (D)V, null, null, print, null, [219, 222], 30}\n" +
- "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (F)V, null, null, print, null, [219, 222], 30}\n" +
- "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (I)V, null, null, print, null, [219, 222], 30}\n" +
- "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (J)V, null, null, print, null, [219, 222], 30}\n" +
- "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (Ljava.lang.Object;)V, null, null, print, null, [219, 222], 30}\n" +
- "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (Ljava.lang.String;)V, null, null, print, null, [219, 222], 30}\n" +
- "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (Z)V, null, null, print, null, [219, 222], 30}\n" +
- "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, ([C)V, null, null, print, null, [219, 222], 30}\n" +
- "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, ()V, null, null, println, null, [219, 222], 30}\n" +
- "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (C)V, null, null, println, null, [219, 222], 30}\n" +
- "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (D)V, null, null, println, null, [219, 222], 30}\n" +
- "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (F)V, null, null, println, null, [219, 222], 30}\n" +
- "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (I)V, null, null, println, null, [219, 222], 30}\n" +
- "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (J)V, null, null, println, null, [219, 222], 30}\n" +
- "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (Ljava.lang.Object;)V, null, null, println, null, [219, 222], 30}\n" +
- "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (Ljava.lang.String;)V, null, null, println, null, [219, 222], 30}\n" +
- "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (Z)V, null, null, println, null, [219, 222], 30}\n" +
- "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, ([C)V, null, null, println, null, [219, 222], 30}\n" +
- "printf[METHOD_NAME_REFERENCE]{printf, Ljava.io.PrintStream;, (Ljava.lang.String;[Ljava.lang.Object;)Ljava.io.PrintStream;, null, null, printf, null, [219, 222], 35}\n" +
- "printf[METHOD_NAME_REFERENCE]{printf, Ljava.io.PrintStream;, (Ljava.util.Locale;Ljava.lang.String;[Ljava.lang.Object;)Ljava.io.PrintStream;, null, null, printf, null, [219, 222], 35}", requestor.getResults());
+ assertResults("print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (C)V, null, null, print, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" +
+ "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (D)V, null, null, print, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" +
+ "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (F)V, null, null, print, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" +
+ "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (I)V, null, null, print, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" +
+ "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (J)V, null, null, print, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" +
+ "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (Ljava.lang.Object;)V, null, null, print, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" +
+ "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (Ljava.lang.String;)V, null, null, print, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" +
+ "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (Z)V, null, null, print, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" +
+ "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, ([C)V, null, null, print, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" +
+ "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, ()V, null, null, println, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" +
+ "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (C)V, null, null, println, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" +
+ "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (D)V, null, null, println, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" +
+ "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (F)V, null, null, println, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" +
+ "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (I)V, null, null, println, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" +
+ "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (J)V, null, null, println, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" +
+ "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (Ljava.lang.Object;)V, null, null, println, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" +
+ "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (Ljava.lang.String;)V, null, null, println, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" +
+ "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (Z)V, null, null, println, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" +
+ "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, ([C)V, null, null, println, null, [219, 222], " + (R_DEFAULT + 25) + "}\n" +
+ "printf[METHOD_NAME_REFERENCE]{printf, Ljava.io.PrintStream;, (Ljava.lang.String;[Ljava.lang.Object;)Ljava.io.PrintStream;, null, null, printf, null, [219, 222], " + (R_DEFAULT + 30) + "}\n" +
+ "printf[METHOD_NAME_REFERENCE]{printf, Ljava.io.PrintStream;, (Ljava.util.Locale;Ljava.lang.String;[Ljava.lang.Object;)Ljava.io.PrintStream;, null, null, printf, null, [219, 222], " + (R_DEFAULT + 30) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=435219, [1.8][content assist] No proposals for some closure cases
public void test435219e() throws JavaModelException {
@@ -1806,9 +1806,9 @@
String completeBehind = "dou";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("doubleToLongBits[METHOD_REF]{doubleToLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToLongBits, (arg0), [355, 358], 24}\n" +
- "doubleToRawLongBits[METHOD_REF]{doubleToRawLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToRawLongBits, (arg0), [355, 358], 24}\n" +
- "doubleValue[METHOD_REF]{doubleValue(), Ljava.lang.Double;, ()D, null, null, doubleValue, null, [355, 358], 35}", requestor.getResults());
+ assertResults("doubleToLongBits[METHOD_REF]{doubleToLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToLongBits, (arg0), [355, 358], " + (R_DEFAULT + 19) + "}\n" +
+ "doubleToRawLongBits[METHOD_REF]{doubleToRawLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToRawLongBits, (arg0), [355, 358], " + (R_DEFAULT + 19) + "}\n" +
+ "doubleValue[METHOD_REF]{doubleValue(), Ljava.lang.Double;, ()D, null, null, doubleValue, null, [355, 358], " + (R_DEFAULT + 30) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=435219, [1.8][content assist] No proposals for some closure cases
public void test435219f() throws JavaModelException {
@@ -1832,8 +1832,8 @@
String completeBehind = "g";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [391, 392], 35}\n" +
- "get[METHOD_REF]{get(), Ljava.util.Optional<Ljava.lang.Double;>;, ()Ljava.lang.Double;, null, null, get, null, [391, 392], 55}", requestor.getResults());
+ assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [391, 392], " + (R_DEFAULT + 30) + "}\n" +
+ "get[METHOD_REF]{get(), Ljava.util.Optional<Ljava.lang.Double;>;, ()Ljava.lang.Double;, null, null, get, null, [391, 392], " + (R_DEFAULT + 50) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=435219, [1.8][content assist] No proposals for some closure cases
public void test435219g() throws JavaModelException {
@@ -1857,9 +1857,9 @@
String completeBehind = "dou";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("doubleToLongBits[METHOD_REF]{doubleToLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToLongBits, (arg0), [376, 379], 54}\n" +
- "doubleToRawLongBits[METHOD_REF]{doubleToRawLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToRawLongBits, (arg0), [376, 379], 54}\n" +
- "doubleValue[METHOD_REF]{doubleValue(), Ljava.lang.Double;, ()D, null, null, doubleValue, null, [376, 379], 65}", requestor.getResults());
+ assertResults("doubleToLongBits[METHOD_REF]{doubleToLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToLongBits, (arg0), [376, 379], " + (R_DEFAULT + 49) + "}\n" +
+ "doubleToRawLongBits[METHOD_REF]{doubleToRawLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToRawLongBits, (arg0), [376, 379], " + (R_DEFAULT + 49) + "}\n" +
+ "doubleValue[METHOD_REF]{doubleValue(), Ljava.lang.Double;, ()D, null, null, doubleValue, null, [376, 379], " + (R_DEFAULT + 60) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=435682, [1.8] content assist not working inside lambda expression
public void test435682() throws JavaModelException {
@@ -1881,7 +1881,7 @@
String completeBehind = "so.tr";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("trim[METHOD_REF]{trim(), Ljava.lang.String;, ()Ljava.lang.String;, null, null, trim, null, [237, 239], 35}", requestor.getResults());
+ assertResults("trim[METHOD_REF]{trim(), Ljava.lang.String;, ()Ljava.lang.String;, null, null, trim, null, [237, 239], " + (R_DEFAULT + 30) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=435682, [1.8] content assist not working inside lambda expression
public void test435682a() throws JavaModelException {
@@ -1903,7 +1903,7 @@
String completeBehind = "so.tr";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("trim[METHOD_REF]{trim(), Ljava.lang.String;, ()Ljava.lang.String;, null, null, trim, null, [246, 248], 35}", requestor.getResults());
+ assertResults("trim[METHOD_REF]{trim(), Ljava.lang.String;, ()Ljava.lang.String;, null, null, trim, null, [246, 248], " + (R_DEFAULT + 30) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=430667, [1.8][content assist] no proposals around lambda as a field
public void test430667() throws JavaModelException {
@@ -1929,8 +1929,8 @@
String completeBehind = "D_F";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("D_F[POTENTIAL_METHOD_DECLARATION]{D_F, LD_DemoRefactorings;, ()V, null, null, D_F, null, [195, 198], 14}\n" +
- "D_FI[TYPE_REF]{D_FI, , LD_FI;, null, null, null, null, [195, 198], 27}", requestor.getResults());
+ assertResults("D_F[POTENTIAL_METHOD_DECLARATION]{D_F, LD_DemoRefactorings;, ()V, null, null, D_F, null, [195, 198], " + (R_DEFAULT + 9) + "}\n" +
+ "D_FI[TYPE_REF]{D_FI, , LD_FI;, null, null, null, null, [195, 198], " + (R_DEFAULT + 22) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=430667, [1.8][content assist] no proposals around lambda as a field
public void test430667a() throws JavaModelException {
@@ -1957,8 +1957,8 @@
String completeBehind = "/*HERE*/D_F";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("D_F[POTENTIAL_METHOD_DECLARATION]{D_F, LD_DemoRefactorings;, ()V, null, null, D_F, null, [150, 153], 14}\n" +
- "D_FI[TYPE_REF]{D_FI, , LD_FI;, null, null, null, null, [150, 153], 27}", requestor.getResults());
+ assertResults("D_F[POTENTIAL_METHOD_DECLARATION]{D_F, LD_DemoRefactorings;, ()V, null, null, D_F, null, [150, 153], " + (R_DEFAULT + 9) + "}\n" +
+ "D_FI[TYPE_REF]{D_FI, , LD_FI;, null, null, null, null, [150, 153], " + (R_DEFAULT + 22) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=430667, [1.8][content assist] no proposals around lambda as a field
public void test430667b() throws JavaModelException {
@@ -1984,8 +1984,8 @@
String completeBehind = "/*HERE*/D_F";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("D_F[POTENTIAL_METHOD_DECLARATION]{D_F, LD_DemoRefactorings;, ()V, null, null, D_F, null, [36, 39], 14}\n" +
- "D_FI[TYPE_REF]{D_FI, , LD_FI;, null, null, null, null, [36, 39], 27}", requestor.getResults());
+ assertResults("D_F[POTENTIAL_METHOD_DECLARATION]{D_F, LD_DemoRefactorings;, ()V, null, null, D_F, null, [36, 39], " + (R_DEFAULT + 9) + "}\n" +
+ "D_FI[TYPE_REF]{D_FI, , LD_FI;, null, null, null, null, [36, 39], " + (R_DEFAULT + 22) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=443932, [1.8][code complete] method reference proposals not applied when caret inside method name
public void test443932() throws JavaModelException {
@@ -2003,15 +2003,15 @@
String completeBehind = "to";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("toBinaryString[METHOD_NAME_REFERENCE]{toBinaryString, Ljava.lang.Integer;, (I)Ljava.lang.String;, null, null, toBinaryString, null, [90, 98], 24}\n" +
- "toHexString[METHOD_NAME_REFERENCE]{toHexString, Ljava.lang.Integer;, (I)Ljava.lang.String;, null, null, toHexString, null, [90, 98], 24}\n" +
- "toOctalString[METHOD_NAME_REFERENCE]{toOctalString, Ljava.lang.Integer;, (I)Ljava.lang.String;, null, null, toOctalString, null, [90, 98], 24}\n" +
- "toString[METHOD_NAME_REFERENCE]{toString, Ljava.lang.Integer;, (I)Ljava.lang.String;, null, null, toString, null, [90, 98], 24}\n" +
- "toString[METHOD_NAME_REFERENCE]{toString, Ljava.lang.Integer;, (II)Ljava.lang.String;, null, null, toString, null, [90, 98], 24}\n" +
- "toUnsignedLong[METHOD_NAME_REFERENCE]{toUnsignedLong, Ljava.lang.Integer;, (I)J, null, null, toUnsignedLong, null, [90, 98], 24}\n" +
- "toUnsignedString[METHOD_NAME_REFERENCE]{toUnsignedString, Ljava.lang.Integer;, (I)Ljava.lang.String;, null, null, toUnsignedString, null, [90, 98], 24}\n" +
- "toUnsignedString[METHOD_NAME_REFERENCE]{toUnsignedString, Ljava.lang.Integer;, (II)Ljava.lang.String;, null, null, toUnsignedString, null, [90, 98], 24}\n" +
- "toString[METHOD_NAME_REFERENCE]{toString, Ljava.lang.Integer;, ()Ljava.lang.String;, null, null, toString, null, [90, 98], 35}", requestor.getResults());
+ assertResults("toBinaryString[METHOD_NAME_REFERENCE]{toBinaryString, Ljava.lang.Integer;, (I)Ljava.lang.String;, null, null, toBinaryString, null, [90, 98], " + (R_DEFAULT + 19) + "}\n" +
+ "toHexString[METHOD_NAME_REFERENCE]{toHexString, Ljava.lang.Integer;, (I)Ljava.lang.String;, null, null, toHexString, null, [90, 98], " + (R_DEFAULT + 19) + "}\n" +
+ "toOctalString[METHOD_NAME_REFERENCE]{toOctalString, Ljava.lang.Integer;, (I)Ljava.lang.String;, null, null, toOctalString, null, [90, 98], " + (R_DEFAULT + 19) + "}\n" +
+ "toString[METHOD_NAME_REFERENCE]{toString, Ljava.lang.Integer;, (I)Ljava.lang.String;, null, null, toString, null, [90, 98], " + (R_DEFAULT + 19) + "}\n" +
+ "toString[METHOD_NAME_REFERENCE]{toString, Ljava.lang.Integer;, (II)Ljava.lang.String;, null, null, toString, null, [90, 98], " + (R_DEFAULT + 19) + "}\n" +
+ "toUnsignedLong[METHOD_NAME_REFERENCE]{toUnsignedLong, Ljava.lang.Integer;, (I)J, null, null, toUnsignedLong, null, [90, 98], " + (R_DEFAULT + 19) + "}\n" +
+ "toUnsignedString[METHOD_NAME_REFERENCE]{toUnsignedString, Ljava.lang.Integer;, (I)Ljava.lang.String;, null, null, toUnsignedString, null, [90, 98], " + (R_DEFAULT + 19) + "}\n" +
+ "toUnsignedString[METHOD_NAME_REFERENCE]{toUnsignedString, Ljava.lang.Integer;, (II)Ljava.lang.String;, null, null, toUnsignedString, null, [90, 98], " + (R_DEFAULT + 19) + "}\n" +
+ "toString[METHOD_NAME_REFERENCE]{toString, Ljava.lang.Integer;, ()Ljava.lang.String;, null, null, toString, null, [90, 98], " + (R_DEFAULT + 30) + "}", requestor.getResults());
assertTrue(str.substring(90, 98).equals("toString"));
}
@@ -2034,8 +2034,8 @@
String completeBehind = "so.ch";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("charAt[METHOD_REF]{charAt(), Ljava.lang.String;, (I)C, null, null, charAt, (arg0), [232, 234], 35}\n" +
- "chars[METHOD_REF]{chars(), Ljava.lang.CharSequence;, ()Ljava.util.stream.IntStream;, null, null, chars, null, [232, 234], 35}", requestor.getResults());
+ assertResults("charAt[METHOD_REF]{charAt(), Ljava.lang.String;, (I)C, null, null, charAt, (arg0), [232, 234], " + (R_DEFAULT + 30) + "}\n" +
+ "chars[METHOD_REF]{chars(), Ljava.lang.CharSequence;, ()Ljava.util.stream.IntStream;, null, null, chars, null, [232, 234], " + (R_DEFAULT + 30) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=435219, [1.8][content assist] No proposals for some closure cases
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=444300, [1.8] content assist not working inside lambda expression in case of fields
@@ -2056,9 +2056,9 @@
String completeBehind = "x.h";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("hashCode[METHOD_REF]{hashCode(), Ljava.lang.Integer;, (I)I, null, null, hashCode, (arg0), [164, 165], 54}\n" +
- "highestOneBit[METHOD_REF]{highestOneBit(), Ljava.lang.Integer;, (I)I, null, null, highestOneBit, (arg0), [164, 165], 54}\n" +
- "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Integer;, ()I, null, null, hashCode, null, [164, 165], 65}", requestor.getResults());
+ assertResults("hashCode[METHOD_REF]{hashCode(), Ljava.lang.Integer;, (I)I, null, null, hashCode, (arg0), [164, 165], " + (R_DEFAULT + 49) + "}\n" +
+ "highestOneBit[METHOD_REF]{highestOneBit(), Ljava.lang.Integer;, (I)I, null, null, highestOneBit, (arg0), [164, 165], " + (R_DEFAULT + 49) + "}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.lang.Integer;, ()I, null, null, hashCode, null, [164, 165], " + (R_DEFAULT + 60) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=435219, [1.8][content assist] No proposals for some closure cases
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=444300, [1.8] content assist not working inside lambda expression in case of fields
@@ -2079,27 +2079,27 @@
String completeBehind = "pri";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (C)V, null, null, print, null, [188, 191], 30}\n" +
- "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (D)V, null, null, print, null, [188, 191], 30}\n" +
- "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (F)V, null, null, print, null, [188, 191], 30}\n" +
- "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (I)V, null, null, print, null, [188, 191], 30}\n" +
- "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (J)V, null, null, print, null, [188, 191], 30}\n" +
- "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (Ljava.lang.Object;)V, null, null, print, null, [188, 191], 30}\n" +
- "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (Ljava.lang.String;)V, null, null, print, null, [188, 191], 30}\n" +
- "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (Z)V, null, null, print, null, [188, 191], 30}\n" +
- "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, ([C)V, null, null, print, null, [188, 191], 30}\n" +
- "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, ()V, null, null, println, null, [188, 191], 30}\n" +
- "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (C)V, null, null, println, null, [188, 191], 30}\n" +
- "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (D)V, null, null, println, null, [188, 191], 30}\n" +
- "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (F)V, null, null, println, null, [188, 191], 30}\n" +
- "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (I)V, null, null, println, null, [188, 191], 30}\n" +
- "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (J)V, null, null, println, null, [188, 191], 30}\n" +
- "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (Ljava.lang.Object;)V, null, null, println, null, [188, 191], 30}\n" +
- "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (Ljava.lang.String;)V, null, null, println, null, [188, 191], 30}\n" +
- "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (Z)V, null, null, println, null, [188, 191], 30}\n" +
- "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, ([C)V, null, null, println, null, [188, 191], 30}\n" +
- "printf[METHOD_NAME_REFERENCE]{printf, Ljava.io.PrintStream;, (Ljava.lang.String;[Ljava.lang.Object;)Ljava.io.PrintStream;, null, null, printf, null, [188, 191], 35}\n" +
- "printf[METHOD_NAME_REFERENCE]{printf, Ljava.io.PrintStream;, (Ljava.util.Locale;Ljava.lang.String;[Ljava.lang.Object;)Ljava.io.PrintStream;, null, null, printf, null, [188, 191], 35}", requestor.getResults());
+ assertResults("print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (C)V, null, null, print, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" +
+ "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (D)V, null, null, print, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" +
+ "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (F)V, null, null, print, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" +
+ "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (I)V, null, null, print, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" +
+ "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (J)V, null, null, print, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" +
+ "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (Ljava.lang.Object;)V, null, null, print, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" +
+ "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (Ljava.lang.String;)V, null, null, print, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" +
+ "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, (Z)V, null, null, print, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" +
+ "print[METHOD_NAME_REFERENCE]{print, Ljava.io.PrintStream;, ([C)V, null, null, print, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" +
+ "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, ()V, null, null, println, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" +
+ "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (C)V, null, null, println, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" +
+ "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (D)V, null, null, println, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" +
+ "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (F)V, null, null, println, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" +
+ "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (I)V, null, null, println, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" +
+ "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (J)V, null, null, println, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" +
+ "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (Ljava.lang.Object;)V, null, null, println, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" +
+ "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (Ljava.lang.String;)V, null, null, println, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" +
+ "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, (Z)V, null, null, println, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" +
+ "println[METHOD_NAME_REFERENCE]{println, Ljava.io.PrintStream;, ([C)V, null, null, println, null, [188, 191], " + (R_DEFAULT + 25) + "}\n" +
+ "printf[METHOD_NAME_REFERENCE]{printf, Ljava.io.PrintStream;, (Ljava.lang.String;[Ljava.lang.Object;)Ljava.io.PrintStream;, null, null, printf, null, [188, 191], " + (R_DEFAULT + 30) + "}\n" +
+ "printf[METHOD_NAME_REFERENCE]{printf, Ljava.io.PrintStream;, (Ljava.util.Locale;Ljava.lang.String;[Ljava.lang.Object;)Ljava.io.PrintStream;, null, null, printf, null, [188, 191], " + (R_DEFAULT + 30) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=435219, [1.8][content assist] No proposals for some closure cases
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=444300, [1.8] content assist not working inside lambda expression in case of fields
@@ -2121,9 +2121,9 @@
String completeBehind = "dou";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("doubleToLongBits[METHOD_REF]{doubleToLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToLongBits, (arg0), [235, 238], 24}\n" +
- "doubleToRawLongBits[METHOD_REF]{doubleToRawLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToRawLongBits, (arg0), [235, 238], 24}\n" +
- "doubleValue[METHOD_REF]{doubleValue(), Ljava.lang.Double;, ()D, null, null, doubleValue, null, [235, 238], 35}", requestor.getResults());
+ assertResults("doubleToLongBits[METHOD_REF]{doubleToLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToLongBits, (arg0), [235, 238], " + (R_DEFAULT + 19) + "}\n" +
+ "doubleToRawLongBits[METHOD_REF]{doubleToRawLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToRawLongBits, (arg0), [235, 238], " + (R_DEFAULT + 19) + "}\n" +
+ "doubleValue[METHOD_REF]{doubleValue(), Ljava.lang.Double;, ()D, null, null, doubleValue, null, [235, 238], " + (R_DEFAULT + 30) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=435219, [1.8][content assist] No proposals for some closure cases
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=444300, [1.8] content assist not working inside lambda expression in case of fields
@@ -2145,8 +2145,8 @@
String completeBehind = "g";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [271, 272], 35}\n" +
- "get[METHOD_REF]{get(), Ljava.util.Optional<Ljava.lang.Double;>;, ()Ljava.lang.Double;, null, null, get, null, [271, 272], 55}", requestor.getResults());
+ assertResults("getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [271, 272], " + (R_DEFAULT + 30) + "}\n" +
+ "get[METHOD_REF]{get(), Ljava.util.Optional<Ljava.lang.Double;>;, ()Ljava.lang.Double;, null, null, get, null, [271, 272], " + (R_DEFAULT + 50) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=435219, [1.8][content assist] No proposals for some closure cases
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=444300, [1.8] content assist not working inside lambda expression in case of fields
@@ -2168,22 +2168,22 @@
String completeBehind = "dou";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("doubleToLongBits[METHOD_REF]{doubleToLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToLongBits, (arg0), [256, 259], 54}\n" +
- "doubleToRawLongBits[METHOD_REF]{doubleToRawLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToRawLongBits, (arg0), [256, 259], 54}\n" +
- "doubleValue[METHOD_REF]{doubleValue(), Ljava.lang.Double;, ()D, null, null, doubleValue, null, [256, 259], 65}", requestor.getResults());
+ assertResults("doubleToLongBits[METHOD_REF]{doubleToLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToLongBits, (arg0), [256, 259], " + (R_DEFAULT + 49) + "}\n" +
+ "doubleToRawLongBits[METHOD_REF]{doubleToRawLongBits(), Ljava.lang.Double;, (D)J, null, null, doubleToRawLongBits, (arg0), [256, 259], " + (R_DEFAULT + 49) + "}\n" +
+ "doubleValue[METHOD_REF]{doubleValue(), Ljava.lang.Double;, ()D, null, null, doubleValue, null, [256, 259], " + (R_DEFAULT + 60) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=435281, [1.8][code assist] No import or completion proposal for anonymous class inside lambda
public void test435281() throws JavaModelException {
this.workingCopies = new ICompilationUnit[3];
this.workingCopies[0] = getWorkingCopy(
- "/Completion/src/p4a/FI1.java",
+ "/Completion/src/FI1.java",
"package p4a;\n" +
"@FunctionalInterface\n" +
"public interface FI1<R> {\n" +
" public R foo1();\n" +
"}\n");
this.workingCopies[1] = getWorkingCopy(
- "/Completion/src/p4a/FI2.java",
+ "/Completion/src/FI2.java",
"package p4a;\n" +
"@FunctionalInterface\n" +
"public interface FI2 {\n" +
@@ -2210,7 +2210,7 @@
String completeBehind = "FI2";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[2].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("FI2[TYPE_REF]{p4a.FI2, p4a, Lp4a.FI2;, null, null, null, null, [104, 107], 28}", requestor.getResults());
+ assertResults("FI2[TYPE_REF]{p4a.FI2, p4a, Lp4a.FI2;, null, null, null, null, [104, 107], " + (R_DEFAULT + 23) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=431811, content assist should propose keyword 'super' after type name
public void test431811() throws JavaModelException {
@@ -2238,7 +2238,7 @@
String completeBehind = "su";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("super[KEYWORD]{super, null, null, null, null, super, null, [192, 194], 26}", requestor.getResults());
+ assertResults("super[KEYWORD]{super, null, null, null, null, super, null, [192, 194], " + (R_DEFAULT + 21) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=447774, Auto complete does not work when using lambdas with cast
public void test447774() throws JavaModelException {
@@ -2300,8 +2300,8 @@
String completeBehind = "/*HERE*/localMeth";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("localmethod1[METHOD_REF]{localmethod1(), LLambdaBug;, ()V, null, null, localmethod1, null, [181, 190], 17}\n" +
- "localmethod2[METHOD_REF]{localmethod2(), LLambdaBug;, ()V, null, null, localmethod2, null, [181, 190], 17}", requestor.getResults());
+ assertResults("localmethod1[METHOD_REF]{localmethod1(), LLambdaBug;, ()V, null, null, localmethod1, null, [181, 190], " + (R_DEFAULT + 12) + "}\n" +
+ "localmethod2[METHOD_REF]{localmethod2(), LLambdaBug;, ()V, null, null, localmethod2, null, [181, 190], " + (R_DEFAULT + 12) + "}", requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=449358, Content assist inside lambda broken in all methods except last
@@ -2333,8 +2333,8 @@
String completeBehind = "/*HERE*/localMeth";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- assertResults("localmethod1[METHOD_REF]{localmethod1(), LLambdaBug;, ()V, null, null, localmethod1, null, [282, 291], 17}\n" +
- "localmethod2[METHOD_REF]{localmethod2(), LLambdaBug;, ()V, null, null, localmethod2, null, [282, 291], 17}", requestor.getResults());
+ assertResults("localmethod1[METHOD_REF]{localmethod1(), LLambdaBug;, ()V, null, null, localmethod1, null, [282, 291], " + (R_DEFAULT + 12) + "}\n" +
+ "localmethod2[METHOD_REF]{localmethod2(), LLambdaBug;, ()V, null, null, localmethod2, null, [282, 291], " + (R_DEFAULT + 12) + "}", requestor.getResults());
}
public void testBug459189_001() throws JavaModelException {
@@ -2359,9 +2359,9 @@
int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "Retention[TYPE_REF]{java.lang.annotation.Retention, java.lang.annotation, Ljava.lang.annotation.Retention;, null, null, 14}\n"+
- "RetentionPolicy[TYPE_REF]{java.lang.annotation.RetentionPolicy, java.lang.annotation, Ljava.lang.annotation.RetentionPolicy;, null, null, 14}\n"+
- "return[KEYWORD]{return, null, null, return, null, 24}",
+ "Retention[TYPE_REF]{java.lang.annotation.Retention, java.lang.annotation, Ljava.lang.annotation.Retention;, null, null, " + (R_DEFAULT + 9) + "}\n"+
+ "RetentionPolicy[TYPE_REF]{java.lang.annotation.RetentionPolicy, java.lang.annotation, Ljava.lang.annotation.RetentionPolicy;, null, null, " + (R_DEFAULT + 9) + "}\n"+
+ "return[KEYWORD]{return, null, null, return, null, " + (R_DEFAULT + 19) + "}",
requestor.getResults());
}
public void testBug459189_002() throws JavaModelException {
@@ -2386,9 +2386,9 @@
int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "Retention[TYPE_REF]{java.lang.annotation.Retention, java.lang.annotation, Ljava.lang.annotation.Retention;, null, null, 14}\n"+
- "RetentionPolicy[TYPE_REF]{java.lang.annotation.RetentionPolicy, java.lang.annotation, Ljava.lang.annotation.RetentionPolicy;, null, null, 14}\n" +
- "return[KEYWORD]{return, null, null, return, null, 24}",
+ "Retention[TYPE_REF]{java.lang.annotation.Retention, java.lang.annotation, Ljava.lang.annotation.Retention;, null, null, " + (R_DEFAULT + 9) + "}\n"+
+ "RetentionPolicy[TYPE_REF]{java.lang.annotation.RetentionPolicy, java.lang.annotation, Ljava.lang.annotation.RetentionPolicy;, null, null, " + (R_DEFAULT + 9) + "}\n" +
+ "return[KEYWORD]{return, null, null, return, null, " + (R_DEFAULT + 19) + "}",
requestor.getResults());
}
public void testBug459189_003() throws JavaModelException {
@@ -2413,8 +2413,8 @@
int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "catch[KEYWORD]{catch, null, null, catch, null, 24}\n"+
- "finally[KEYWORD]{finally, null, null, finally, null, 24}",
+ "catch[KEYWORD]{catch, null, null, catch, null, " + (R_DEFAULT + 19) + "}\n"+
+ "finally[KEYWORD]{finally, null, null, finally, null, " + (R_DEFAULT + 19) + "}",
requestor.getResults());
}
public void testBug459189_004() throws JavaModelException {
@@ -2439,7 +2439,7 @@
int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "while[KEYWORD]{while, null, null, while, null, 24}",
+ "while[KEYWORD]{while, null, null, while, null, " + (R_DEFAULT + 19) + "}",
requestor.getResults());
}
public void testBug460410() throws JavaModelException {
@@ -2491,7 +2491,7 @@
int cursorLocation = str.indexOf(completeBehind) ;
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "someMethod[METHOD_REF]{someMethod(), LX;, ()V, someMethod, null, 27}", requestor.getResults());
+ "someMethod[METHOD_REF]{someMethod(), LX;, ()V, someMethod, null, " + (R_DEFAULT + 22) + "}", requestor.getResults());
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=481215
public void testBug481215a() throws JavaModelException {
@@ -2523,11 +2523,11 @@
int cursorLocation = str.indexOf(completeBehind) ;
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "ResourceBundle[TYPE_REF]{java.util.ResourceBundle, java.util, Ljava.util.ResourceBundle;, null, null, 14}\n" +
- "ResponseCache[TYPE_REF]{java.net.ResponseCache, java.net, Ljava.net.ResponseCache;, null, null, 14}\n" +
- "ResultSet[TYPE_REF]{java.sql.ResultSet, java.sql, Ljava.sql.ResultSet;, null, null, 14}\n" +
- "ResultSetMetaData[TYPE_REF]{java.sql.ResultSetMetaData, java.sql, Ljava.sql.ResultSetMetaData;, null, null, 14}\n" +
- "result[LOCAL_VARIABLE_REF]{result, null, Ljava.lang.String;, result, null, 27}", requestor.getResults());
+ "ResourceBundle[TYPE_REF]{java.util.ResourceBundle, java.util, Ljava.util.ResourceBundle;, null, null, " + (R_DEFAULT + 9) + "}\n" +
+ "ResponseCache[TYPE_REF]{java.net.ResponseCache, java.net, Ljava.net.ResponseCache;, null, null, " + (R_DEFAULT + 9) + "}\n" +
+ "ResultSet[TYPE_REF]{java.sql.ResultSet, java.sql, Ljava.sql.ResultSet;, null, null, " + (R_DEFAULT + 9) + "}\n" +
+ "ResultSetMetaData[TYPE_REF]{java.sql.ResultSetMetaData, java.sql, Ljava.sql.ResultSetMetaData;, null, null, " + (R_DEFAULT + 9) + "}\n" +
+ "result[LOCAL_VARIABLE_REF]{result, null, Ljava.lang.String;, result, null, " + (R_DEFAULT + 22) + "}", requestor.getResults());
}
public void testBug481215b() throws JavaModelException {
this.workingCopies = new ICompilationUnit[1];
@@ -2555,11 +2555,11 @@
int cursorLocation = str.indexOf(completeBehind) ;
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "ResourceBundle[TYPE_REF]{java.util.ResourceBundle, java.util, Ljava.util.ResourceBundle;, null, null, 14}\n" +
- "ResponseCache[TYPE_REF]{java.net.ResponseCache, java.net, Ljava.net.ResponseCache;, null, null, 14}\n" +
- "ResultSet[TYPE_REF]{java.sql.ResultSet, java.sql, Ljava.sql.ResultSet;, null, null, 14}\n" +
- "ResultSetMetaData[TYPE_REF]{java.sql.ResultSetMetaData, java.sql, Ljava.sql.ResultSetMetaData;, null, null, 14}\n" +
- "result[LOCAL_VARIABLE_REF]{result, null, Ljava.lang.String;, result, null, 27}", requestor.getResults());
+ "ResourceBundle[TYPE_REF]{java.util.ResourceBundle, java.util, Ljava.util.ResourceBundle;, null, null, " + (R_DEFAULT + 9) + "}\n" +
+ "ResponseCache[TYPE_REF]{java.net.ResponseCache, java.net, Ljava.net.ResponseCache;, null, null, " + (R_DEFAULT + 9) + "}\n" +
+ "ResultSet[TYPE_REF]{java.sql.ResultSet, java.sql, Ljava.sql.ResultSet;, null, null, " + (R_DEFAULT + 9) + "}\n" +
+ "ResultSetMetaData[TYPE_REF]{java.sql.ResultSetMetaData, java.sql, Ljava.sql.ResultSetMetaData;, null, null, " + (R_DEFAULT + 9) + "}\n" +
+ "result[LOCAL_VARIABLE_REF]{result, null, Ljava.lang.String;, result, null, " + (R_DEFAULT + 22) + "}", requestor.getResults());
}
public void testBug481215c() throws JavaModelException {
this.workingCopies = new ICompilationUnit[1];
@@ -2587,11 +2587,11 @@
int cursorLocation = str.indexOf(completeBehind) ;
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "ResourceBundle[TYPE_REF]{java.util.ResourceBundle, java.util, Ljava.util.ResourceBundle;, null, null, 14}\n" +
- "ResponseCache[TYPE_REF]{java.net.ResponseCache, java.net, Ljava.net.ResponseCache;, null, null, 14}\n" +
- "ResultSet[TYPE_REF]{java.sql.ResultSet, java.sql, Ljava.sql.ResultSet;, null, null, 14}\n" +
- "ResultSetMetaData[TYPE_REF]{java.sql.ResultSetMetaData, java.sql, Ljava.sql.ResultSetMetaData;, null, null, 14}\n" +
- "result[LOCAL_VARIABLE_REF]{result, null, Ljava.lang.String;, result, null, 27}", requestor.getResults());
+ "ResourceBundle[TYPE_REF]{java.util.ResourceBundle, java.util, Ljava.util.ResourceBundle;, null, null, " + (R_DEFAULT + 9) + "}\n" +
+ "ResponseCache[TYPE_REF]{java.net.ResponseCache, java.net, Ljava.net.ResponseCache;, null, null, " + (R_DEFAULT + 9) + "}\n" +
+ "ResultSet[TYPE_REF]{java.sql.ResultSet, java.sql, Ljava.sql.ResultSet;, null, null, " + (R_DEFAULT + 9) + "}\n" +
+ "ResultSetMetaData[TYPE_REF]{java.sql.ResultSetMetaData, java.sql, Ljava.sql.ResultSetMetaData;, null, null, " + (R_DEFAULT + 9) + "}\n" +
+ "result[LOCAL_VARIABLE_REF]{result, null, Ljava.lang.String;, result, null, " + (R_DEFAULT + 22) + "}", requestor.getResults());
}
public void testBug481215d() throws JavaModelException {
this.workingCopies = new ICompilationUnit[1];
@@ -2627,12 +2627,12 @@
int cursorLocation = str.indexOf(completeBehind) ;
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "ResourceBundle[TYPE_REF]{java.util.ResourceBundle, java.util, Ljava.util.ResourceBundle;, null, null, 14}\n" +
- "ResponseCache[TYPE_REF]{java.net.ResponseCache, java.net, Ljava.net.ResponseCache;, null, null, 14}\n" +
- "ResultSet[TYPE_REF]{java.sql.ResultSet, java.sql, Ljava.sql.ResultSet;, null, null, 14}\n" +
- "ResultSetMetaData[TYPE_REF]{java.sql.ResultSetMetaData, java.sql, Ljava.sql.ResultSetMetaData;, null, null, 14}\n" +
- "result[LOCAL_VARIABLE_REF]{result, null, Ljava.lang.String;, result, null, 27}\n" +
- "result2[LOCAL_VARIABLE_REF]{result2, null, Ljava.lang.String;, result2, null, 27}", requestor.getResults());
+ "ResourceBundle[TYPE_REF]{java.util.ResourceBundle, java.util, Ljava.util.ResourceBundle;, null, null, " + (R_DEFAULT + 9) + "}\n" +
+ "ResponseCache[TYPE_REF]{java.net.ResponseCache, java.net, Ljava.net.ResponseCache;, null, null, " + (R_DEFAULT + 9) + "}\n" +
+ "ResultSet[TYPE_REF]{java.sql.ResultSet, java.sql, Ljava.sql.ResultSet;, null, null, " + (R_DEFAULT + 9) + "}\n" +
+ "ResultSetMetaData[TYPE_REF]{java.sql.ResultSetMetaData, java.sql, Ljava.sql.ResultSetMetaData;, null, null, " + (R_DEFAULT + 9) + "}\n" +
+ "result[LOCAL_VARIABLE_REF]{result, null, Ljava.lang.String;, result, null, " + (R_DEFAULT + 22) + "}\n" +
+ "result2[LOCAL_VARIABLE_REF]{result2, null, Ljava.lang.String;, result2, null, " + (R_DEFAULT + 22) + "}", requestor.getResults());
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=484479
public void test484479() throws JavaModelException {
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 827681c..ea37cbc 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
@@ -5502,7 +5502,7 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
cu.codeComplete(cursorLocation, requestor);
assertResults(
- "Enum[TYPE_REF]{Enum, java.lang, Ljava.lang.Enum;, null, null, 17}",
+ "Enum[TYPE_REF]{Enum, java.lang, Ljava.lang.Enum;, null, null, " + (R_DEFAULT + 12) + "}",
requestor.getResults());
} finally {
@@ -5535,7 +5535,7 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
cu.codeComplete(cursorLocation, requestor);
assertResults(
- "Enum[TYPE_REF]{org.apache.commons.lang.enum.Enum, org.apache.commons.lang.enum, Lorg.apache.commons.lang.enum.Enum;, null, null, 14}",
+ "Enum[TYPE_REF]{org.apache.commons.lang.enum.Enum, org.apache.commons.lang.enum, Lorg.apache.commons.lang.enum.Enum;, null, null, " + (R_DEFAULT + 9) + "}",
requestor.getResults());
} finally {
@@ -5597,7 +5597,7 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
cu.codeComplete(cursorLocation, requestor);
assertResults(
- "org.apache.commons.lang.enum[PACKAGE_REF]{org.apache.commons.lang.enum.*;, org.apache.commons.lang.enum, null, null, null, 24}",
+ "org.apache.commons.lang.enum[PACKAGE_REF]{org.apache.commons.lang.enum.*;, org.apache.commons.lang.enum, null, null, null, " + (R_DEFAULT + 19) + "}",
requestor.getResults());
} finally {
@@ -6148,7 +6148,7 @@
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
cu.codeComplete(cursorLocation, requestor);
assertResults(
- "Main[TYPE_REF]{Main, p, Lp.Main;, null, null, 27}",
+ "Main[TYPE_REF]{Main, p, Lp.Main;, null, null, " + (R_DEFAULT + 22) + "}",
requestor.getResults());
} finally {
deleteProject("P");
@@ -6206,7 +6206,7 @@
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
cu.codeComplete(cursorLocation, requestor);
assertResults(
- "Main[TYPE_REF]{Main, p, Lp.Main;, null, null, 27}",
+ "Main[TYPE_REF]{Main, p, Lp.Main;, null, null, " + (R_DEFAULT + 22) + "}",
requestor.getResults());
} finally {
deleteProject("P");
@@ -6262,7 +6262,7 @@
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
cu.codeComplete(cursorLocation, requestor);
assertResults(
- "Main[TYPE_REF]{Main, p, Lp.Main;, null, null, 27}",
+ "Main[TYPE_REF]{Main, p, Lp.Main;, null, null, " + (R_DEFAULT + 22) + "}",
requestor.getResults());
} finally {
deleteProjects(new String[] { "Lib", "P" });
@@ -6318,7 +6318,7 @@
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
cu.codeComplete(cursorLocation, requestor);
assertResults(
- "Main[TYPE_REF]{Main, p, Lp.Main;, null, null, 27}",
+ "Main[TYPE_REF]{Main, p, Lp.Main;, null, null, " + (R_DEFAULT + 22) + "}",
requestor.getResults());
} finally {
deleteProjects(new String[] { "Lib", "P" });
@@ -6409,7 +6409,7 @@
this.workingCopies[2].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
assertResults(
- "Nested[TYPE_REF]{Nested, myannotations, Lmyannotations.Nested;, null, null, 47}",
+ "Nested[TYPE_REF]{Nested, myannotations, Lmyannotations.Nested;, null, null, " + (R_DEFAULT + 42) + "}",
requestor.getResults());
} finally {
deleteProject("P");
@@ -6483,7 +6483,7 @@
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
cu.codeComplete(cursorLocation, requestor);
assertResults(
- "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, 35}",
+ "toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, " + (R_DEFAULT + 30) + "}",
requestor.getResults());
} finally {
deleteProject("P");
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 2a685d5..ac30574 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -13503,8 +13503,8 @@
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "ThisClassIsFinal[TYPE_REF]{ThisClassIsFinal, test, Ltest.ThisClassIsFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_CLASS) + "}\n" +
- "ThisClassIsNotFinal[TYPE_REF]{ThisClassIsNotFinal, test, Ltest.ThisClassIsNotFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_CLASS) + "}",
+ "ThisClassIsFinal[TYPE_REF]{ThisClassIsFinal, test, Ltest.ThisClassIsFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
+ "ThisClassIsNotFinal[TYPE_REF]{ThisClassIsNotFinal, test, Ltest.ThisClassIsNotFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
requestor.getResults());
}
@@ -13846,9 +13846,9 @@
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "Inn.Inn2[TYPE_REF]{label.Inn.Inn2, label, Llabel.Inn$Inn2;, null, null, 44}\n" +
- "In[TYPE_REF]{In, label, Llabel.In;, null, null, 47}\n" +
- "Inn[TYPE_REF]{Inn, label, Llabel.Inn;, null, null, 47}",
+ "Inn.Inn2[TYPE_REF]{label.Inn.Inn2, label, Llabel.Inn$Inn2;, null, null, " + (R_DEFAULT + 39) + "}\n" +
+ "In[TYPE_REF]{In, label, Llabel.In;, null, null, " + (R_DEFAULT + 42) + "}\n" +
+ "Inn[TYPE_REF]{Inn, label, Llabel.Inn;, null, null, " + (R_DEFAULT + 42) + "}",
requestor.getResults());
}
@@ -13874,8 +13874,8 @@
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "Inn.Inn2[TYPE_REF]{Inn2, label, Llabel.Inn$Inn2;, null, null, 44}\n" +
- "Inn.Inn3[TYPE_REF]{Inn3, label, Llabel.Inn$Inn3;, null, null, 44}",
+ "Inn.Inn2[TYPE_REF]{Inn2, label, Llabel.Inn$Inn2;, null, null, " + (R_DEFAULT + 39) + "}\n" +
+ "Inn.Inn3[TYPE_REF]{Inn3, label, Llabel.Inn$Inn3;, null, null, " + (R_DEFAULT + 39) + "}",
requestor.getResults());
}
@@ -13891,8 +13891,10 @@
cu.codeComplete(cursorLocation, requestor);
assertResults(
- "name[ANNOTATION_ATTRIBUTE_REF]{name, Ltestxxx.YAAnnot;, Ljava.lang.String;, name, null, " + (R_NAME_FIRST_PREFIX + R_EXPECTED_TYPE + R_RESOLVED) + "}\n" +
- "val[ANNOTATION_ATTRIBUTE_REF]{val, Ltestxxx.YAAnnot;, I, val, null, " + (R_NAME_FIRST_PREFIX + R_EXPECTED_TYPE + R_RESOLVED) + "}",
+ "name[ANNOTATION_ATTRIBUTE_REF]{name, Ltestxxx.YAAnnot;, Ljava.lang.String;, name, null, " +
+ (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
+ "val[ANNOTATION_ATTRIBUTE_REF]{val, Ltestxxx.YAAnnot;, I, val, null, " +
+ (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
requestor.getResults());
}
@@ -13913,8 +13915,10 @@
requestor.getContext());
assertResults(
- "xxyy[FIELD_REF]{xxyy, Ltestxxx.TestType2;, I, xxyy, null, " + (R_NAME_FIRST_PREFIX + R_EXPECTED_TYPE + R_RESOLVED) + "}\n" +
- "xxyy1[FIELD_REF]{xxyy1, Ltestxxx.TestType2;, Ljava.lang.String;, xxyy1, null, " + (R_NAME_FIRST_PREFIX + R_EXPECTED_TYPE + R_RESOLVED + R_EXACT_EXPECTED_TYPE) + "}",
+ "xxyy[FIELD_REF]{xxyy, Ltestxxx.TestType2;, I, xxyy, null, " +
+ (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
+ "xxyy1[FIELD_REF]{xxyy1, Ltestxxx.TestType2;, Ljava.lang.String;, xxyy1, null, " +
+ (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}",
requestor.getResults());
}
public void testBug351426() throws JavaModelException {
@@ -13936,7 +13940,7 @@
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE;
+ int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_NAME + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED;
assertResults(
"expectedTypesSignatures={Ltest.X<Ljava.lang.String;>;}\n" +
@@ -13965,7 +13969,7 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE;
+ int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_NAME + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED;
assertResults(
"expectedTypesSignatures={Ltest.X<Ljava.lang.String;>;}\n" +
@@ -13996,7 +14000,7 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE;
+ int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_NAME + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED;
assertResults(
"expectedTypesSignatures={Ltest.X<Ljava.lang.String;>.X1<Ljava.lang.String;>;}\n" +
@@ -14029,7 +14033,7 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE;
+ int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_NAME + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED;
assertResults(
"expectedTypesSignatures={Ltest.X<Ljava.lang.String;>.X1<Ljava.lang.Object;>.X11<Ljava.lang.String;>;}\n" +
@@ -14061,7 +14065,7 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE;
+ int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_NAME + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED;
assertResults(
"expectedTypesSignatures={Ltest.X$X1<Ljava.lang.String;>;}\n" +
@@ -14091,7 +14095,7 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE;
+ int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_NAME + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED;
assertResults(
"expectedTypesSignatures={Ltest.X<Ljava.lang.String;>;}\n" +
@@ -14122,7 +14126,7 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE;
+ int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_NAME + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED;
assertResults(
"expectedTypesSignatures={Ltest.X<TT;>.X1<Ljava.lang.String;>;}\n" +
@@ -14153,7 +14157,7 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE;
+ int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_NAME + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED;
assertResults(
"expectedTypesSignatures={Ltest.X$X1<Ljava.lang.String;>;}\n" +
@@ -14181,7 +14185,7 @@
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE;
+ int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_NAME + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED;
assertResults(
"expectedTypesSignatures={Ltest.X<Ljava.lang.String;>;}\n" +
@@ -14213,7 +14217,7 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE;
+ int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_NAME + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED;
assertResults(
"expectedTypesSignatures={Ltest.X$X1<Ljava.lang.String;>;}\n" +
@@ -14243,7 +14247,7 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE;
+ int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_NAME + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED;
assertResults(
"expectedTypesSignatures={Ltest.X<Ljava.lang.String;Ljava.lang.String;>;}\n" +
@@ -14278,7 +14282,7 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
- int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE;
+ int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_NAME + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED;
assertResults(
"expectedTypesSignatures={Ltest.X1<Ljava.lang.String;>;}\n" +
@@ -14305,7 +14309,8 @@
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "X<T>[TYPE_REF]{, , LX<TT;>;, null, null, replace[116, 116], token[116, 116], 51}",
+ "X<T>[TYPE_REF]{, , LX<TT;>;, null, null, replace[116, 116], token[116, 116], " +
+ (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_NAME + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+ "}",
requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=326610
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExclusionPatternsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExclusionPatternsTests.java
index 41ec92c..bfede2d 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExclusionPatternsTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExclusionPatternsTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -289,12 +289,16 @@
root.getNonJavaResources());
}
/*
- * Ensure that crearing an excluded package doesn't make it appear as a child of its package fragment root but it is a non-java resource.
+ * Ensure that creating an excluded package doesn't make it appear as a child of its package fragment root but it is a non-java resource.
* (regression test for bug 65637 [model] Excluded package still in Java model)
*/
public void testCreateExcludedPackage2() throws CoreException {
setClasspath(new String[] {"/P/src", "org/*|org/eclipse/*"});
+ // Trigger population of cache to check if it is properly invalidated by the delta processor.
+ // See http://bugs.eclipse.org/500714
+ getPackageFragmentRoot("/P/src").getChildren();
+
clearDeltas();
createFolder("/P/src/org/eclipse/mypack");
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExternalAnnotations18Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExternalAnnotations18Test.java
index 680ae6b..bc2e744 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExternalAnnotations18Test.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExternalAnnotations18Test.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.model;
+import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -350,6 +351,19 @@
return ((AbstractCompilerTest.getPossibleComplianceLevels() & AbstractCompilerTest.F_1_8) != 0);
}
+ String readFully(IFile file) throws IOException, CoreException {
+ try (BufferedInputStream bs = new BufferedInputStream(file.getContents())) {
+ int available = 0;
+ StringBuilder buf = new StringBuilder();
+ while ((available = bs.available()) > 0) {
+ byte[] contents = new byte[available];
+ bs.read(contents);
+ buf.append(new String(contents));
+ }
+ return buf.toString();
+ }
+ }
+
/** Perform full build. */
public void test1FullBuild() throws Exception {
setupJavaProject("Test1");
@@ -1012,11 +1026,104 @@
MergeStrategy.OVERWRITE_ANNOTATIONS, null);
assertTrue("file should exist", annotationFile.exists());
- // check that the error is even worse now:
+ // check that the error is resolved now:
reconciled = cu.reconcile(AST.JLS8, true, null, new NullProgressMonitor());
assertNoProblems(reconciled.getProblems());
}
+
+ public void testAnnotateConstructorParameter() throws Exception {
+ myCreateJavaProject("TestLibs");
+ String lib1Content =
+ "package libs;\n" +
+ "\n" +
+ "public class Lib1<U> {\n" +
+ " public Lib1(int ignore, U string) {}\n" +
+ "}\n";
+ addLibraryWithExternalAnnotations(this.project, "lib1.jar", "annots", new String[] {
+ "/UnannotatedLib/libs/Lib1.java",
+ lib1Content
+ }, null);
+
+ // type check sources:
+ IPackageFragment fragment = this.project.getPackageFragmentRoots()[0].createPackageFragment("tests", true, null);
+ ICompilationUnit cu = fragment.createCompilationUnit("Test1.java",
+ "package tests;\n" +
+ "import org.eclipse.jdt.annotation.*;\n" +
+ "import libs.Lib1;\n" +
+ "\n" +
+ "public class Test1 {\n" +
+ " Object test0() {\n" +
+ " Lib1<@NonNull String> lib = new Lib1<>(1, null);\n" +
+ " return lib;\n" +
+ " }\n" +
+ "}\n",
+ true, new NullProgressMonitor()).getWorkingCopy(new NullProgressMonitor());
+ CompilationUnit reconciled = cu.reconcile(AST.JLS8, true, null, new NullProgressMonitor());
+ assertProblems(reconciled.getProblems(), new String[] {
+ "Pb(910) Null type mismatch: required '@NonNull String' but the provided value is null",
+ }, new int[] { 7 });
+
+ // acquire library AST:
+ IType type = this.project.findType("libs.Lib1");
+ ICompilationUnit libWorkingCopy = type.getClassFile().getWorkingCopy(this.wcOwner, null);
+ ASTParser parser = ASTParser.newParser(AST.JLS8);
+ parser.setSource(libWorkingCopy);
+ parser.setResolveBindings(true);
+ parser.setStatementsRecovery(false);
+ parser.setBindingsRecovery(false);
+ CompilationUnit unit = (CompilationUnit) parser.createAST(null);
+ libWorkingCopy.discardWorkingCopy();
+
+ // find type binding:
+ int start = lib1Content.indexOf("U string");
+ ASTNode name = NodeFinder.perform(unit, start, 0);
+ assertTrue("should be simple name", name.getNodeType() == ASTNode.SIMPLE_NAME);
+ ASTNode method = name.getParent().getParent().getParent();
+ IMethodBinding methodBinding = ((MethodDeclaration)method).resolveBinding();
+
+ // find annotation file (not yet existing):
+ IFile annotationFile = ExternalAnnotationUtil.getAnnotationFile(this.project, methodBinding.getDeclaringClass(), null);
+ assertFalse("file should not exist", annotationFile.exists());
+ assertEquals("file path", "/TestLibs/annots/libs/Lib1.eea", annotationFile.getFullPath().toString());
+
+ // annotate:
+ String originalSignature = ExternalAnnotationUtil.extractGenericSignature(methodBinding);
+ ExternalAnnotationUtil.annotateMember("libs/Lib1", annotationFile,
+ "<init>",
+ originalSignature,
+ "(IT0U;)V", // <- @Nullable U
+ MergeStrategy.OVERWRITE_ANNOTATIONS, null);
+ assertTrue("file should exist", annotationFile.exists());
+
+ // check that the error is resolved now:
+ reconciled = cu.reconcile(AST.JLS8, true, null, new NullProgressMonitor());
+ assertNoProblems(reconciled.getProblems());
+
+ // invert annotation:
+ ExternalAnnotationUtil.annotateMethodParameterType("libs/Lib1", annotationFile,
+ "<init>",
+ originalSignature,
+ "T1U;", // <- @NonNull U
+ 1, // position
+ MergeStrategy.OVERWRITE_ANNOTATIONS, null);
+ assertTrue("file should exist", annotationFile.exists());
+
+ // check that the error is back now:
+ reconciled = cu.reconcile(AST.JLS8, true, null, new NullProgressMonitor());
+ assertProblems(reconciled.getProblems(), new String[] {
+ "Pb(910) Null type mismatch: required '@NonNull String' but the provided value is null",
+ }, new int[] { 7 });
+
+ // check that the previous entry has been overwritten:
+ assertEquals(
+ "class libs/Lib1\n" +
+ "<init>\n" +
+ " (ITU;)V\n" +
+ " (IT1U;)V\n",
+ readFully(annotationFile));
+ }
+
// ===== white box tests for ExternalAnnotationUtil =====
public void testBug470666a() throws CoreException, IOException {
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/FreezeMonitor.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/FreezeMonitor.java
new file mode 100644
index 0000000..19fd7a7
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/FreezeMonitor.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Google, Inc 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:
+ * Stefan Xenos (Google) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.model;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.ThreadInfo;
+import java.lang.management.ThreadMXBean;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.ICoreRunnable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.jobs.Job;
+
+public class FreezeMonitor {
+
+ private static /* @Nullable */ Job monitorJob;
+
+ public static void expectCompletionIn(final long millis) {
+ done();
+ monitorJob = Job.create("", new ICoreRunnable() {
+ @Override
+ public void run(IProgressMonitor monitor) throws CoreException {
+ if (monitor.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+ StringBuilder result = new StringBuilder();
+ result.append("Possible frozen test case\n");
+ ThreadMXBean threadStuff = ManagementFactory.getThreadMXBean();
+ ThreadInfo[] allThreads = threadStuff.getThreadInfo(threadStuff.getAllThreadIds(), 200);
+ for (ThreadInfo threadInfo : allThreads) {
+ result.append("\"");
+ result.append(threadInfo.getThreadName());
+ result.append("\": ");
+ result.append(threadInfo.getThreadState());
+ result.append("\n");
+ final StackTraceElement[] elements = threadInfo.getStackTrace();
+ for (StackTraceElement element : elements) {
+ result.append(" ");
+ result.append(element);
+ result.append("\n");
+ }
+ result.append("\n");
+ }
+ System.out.println(result.toString());
+ }
+ });
+ monitorJob.schedule(millis);
+ }
+
+ public static void done() {
+ if (monitorJob != null) {
+ monitorJob.cancel();
+ monitorJob = null;
+ }
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java
index ef9d23c..9ea4398 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java
@@ -2809,4 +2809,75 @@
deleteProject(project15);
}
}
+
+public void testBug501220() throws CoreException {
+ IJavaProject jdkPrj = null, swtPrj = null, egitPrj = null;
+ try {
+ jdkPrj = createJavaProject("JDK8", new String[]{"src"}, new String[] {"JCL_LIB"}, null, null, "bin", new String[]{"bin"}, null, null, "1.8");
+ createFolder("/JDK8/src/jdk8");
+ createFile("/JDK8/src/jdk8/MyConsumer.java",
+ "package jdk8;\n" +
+ "@FunctionalInterface\n" +
+ "public interface MyConsumer<T> {\n" +
+ " void accept(T t);\n" +
+ "}\n");
+
+ swtPrj = createJavaProject("SWT", new String[]{"src"}, new String[] {"JCL_LIB"}, new String[]{"/JDK8"}, null, "bin", new String[]{"bin"}, null, null, "1.8");
+ createFolder("/SWT/src/swt");
+ createFile("/SWT/src/swt/EventObject.java",
+ "package swt;\n" +
+ "\n" +
+ "import jdk8.MyConsumer;\n" +
+ "\n" +
+ "public class EventObject {\n" +
+ "}");
+ createFile("/SWT/src/swt/SelectionListener.java",
+ "package swt;\n" +
+ "\n" +
+ "import java.util.EventObject;\n" +
+ "\n" +
+ "import jdk8.MyConsumer;\n" +
+ "\n" +
+ "public interface SelectionListener {\n" +
+ " void widgetSelected(EventObject event);\n" +
+ "\n" +
+ " static SelectionListener widgetSelected(MyConsumer<EventObject> c) {\n" +
+ " return new SelectionListener() {\n" +
+ " public void widgetSelected(EventObject e) {\n" +
+ " c.accept(e);\n" +
+ " }\n" +
+ " };\n" +
+ " }\n" +
+ "}");
+ egitPrj = createJavaProject("EGit", new String[]{"src"}, new String[] {"JCL_LIB"}, new String[]{"/SWT"}, null, "bin", new String[]{"bin"}, null, null, "1.8");
+ egitPrj.setOption(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED);
+ createFolder("/EGit/src/egit");
+ createFile("/EGit/src/egit/UIUtils.java",
+ "package egit; // Error: The type jdk8.MyConsumer cannot be resolved. It is indirectly referenced from required .class files\n" +
+ "\n" +
+ "import swt.EventObject;\n" +
+ "\n" +
+ "import swt.SelectionListener;\n" +
+ "\n" +
+ "public class UIUtils {\n" +
+ " void foo() {\n" +
+ " SelectionListener listener = new SelectionListener() {\n" +
+ " public void widgetSelected(EventObject event) {\n" +
+ " }\n" +
+ " };\n" +
+ " listener.toString();\n" +
+ " }\n" +
+ "}\n");
+ egitPrj.getProject().getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null);
+ IMarker[] markers = egitPrj.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE);
+ assertMarkers("Unexpected markers", "", markers);
+ } finally {
+ if (jdkPrj != null)
+ deleteProject(jdkPrj);
+ if (swtPrj != null)
+ deleteProject(swtPrj);
+ if (egitPrj != null)
+ deleteProject(egitPrj);
+ }
+}
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavadocFieldCompletionModelTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavadocFieldCompletionModelTest.java
index 696669a..2587d80 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavadocFieldCompletionModelTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavadocFieldCompletionModelTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -513,7 +513,7 @@
"}";
completeInJavadoc("/Completion/src/javadoc/fields/tags/BasicTestFields.java", source, true, "oTT");
assertResults(
- "oneTwoThree[FIELD_REF]{oneTwoThree, Ljavadoc.fields.tags.BasicTestFields;, Ljava.lang.Object;, oneTwoThree, null, "+this.positions+"30}"
+ "oneTwoThree[FIELD_REF]{oneTwoThree, Ljavadoc.fields.tags.BasicTestFields;, Ljava.lang.Object;, oneTwoThree, null, "+this.positions+(R_DEFAULT + 25) + "}"
);
} finally {
JavaCore.setOptions(this.oldOptions);
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavadocMethodCompletionModelTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavadocMethodCompletionModelTest.java
index af02169..eeae0e8 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavadocMethodCompletionModelTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavadocMethodCompletionModelTest.java
@@ -1768,8 +1768,8 @@
"}\n";
completeInJavadoc("/Completion/src/javadoc/methods/tags/BasicTestMethods.java", source, true, "@param ", 0); // empty token
assertSortedResults(
- "xtm[JAVADOC_PARAM_REF]{xtm, null, null, xtm, null, "+this.positions+"19}\n" +
- "xtc[JAVADOC_PARAM_REF]{xtc, null, null, xtc, null, "+this.positions+"18}\n" +
+ "xtm[JAVADOC_PARAM_REF]{xtm, null, null, xtm, null, "+this.positions+(R_DEFAULT + 14)+"}\n" +
+ "xtc[JAVADOC_PARAM_REF]{xtc, null, null, xtc, null, "+this.positions+(R_DEFAULT + 13)+"}\n" +
"TM[JAVADOC_PARAM_REF]{<TM>, null, null, TM, null, "+this.positions+JAVADOC_RELEVANCE+"}"
);
}
@@ -1834,8 +1834,8 @@
"}\n";
completeInJavadoc("/Completion/src/javadoc/methods/tags/BasicTestMethods.java", source, true, "@param ", 0); // empty token
assertSortedResults(
- "xtm[JAVADOC_PARAM_REF]{xtm, null, null, xtm, null, [105, 108], 19}\n" +
- "xtc[JAVADOC_PARAM_REF]{xtc, null, null, xtc, null, [105, 108], 18}\n" +
+ "xtm[JAVADOC_PARAM_REF]{xtm, null, null, xtm, null, [105, 108], " + (R_DEFAULT + 14) +"}\n" +
+ "xtc[JAVADOC_PARAM_REF]{xtc, null, null, xtc, null, [105, 108], " + (R_DEFAULT + 13) +"}\n" +
"TM[JAVADOC_PARAM_REF]{<TM>, null, null, TM, null, [105, 108], "+JAVADOC_RELEVANCE+"}"
);
}
@@ -1883,8 +1883,8 @@
"}\n";
completeInJavadoc("/Completion/src/javadoc/methods/tags/BasicTestMethods.java", source, true, "@param ", 0); // empty token
assertSortedResults(
- "xtm[JAVADOC_PARAM_REF]{xtm, null, null, xtm, null, "+this.positions+"19}\n" +
- "xtc[JAVADOC_PARAM_REF]{xtc, null, null, xtc, null, "+this.positions+"18}\n" +
+ "xtm[JAVADOC_PARAM_REF]{xtm, null, null, xtm, null, "+this.positions+(R_DEFAULT + 14)+"}\n" +
+ "xtc[JAVADOC_PARAM_REF]{xtc, null, null, xtc, null, "+this.positions+(R_DEFAULT + 13)+"}\n" +
"TM[JAVADOC_PARAM_REF]{<TM>, null, null, TM, null, "+this.positions+JAVADOC_RELEVANCE+"}"
);
}
@@ -1902,8 +1902,8 @@
"}\n";
completeInJavadoc("/Completion/src/javadoc/methods/tags/BasicTestMethods.java", source, true, "@param ", 0); // empty token
assertSortedResults(
- "xtm[JAVADOC_PARAM_REF]{xtm, null, null, xtm, null, "+this.positions+"19}\n" +
- "xtc[JAVADOC_PARAM_REF]{xtc, null, null, xtc, null, "+this.positions+"18}\n" +
+ "xtm[JAVADOC_PARAM_REF]{xtm, null, null, xtm, null, "+this.positions+(R_DEFAULT + 14)+"}\n" +
+ "xtc[JAVADOC_PARAM_REF]{xtc, null, null, xtc, null, "+this.positions+(R_DEFAULT + 13)+"}\n" +
"TM[JAVADOC_PARAM_REF]{<TM>, null, null, TM, null, "+this.positions+JAVADOC_RELEVANCE+"}"
);
}
@@ -1921,8 +1921,8 @@
"}\n";
completeInJavadoc("/Completion/src/javadoc/methods/tags/BasicTestMethods.java", source, true, "@param ", 0); // empty token
assertSortedResults(
- "xtm[JAVADOC_PARAM_REF]{xtm, null, null, xtm, null, "+this.positions+"19}\n" +
- "xtc[JAVADOC_PARAM_REF]{xtc, null, null, xtc, null, "+this.positions+"18}\n" +
+ "xtm[JAVADOC_PARAM_REF]{xtm, null, null, xtm, null, "+this.positions+(R_DEFAULT + 14)+"}\n" +
+ "xtc[JAVADOC_PARAM_REF]{xtc, null, null, xtc, null, "+this.positions+(R_DEFAULT + 13)+"}\n" +
"TM[JAVADOC_PARAM_REF]{<TM>, null, null, TM, null, "+this.positions+JAVADOC_RELEVANCE+"}"
);
}
@@ -2536,7 +2536,7 @@
"}\n";
completeInJavadoc("/Completion/src/javadoc/methods/tags/BasicTestMethods.java", source, true, "oTT");
assertResults(
- "oneTwoThree[METHOD_REF]{oneTwoThree(int), Ljavadoc.methods.tags.BasicTestMethods;, (I)V, oneTwoThree, (i), "+this.positions+"30}"
+ "oneTwoThree[METHOD_REF]{oneTwoThree(int), Ljavadoc.methods.tags.BasicTestMethods;, (I)V, oneTwoThree, (i), "+this.positions+(R_DEFAULT + 25)+"}"
);
} finally {
JavaCore.setOptions(this.oldOptions);
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavadocTypeCompletionModelTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavadocTypeCompletionModelTest.java
index a567e07..1452f4d 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavadocTypeCompletionModelTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavadocTypeCompletionModelTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -1036,7 +1036,7 @@
" */\n" +
"public class BasicTestTypes {}\n";
completeInJavadoc("/Completion/src/javadoc/types/tags/BasicTestTypes.java", source, true, "BTT");
- assertResults("BasicTestTypes[TYPE_REF]{BasicTestTypes, javadoc.types.tags, Ljavadoc.types.tags.BasicTestTypes;, null, null, "+this.positions+"22}");
+ assertResults("BasicTestTypes[TYPE_REF]{BasicTestTypes, javadoc.types.tags, Ljavadoc.types.tags.BasicTestTypes;, null, null, "+this.positions+ (R_DEFAULT + 17) +"}");
} finally {
JavaCore.setOptions(this.oldOptions);
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModifyingResourceTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModifyingResourceTests.java
index 4a50363..3f44c37 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModifyingResourceTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModifyingResourceTests.java
@@ -19,6 +19,7 @@
import org.eclipse.jdt.core.compiler.batch.BatchCompiler;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.core.JavaElement;
+import org.eclipse.jdt.internal.core.nd.indexer.Indexer;
public class ModifyingResourceTests extends AbstractJavaModelTests {
@@ -102,6 +103,7 @@
} catch (IOException e) {
e.printStackTrace();
}
+ Indexer.getInstance().waitForIndex(null);
return file;
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NameLookupTests2.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NameLookupTests2.java
index a529c77..1dd9354 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NameLookupTests2.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NameLookupTests2.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -14,9 +14,6 @@
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
-import java.nio.file.StandardCopyOption;
-import java.nio.file.attribute.FileTime;
-import java.util.Arrays;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.runtime.CoreException;
@@ -361,15 +358,7 @@
* JavaProjectElementInfo cache without restarting Eclipse or closing and reopening the project.
*/
public void testTransitionFromInvalidToValidJar() throws CoreException, IOException {
- /*
- * Since it is difficult to test intermittent IO errors, simulate it
- * by creating two jars of equal size, one of which has an invalid format.
- * Set up the classpath with the invalid jar, and then swap in the valid jar
- * and reset its timestamp to be the same as the original file.
- */
- String goodJar = getExternalPath() + "goodJar.jar";
String transitioningJar = getExternalPath() + "transitioningJar.jar";
- java.nio.file.Path goodJarPath = FileSystems.getDefault().getPath(goodJar);
java.nio.file.Path transitioningJarPath = FileSystems.getDefault().getPath(transitioningJar);
IPath transitioningIPath = Path.fromOSString(transitioningJar);
@@ -385,33 +374,29 @@
"META-INF/MANIFEST.MF",
"Manifest-Version: 1.0\n"
},
- goodJar,
+ transitioningJar,
JavaCore.VERSION_1_4);
- char[] invalidContents = new char[(int) goodJarPath.toFile().length()];
- Arrays.fill(invalidContents, ' ');
- Util.createFile(transitioningJar, String.copyValueOf(invalidContents));
// Set up the project with the invalid jar and allow all of the classpath validation
// and delta processing to complete.
+ JavaModelManager.throwIoExceptionsInGetZipFile = true;
JavaProject proj = (JavaProject) createJavaProject("P", new String[] {}, new String[] {transitioningJar}, "bin");
JavaModelManager.getJavaModelManager().getJavaModel().refreshExternalArchives(null, null);
waitForAutoBuild();
assertTrue("The invalid archive cache should report that the jar is invalid",
- JavaModelManager.getJavaModelManager().isInvalidArchive(transitioningIPath));
+ !JavaModelManager.getJavaModelManager().getArchiveValidity(transitioningIPath).isValid());
IType type = getNameLookup(proj).findType("test1.IResource", false, NameLookup.ACCEPT_CLASSES);
assertEquals("Name lookup should fail when the jar is invalid", null, type);
- // Substitute the good jar, maintaining the timestamp.
- FileTime fileTime = Files.getLastModifiedTime(transitioningJarPath);
- Files.move(goodJarPath, transitioningJarPath, StandardCopyOption.REPLACE_EXISTING);
- Files.setLastModifiedTime(transitioningJarPath, fileTime);
+ // Cause IO exceptions to be thrown on all file operations
+ JavaModelManager.throwIoExceptionsInGetZipFile = false;
// Since the timestamp hasn't changed, an external archive refresh isn't going
// to update the caches or cause name lookups to work.
JavaModelManager.getJavaModelManager().getJavaModel().refreshExternalArchives(null, null);
assertTrue("External archive refresh sees no changes, so the invalid archive cache should be unchanged",
- JavaModelManager.getJavaModelManager().isInvalidArchive(transitioningIPath));
+ !JavaModelManager.getJavaModelManager().getArchiveValidity(transitioningIPath).isValid());
type = getNameLookup(proj).findType("test1.IResource", false, NameLookup.ACCEPT_CLASSES);
assertEquals("External archive refresh sees no changes, so the project cache should be unchanged",
null, type);
@@ -423,11 +408,10 @@
ClasspathEntry.validateClasspathEntry(proj, transitioningEntry, false, false);
assertFalse("The invalid archive cache should no longer report the jar as invalid",
- JavaModelManager.getJavaModelManager().isInvalidArchive(transitioningIPath));
+ !JavaModelManager.getJavaModelManager().getArchiveValidity(transitioningIPath).isValid());
type = getNameLookup(proj).findType("test1.IResource", false, NameLookup.ACCEPT_CLASSES);
assertFalse("Name lookup should be able to find types in the valid jar", type == null);
} finally {
- Files.deleteIfExists(goodJarPath);
Files.deleteIfExists(transitioningJarPath);
deleteProject("P");
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SubstringCompletionTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SubstringCompletionTests.java
index 81e976d..4fea3b3 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SubstringCompletionTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SubstringCompletionTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 Gábor Kövesdán and others.
+ * Copyright (c) 2015, 2016 Gábor Kövesdán 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,59 +17,20 @@
import org.eclipse.jdt.core.JavaModelException;
import junit.framework.Test;
-import junit.framework.TestSuite;
public class SubstringCompletionTests extends AbstractJavaModelCompletionTests {
public static Test suite() {
- if (TESTS_PREFIX != null || TESTS_NAMES != null || TESTS_NUMBERS != null || TESTS_RANGE != null) {
- return buildModelTestSuite(SubstringCompletionTests.class);
- }
- TestSuite suite = new Suite(SubstringCompletionTests.class.getName());
- suite.addTest(new SubstringCompletionTests("testQualifiedNonStaticMethod"));
- suite.addTest(new SubstringCompletionTests("testQualifiedStaticMethod"));
- suite.addTest(new SubstringCompletionTests("testUnqualifiedNonStaticMethod"));
- suite.addTest(new SubstringCompletionTests("testUnqualifiedStaticMethod"));
- suite.addTest(new SubstringCompletionTests("testQualifiedNonStaticField"));
- suite.addTest(new SubstringCompletionTests("testQualifiedStaticField"));
- suite.addTest(new SubstringCompletionTests("testUnqualifiedNonStaticField"));
- suite.addTest(new SubstringCompletionTests("testUnqualifiedStaticField"));
- suite.addTest(new SubstringCompletionTests("testLocalVariable"));
- suite.addTest(new SubstringCompletionTests("testMethodParamVariable"));
- suite.addTest(new SubstringCompletionTests("testClassTypeInstantiation"));
- suite.addTest(new SubstringCompletionTests("testClassTypeFieldDeclaration"));
- suite.addTest(new SubstringCompletionTests("testClassTypeParamDeclaration"));
- suite.addTest(new SubstringCompletionTests("testClassTypeLocalVarDeclaration"));
- suite.addTest(new SubstringCompletionTests("testClassTypeThrowsDeclaration"));
- suite.addTest(new SubstringCompletionTests("testClassTypeExtends"));
- suite.addTest(new SubstringCompletionTests("testClassTypeImplements"));
- suite.addTest(new SubstringCompletionTests("testInnerClassTypeInstantiation"));
- suite.addTest(new SubstringCompletionTests("testInnerClassTypeFieldDeclaration"));
- suite.addTest(new SubstringCompletionTests("testInnerClassTypeParamDeclaration"));
- suite.addTest(new SubstringCompletionTests("testInnerClassTypeLocalVarDeclaration"));
- suite.addTest(new SubstringCompletionTests("testInnerClassTypeThrowsDeclaration"));
- suite.addTest(new SubstringCompletionTests("testInnerClassTypeExtends"));
- suite.addTest(new SubstringCompletionTests("testInnerClassTypeImplements"));
- suite.addTest(new SubstringCompletionTests("testStaticNestedClassTypeInstantiation"));
- suite.addTest(new SubstringCompletionTests("testStaticNestedClassTypeFieldDeclaration"));
- suite.addTest(new SubstringCompletionTests("testStaticNestedClassTypeParamDeclaration"));
- suite.addTest(new SubstringCompletionTests("testStaticNestedClassTypeLocalVarDeclaration"));
- suite.addTest(new SubstringCompletionTests("testStaticNestedClassTypeThrowsDeclaration"));
- suite.addTest(new SubstringCompletionTests("testStaticNestedClassTypeExtends"));
- suite.addTest(new SubstringCompletionTests("testStaticNestedClassTypeImplements"));
- suite.addTest(new SubstringCompletionTests("testLocalClassTypeInstantiation"));
- suite.addTest(new SubstringCompletionTests("testLocalClassTypeLocalVarDeclaration"));
- suite.addTest(new SubstringCompletionTests("testLocalClassTypeExtends"));
- return suite;
+ return buildModelTestSuite(SubstringCompletionTests.class, BYTECODE_DECLARATION_ORDER);
}
public SubstringCompletionTests(String name) {
super(name);
}
public void setUpSuite() throws Exception {
if (COMPLETION_PROJECT == null) {
- COMPLETION_PROJECT = setUpJavaProject("Completion");
+ COMPLETION_PROJECT = setUpJavaProject("Completion", "1.8", true);
} else {
- setUpProjectCompliance(COMPLETION_PROJECT, "1.8");
+ setUpProjectCompliance(COMPLETION_PROJECT, "1.8", true);
}
super.setUpSuite();
Hashtable<String, String> options = new Hashtable<>(this.oldOptions);
@@ -202,24 +163,24 @@
"/Completion/src/test/Test.java",
"package test;"+
"public class Test {\n" +
- " int element;\n" +
- " int otherElement;\n" +
- " long elementCount;\n" +
+ " int items;\n" +
+ " int otherItems;\n" +
+ " long itemsCount;\n" +
" void foo() {\n" +
- " this.elem\n" +
+ " this.item\n" +
" }\n" +
"}\n");
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
String str = this.workingCopies[0].getSource();
- String completeBehind = "this.elem";
+ String completeBehind = "this.item";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "otherElement[FIELD_REF]{otherElement, Ltest.Test;, I, otherElement, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_STATIC + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" +
- "element[FIELD_REF]{element, Ltest.Test;, I, element, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + + R_CASE + R_NON_STATIC + R_NON_RESTRICTED) + "}\n" +
- "elementCount[FIELD_REF]{elementCount, Ltest.Test;, J, elementCount, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED) + "}",
+ "otherItems[FIELD_REF]{otherItems, Ltest.Test;, I, otherItems, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_STATIC + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" +
+ "items[FIELD_REF]{items, Ltest.Test;, I, items, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + + R_CASE + R_NON_STATIC + R_NON_RESTRICTED) + "}\n" +
+ "itemsCount[FIELD_REF]{itemsCount, Ltest.Test;, J, itemsCount, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED) + "}",
requestor.getResults());
}
@@ -229,25 +190,24 @@
"/Completion/src/test/Test.java",
"package test;"+
"public class Test {\n" +
- " int element;\n" +
- " int otherElement;\n" +
- " long elementCount;\n" +
+ " int items;\n" +
+ " int otherItems;\n" +
+ " long itemsCount;\n" +
" void foo() {\n" +
- " elem\n" +
+ " item\n" +
" }\n" +
"}\n");
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
String str = this.workingCopies[0].getSource();
- String completeBehind = "elem";
+ String completeBehind = "item";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "ElementType[TYPE_REF]{java.lang.annotation.ElementType, java.lang.annotation, Ljava.lang.annotation.ElementType;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
- "otherElement[FIELD_REF]{otherElement, Ltest.Test;, I, otherElement, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" +
- "element[FIELD_REF]{element, Ltest.Test;, I, element, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
- "elementCount[FIELD_REF]{elementCount, Ltest.Test;, J, elementCount, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
+ "otherItems[FIELD_REF]{otherItems, Ltest.Test;, I, otherItems, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" +
+ "items[FIELD_REF]{items, Ltest.Test;, I, items, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
+ "itemsCount[FIELD_REF]{itemsCount, Ltest.Test;, J, itemsCount, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
requestor.getResults());
}
public void testQualifiedStaticField() throws JavaModelException {
@@ -256,23 +216,23 @@
"/Completion/src/test/Test.java",
"package test;"+
"public class Test {\n" +
- " static int element;\n" +
- " int otherElement;\n" +
- " static long elementCount;\n" +
+ " static int items;\n" +
+ " int otherItems;\n" +
+ " static long itemsCount;\n" +
" void foo() {\n" +
- " Test.elem\n" +
+ " Test.item\n" +
" }\n" +
"}\n");
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
String str = this.workingCopies[0].getSource();
- String completeBehind = "Test.elem";
+ String completeBehind = "Test.item";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "element[FIELD_REF]{element, Ltest.Test;, I, element, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_NON_INHERITED) + "}\n" +
- "elementCount[FIELD_REF]{elementCount, Ltest.Test;, J, elementCount, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_NON_INHERITED) + "}",
+ "items[FIELD_REF]{items, Ltest.Test;, I, items, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_NON_INHERITED) + "}\n" +
+ "itemsCount[FIELD_REF]{itemsCount, Ltest.Test;, J, itemsCount, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_NON_INHERITED) + "}",
requestor.getResults());
}
public void testUnqualifiedStaticField() throws JavaModelException {
@@ -281,25 +241,24 @@
"/Completion/src/test/Test.java",
"package test;"+
"public class Test {\n" +
- " static int element;\n" +
- " int otherElement;\n" +
- " static long elementCount;\n" +
+ " static int items;\n" +
+ " int otherItems;\n" +
+ " static long itemsCount;\n" +
" void foo() {\n" +
- " elem\n" +
+ " item\n" +
" }\n" +
"}\n");
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
String str = this.workingCopies[0].getSource();
- String completeBehind = "elem";
+ String completeBehind = "item";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "ElementType[TYPE_REF]{java.lang.annotation.ElementType, java.lang.annotation, Ljava.lang.annotation.ElementType;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
- "otherElement[FIELD_REF]{otherElement, Ltest.Test;, I, otherElement, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" +
- "element[FIELD_REF]{element, Ltest.Test;, I, element, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
- "elementCount[FIELD_REF]{elementCount, Ltest.Test;, J, elementCount, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
+ "otherItems[FIELD_REF]{otherItems, Ltest.Test;, I, otherItems, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" +
+ "items[FIELD_REF]{items, Ltest.Test;, I, items, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
+ "itemsCount[FIELD_REF]{itemsCount, Ltest.Test;, J, itemsCount, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
requestor.getResults());
}
public void testLocalVariable() throws JavaModelException {
@@ -308,27 +267,26 @@
"/Completion/src/test/Test.java",
"package test;"+
"public class Test {\n" +
- " static int element;\n" +
- " int otherElement;\n" +
- " static long elementCount;\n" +
+ " static int items;\n" +
+ " int otherItems;\n" +
+ " static long itemsCount;\n" +
" void foo() {\n" +
- " int temporaryElement = 0;\n" +
- " elem\n" +
+ " int temporaryItem = 0;\n" +
+ " item\n" +
" }\n" +
"}\n");
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
String str = this.workingCopies[0].getSource();
- String completeBehind = "elem";
+ String completeBehind = "item";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "ElementType[TYPE_REF]{java.lang.annotation.ElementType, java.lang.annotation, Ljava.lang.annotation.ElementType;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
- "otherElement[FIELD_REF]{otherElement, Ltest.Test;, I, otherElement, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" +
- "temporaryElement[LOCAL_VARIABLE_REF]{temporaryElement, null, I, temporaryElement, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" +
- "element[FIELD_REF]{element, Ltest.Test;, I, element, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
- "elementCount[FIELD_REF]{elementCount, Ltest.Test;, J, elementCount, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
+ "otherItems[FIELD_REF]{otherItems, Ltest.Test;, I, otherItems, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" +
+ "temporaryItem[LOCAL_VARIABLE_REF]{temporaryItem, null, I, temporaryItem, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" +
+ "items[FIELD_REF]{items, Ltest.Test;, I, items, null, " + (R_DEFAULT + R_RESOLVED + R_CASE + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
+ "itemsCount[FIELD_REF]{itemsCount, Ltest.Test;, J, itemsCount, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
requestor.getResults());
}
public void testMethodParamVariable() throws JavaModelException {
@@ -337,26 +295,25 @@
"/Completion/src/test/Test.java",
"package test;"+
"public class Test {\n" +
- " static int element;\n" +
- " int otherElement;\n" +
- " static long elementCount;\n" +
- " void foo(int initElement) {\n" +
- " elem\n" +
+ " static int items;\n" +
+ " int otherItems;\n" +
+ " static long itemsCount;\n" +
+ " void foo(int initItems) {\n" +
+ " item\n" +
" }\n" +
"}\n");
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
String str = this.workingCopies[0].getSource();
- String completeBehind = "elem";
+ String completeBehind = "item";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "ElementType[TYPE_REF]{java.lang.annotation.ElementType, java.lang.annotation, Ljava.lang.annotation.ElementType;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
- "initElement[LOCAL_VARIABLE_REF]{initElement, null, I, initElement, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" +
- "otherElement[FIELD_REF]{otherElement, Ltest.Test;, I, otherElement, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" +
- "element[FIELD_REF]{element, Ltest.Test;, I, element, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
- "elementCount[FIELD_REF]{elementCount, Ltest.Test;, J, elementCount, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
+ "initItems[LOCAL_VARIABLE_REF]{initItems, null, I, initItems, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" +
+ "otherItems[FIELD_REF]{otherItems, Ltest.Test;, I, otherItems, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED + R_SUBSTRING) + "}\n" +
+ "items[FIELD_REF]{items, Ltest.Test;, I, items, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
+ "itemsCount[FIELD_REF]{itemsCount, Ltest.Test;, J, itemsCount, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
requestor.getResults());
}
public void testClassTypeInstantiation() throws JavaModelException {
@@ -899,4 +856,257 @@
"FooBar[TYPE_REF]{FooBar, test, LFooBar;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE + R_NON_RESTRICTED + R_UNQUALIFIED + R_SUBSTRING) + "}",
requestor.getResults());
}
-}
\ No newline at end of file
+public void testBug488441_1() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ String content = "public class Try18 {\n" +
+ " public void main(String[] args) {\n" +
+ " \"s\".st\n" +
+ " }\n" +
+ "}\n" +
+ "}\n";
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/test/Test.java",
+ content);
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = ".st";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_STATIC + R_NON_RESTRICTED;
+ assertResults(
+ "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (I)I, lastIndexOf, (arg0), "+ (relevance + R_SUBSTRING) +"}\n" +
+ "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (II)I, lastIndexOf, (arg0, arg1), "+ (relevance + R_SUBSTRING) +"}\n" +
+ "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (Ljava.lang.String;)I, lastIndexOf, (arg0), "+ (relevance + R_SUBSTRING) +"}\n" +
+ "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (Ljava.lang.String;I)I, lastIndexOf, (arg0, arg1), "+ (relevance + R_SUBSTRING) +"}\n" +
+ "replaceFirst[METHOD_REF]{replaceFirst(), Ljava.lang.String;, (Ljava.lang.String;Ljava.lang.String;)Ljava.lang.String;, replaceFirst, (arg0, arg1), "+ (relevance + R_SUBSTRING) +"}\n" +
+ "substring[METHOD_REF]{substring(), Ljava.lang.String;, (I)Ljava.lang.String;, substring, (arg0), "+ (relevance + R_SUBSTRING) +"}\n" +
+ "substring[METHOD_REF]{substring(), Ljava.lang.String;, (II)Ljava.lang.String;, substring, (arg0, arg1), "+ (relevance + R_SUBSTRING) +"}\n" +
+ "toString[METHOD_REF]{toString(), Ljava.lang.String;, ()Ljava.lang.String;, toString, null, "+ (relevance + R_SUBSTRING) +"}\n" +
+ "startsWith[METHOD_REF]{startsWith(), Ljava.lang.String;, (Ljava.lang.String;)Z, startsWith, (arg0), "+ (relevance + R_CASE) +"}\n" +
+ "startsWith[METHOD_REF]{startsWith(), Ljava.lang.String;, (Ljava.lang.String;I)Z, startsWith, (arg0, arg1), "+ (relevance + R_CASE) +"}",
+ requestor.getResults());
+}
+public void testBug488441_2() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ String content = "public class Try18 {\n" +
+ " public void main(String[] args) {\n" +
+ " int i = \"s\".st\n" +
+ " }\n" +
+ "}\n";
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/test/Test.java",
+ content);
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = ".st";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_STATIC + R_NON_RESTRICTED;
+ assertResults(
+ "replaceFirst[METHOD_REF]{replaceFirst(), Ljava.lang.String;, (Ljava.lang.String;Ljava.lang.String;)Ljava.lang.String;, replaceFirst, (arg0, arg1), "+ (relevance + R_SUBSTRING) +"}\n" +
+ "substring[METHOD_REF]{substring(), Ljava.lang.String;, (I)Ljava.lang.String;, substring, (arg0), "+ (relevance + R_SUBSTRING) +"}\n" +
+ "substring[METHOD_REF]{substring(), Ljava.lang.String;, (II)Ljava.lang.String;, substring, (arg0, arg1), "+ (relevance + R_SUBSTRING) +"}\n" +
+ "toString[METHOD_REF]{toString(), Ljava.lang.String;, ()Ljava.lang.String;, toString, null, "+ (relevance + R_SUBSTRING) +"}\n" +
+ "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (I)I, lastIndexOf, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (II)I, lastIndexOf, (arg0, arg1), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (Ljava.lang.String;)I, lastIndexOf, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (Ljava.lang.String;I)I, lastIndexOf, (arg0, arg1), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "startsWith[METHOD_REF]{startsWith(), Ljava.lang.String;, (Ljava.lang.String;)Z, startsWith, (arg0), "+ (relevance + R_CASE) +"}\n" +
+ "startsWith[METHOD_REF]{startsWith(), Ljava.lang.String;, (Ljava.lang.String;I)Z, startsWith, (arg0, arg1), "+ (relevance + R_CASE) +"}",
+ requestor.getResults());
+}
+public void testBug488441_3() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ String content = "public class Try18 {\n" +
+ " public void main(String[] args) {\n" +
+ " String s = \"s\".st\n" +
+ " }\n" +
+ "}\n";
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/test/Test.java",
+ content);
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = ".st";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_STATIC + R_NON_RESTRICTED;
+ assertResults(
+ "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (I)I, lastIndexOf, (arg0), "+ (relevance + R_SUBSTRING) +"}\n" +
+ "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (II)I, lastIndexOf, (arg0, arg1), "+ (relevance + R_SUBSTRING) +"}\n" +
+ "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (Ljava.lang.String;)I, lastIndexOf, (arg0), "+ (relevance + R_SUBSTRING) +"}\n" +
+ "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (Ljava.lang.String;I)I, lastIndexOf, (arg0, arg1), "+ (relevance + R_SUBSTRING) +"}\n" +
+ "replaceFirst[METHOD_REF]{replaceFirst(), Ljava.lang.String;, (Ljava.lang.String;Ljava.lang.String;)Ljava.lang.String;, replaceFirst, (arg0, arg1), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "startsWith[METHOD_REF]{startsWith(), Ljava.lang.String;, (Ljava.lang.String;)Z, startsWith, (arg0), "+ (relevance + R_CASE) +"}\n" +
+ "startsWith[METHOD_REF]{startsWith(), Ljava.lang.String;, (Ljava.lang.String;I)Z, startsWith, (arg0, arg1), "+ (relevance + R_CASE) +"}\n" +
+ "substring[METHOD_REF]{substring(), Ljava.lang.String;, (I)Ljava.lang.String;, substring, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "substring[METHOD_REF]{substring(), Ljava.lang.String;, (II)Ljava.lang.String;, substring, (arg0, arg1), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "toString[METHOD_REF]{toString(), Ljava.lang.String;, ()Ljava.lang.String;, toString, null, "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}",
+ requestor.getResults());
+}
+public void testBug488441_4() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ String content = "public class Try18 {\n" +
+ " public void main(String[] args) {\n" +
+ " boolean s = \"s\".st\n" +
+ " }\n" +
+ "}\n";
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/test/Test.java",
+ content);
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = ".st";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_STATIC + R_NON_RESTRICTED;
+ assertResults(
+ "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (I)I, lastIndexOf, (arg0), " + (relevance + R_SUBSTRING) + "}\n" +
+ "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (II)I, lastIndexOf, (arg0, arg1), " + (relevance + R_SUBSTRING) + "}\n" +
+ "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (Ljava.lang.String;)I, lastIndexOf, (arg0), " + (relevance + R_SUBSTRING) + "}\n" +
+ "lastIndexOf[METHOD_REF]{lastIndexOf(), Ljava.lang.String;, (Ljava.lang.String;I)I, lastIndexOf, (arg0, arg1), " + (relevance + R_SUBSTRING) + "}\n" +
+ "replaceFirst[METHOD_REF]{replaceFirst(), Ljava.lang.String;, (Ljava.lang.String;Ljava.lang.String;)Ljava.lang.String;, replaceFirst, (arg0, arg1), " + (relevance + R_SUBSTRING) + "}\n" +
+ "substring[METHOD_REF]{substring(), Ljava.lang.String;, (I)Ljava.lang.String;, substring, (arg0), " + (relevance + R_SUBSTRING) + "}\n" +
+ "substring[METHOD_REF]{substring(), Ljava.lang.String;, (II)Ljava.lang.String;, substring, (arg0, arg1), " + (relevance + R_SUBSTRING) + "}\n" +
+ "toString[METHOD_REF]{toString(), Ljava.lang.String;, ()Ljava.lang.String;, toString, null, " + (relevance + R_SUBSTRING) + "}\n" +
+ "startsWith[METHOD_REF]{startsWith(), Ljava.lang.String;, (Ljava.lang.String;)Z, startsWith, (arg0), " + (relevance + R_EXACT_EXPECTED_TYPE + R_CASE) + "}\n" +
+ "startsWith[METHOD_REF]{startsWith(), Ljava.lang.String;, (Ljava.lang.String;I)Z, startsWith, (arg0, arg1), " + (relevance + R_EXACT_EXPECTED_TYPE + R_CASE) + "}",
+ requestor.getResults());
+}
+public void testBug488441_5() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/test/Test.java",
+ "import java.util.Arrays;\n" +
+ "public class Try18 {\n" +
+ " public void main(String[] args) {\n" +
+ " String msg=\"\";\n" +
+ " String[] parameters = {\"a\"};\n" +
+ " System.out.println(msg + Arrays.as);\n" +
+ " }\n" +
+ "}\n");
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = ".as";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED + R_NON_INHERITED;
+ assertResults(
+ "asList[METHOD_REF]{asList(), Ljava.util.Arrays;, <T:Ljava.lang.Object;>([TT;)Ljava.util.List<TT;>;, asList, (arg0), "+ (relevance + R_CASE) +"}\n" +
+ "deepHashCode[METHOD_REF]{deepHashCode(), Ljava.util.Arrays;, ([Ljava.lang.Object;)I, deepHashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([B)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([C)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([D)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([F)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([I)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([J)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([Ljava.lang.Object;)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([S)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([Z)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}",
+ requestor.getResults());
+}
+public void testBug488441_6() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/test/Test.java",
+ "import java.util.Arrays;\n" +
+ "public class Try18 {\n" +
+ " public void main(String[] args) {\n" +
+ " String msg=\"\";\n" +
+ " String[] parameters = {\"a\"};\n" +
+ " System.out.println(msg + Arrays.aS);\n" +
+ " }\n" +
+ "}\n");
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = ".aS";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED + R_NON_INHERITED;
+ assertResults(
+ "asList[METHOD_REF]{asList(), Ljava.util.Arrays;, <T:Ljava.lang.Object;>([TT;)Ljava.util.List<TT;>;, asList, (arg0), "+ (relevance) +"}\n" +
+ "deepHashCode[METHOD_REF]{deepHashCode(), Ljava.util.Arrays;, ([Ljava.lang.Object;)I, deepHashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([B)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([C)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([D)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([F)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([I)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([J)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([Ljava.lang.Object;)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([S)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([Z)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}",
+ requestor.getResults());
+}
+public void testBug488441_7() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/test/Test.java",
+ "import java.util.Arrays;\n" +
+ "public class Try18 {\n" +
+ " public void main(String[] args) {\n" +
+ " String msg=\"\";\n" +
+ " String[] parameters = {\"a\"};\n" +
+ " System.out.println(Arrays.as);\n" +
+ " }\n" +
+ "}\n");
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = ".as";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED + R_NON_INHERITED;
+ assertResults(
+ "deepHashCode[METHOD_REF]{deepHashCode(), Ljava.util.Arrays;, ([Ljava.lang.Object;)I, deepHashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([B)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([C)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([D)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([F)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([I)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([J)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([Ljava.lang.Object;)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([S)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([Z)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "asList[METHOD_REF]{asList(), Ljava.util.Arrays;, <T:Ljava.lang.Object;>([TT;)Ljava.util.List<TT;>;, asList, (arg0), "+ (relevance + R_EXPECTED_TYPE + R_CASE) +"}",
+ requestor.getResults());
+}
+public void testBug488441_8() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/test/Test.java",
+ "import java.util.Arrays;\n" +
+ "public class Try18 {\n" +
+ " public void main(String[] args) {\n" +
+ " String msg=\"\";\n" +
+ " String[] parameters = {\"a\"};\n" +
+ " int i = Arrays.as;\n" +
+ " }\n" +
+ "}\n");
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = ".as";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+
+ int relevance = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED + R_NON_INHERITED;
+ assertResults(
+ "asList[METHOD_REF]{asList(), Ljava.util.Arrays;, <T:Ljava.lang.Object;>([TT;)Ljava.util.List<TT;>;, asList, (arg0), "+ (relevance + R_CASE) +"}\n" +
+ "deepHashCode[METHOD_REF]{deepHashCode(), Ljava.util.Arrays;, ([Ljava.lang.Object;)I, deepHashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([B)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([C)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([D)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([F)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([I)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([J)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([Ljava.lang.Object;)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([S)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}\n" +
+ "hashCode[METHOD_REF]{hashCode(), Ljava.util.Arrays;, ([Z)I, hashCode, (arg0), "+ (relevance + R_SUBSTRING + R_EXACT_EXPECTED_TYPE) +"}",
+ requestor.getResults());
+}
+}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SuiteOfTestCases.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SuiteOfTestCases.java
index 3917b75..94385de 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SuiteOfTestCases.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SuiteOfTestCases.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -14,6 +14,7 @@
import java.lang.reflect.Modifier;
import java.util.Set;
+import org.eclipse.jdt.internal.core.nd.indexer.Indexer;
import org.eclipse.test.internal.performance.PerformanceMeterFactory;
import junit.extensions.TestSetup;
@@ -29,6 +30,12 @@
@SuppressWarnings("rawtypes")
public class SuiteOfTestCases extends org.eclipse.jdt.core.tests.junit.extension.TestCase {
+ /**
+ * Number of milliseconds that a test case can run for before we consider it to be potentially
+ * deadlocked and dump out a stack trace. Currently set to 5 minutes.
+ */
+ private static final long FROZEN_TEST_TIMEOUT_MS = 1000 * 60 * 5;
+
/*
* A test suite that initialize the test case's fields once, then that copies the values
* of these fields into each subsequent test case.
@@ -118,12 +125,27 @@
* Setup the test suite once before all test cases run.
*/
public void setUpSuite() throws Exception {
+ Indexer.getInstance().enableAutomaticIndexing(false);
+ //Indexer.getInstance().waitForIndex(null);
}
/**
* Tear down the test suite once after all test cases have run.
*/
public void tearDownSuite() throws Exception {
+ Indexer.getInstance().enableAutomaticIndexing(true);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ FreezeMonitor.expectCompletionIn(FROZEN_TEST_TIMEOUT_MS);
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ FreezeMonitor.done();
+ super.tearDown();
}
/**
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/BTreeExpensiveTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/BTreeExpensiveTests.java
new file mode 100644
index 0000000..1557260
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/BTreeExpensiveTests.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2016 Symbian Software Systems 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:
+ * Symbian - Initial implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.nd;
+
+import junit.framework.Test;
+
+/**
+ * Tests which are too expensive to run as part of normal testing, but
+ * should be run after B-tree related development.
+ * <p>
+ * The 'Full Checking' tests perform a full validation of the B-tree
+ * invariants after each B-tree operation, and so are especially
+ * expensive and cpu hungry.
+ */
+public class BTreeExpensiveTests extends BTreeTests {
+
+ public static Test suite() {
+ return suite(BTreeExpensiveTests.class);
+ }
+
+ public void testBySortedSetMirror() throws Exception {
+ sortedMirrorTest(100);
+ }
+
+ // @Override
+ @Override
+ public void testInsertion() throws Exception {
+ super.testInsertion();
+ }
+
+ /*
+ * N.B. Each of the following tests are quite expensive (i.e. > 10mins each on a 2Ghz machine)
+ */
+
+ public void testBySortedSetMirror1682762087() throws Exception {
+ System.out.println("1682762087 Full Checking");
+ trial(1682762087, true); // exposed bugs in 2a,b
+ }
+
+ public void testBySortedSetMirror322922974() throws Exception {
+ System.out.println("322922974 Full Checking");
+ trial(322922974, true); // exposed bugs in 3b(ii)
+ }
+
+ public void testBySortedSetMirror_588448152() throws Exception {
+ System.out.println("-588448152 Full Checking");
+ trial(-588448152, true); // exposed root-delete-on-merge problems
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/BTreeTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/BTreeTests.java
new file mode 100644
index 0000000..42711e2
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/BTreeTests.java
@@ -0,0 +1,264 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2016 Symbian Software Systems 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:
+ * Symbian - Initial implementation
+ * Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.nd;
+
+import junit.framework.Test;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.tests.nd.util.BaseTestCase;
+import org.eclipse.jdt.internal.core.nd.Nd;
+import org.eclipse.jdt.internal.core.nd.db.BTree;
+import org.eclipse.jdt.internal.core.nd.db.Database;
+import org.eclipse.jdt.internal.core.nd.db.IBTreeComparator;
+import org.eclipse.jdt.internal.core.nd.db.IBTreeVisitor;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Random;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+/**
+ * Test insertion/deletion of records of a mock record type in a B-tree.
+ *
+ * @author aferguso
+ */
+public class BTreeTests extends BaseTestCase {
+ private static int DEBUG= 0;
+ protected File dbFile;
+ protected Nd nd;
+ protected Database db;
+ protected BTree btree;
+ protected int rootRecord;
+ protected IBTreeComparator comparator;
+
+ public static Test suite() {
+ return suite(BTreeTests.class);
+ }
+
+ // setUp is not used since we need to parameterize this method,
+ // and invoke it multiple times per Junit test
+ protected void init(int degree) throws Exception {
+ this.dbFile = File.createTempFile("ndtest", "db");
+ this.nd = DatabaseTestUtil.createEmptyNd(getName());
+ this.db = this.nd.getDB();
+ this.db.setExclusiveLock();
+ this.rootRecord = Database.DATA_AREA_OFFSET;
+ this.comparator = new BTMockRecordComparator();
+ this.btree = new BTree(this.nd, this.rootRecord, degree, this.comparator);
+ }
+
+ // tearDown is not used for the same reason as above
+ protected void finish() throws Exception {
+ this.db.close();
+ this.dbFile.deleteOnExit();
+ }
+
+
+ public void testBySortedSetMirrorLite() throws Exception {
+ sortedMirrorTest(8);
+ }
+
+ /**
+ * Test random (but reproducible via known seed) sequences of insertions/deletions
+ * and use TreeSet as a reference implementation to check behaviour against.
+ * @throws Exception
+ */
+ protected void sortedMirrorTest(int noTrials) throws Exception {
+ Random seeder = new Random(90210);
+
+ for (int i = 0; i < noTrials; i++) {
+ int seed = seeder.nextInt();
+ if (DEBUG > 0)
+ System.out.println("Iteration #" + i);
+ trial(seed, false);
+ }
+ }
+
+ /**
+ * Test random (but reproducible via known seed) sequence of insertions
+ * and use TreeSet as a reference implementation to check behaviour against.
+ * @throws Exception
+ */
+ public void testInsertion() throws Exception {
+ Random seeder = new Random();
+
+ for (int i = 0; i < 6; i++) {
+ int seed = seeder.nextInt();
+ if (DEBUG > 0)
+ System.out.println("Iteration #" + i);
+ trialImp(seed, false, new Random(seed * 2), 1);
+ }
+ }
+
+ /**
+ * Bug 402177: BTree.insert should return the matching record if the new record was not inserted.
+ */
+ public void testEquivalentRecordInsert_Bug402177() throws Exception {
+ init(8);
+ try {
+ BTMockRecord value1 = new BTMockRecord(this.db, 42);
+ BTMockRecord value2 = new BTMockRecord(this.db, 42);
+
+ long insert1 = this.btree.insert(value1.getRecord());
+ long insert2 = this.btree.insert(value2.getRecord());
+ assertEquals(insert1, insert2);
+ } finally {
+ finish();
+ }
+ }
+
+ /**
+ * Insert/Delete a random number of records into/from the B-tree
+ * @param seed the seed for obtaining the deterministic random testing
+ * @param checkCorrectnessEachIteration if true, then on every single insertion/deletion check that the B-tree invariants
+ * still hold
+ * @throws Exception
+ */
+ protected void trial(int seed, final boolean checkCorrectnessEachIteration) throws Exception {
+ Random random = new Random(seed);
+
+ // the probabilty that a particular iterations action will be an insertion
+ double pInsert = Math.min(0.5 + random.nextDouble(), 1);
+
+ trialImp(seed, checkCorrectnessEachIteration, random, pInsert);
+ }
+
+ private void trialImp(int seed, final boolean checkCorrectnessEachIteration, Random random,
+ double pInsert) throws Exception {
+ final int degree = 2 + random.nextInt(11);
+ final int nIterations = random.nextInt(100000);
+ final SortedSet<Integer> expected = new TreeSet<>();
+ final List<BTMockRecord> history = new ArrayList<>();
+
+ init(degree);
+
+ if (DEBUG > 0)
+ System.out.print("\t " + seed + " " + (nIterations/1000) + "K: ");
+ for (int i = 0; i < nIterations; i++) {
+ if (random.nextDouble() < pInsert) {
+ Integer value = new Integer(random.nextInt(Integer.MAX_VALUE));
+ boolean newEntry = expected.add(value);
+ if (newEntry) {
+ BTMockRecord btValue = new BTMockRecord(this.db, value.intValue());
+ history.add(btValue);
+ if (DEBUG > 1)
+ System.out.println("Add: " + value + " @ " + btValue.record);
+ this.btree.insert(btValue.getRecord());
+ }
+ } else {
+ if (!history.isEmpty()) {
+ int index = random.nextInt(history.size());
+ BTMockRecord btValue = history.get(index);
+ history.remove(index);
+ expected.remove(new Integer(btValue.intValue()));
+ if (DEBUG > 1)
+ System.out.println("Remove: " + btValue.intValue() + " @ " + btValue.record);
+ this.btree.delete(btValue.getRecord());
+ }
+ }
+ if (i % 1000 == 0 && DEBUG > 0) {
+ System.out.print(".");
+ }
+ if (checkCorrectnessEachIteration) {
+ assertBTreeMatchesSortedSet("[iteration " + i + "] ", this.btree, expected);
+ assertBTreeInvariantsHold("[iteration " + i + "] ");
+ }
+ }
+ if (DEBUG > 0)
+ System.out.println();
+
+ assertBTreeMatchesSortedSet("[Trial end] ", this.btree, expected);
+ assertBTreeInvariantsHold("[Trial end]");
+
+ finish();
+ }
+
+ public void assertBTreeInvariantsHold(String msg) throws CoreException {
+ String errorReport = this.btree.getInvariantsErrorReport();
+ if (!errorReport.equals("")) {
+ fail("Invariants do not hold: " + errorReport);
+ }
+ }
+
+ public void assertBTreeMatchesSortedSet(final String msg, BTree actual, SortedSet<Integer> expected) throws CoreException {
+ final Iterator<Integer> i = expected.iterator();
+ this.btree.accept(new IBTreeVisitor() {
+ int k;
+ @Override
+ public int compare(long record) {
+ return 0;
+ }
+
+ @Override
+ public boolean visit(long record) {
+ if (record != 0) {
+ BTMockRecord btValue = new BTMockRecord(record, BTreeTests.this.db);
+ if (i.hasNext()) {
+ Integer exp = i.next();
+ assertEquals(msg + " Differ at index: " + this.k, btValue.intValue(), exp.intValue());
+ this.k++;
+ } else {
+ fail("Sizes different");
+ return false;
+ }
+ }
+ return true;
+ }
+ });
+ }
+
+ private static class BTMockRecord {
+ public static final int VALUE_PTR = 0;
+ public static final int RECORD_SIZE = Database.INT_SIZE;
+ long record;
+ Database db;
+
+ /**
+ * Make a new record
+ */
+ public BTMockRecord(Database db, int value) throws CoreException {
+ this.db = db;
+ this.record = db.malloc(BTMockRecord.RECORD_SIZE, Database.POOL_MISC);
+ db.putInt(this.record + VALUE_PTR, value);
+ }
+
+ /**
+ * Get an existing record
+ */
+ public BTMockRecord(long record, Database db) {
+ this.db = db;
+ this.record = record;
+ }
+
+ public int intValue() {
+ return this.db.getInt(this.record);
+ }
+
+ public long getRecord() {
+ return this.record;
+ }
+ }
+
+ private class BTMockRecordComparator implements IBTreeComparator {
+ public BTMockRecordComparator() {
+ }
+
+ @Override
+ public int compare(Nd ndToCompare, long record1, long record2) {
+ Database dbToCompare = ndToCompare.getDB();
+ return dbToCompare.getInt(record1) - dbToCompare.getInt(record2);
+ }
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/DatabaseTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/DatabaseTest.java
new file mode 100644
index 0000000..9dd4557
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/DatabaseTest.java
@@ -0,0 +1,333 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2016 QNX Software Systems 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:
+ * QNX Software Systems - initial API and implementation
+ * Andrew Ferguson (Symbian)
+ * Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.nd;
+
+import java.io.File;
+import java.util.Random;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.tests.nd.util.BaseTestCase;
+import org.eclipse.jdt.internal.core.nd.Nd;
+import org.eclipse.jdt.internal.core.nd.NdNode;
+import org.eclipse.jdt.internal.core.nd.NdNodeTypeRegistry;
+import org.eclipse.jdt.internal.core.nd.db.BTree;
+import org.eclipse.jdt.internal.core.nd.db.ChunkCache;
+import org.eclipse.jdt.internal.core.nd.db.Database;
+import org.eclipse.jdt.internal.core.nd.db.IBTreeComparator;
+import org.eclipse.jdt.internal.core.nd.db.IBTreeVisitor;
+import org.eclipse.jdt.internal.core.nd.db.IString;
+import org.eclipse.jdt.internal.core.nd.db.IndexException;
+import org.eclipse.jdt.internal.core.nd.db.ShortString;
+
+import junit.framework.Test;
+
+/**
+ * Tests for the {@link Database} class.
+ */
+public class DatabaseTest extends BaseTestCase {
+ // This constant can be used to run the test with very large databases.
+ // Try, for example, setting it to Integer.MAX_VALUE * 7L;
+ private static final long TEST_OFFSET = 0;
+ private Nd nd;
+ protected Database db;
+ private static final int CURRENT_VERSION = 10;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ String testName = getName();
+ NdNodeTypeRegistry<NdNode> registry = new NdNodeTypeRegistry<>();
+ this.nd = new Nd(DatabaseTestUtil.getTempDbName(testName), new ChunkCache(), registry,
+ 0, 100, CURRENT_VERSION);
+ this.db = this.nd.getDB();
+ this.db.setExclusiveLock();
+
+ // Allocate all database chunks up to TEST_OFFSET.
+ int count = 0;
+ for (long offset = 0; offset < TEST_OFFSET;) {
+ offset = this.db.malloc(Database.MAX_MALLOC_SIZE, Database.POOL_MISC);
+ if (++count >= 1000) {
+ this.db.flush();
+ count = 0;
+ }
+ }
+ this.db.flush();
+ }
+
+ public static Test suite() {
+ return BaseTestCase.suite(DatabaseTest.class);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ this.db.close();
+ if (!this.db.getLocation().delete()) {
+ this.db.getLocation().deleteOnExit();
+ }
+ this.db= null;
+ }
+
+ public void testBlockSizeAndFirstBlock() throws Exception {
+ assertEquals(CURRENT_VERSION, this.db.getVersion());
+
+ final int realsize = 42;
+ final int deltas = (realsize + Database.BLOCK_HEADER_SIZE + Database.BLOCK_SIZE_DELTA - 1) / Database.BLOCK_SIZE_DELTA;
+ final int blocksize = deltas * Database.BLOCK_SIZE_DELTA;
+ final int freeDeltas= Database.CHUNK_SIZE / Database.BLOCK_SIZE_DELTA - deltas;
+
+ long mem = this.db.malloc(realsize, Database.POOL_MISC);
+ assertEquals(-blocksize, this.db.getShort(mem - Database.BLOCK_HEADER_SIZE));
+ this.db.free(mem, Database.POOL_MISC);
+ assertEquals(blocksize, this.db.getShort(mem - Database.BLOCK_HEADER_SIZE));
+ assertEquals(mem, this.db.getRecPtr((deltas - Database.MIN_BLOCK_DELTAS +1 ) * Database.INT_SIZE));
+ assertEquals(mem + blocksize, this.db.getRecPtr((freeDeltas - Database.MIN_BLOCK_DELTAS + 1) * Database.INT_SIZE));
+ }
+
+ public void testBug192437() throws Exception {
+ File tmp= File.createTempFile("readOnlyEmpty", ".db");
+ try {
+ tmp.setReadOnly();
+
+ /* check opening a readonly file for rw access fails */
+ try {
+ new Database(tmp, ChunkCache.getSharedInstance(), 0, false);
+ fail("A readonly file should not be openable with write-access");
+ } catch (IndexException e) {
+ // we expect to get a failure here
+ }
+
+ /* check opening a readonly file for read access does not fail */
+ try {
+ new Database(tmp, ChunkCache.getSharedInstance(), 0, true);
+ } catch (IndexException e) {
+ fail("A readonly file should be readable by a permanently readonly database " + e);
+ }
+ } finally {
+ tmp.delete(); // this may be pointless on some platforms
+ }
+ }
+
+ public void testFreeBlockLinking() throws Exception {
+ final int realsize = 42;
+ final int deltas = (realsize + Database.BLOCK_HEADER_SIZE + Database.BLOCK_SIZE_DELTA - 1) / Database.BLOCK_SIZE_DELTA;
+
+ long mem1 = this.db.malloc(realsize, Database.POOL_MISC);
+ long mem2 = this.db.malloc(realsize, Database.POOL_MISC);
+ this.db.free(mem1, Database.POOL_MISC);
+ this.db.free(mem2, Database.POOL_MISC);
+ assertEquals(mem2, this.db.getRecPtr((deltas - Database.MIN_BLOCK_DELTAS + 1) * Database.INT_SIZE));
+ assertEquals(0, this.db.getRecPtr(mem2));
+ assertEquals(mem1, this.db.getRecPtr(mem2 + Database.INT_SIZE));
+ assertEquals(mem2, this.db.getRecPtr(mem1));
+ assertEquals(0, this.db.getRecPtr(mem1 + Database.INT_SIZE));
+ }
+
+ public void testSimpleAllocationLifecycle() throws Exception {
+ long mem1 = this.db.malloc(42, Database.POOL_MISC);
+ this.db.free(mem1, Database.POOL_MISC);
+ long mem2 = this.db.malloc(42, Database.POOL_MISC);
+ assertEquals(mem2, mem1);
+ }
+
+ private static class FindVisitor implements IBTreeVisitor {
+ private Database db;
+ private String key;
+ private long address;
+
+ public FindVisitor(Database db, String key) {
+ this.db = db;
+ this.key = key;
+ }
+
+ @Override
+ public int compare(long toCompare) {
+ return this.db.getString(this.db.getRecPtr(toCompare + 4)).compare(this.key, true);
+ }
+
+ @Override
+ public boolean visit(long toCompare) {
+ this.address = toCompare;
+ return false;
+ }
+
+ public long getRecord() {
+ return this.address;
+ }
+ }
+
+ public void testStringsInBTree() throws Exception {
+ String[] names = {
+ "ARLENE",
+ "BRET",
+ "CINDY",
+ "DENNIS",
+ "EMILY",
+ "FRANKLIN",
+ "GERT",
+ "HARVEY",
+ "IRENE",
+ "JOSE",
+ "KATRINA",
+ "LEE",
+ "MARIA",
+ "NATE",
+ "OPHELIA",
+ "PHILIPPE",
+ "RITA",
+ "STAN",
+ "TAMMY",
+ "VINCE",
+ "WILMA",
+ "ALPHA",
+ "BETA"
+ };
+
+ IBTreeComparator comparator = new IBTreeComparator() {
+ @Override
+ public int compare(Nd ndToCompare, long record1, long record2) {
+ IString string1 = DatabaseTest.this.db.getString(DatabaseTest.this.db.getRecPtr(record1 + 4));
+ IString string2 = DatabaseTest.this.db.getString(DatabaseTest.this.db.getRecPtr(record2 + 4));
+ return string1.compare(string2, true);
+ }
+ };
+
+ BTree btree = new BTree(this.nd, Database.DATA_AREA_OFFSET, comparator);
+ for (int i = 0; i < names.length; ++i) {
+ String name = names[i];
+ long record = this.db.malloc(8, Database.POOL_MISC);
+ this.db.putInt(record + 0, i);
+ IString string = this.db.newString(name);
+ this.db.putRecPtr(record + 4, string.getRecord());
+ btree.insert(record);
+ }
+
+ for (int i = 0; i < names.length; ++i) {
+ String name = names[i];
+ FindVisitor finder = new FindVisitor(this.db, name);
+ btree.accept(finder);
+ long record = finder.getRecord();
+ assertTrue(record != 0);
+ assertEquals(i, this.db.getInt(record));
+ IString rname = this.db.getString(this.db.getRecPtr(record + 4));
+ assertTrue(rname.equals(name));
+ }
+ }
+
+ private final int GT = 1, LT = -1, EQ = 0;
+
+ public void testShortStringComparison() throws CoreException {
+ Random r= new Random(90210);
+
+ assertCMP("", this.EQ, "", true);
+ assertCMP("", this.EQ, "", false);
+
+ doTrials(1000, 1, ShortString.MAX_BYTE_LENGTH / 2, r, true);
+ doTrials(1000, 1, ShortString.MAX_BYTE_LENGTH / 2, r, false);
+ doTrials(1000, 1, ShortString.MAX_BYTE_LENGTH, r, true);
+ doTrials(1000, 1, ShortString.MAX_BYTE_LENGTH, r, false);
+
+ assertCMP("a", this.LT, "b", true);
+ assertCMP("aa", this.LT, "ab", true);
+ assertCMP("a", this.EQ, "a", true);
+
+ assertCMP("a", this.GT, "A", true);
+ assertCMP("aa", this.GT, "aA", true);
+ assertCMP("a", this.GT, "B", true);
+
+ assertCMP("a", this.EQ, "a", false);
+ assertCMP("a", this.EQ, "A", false);
+ }
+
+ public void testLongStringComparison() throws CoreException {
+ Random r= new Random(314159265);
+ doTrials(100, ShortString.MAX_BYTE_LENGTH + 1, ShortString.MAX_BYTE_LENGTH * 2, r, true);
+ doTrials(100, ShortString.MAX_BYTE_LENGTH + 1, ShortString.MAX_BYTE_LENGTH * 2, r, false);
+ }
+
+ private void doTrials(int n, int min, int max, Random r, boolean caseSensitive) throws CoreException {
+// long start = System.currentTimeMillis();
+ for (int i= 0; i < n; i++) {
+ String a = randomString(min, max, r);
+ String b = randomString(min, max, r);
+ int expected = caseSensitive ? a.compareTo(b) : a.compareToIgnoreCase(b);
+ assertCMP(a, expected, b, caseSensitive);
+ }
+// System.out.print("Trials: " + n + " Max length: " + max + " ignoreCase: " + !caseSensitive);
+// System.out.println(" Time: " + (System.currentTimeMillis() - start));
+ }
+
+ private String randomString(int min, int max, Random r) {
+ int len = min + r.nextInt(max - min);
+ return randomString(len, r);
+ }
+
+ private String randomString(int len, Random r) {
+ StringBuilder result = new StringBuilder(len);
+ for (int i= 0; i < len; i++) {
+ result.append(randomChar(r));
+ }
+ return result.toString();
+ }
+
+ private char randomChar(Random r) {
+ // We only match String.compareToIgnoreCase behavior within this limited range.
+ return (char) (32 + r.nextInt(40));
+ }
+
+ private void assertCMP(String a, int expected, String b, boolean caseSensitive) throws CoreException {
+ char[] acs = a.toCharArray();
+ char[] bcs = b.toCharArray();
+ IString aiss = this.db.newString(a);
+ IString biss = this.db.newString(b);
+ IString aisc = this.db.newString(acs);
+ IString bisc = this.db.newString(bcs);
+
+ assertEquals(a.hashCode(), aiss.hashCode());
+ assertEquals(a.hashCode(), aisc.hashCode());
+ assertEquals(b.hashCode(), biss.hashCode());
+ assertEquals(b.hashCode(), bisc.hashCode());
+
+ assertEquals(aiss, a);
+ assertEquals(aisc, a);
+ assertEquals(biss, b);
+ assertEquals(bisc, b);
+
+ assertSignEquals(expected, aiss.compare(bcs, caseSensitive));
+ assertSignEquals(expected, aiss.compare(biss, caseSensitive));
+ assertSignEquals(expected, aiss.compare(bisc, caseSensitive));
+ assertSignEquals(expected, aiss.compare(b, caseSensitive));
+ assertSignEquals(expected, aiss.comparePrefix(bcs, caseSensitive));
+
+ assertSignEquals(expected, -biss.compare(acs, caseSensitive));
+ assertSignEquals(expected, -biss.compare(aiss, caseSensitive));
+ assertSignEquals(expected, -biss.compare(aisc, caseSensitive));
+ assertSignEquals(expected, -biss.compare(a, caseSensitive));
+ assertSignEquals(expected, -biss.comparePrefix(acs, caseSensitive));
+
+ if (!caseSensitive && expected != 0) {
+ assertSignEquals(expected, aiss.compareCompatibleWithIgnoreCase(bcs));
+ assertSignEquals(expected, aiss.compareCompatibleWithIgnoreCase(biss));
+ assertSignEquals(expected, aiss.compareCompatibleWithIgnoreCase(bisc));
+
+ assertSignEquals(expected, -biss.compareCompatibleWithIgnoreCase(acs));
+ assertSignEquals(expected, -biss.compareCompatibleWithIgnoreCase(aiss));
+ assertSignEquals(expected, -biss.compareCompatibleWithIgnoreCase(aisc));
+ }
+ }
+
+ private void assertSignEquals(int a, int b) {
+ a= a < 0 ? -1 : (a > 0 ? 1 : 0);
+ b= b < 0 ? -1 : (b > 0 ? 1 : 0);
+ assertEquals(a, b);
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/DatabaseTestUtil.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/DatabaseTestUtil.java
new file mode 100644
index 0000000..30040db
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/DatabaseTestUtil.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Google, Inc 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:
+ * Stefan Xenos (Google) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.nd;
+
+import java.io.File;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.jdt.core.tests.Activator;
+import org.eclipse.jdt.internal.core.nd.Nd;
+import org.eclipse.jdt.internal.core.nd.NdNode;
+import org.eclipse.jdt.internal.core.nd.NdNodeTypeRegistry;
+import org.eclipse.jdt.internal.core.nd.db.ChunkCache;
+
+/**
+ *
+ */
+public class DatabaseTestUtil {
+
+ public static IPath getTestDir() {
+ Plugin plugin = Activator.getInstance();
+
+ IPath path = plugin.getStateLocation().append("tests/");
+ File file = path.toFile();
+ if (!file.exists())
+ file.mkdir();
+ return path;
+ }
+
+ public static File getTempDbName(String testName) {
+ return DatabaseTestUtil.getTestDir().append(testName + System.currentTimeMillis() + ".dat").toFile();
+ }
+
+ /**
+ * Creates an empty {@link Nd} with an empty type registry and randomly-named
+ * database for the given test name
+ *
+ * @param testName
+ * @return the new {@link Nd}
+ */
+ public static Nd createEmptyNd(String testName) {
+ NdNodeTypeRegistry<NdNode> registry = new NdNodeTypeRegistry<>();
+ return new Nd(DatabaseTestUtil.getTempDbName(testName), new ChunkCache(), registry, 0, 0, 0);
+ }
+
+ public static Nd createEmptyNd(String testName, NdNodeTypeRegistry<NdNode> registry) {
+ return new Nd(DatabaseTestUtil.getTempDbName(testName), new ChunkCache(), registry, 0, 0, 0);
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/FieldBackPointerTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/FieldBackPointerTest.java
new file mode 100644
index 0000000..b2ccfad
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/FieldBackPointerTest.java
@@ -0,0 +1,379 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 Google, Inc 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:
+ * Stefan Xenos (Google) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.nd;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+
+import org.eclipse.jdt.core.tests.nd.util.BaseTestCase;
+import org.eclipse.jdt.internal.core.nd.Nd;
+import org.eclipse.jdt.internal.core.nd.NdNode;
+import org.eclipse.jdt.internal.core.nd.NdNodeTypeRegistry;
+import org.eclipse.jdt.internal.core.nd.RawGrowableArray;
+import org.eclipse.jdt.internal.core.nd.field.FieldInt;
+import org.eclipse.jdt.internal.core.nd.field.FieldManyToOne;
+import org.eclipse.jdt.internal.core.nd.field.FieldOneToMany;
+import org.eclipse.jdt.internal.core.nd.field.StructDef;
+
+import junit.framework.Test;
+
+public class FieldBackPointerTest extends BaseTestCase {
+ public static class ForwardPointerStruct extends NdNode {
+ public static final FieldManyToOne<BackPointerStruct> FORWARD;
+ public static final FieldManyToOne<BackPointerStruct> OWNER;
+
+ @SuppressWarnings("hiding")
+ public static final StructDef<ForwardPointerStruct> type;
+
+ static {
+ type = StructDef.create(ForwardPointerStruct.class, NdNode.type);
+
+ FORWARD = FieldManyToOne.create(type, BackPointerStruct.BACK);
+ OWNER = FieldManyToOne.createOwner(type, BackPointerStruct.OWNED);
+ type.done();
+ }
+
+ public ForwardPointerStruct(Nd nd) {
+ super(nd);
+ }
+
+ public ForwardPointerStruct(Nd nd, long record) {
+ super(nd, record);
+ }
+
+ public void setBp(BackPointerStruct toSet) {
+ FORWARD.put(getNd(), this.address, toSet);
+ }
+
+ public BackPointerStruct getBp() {
+ return FORWARD.get(getNd(), this.address);
+ }
+
+ public void setOwner(BackPointerStruct owner) {
+ OWNER.put(getNd(), this.address, owner);
+ }
+
+ public BackPointerStruct getOwner() {
+ return OWNER.get(getNd(), this.address);
+ }
+ }
+
+ public static class BackPointerStruct extends NdNode {
+ public static final FieldOneToMany<ForwardPointerStruct> BACK;
+ public static final FieldOneToMany<ForwardPointerStruct> OWNED;
+ public static final FieldInt SOMEINT;
+
+ @SuppressWarnings("hiding")
+ public static final StructDef<BackPointerStruct> type;
+
+ static {
+ type = StructDef.create(BackPointerStruct.class, NdNode.type);
+
+ BACK = FieldOneToMany.create(type, ForwardPointerStruct.FORWARD, 2);
+ OWNED = FieldOneToMany.create(type, ForwardPointerStruct.OWNER, 0);
+ SOMEINT = type.addInt();
+ type.done();
+ }
+
+ public BackPointerStruct(Nd nd) {
+ super(nd);
+
+ // Fill with nonzero values to ensure that "OWNED" doesn't read beyond its boundary
+ SOMEINT.put(nd, this.address, 0xf0f0f0f0);
+ }
+
+ public BackPointerStruct(Nd nd, long record) {
+ super(nd, record);
+ }
+
+ public void ensureBackPointerCapacity(int capacity) {
+ BACK.ensureCapacity(getNd(), this.address, capacity);
+ }
+
+ public int getBackPointerCapacity() {
+ return BACK.getCapacity(getNd(), this.address);
+ }
+
+ public List<ForwardPointerStruct> getBackPointers() {
+ return BACK.asList(getNd(), this.address);
+ }
+
+ public List<ForwardPointerStruct> getOwned() {
+ return OWNED.asList(getNd(), this.address);
+ }
+
+ public int backPointerSize() {
+ return BACK.size(getNd(), this.address);
+ }
+
+ public boolean backPointersAreEmpty() {
+ return BACK.isEmpty(getNd(), this.address);
+ }
+
+ public boolean ownedPointersAreEmpty() {
+ return OWNED.isEmpty(getNd(), this.address);
+ }
+
+ public ForwardPointerStruct getBackPointer(int i) {
+ return BACK.get(getNd(), this.address, i);
+ }
+ }
+
+ ForwardPointerStruct fa;
+ ForwardPointerStruct fb;
+ ForwardPointerStruct fc;
+ ForwardPointerStruct fd;
+ BackPointerStruct ba;
+ BackPointerStruct bb;
+ private Nd nd;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ NdNodeTypeRegistry<NdNode> registry = new NdNodeTypeRegistry<>();
+ registry.register(0, BackPointerStruct.type.getFactory());
+ registry.register(1, ForwardPointerStruct.type.getFactory());
+ this.nd = DatabaseTestUtil.createEmptyNd(getName(), registry);
+ this.nd.getDB().setExclusiveLock();
+ this.ba = new BackPointerStruct(this.nd);
+ this.bb = new BackPointerStruct(this.nd);
+ this.fa = new ForwardPointerStruct(this.nd);
+ this.fb = new ForwardPointerStruct(this.nd);
+ this.fc = new ForwardPointerStruct(this.nd);
+ this.fd = new ForwardPointerStruct(this.nd);
+ }
+
+ public static Test suite() {
+ return BaseTestCase.suite(FieldBackPointerTest.class);
+ }
+
+ void assertBackPointers(BackPointerStruct bp, ForwardPointerStruct... fp) {
+ HashSet<ForwardPointerStruct> backPointers = new HashSet<>(bp.getBackPointers());
+ HashSet<ForwardPointerStruct> desired = new HashSet<>();
+
+ desired.addAll(Arrays.asList(fp));
+ assertEquals(desired, backPointers);
+ }
+
+ public void testWriteFollowedByReadReturnsSameThing() throws Exception {
+ this.fa.setBp(this.ba);
+ BackPointerStruct backpointer = this.fa.getBp();
+
+ assertEquals(this.ba, backpointer);
+ }
+
+ public void testListWithoutInlineElementsCanBeEmpty() throws Exception {
+ assertTrue(this.ba.ownedPointersAreEmpty());
+ }
+
+ public void testReadNull() throws Exception {
+ assertEquals(null, this.fa.getBp());
+ }
+
+ public void testAssigningTheSamePointerTwiceIsANoop() throws Exception {
+ this.fa.setBp(this.ba);
+
+ assertBackPointers(this.ba, this.fa);
+
+ // Now do the same thing again
+ this.fa.setBp(this.ba);
+
+ assertBackPointers(this.ba, this.fa);
+ }
+
+ public void testAssigningForwardPointerInsertsBackPointer() throws Exception {
+ this.fa.setBp(this.ba);
+
+ assertEquals(Arrays.asList(this.fa), this.ba.getBackPointers());
+ assertEquals(1, this.ba.backPointerSize());
+ }
+
+ public void testRemovesInlineElement() throws Exception {
+ this.fa.setBp(this.ba);
+ this.fb.setBp(this.ba);
+ this.fc.setBp(this.ba);
+ this.fd.setBp(this.ba);
+
+ assertEquals(4, this.ba.backPointerSize());
+ this.fb.setBp(null);
+ assertEquals(3, this.ba.backPointerSize());
+
+ assertBackPointers(this.ba, this.fa, this.fc, this.fd);
+ }
+
+ public void testRemovesElementFromGrowableBlock() throws Exception {
+ this.fa.setBp(this.ba);
+ this.fb.setBp(this.ba);
+ this.fc.setBp(this.ba);
+ this.fd.setBp(this.ba);
+
+ assertEquals(4, this.ba.backPointerSize());
+ this.fc.setBp(null);
+ assertEquals(3, this.ba.backPointerSize());
+
+ assertBackPointers(this.ba, this.fa, this.fb, this.fd);
+ }
+
+ public void testDestructingForwardPointerRemovesBackPointer() throws Exception {
+ this.fa.setBp(this.ba);
+ this.fb.setBp(this.ba);
+ this.fc.setBp(this.ba);
+
+ this.fb.delete();
+ this.nd.processDeletions();
+
+ assertBackPointers(this.ba, this.fa, this.fc);
+ }
+
+ public void testDestructingBackPointerClearsForwardPointers() throws Exception {
+ this.fa.setBp(this.ba);
+ this.fb.setBp(this.ba);
+ this.fc.setBp(this.ba);
+
+ this.ba.delete();
+ this.nd.processDeletions();
+
+ assertEquals(null, this.fa.getBp());
+ assertEquals(null, this.fb.getBp());
+ assertEquals(null, this.fc.getBp());
+ }
+
+ public void testElementsRemainInInsertionOrderIfNoRemovals() throws Exception {
+ this.fa.setBp(this.ba);
+ this.fb.setBp(this.ba);
+ this.fc.setBp(this.ba);
+ this.fd.setBp(this.ba);
+
+ assertEquals(Arrays.asList(this.fa, this.fb, this.fc, this.fd), this.ba.getBackPointers());
+ }
+
+ public void testDeletingOwnerDeletesOwned() throws Exception {
+ this.fa.setBp(this.ba);
+ this.fa.setOwner(this.bb);
+
+ this.fb.setBp(this.ba);
+ this.fb.setOwner(this.bb);
+
+ this.fc.setBp(this.ba);
+
+ this.bb.delete();
+ this.nd.processDeletions();
+
+ assertBackPointers(this.ba, this.fc);
+ }
+
+ public void testEnsureCapacityDoesNothingIfLessThanInlineElements() throws Exception {
+ this.ba.ensureBackPointerCapacity(1);
+ assertEquals(2, this.ba.getBackPointerCapacity());
+ }
+
+ public void testEnsureCapacityAllocatesPowersOfTwoPlusInlineSize() throws Exception {
+ this.ba.ensureBackPointerCapacity(60);
+ assertEquals(66, this.ba.getBackPointerCapacity());
+ }
+
+ public void testEnsureCapacityAllocatesMinimumSize() throws Exception {
+ this.ba.ensureBackPointerCapacity(3);
+ assertEquals(4, this.ba.getBackPointerCapacity());
+ }
+
+ public void testEnsureCapacityClampsToChunkSize() throws Exception {
+ this.ba.ensureBackPointerCapacity(RawGrowableArray.getMaxGrowableBlockSize() - 40);
+ assertEquals(RawGrowableArray.getMaxGrowableBlockSize() + 2, this.ba.getBackPointerCapacity());
+ }
+
+ public void testEnsureCapacityGrowsByMultiplesOfMaxBlockSizeOnceMetablockInUse() throws Exception {
+ int maxBlockSize = RawGrowableArray.getMaxGrowableBlockSize();
+ this.ba.ensureBackPointerCapacity(maxBlockSize * 3 - 100);
+ assertEquals(maxBlockSize * 3 + 2, this.ba.getBackPointerCapacity());
+ }
+
+ public void testAdditionsWontReduceCapacity() throws Exception {
+ int maxBlockSize = RawGrowableArray.getMaxGrowableBlockSize();
+ this.ba.ensureBackPointerCapacity(maxBlockSize);
+
+ this.fa.setBp(this.ba);
+ this.fb.setBp(this.ba);
+ this.fc.setBp(this.ba);
+ this.fd.setBp(this.ba);
+
+ assertEquals(maxBlockSize + 2, this.ba.getBackPointerCapacity());
+ }
+
+ public void testIsEmpty() throws Exception {
+ assertTrue(this.ba.backPointersAreEmpty());
+ this.fa.setBp(this.ba);
+ assertFalse(this.ba.backPointersAreEmpty());
+ this.fb.setBp(this.ba);
+ this.fc.setBp(this.ba);
+ this.fd.setBp(this.ba);
+ assertFalse(this.ba.backPointersAreEmpty());
+ }
+
+ public void testRemovalsReduceCapacity() throws Exception {
+ int maxBlockSize = RawGrowableArray.getMaxGrowableBlockSize();
+ this.ba.ensureBackPointerCapacity(maxBlockSize);
+
+ this.fa.setBp(this.ba);
+ this.fb.setBp(this.ba);
+ this.fc.setBp(this.ba);
+ assertEquals(maxBlockSize + 2, this.ba.getBackPointerCapacity());
+
+ this.fb.setBp(null);
+ this.fc.setBp(null);
+
+ assertEquals(2, this.ba.getBackPointerCapacity());
+ }
+
+ public void testInsertEnoughToUseMetablock() throws Exception {
+ // We need enough instances to fill several full blocks since we don't reclaim
+ // memory until there are two unused blocks.
+ int numToAllocate = RawGrowableArray.getMaxGrowableBlockSize() * 4 + 1;
+
+ List<ForwardPointerStruct> allocated = new ArrayList<>();
+
+ for (int count = 0; count < numToAllocate; count++) {
+ ForwardPointerStruct next = new ForwardPointerStruct(this.nd);
+
+ next.setBp(this.ba);
+ assertEquals(next, this.ba.getBackPointer(count));
+ allocated.add(next);
+ assertEquals(count + 1, this.ba.backPointerSize());
+ }
+
+ assertEquals(allocated.get(numToAllocate - 1), this.ba.getBackPointer(numToAllocate - 1));
+ assertEquals(numToAllocate, this.ba.backPointerSize());
+
+ int correctSize = numToAllocate;
+ for (ForwardPointerStruct next : allocated) {
+ next.setBp(null);
+ assertEquals(--correctSize, this.ba.backPointerSize());
+ }
+
+ assertEquals(0, this.ba.backPointerSize());
+ assertEquals(2, this.ba.getBackPointerCapacity());
+ }
+
+ public void testGrowExistingMetablock() throws Exception {
+ int blockSize = RawGrowableArray.getMaxGrowableBlockSize();
+
+ this.ba.ensureBackPointerCapacity(2 * blockSize);
+
+ assertEquals(2 * blockSize + 2, this.ba.getBackPointerCapacity());
+
+ this.ba.ensureBackPointerCapacity(6 * blockSize);
+
+ assertEquals(6 * blockSize + 2, this.ba.getBackPointerCapacity());
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/InheritenceTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/InheritenceTests.java
new file mode 100644
index 0000000..bb0db53
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/InheritenceTests.java
@@ -0,0 +1,244 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 Google, Inc 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:
+ * Stefan Xenos (Google) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.nd;
+
+import org.eclipse.jdt.core.tests.nd.util.BaseTestCase;
+import org.eclipse.jdt.internal.core.nd.Nd;
+import org.eclipse.jdt.internal.core.nd.NdNode;
+import org.eclipse.jdt.internal.core.nd.NdNodeTypeRegistry;
+import org.eclipse.jdt.internal.core.nd.field.FieldManyToOne;
+import org.eclipse.jdt.internal.core.nd.field.FieldOneToMany;
+import org.eclipse.jdt.internal.core.nd.field.StructDef;
+
+import junit.framework.Test;
+
+public class InheritenceTests extends BaseTestCase {
+ /**
+ * Every other object in this test has a pointer to the deletion detector, so we can detect
+ * which objects have been deleted by looking for the object in the backpointer list.
+ */
+ public static class AllObjects extends NdNode {
+ public static final FieldOneToMany<BaseClass> BASE_CLASS_INSTANCES;
+ public static final FieldOneToMany<Reference> REFERENCE_INSTANCES;
+
+ @SuppressWarnings("hiding")
+ public static final StructDef<AllObjects> type;
+
+ static {
+ type = StructDef.create(AllObjects.class, NdNode.type);
+
+ BASE_CLASS_INSTANCES = FieldOneToMany.create(type, BaseClass.DELETION_DETECTOR, 0);
+ REFERENCE_INSTANCES = FieldOneToMany.create(type, Reference.DELETION_DETECTOR, 0);
+ type.done();
+ }
+
+ public AllObjects(Nd nd, long record) {
+ super(nd, record);
+ }
+
+ public AllObjects(Nd nd) {
+ super(nd);
+ }
+
+ boolean contains(BaseClass toTest) {
+ return BASE_CLASS_INSTANCES.asList(getNd(), this.address).contains(toTest);
+ }
+
+ boolean contains(Reference toTest) {
+ return REFERENCE_INSTANCES.asList(getNd(), this.address).contains(toTest);
+ }
+ }
+
+ public static class BaseClass extends NdNode {
+ public static final FieldOneToMany<Reference> INCOMING_REFERENCES;
+ public static final FieldOneToMany<Reference> OWNED_REFERENCES;
+ public static final FieldManyToOne<AllObjects> DELETION_DETECTOR;
+
+ @SuppressWarnings("hiding")
+ public static final StructDef<BaseClass> type;
+
+ static {
+ type = StructDef.create(BaseClass.class, NdNode.type);
+
+ INCOMING_REFERENCES = FieldOneToMany.create(type, Reference.BASE_CLASS_REFERENCE, 0);
+ OWNED_REFERENCES = FieldOneToMany.create(type, Reference.OWNER, 0);
+ DELETION_DETECTOR = FieldManyToOne.create(type, AllObjects.BASE_CLASS_INSTANCES);
+ type.useStandardRefCounting().done();
+ }
+
+ public BaseClass(Nd nd, AllObjects deletionDetector) {
+ super(nd);
+
+ DELETION_DETECTOR.put(nd, this.address, deletionDetector);
+ }
+
+ public BaseClass(Nd nd, long record) {
+ super(nd, record);
+ }
+ }
+
+ public static class SubClass extends BaseClass {
+ public static final FieldOneToMany<Reference> MORE_REFERENCES;
+
+ @SuppressWarnings("hiding")
+ public static final StructDef<SubClass> type;
+
+ static {
+ type = StructDef.create(SubClass.class, BaseClass.type);
+
+ MORE_REFERENCES = FieldOneToMany.create(type, Reference.SUB_CLASS_REFERENCE, 0);
+ type.useStandardRefCounting().done();
+ }
+
+ public SubClass(Nd nd, long record) {
+ super(nd, record);
+ }
+
+ public SubClass(Nd nd, AllObjects deletionDetector) {
+ super(nd, deletionDetector);
+ }
+ }
+
+ public static class Reference extends NdNode {
+ public static final FieldManyToOne<BaseClass> BASE_CLASS_REFERENCE;
+ public static final FieldManyToOne<BaseClass> OWNER;
+ public static final FieldManyToOne<SubClass> SUB_CLASS_REFERENCE;
+ public static final FieldManyToOne<AllObjects> DELETION_DETECTOR;
+
+ @SuppressWarnings("hiding")
+ public static StructDef<Reference> type;
+
+ static {
+ type = StructDef.create(Reference.class, NdNode.type);
+
+ BASE_CLASS_REFERENCE = FieldManyToOne.create(type, BaseClass.INCOMING_REFERENCES);
+ OWNER = FieldManyToOne.createOwner(type, BaseClass.OWNED_REFERENCES);
+ SUB_CLASS_REFERENCE = FieldManyToOne.create(type, SubClass.MORE_REFERENCES);
+ DELETION_DETECTOR = FieldManyToOne.create(type, AllObjects.REFERENCE_INSTANCES);
+ type.done();
+ }
+
+ public Reference(Nd nd, long record) {
+ super(nd, record);
+ }
+
+ public Reference(Nd nd, AllObjects deletionDetector) {
+ super(nd);
+
+ DELETION_DETECTOR.put(nd, this.address, deletionDetector);
+ }
+
+ public void setBaseClassReference(BaseClass target) {
+ BASE_CLASS_REFERENCE.put(getNd(), this.address, target);
+ }
+
+ public void setOwner(BaseClass target) {
+ OWNER.put(getNd(), this.address, target);
+ }
+
+ public void setSubClassReference(SubClass target) {
+ SUB_CLASS_REFERENCE.put(getNd(), this.address, target);
+ }
+ }
+
+ AllObjects allObjects;
+ BaseClass baseClass;
+ SubClass subClass;
+ Reference refA;
+ Reference refB;
+ Reference refC;
+ private Nd nd;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ NdNodeTypeRegistry<NdNode> registry = new NdNodeTypeRegistry<>();
+ registry.register(0, BaseClass.type.getFactory());
+ registry.register(1, SubClass.type.getFactory());
+ registry.register(2, Reference.type.getFactory());
+ registry.register(3, AllObjects.type.getFactory());
+ this.nd = DatabaseTestUtil.createEmptyNd(getName(), registry);
+ this.nd.getDB().setExclusiveLock();
+
+ this.allObjects = new AllObjects(this.nd);
+ this.baseClass = new BaseClass(this.nd, this.allObjects);
+ this.subClass = new SubClass(this.nd, this.allObjects);
+
+ this.refA = new Reference(this.nd, this.allObjects);
+ this.refB = new Reference(this.nd, this.allObjects);
+ this.refC = new Reference(this.nd, this.allObjects);
+ }
+
+ public static Test suite() {
+ return BaseTestCase.suite(InheritenceTests.class);
+ }
+
+ public void testRemovingOnlyRefcountDeletesObject() {
+ assertTrue(this.allObjects.contains(this.subClass));
+ this.refA.setSubClassReference(this.subClass);
+ this.refA.setSubClassReference(null);
+ this.nd.processDeletions();
+ assertFalse(this.allObjects.contains(this.subClass));
+ }
+
+ public void testReferencesToBaseClassIncludedInRefCountA() {
+ // Test what happens when the subclass reference is removed first.
+ this.refA.setSubClassReference(this.subClass);
+ this.refB.setBaseClassReference(this.subClass);
+ assertTrue(this.allObjects.contains(this.subClass));
+ this.refA.setSubClassReference(null);
+ this.nd.processDeletions();
+ assertTrue(this.allObjects.contains(this.subClass));
+ this.refB.setBaseClassReference(null);
+ this.nd.processDeletions();
+ assertFalse(this.allObjects.contains(this.subClass));
+ }
+
+ public void testReferencesToBaseClassIncludedInRefCountB() {
+ // Test what happens when the base class reference is removed first.
+ this.refA.setSubClassReference(this.subClass);
+ this.refB.setBaseClassReference(this.subClass);
+ this.nd.processDeletions();
+ assertTrue(this.allObjects.contains(this.subClass));
+ this.refB.setBaseClassReference(null);
+ this.nd.processDeletions();
+ assertTrue(this.allObjects.contains(this.subClass));
+ this.refA.setSubClassReference(null);
+ this.nd.processDeletions();
+ assertFalse(this.allObjects.contains(this.subClass));
+ }
+
+ public void testOwnedPointersDontCountTowardsRefCount() {
+ this.refA.setOwner(this.subClass);
+ this.nd.processDeletions();
+ assertTrue(this.allObjects.contains(this.subClass));
+ this.refB.setBaseClassReference(this.subClass);
+ this.nd.processDeletions();
+ assertTrue(this.allObjects.contains(this.subClass));
+ assertTrue(this.allObjects.contains(this.refA));
+ this.refB.setBaseClassReference(null);
+ this.nd.processDeletions();
+ assertFalse(this.allObjects.contains(this.subClass));
+ assertFalse(this.allObjects.contains(this.refA));
+ }
+
+ public void testMultipleReferences() {
+ this.refA.setBaseClassReference(this.subClass);
+ this.refB.setBaseClassReference(this.subClass);
+ this.refA.setBaseClassReference(null);
+ this.nd.processDeletions();
+ assertTrue(this.allObjects.contains(this.subClass));
+ this.refB.setBaseClassReference(null);
+ this.nd.processDeletions();
+ assertFalse(this.allObjects.contains(this.subClass));
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/Package.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/Package.java
new file mode 100644
index 0000000..7485b54
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/Package.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 Google, Inc 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:
+ * Stefan Xenos (Google) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.nd;
+
+import org.eclipse.core.runtime.ILog;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.JavaCore;
+
+/**
+ * @noreference This class is not intended to be referenced by clients
+ */
+/* package */ class Package {
+ public static String PLUGIN_ID = JavaCore.PLUGIN_ID;
+
+ /**
+ * @noreference This method is not intended to be referenced by clients.
+ */
+ public static void log(Throwable e) {
+ String msg= e.getMessage();
+ if (msg == null) {
+ log("Error", e); //$NON-NLS-1$
+ } else {
+ log("Error: " + msg, e); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @noreference This method is not intended to be referenced by clients.
+ */
+ public static void log(String message, Throwable e) {
+ log(createStatus(message, e));
+ }
+
+ /**
+ * @noreference This method is not intended to be referenced by clients.
+ */
+ public static IStatus createStatus(String msg, Throwable e) {
+ return new Status(IStatus.ERROR, PLUGIN_ID, msg, e);
+ }
+
+ /**
+ * @noreference This method is not intended to be referenced by clients.
+ */
+ public static IStatus createStatus(String msg) {
+ return new Status(IStatus.ERROR, PLUGIN_ID, msg);
+ }
+
+ /**
+ * @noreference This method is not intended to be referenced by clients.
+ *
+ * Returns the appropriate ILog for this package
+ */
+ public static ILog getLog() {
+ Plugin plugin = JavaCore.getPlugin();
+ if (plugin == null) {
+ return null;
+ }
+ return plugin.getLog();
+ }
+
+ /**
+ * @noreference This method is not intended to be referenced by clients.
+ */
+ public static void log(IStatus status) {
+ getLog().log(status);
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/RunIndexTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/RunIndexTests.java
new file mode 100644
index 0000000..a6c2bbc
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/RunIndexTests.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 Google, Inc 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:
+ * Stefan Xenos (Google) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.nd;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.eclipse.jdt.core.tests.junit.extension.TestCase;
+import org.eclipse.jdt.core.tests.nd.indexer.IndexerTest;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class RunIndexTests extends junit.framework.TestCase {
+public RunIndexTests(String name) {
+ super(name);
+}
+public static Class[] getAllTestClasses() {
+ return new Class[] {
+ BTreeTests.class,
+ DatabaseTest.class,
+ FieldBackPointerTest.class,
+ IndexerTest.class,
+ InheritenceTests.class,
+ SearchKeyTests.class
+ };
+}
+public static Test suite() {
+ TestSuite ts = new TestSuite(RunIndexTests.class.getName());
+
+ Class[] testClasses = getAllTestClasses();
+ // Reset forgotten subsets of tests
+ TestCase.TESTS_PREFIX = null;
+ TestCase.TESTS_NAMES = null;
+ TestCase.TESTS_NUMBERS = null;
+ TestCase.TESTS_RANGE = null;
+ TestCase.RUN_ONLY_ID = null;
+
+ for (int i = 0; i < testClasses.length; i++) {
+ Class testClass = testClasses[i];
+
+ // call the suite() method and add the resulting suite to the suite
+ try {
+ Method suiteMethod = testClass.getDeclaredMethod("suite", new Class[0]); //$NON-NLS-1$
+ Test suite = (Test)suiteMethod.invoke(null, new Object[0]);
+ ts.addTest(suite);
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.getTargetException().printStackTrace();
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ }
+ }
+ return ts;
+}
+}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/SearchKeyTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/SearchKeyTests.java
new file mode 100644
index 0000000..e48ae79
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/SearchKeyTests.java
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 Google, Inc 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:
+ * Stefan Xenos (Google) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.nd;
+
+import org.eclipse.jdt.core.tests.nd.util.BaseTestCase;
+import org.eclipse.jdt.internal.core.nd.Nd;
+import org.eclipse.jdt.internal.core.nd.NdNode;
+import org.eclipse.jdt.internal.core.nd.NdNodeTypeRegistry;
+import org.eclipse.jdt.internal.core.nd.db.Database;
+import org.eclipse.jdt.internal.core.nd.field.FieldSearchIndex;
+import org.eclipse.jdt.internal.core.nd.field.FieldSearchKey;
+import org.eclipse.jdt.internal.core.nd.field.StructDef;
+
+import junit.framework.Test;
+
+public class SearchKeyTests extends BaseTestCase {
+ private static final String SEARCH_STRING_B = "Yo";
+ private static final String SEARCH_STRING_A = "Heyguyswhatshappening";
+ private static final String SEARCH_STRING_C = "Shnoogins";
+
+ public static class TestSearchIndex {
+ public static final FieldSearchIndex<Element> NICKNAME_INDEX;
+ public static final FieldSearchIndex<Element> NAME_INDEX;
+
+ public static final StructDef<TestSearchIndex> type;
+
+ static {
+ type = StructDef.create(TestSearchIndex.class);
+ NICKNAME_INDEX = FieldSearchIndex.create(type, Element.NICKNAME);
+ NAME_INDEX = FieldSearchIndex.create(type, Element.NAME);
+ type.done();
+ }
+
+ private final long address;
+ private Nd nd;
+
+ public TestSearchIndex(Nd dom, long address) {
+ this.address = address;
+ this.nd = dom;
+ }
+
+ public static TestSearchIndex getIndex(Nd nd) {
+ return new TestSearchIndex(nd, Database.DATA_AREA_OFFSET);
+ }
+
+ public Element findName(String searchString) {
+ return NAME_INDEX.findFirst(this.nd, this.address,
+ FieldSearchIndex.SearchCriteria.create(searchString.toCharArray()));
+ }
+
+ public Element findNickName(String searchString) {
+ return NICKNAME_INDEX.findFirst(this.nd, this.address,
+ FieldSearchIndex.SearchCriteria.create(searchString.toCharArray()));
+ }
+ }
+
+ public static class Element extends NdNode {
+ public static final FieldSearchKey<TestSearchIndex> NAME;
+ public static final FieldSearchKey<TestSearchIndex> NICKNAME;
+
+ @SuppressWarnings("hiding")
+ public static StructDef<Element> type;
+
+ static {
+ type = StructDef.create(Element.class, NdNode.type);
+
+ NAME = FieldSearchKey.create(type, TestSearchIndex.NAME_INDEX);
+ NICKNAME = FieldSearchKey.create(type, TestSearchIndex.NICKNAME_INDEX);
+ type.done();
+ }
+
+ public Element(Nd nd, long record) {
+ super(nd, record);
+ }
+
+ public Element(Nd nd) {
+ super(nd);
+ }
+
+ public void setName(String searchStringA) {
+ NAME.put(getNd(), this.address, searchStringA);
+ }
+
+ public void setNickName(String searchStringA) {
+ NICKNAME.put(getNd(), this.address, searchStringA);
+ }
+ }
+
+ private Nd nd;
+ private Element elementA;
+ private Element elementB;
+ private TestSearchIndex index;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ NdNodeTypeRegistry<NdNode> registry = new NdNodeTypeRegistry<>();
+ registry.register(0, Element.type.getFactory());
+ this.nd = DatabaseTestUtil.createEmptyNd(getName(), registry);
+ this.nd.getDB().setExclusiveLock();
+
+ this.elementA = new Element(this.nd);
+ this.elementB = new Element(this.nd);
+
+ this.index = TestSearchIndex.getIndex(this.nd);
+ }
+
+ public static Test suite() {
+ return BaseTestCase.suite(SearchKeyTests.class);
+ }
+
+ public void testSettingKeyCausesInsertionInSearchIndex() {
+ this.elementA.setName(SEARCH_STRING_A);
+ this.elementB.setName(SEARCH_STRING_B);
+
+ Element foundElementA = this.index.findName(SEARCH_STRING_A);
+ Element foundElementB = this.index.findName(SEARCH_STRING_B);
+ Element foundElementC = this.index.findName(SEARCH_STRING_C);
+
+ assertEquals(this.elementA, foundElementA);
+ assertEquals(this.elementB, foundElementB);
+ assertEquals(null, foundElementC);
+ }
+
+ public void testChangingSearchKeyAffectsIndex() {
+ this.elementA.setName(SEARCH_STRING_A);
+
+ Element foundElementA = this.index.findName(SEARCH_STRING_A);
+ Element foundElementB = this.index.findName(SEARCH_STRING_B);
+
+ assertEquals(null, foundElementB);
+ assertEquals(this.elementA, foundElementA);
+
+ this.elementA.setName(SEARCH_STRING_B);
+
+ foundElementA = this.index.findName(SEARCH_STRING_A);
+ foundElementB = this.index.findName(SEARCH_STRING_B);
+
+ assertEquals(this.elementA, foundElementB);
+ assertEquals(null, foundElementA);
+ }
+
+ public void testDeletingElementRemovesFromIndex() {
+ this.elementA.setName(SEARCH_STRING_A);
+ this.elementA.setNickName(SEARCH_STRING_B);
+
+ assertEquals(this.elementA, this.index.findName(SEARCH_STRING_A));
+ assertEquals(this.elementA, this.index.findNickName(SEARCH_STRING_B));
+
+ this.elementA.delete();
+ this.nd.processDeletions();
+ assertEquals(null, this.index.findName(SEARCH_STRING_A));
+ assertEquals(null, this.index.findNickName(SEARCH_STRING_B));
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/indexer/IndexerTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/indexer/IndexerTest.java
new file mode 100644
index 0000000..f378a33
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/indexer/IndexerTest.java
@@ -0,0 +1,214 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 Google, Inc 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:
+ * Stefan Xenos (Google) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.nd.indexer;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.concurrent.Semaphore;
+
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.jdt.core.IClassFile;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.IParent;
+import org.eclipse.jdt.core.tests.model.AbstractJavaModelTests;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
+import org.eclipse.jdt.internal.core.nd.IReader;
+import org.eclipse.jdt.internal.core.nd.db.ChunkCache;
+import org.eclipse.jdt.internal.core.nd.db.Database;
+import org.eclipse.jdt.internal.core.nd.indexer.IndexTester;
+import org.eclipse.jdt.internal.core.nd.indexer.Indexer;
+import org.eclipse.jdt.internal.core.nd.java.JavaIndex;
+import org.eclipse.jdt.internal.core.nd.java.NdType;
+import org.eclipse.jdt.internal.core.nd.java.NdTypeId;
+import org.eclipse.jdt.internal.core.nd.java.model.BinaryTypeDescriptor;
+import org.eclipse.jdt.internal.core.nd.java.model.BinaryTypeFactory;
+import org.eclipse.jdt.internal.core.nd.java.model.IndexBinaryType;
+
+import junit.framework.Test;
+
+/**
+ * Tests for the {@link Database} class.
+ */
+public class IndexerTest extends AbstractJavaModelTests {
+
+ public IndexerTest(String name) {
+ super(name);
+ }
+
+ private static final String PROJECT_NAME = "IndexerTest";
+ private static JavaIndex index;
+
+ @Override
+ protected void setUp() throws Exception {
+ String testName = getName();
+ index = JavaIndexTestUtil.createTempIndex(testName);
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ deleteProject(PROJECT_NAME);
+ index.getNd().getPath().delete();
+ index = null;
+ super.tearDown();
+ }
+
+ public static Test suite() {
+ return buildModelTestSuite(IndexerTest.class);
+ }
+
+ /**
+ * Verifies that if the index fails a read due to call to {@link Thread#interrupt()}, subsequent reads will
+ * still succeed.
+ */
+ public void testInterruptedException() throws Exception {
+ createJavaProject(PROJECT_NAME, new String[] {"src"}, new String[] {"JCL18_FULL"}, "bin", "1.8", true);
+ // Create an index
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ Indexer indexer = new Indexer(index.getNd(), root);
+ indexer.rescan(SubMonitor.convert(null));
+ // Ensure we're starting with an empty page cache by creating a new
+ // Index accessor object on the same database
+ JavaIndex testIndex = JavaIndex
+ .getIndex(JavaIndex.createNd(index.getNd().getDB().getLocation(), new ChunkCache()));
+
+ Semaphore semaphore = new Semaphore(0);
+
+ boolean[] wasInterrupted = new boolean[1];
+ Thread newThread = new Thread(() -> {
+ try (IReader reader = testIndex.getNd().acquireReadLock()) {
+ Thread.currentThread().interrupt();
+ testIndex.findType("Ljava/util/List;".toCharArray());
+ } catch (OperationCanceledException e) {
+ wasInterrupted[0] = true;
+ } finally {
+ semaphore.release();
+ }
+ });
+
+ newThread.start();
+
+ semaphore.acquire();
+
+ assertTrue(wasInterrupted[0]);
+ try (IReader reader = testIndex.getNd().acquireReadLock()) {
+ NdTypeId type = testIndex.findType("Ljava/util/List;".toCharArray());
+ assertNotNull(type);
+ }
+ }
+
+ public void testSubclassesOfGenericTypeCanBeFound() throws Exception {
+ createJavaProject(PROJECT_NAME, new String[] {"src"}, new String[] {"JCL18_FULL"}, "bin", "1.8", true);
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ Indexer indexer = new Indexer(index.getNd(), root);
+
+ indexer.rescan(SubMonitor.convert(null));
+
+ try (IReader reader = IndexerTest.index.getNd().acquireReadLock()) {
+ NdTypeId javaUtilList = IndexerTest.index.findType("Ljava/util/List;".toCharArray());
+ NdTypeId javaUtilArrayList = IndexerTest.index.findType("Ljava/util/ArrayList;".toCharArray());
+
+ boolean found = false;
+ List<NdType> subtypes = javaUtilList.getSubTypes();
+ for (NdType next : subtypes) {
+ if (Objects.equals(next.getTypeId(), javaUtilArrayList)) {
+ found = true;
+ }
+ }
+
+ assertTrue("ArrayList was found as a subtype of List", found);
+ }
+ }
+
+ private void collectAllClassFiles(List<? super IClassFile> result, IParent nextRoot) throws CoreException {
+ for (IJavaElement child : nextRoot.getChildren()) {
+ int type = child.getElementType();
+
+ if (type == IJavaElement.CLASS_FILE) {
+ result.add((IClassFile)child);
+ } else if (child instanceof IParent) {
+ IParent parent = (IParent) child;
+
+ collectAllClassFiles(result, parent);
+ }
+ }
+ }
+
+ public void testReadingAllClassesInIndexAreEquivalentToOriginalJarFiles() throws Exception {
+ IJavaProject javaProject = createJavaProject(PROJECT_NAME, new String[] {"src"}, new String[] {"JCL18_FULL"}, "bin", "1.8", true);
+ addClassFolder(javaProject, "lib", new String[] {
+ "p/Outer.java",
+ "import java.lang.annotation.*;\n" +
+ "\n" +
+ "@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE_USE) @interface A {}\n" +
+ "@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) @interface M {}\n" +
+ "@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.PARAMETER) @interface P {}\n" +
+ "\n" +
+ "class Outer {\n" +
+ " class Middle1 {\n" +
+ " class Inner {}\n" +
+ " }\n" +
+ " static class Middle2 {\n" +
+ " class Inner {}\n" +
+ " static class Middle3 {\n" +
+ " class Inner2{};\n" +
+ " }\n" +
+ " }\n" +
+ " Middle1.@A Inner e1;\n" +
+ " Middle2.@A Inner e2;\n" +
+ " Middle2.Middle3.@A Inner2 e3;\n" +
+ " @M void foo(@P Middle2.Middle3.@A Inner2 e3) {};\n" +
+ " class Middle4 extends @A Middle1 {}\n" +
+ "}\n",
+ }, "1.8");
+
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ Indexer indexer = new Indexer(index.getNd(), root);
+
+ indexer.rescan(SubMonitor.convert(null));
+
+ boolean foundAtLeastOneClass = false;
+ SubMonitor subMonitor = SubMonitor.convert(null);
+ JavaIndex localIndex = IndexerTest.index;
+ try (IReader reader = localIndex.getNd().acquireReadLock()) {
+ IPackageFragmentRoot[] roots = javaProject.getAllPackageFragmentRoots();
+ subMonitor.setWorkRemaining(roots.length);
+ for (IPackageFragmentRoot next : roots) {
+ SubMonitor iterationMon = subMonitor.split(1);
+ if (next.getKind() == IPackageFragmentRoot.K_BINARY) {
+ List<IClassFile> result = new ArrayList<>();
+ collectAllClassFiles(result, next);
+ iterationMon.setWorkRemaining(result.size());
+ for (IClassFile nextClass : result) {
+ SubMonitor classMon = iterationMon.split(1);
+ BinaryTypeDescriptor descriptor = BinaryTypeFactory.createDescriptor(nextClass);
+ IndexBinaryType indexedBinaryType = (IndexBinaryType)BinaryTypeFactory.readFromIndex(localIndex, descriptor, classMon);
+ ClassFileReader originalBinaryType = BinaryTypeFactory.rawReadType(descriptor, true);
+
+ if (!indexedBinaryType.exists()) {
+ throw new IllegalStateException("Unable to find class in index " + new String(descriptor.indexPath));
+ }
+ IndexTester.testType(originalBinaryType, indexedBinaryType);
+ foundAtLeastOneClass = true;
+ }
+ }
+ }
+ }
+ assertTrue("No classes found in the index", foundAtLeastOneClass);
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/indexer/JavaIndexTestUtil.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/indexer/JavaIndexTestUtil.java
new file mode 100644
index 0000000..84a1cd7
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/indexer/JavaIndexTestUtil.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 Google, Inc 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:
+ * Stefan Xenos (Google) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.nd.indexer;
+
+import java.io.File;
+
+import org.eclipse.jdt.core.tests.nd.DatabaseTestUtil;
+import org.eclipse.jdt.internal.core.nd.db.ChunkCache;
+import org.eclipse.jdt.internal.core.nd.java.JavaIndex;
+
+public class JavaIndexTestUtil {
+ public static JavaIndex createTempIndex(String id) {
+ File dbName = DatabaseTestUtil.getTempDbName(id);
+ return JavaIndex.getIndex(JavaIndex.createNd(dbName, new ChunkCache()));
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/util/BaseTestCase.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/util/BaseTestCase.java
new file mode 100644
index 0000000..cb99bf2
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/util/BaseTestCase.java
@@ -0,0 +1,269 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2016 Wind River Systems, Inc. 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:
+ * Markus Schorn - initial API and implementation
+ * Andrew Ferguson (Symbian)
+ * Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.nd.util;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestFailure;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+
+import org.eclipse.core.resources.IResourceStatus;
+import org.eclipse.core.runtime.ILog;
+import org.eclipse.core.runtime.ILogListener;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Deque;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class BaseTestCase extends TestCase {
+ private static final String DEFAULT_INDEXER_TIMEOUT_SEC = "10";
+ private static final String INDEXER_TIMEOUT_PROPERTY = "indexer.timeout";
+ /**
+ * Indexer timeout used by tests. To avoid this timeout expiring during debugging add
+ * -Dindexer.timeout=some_large_number to VM arguments of the test launch configuration.
+ */
+ protected static final int INDEXER_TIMEOUT_SEC =
+ Integer.parseInt(System.getProperty(INDEXER_TIMEOUT_PROPERTY, DEFAULT_INDEXER_TIMEOUT_SEC));
+ protected static final int INDEXER_TIMEOUT_MILLISEC= INDEXER_TIMEOUT_SEC * 1000;
+
+ private boolean fExpectFailure;
+ private int fBugNumber;
+ private int fExpectedLoggedNonOK;
+ private Deque<File> filesToDeleteOnTearDown= new ArrayDeque<>();
+
+ public BaseTestCase() {
+ super();
+ }
+
+ public BaseTestCase(String name) {
+ super(name);
+ }
+
+ public static NullProgressMonitor npm() {
+ return new NullProgressMonitor();
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ //CModelListener.sSuppressUpdateOfLastRecentlyUsed= true;
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ for (File file; (file = this.filesToDeleteOnTearDown.pollLast()) != null;) {
+ file.delete();
+ }
+ ResourceHelper.cleanUp();
+ //TestScannerProvider.clear();
+ super.tearDown();
+ }
+
+ protected void deleteOnTearDown(File file) {
+ this.filesToDeleteOnTearDown.add(file);
+ }
+
+ protected File createTempFile(String prefix, String suffix) throws IOException {
+ File file = File.createTempFile(prefix, suffix);
+ this.filesToDeleteOnTearDown.add(file);
+ return file;
+ }
+
+ protected File nonExistentTempFile(String prefix, String suffix) {
+ File file= new File(System.getProperty("java.io.tmpdir"),
+ prefix + System.currentTimeMillis() + suffix);
+ this.filesToDeleteOnTearDown.add(file);
+ return file;
+ }
+
+ public static TestSuite suite(Class<? extends BaseTestCase> clazz) {
+ return suite(clazz, null);
+ }
+
+ protected static TestSuite suite(Class<? extends BaseTestCase> clazz, String failingTestPrefix) {
+ TestSuite suite= new TestSuite(clazz);
+ Test failing= getFailingTests(clazz, failingTestPrefix);
+ if (failing != null) {
+ suite.addTest(failing);
+ }
+ return suite;
+ }
+
+ private static Test getFailingTests(Class<? extends BaseTestCase> clazz, String prefix) {
+ TestSuite suite= new TestSuite("Failing Tests");
+ HashSet<String> names= new HashSet<>();
+ Class<?> superClass= clazz;
+ while (Test.class.isAssignableFrom(superClass) && !TestCase.class.equals(superClass)) {
+ Method[] methods= superClass.getDeclaredMethods();
+ for (Method method : methods) {
+ addFailingMethod(suite, method, names, clazz, prefix);
+ }
+ superClass= superClass.getSuperclass();
+ }
+ if (suite.countTestCases() == 0) {
+ return null;
+ }
+ return suite;
+ }
+
+ private static void addFailingMethod(TestSuite suite, Method m, Set<String> names,
+ Class<? extends BaseTestCase> clazz, String prefix) {
+ String name = m.getName();
+ if (!names.add(name)) {
+ return;
+ }
+ if (name.startsWith("test") || (prefix != null && !name.startsWith(prefix))) {
+ return;
+ }
+ if (name.equals("tearDown") || name.equals("setUp") || name.equals("runBare")) {
+ return;
+ }
+ if (Modifier.isPublic(m.getModifiers())) {
+ Class<?>[] parameters = m.getParameterTypes();
+ Class<?> returnType = m.getReturnType();
+ if (parameters.length == 0 && returnType.equals(Void.TYPE)) {
+ Test test = TestSuite.createTest(clazz, name);
+ ((BaseTestCase) test).setExpectFailure(0);
+ suite.addTest(test);
+ }
+ }
+ }
+
+ @Override
+ public void runBare() throws Throwable {
+ final List<IStatus> statusLog= Collections.synchronizedList(new ArrayList<>());
+ ILogListener logListener= new ILogListener() {
+ @Override
+ public void logging(IStatus status, String plugin) {
+ if (!status.isOK() && status.getSeverity() != IStatus.INFO) {
+ switch (status.getCode()) {
+ case IResourceStatus.NOT_FOUND_LOCAL:
+ case IResourceStatus.NO_LOCATION_LOCAL:
+ case IResourceStatus.FAILED_READ_LOCAL:
+ case IResourceStatus.RESOURCE_NOT_LOCAL:
+ // Logged by the resources plugin.
+ return;
+ }
+ statusLog.add(status);
+ }
+ }
+ };
+ final ILog log = Package.getLog();
+ if (log != null) { // Iff we don't run as a JUnit Plugin Test.
+ log.addLogListener(logListener);
+ }
+
+ Throwable testThrowable= null;
+ try {
+ try {
+ super.runBare();
+ } catch (Throwable e) {
+ testThrowable= e;
+ }
+
+ if (statusLog.size() != this.fExpectedLoggedNonOK) {
+ StringBuilder msg= new StringBuilder("Expected number (" + this.fExpectedLoggedNonOK + ") of ");
+ msg.append("Non-OK status objects in log differs from actual (" + statusLog.size() + ").\n");
+ Throwable cause= null;
+ if (!statusLog.isEmpty()) {
+ synchronized (statusLog) {
+ for (IStatus status : statusLog) {
+ IStatus[] ss= {status};
+ ss= status instanceof MultiStatus ? ((MultiStatus) status).getChildren() : ss;
+ for (IStatus s : ss) {
+ msg.append("\t" + s.getMessage() + " ");
+
+ Throwable t= s.getException();
+ cause= cause != null ? cause : t;
+ if (t != null) {
+ msg.append(t.getMessage() != null ? t.getMessage() : t.getClass().getCanonicalName());
+ }
+
+ msg.append("\n");
+ }
+ }
+ }
+ }
+ cause= cause != null ? cause : testThrowable;
+ AssertionFailedError afe= new AssertionFailedError(msg.toString());
+ afe.initCause(cause);
+ throw afe;
+ }
+ } finally {
+ if (log != null) {
+ log.removeLogListener(logListener);
+ }
+ }
+
+ if (testThrowable != null)
+ throw testThrowable;
+ }
+
+ @Override
+ public void run(TestResult result) {
+ if (!this.fExpectFailure || Boolean.parseBoolean(System.getProperty("SHOW_EXPECTED_FAILURES"))) {
+ super.run(result);
+ return;
+ }
+
+ result.startTest(this);
+
+ TestResult r = new TestResult();
+ super.run(r);
+ if (r.failureCount() == 1) {
+ TestFailure failure= r.failures().nextElement();
+ String msg= failure.exceptionMessage();
+ if (msg != null && msg.startsWith("Method \"" + getName() + "\"")) {
+ result.addFailure(this, new AssertionFailedError(msg));
+ }
+ } else if (r.errorCount() == 0 && r.failureCount() == 0) {
+ String err = "Unexpected success of " + getName();
+ if (this.fBugNumber > 0) {
+ err += ", bug #" + this.fBugNumber;
+ }
+ result.addFailure(this, new AssertionFailedError(err));
+ }
+
+ result.endTest(this);
+ }
+
+ public void setExpectFailure(int bugNumber) {
+ this.fExpectFailure= true;
+ this.fBugNumber= bugNumber;
+ }
+
+ /**
+ * The last value passed to this method in the body of a testXXX method
+ * will be used to determine whether or not the presence of non-OK status objects
+ * in the log should fail the test. If the logged number of non-OK status objects
+ * differs from the last value passed, the test is failed. If this method is not called
+ * at all, the expected number defaults to zero.
+ * @param count the expected number of logged error and warning messages
+ */
+ public void setExpectedNumberOfLoggedNonOKStatusObjects(int count) {
+ this.fExpectedLoggedNonOK= count;
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/util/Package.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/util/Package.java
new file mode 100644
index 0000000..4e2dbbd
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/util/Package.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 Google, Inc 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:
+ * Stefan Xenos (Google) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.nd.util;
+
+import org.eclipse.core.runtime.ILog;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.JavaCore;
+
+/**
+ * @noreference This class is not intended to be referenced by clients
+ */
+/* package */ class Package {
+ public static String PLUGIN_ID = JavaCore.PLUGIN_ID;
+
+ /**
+ * @noreference This method is not intended to be referenced by clients.
+ */
+ public static void log(Throwable e) {
+ String msg= e.getMessage();
+ if (msg == null) {
+ log("Error", e); //$NON-NLS-1$
+ } else {
+ log("Error: " + msg, e); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @noreference This method is not intended to be referenced by clients.
+ */
+ public static void log(String message, Throwable e) {
+ log(createStatus(message, e));
+ }
+
+ /**
+ * @noreference This method is not intended to be referenced by clients.
+ */
+ public static IStatus createStatus(String msg, Throwable e) {
+ return new Status(IStatus.ERROR, PLUGIN_ID, msg, e);
+ }
+
+ /**
+ * @noreference This method is not intended to be referenced by clients.
+ */
+ public static IStatus createStatus(String msg) {
+ return new Status(IStatus.ERROR, PLUGIN_ID, msg);
+ }
+
+ /**
+ * @noreference This method is not intended to be referenced by clients.
+ *
+ * Returns the appropriate ILog for this package
+ */
+ public static ILog getLog() {
+ Plugin plugin = JavaCore.getPlugin();
+ if (plugin == null) {
+ return null;
+ }
+ return plugin.getLog();
+ }
+
+ /**
+ * @noreference This method is not intended to be referenced by clients.
+ */
+ public static void log(IStatus status) {
+ getLog().log(status);
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/util/ResourceHelper.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/util/ResourceHelper.java
new file mode 100644
index 0000000..5b2cd89
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/nd/util/ResourceHelper.java
@@ -0,0 +1,576 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2016 Andrew Gvozdev 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:
+ * Andrew Gvozdev - Initial API and implementation
+ * James Blackburn (Broadcom Corp.)
+ * Liviu Ionescu - bug 392416
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.nd.util;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.charset.Charset;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.UUID;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.junit.Assert;
+
+/**
+ * This class contains utility methods for creating resources
+ * such as projects, files, folders etc. which are being used
+ * in test fixture of unit tests.
+ *
+ * Some classes with similar idea worth to look at:
+ * org.eclipse.core.filebuffers.tests.ResourceHelper,
+ * org.eclipse.cdt.ui.tests.text.ResourceHelper.
+ */
+public class ResourceHelper {
+ private final static IProgressMonitor NULL_MONITOR = new NullProgressMonitor();
+ private static final int MAX_RETRY= 5;
+
+ private final static Set<String> externalFilesCreated = new HashSet<String>();
+ private final static Set<IResource> resourcesCreated = new HashSet<IResource>();
+
+ /**
+ * Creates a plain Eclipse project.
+ *
+ * @param projectName
+ * @return the project handle
+ * @throws CoreException if project could not be created
+ */
+ public static IProject createProject(String projectName) throws CoreException {
+ IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
+ IProject project= root.getProject(projectName);
+ if (!project.exists()) {
+ project.create(NULL_MONITOR);
+ } else {
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
+ }
+
+ if (!project.isOpen())
+ project.open(NULL_MONITOR);
+
+ resourcesCreated.add(project);
+ return project;
+ }
+
+ /**
+ * Deletes project by name.
+ *
+ * @param projectName
+ * @throws CoreException
+ */
+ public static void deleteProject(String projectName) throws CoreException {
+ IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
+ IProject project= root.getProject(projectName);
+ if (project.exists())
+ delete(project);
+ }
+
+ /**
+ * Deletes given project with content.
+ *
+ * @param project
+ * @throws CoreException
+ */
+ public static void delete(final IProject project) throws CoreException {
+ delete(project, true);
+ }
+
+ /**
+ * Deletes project.
+ *
+ * @param project
+ * @param deleteContent whether to delete project content
+ * @throws CoreException
+ */
+ public static void delete(final IProject project, boolean deleteContent) throws CoreException {
+ for (int i= 0; i < MAX_RETRY; i++) {
+ try {
+ project.delete(deleteContent, true, NULL_MONITOR);
+ i= MAX_RETRY;
+ } catch (CoreException x) {
+ if (i == MAX_RETRY - 1) {
+ Package.log(x.getStatus());
+ }
+ try {
+ Thread.sleep(1000); // sleep a second
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+ }
+
+ /**
+ * Creates a file with specified content.
+ *
+ * @param file - file name.
+ * @param contents - contents of the file.
+ * @return file handle.
+ * @throws CoreException - if the file can't be created.
+ */
+ public static IFile createFile(IFile file, String contents) throws CoreException {
+ if (contents == null) {
+ contents= "";
+ }
+
+ InputStream inputStream = new ByteArrayInputStream(contents.getBytes());
+ file.create(inputStream, true, NULL_MONITOR);
+ resourcesCreated.add(file);
+ return file;
+ }
+
+ /**
+ * Creates new file from project root with empty content. The filename
+ * can include relative path as a part of the name but the the path
+ * has to be present on disk.
+ *
+ * @param project - project where to create the file.
+ * @param name - filename.
+ * @return file handle.
+ * @throws CoreException if something goes wrong.
+ */
+ public static IFile createFile(IProject project, String name) throws CoreException {
+ if (new Path(name).segmentCount() > 1)
+ createFolder(project, new Path(name).removeLastSegments(1).toString());
+ return createFile(project.getFile(name), null);
+ }
+
+ /**
+ * Creates new file from workspace root with empty content. The filename
+ * can include relative path as a part of the name but the the path
+ * has to be present on disk.
+ * The intention of the method is to create files which do not belong to any project.
+ *
+ * @param name - filename.
+ * @return full path of the created file.
+ *
+ * @throws CoreException...
+ * @throws IOException...
+ */
+ public static IPath createWorkspaceFile(String name) throws CoreException, IOException {
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+ IPath fullPath = workspaceRoot.getLocation().append(name);
+ java.io.File file = new java.io.File(fullPath.toOSString());
+ if (!file.exists()) {
+ boolean result = file.createNewFile();
+ Assert.assertTrue(result);
+ }
+ Assert.assertTrue(file.exists());
+
+ externalFilesCreated.add(fullPath.toOSString());
+ workspaceRoot.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ return fullPath;
+ }
+
+ /**
+ * Creates new folder from project root. The folder name
+ * can include relative path as a part of the name.
+ * Nonexistent parent directories are being created.
+ *
+ * @param project - project where to create the folder.
+ * @param name - folder name.
+ * @return folder handle.
+ * @throws CoreException if something goes wrong.
+ */
+ public static IFolder createFolder(IProject project, String name) throws CoreException {
+ final IPath p = new Path(name);
+ IContainer folder = project;
+ for (String seg : p.segments()) {
+ folder = folder.getFolder(new Path(seg));
+ if (!folder.exists())
+ ((IFolder)folder).create(true, true, NULL_MONITOR);
+ }
+ resourcesCreated.add(folder);
+ return (IFolder)folder;
+ }
+
+ /**
+ * Creates new folder from workspace root. The folder name
+ * can include relative path as a part of the name.
+ * Nonexistent parent directories are being created as per {@link File#mkdirs()}.
+ * The intention of the method is to create folders which do not belong to any project.
+ *
+ * @param name - folder name.
+ * @return absolute location of the folder on the file system.
+ * @throws IOException if something goes wrong.
+ */
+ public static IPath createWorkspaceFolder(String name) throws CoreException, IOException {
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+ IPath fullPath = workspaceRoot.getLocation().append(name);
+ java.io.File folder = new java.io.File(fullPath.toOSString());
+ if (!folder.exists()) {
+ boolean result = folder.mkdirs();
+ Assert.assertTrue(result);
+ }
+ Assert.assertTrue(folder.exists());
+
+ externalFilesCreated.add(fullPath.toOSString());
+ workspaceRoot.refreshLocal(IResource.DEPTH_INFINITE, NULL_MONITOR);
+ return fullPath;
+ }
+
+ /**
+ * Creates new temporary folder with generated name from workspace root.
+ *
+ * @return absolute location of the folder on the file system.
+ * @throws IOException if something goes wrong.
+ */
+ public static IPath createTemporaryFolder() throws CoreException, IOException {
+ return ResourceHelper.createWorkspaceFolder("tmp/" + System.currentTimeMillis() + '.' + UUID.randomUUID());
+ }
+
+ /**
+ * Creates new eclipse file-link from project root to file system file. The filename
+ * can include relative path as a part of the name but the the path
+ * has to be present on disk.
+ *
+ * @param project - project where to create the file.
+ * @param fileLink - filename of the link being created.
+ * @param realFile - file on the file system, the target of the link.
+ * @return file handle.
+ * @throws CoreException if something goes wrong.
+ */
+ public static IFile createLinkedFile(IProject project, String fileLink, IPath realFile) throws CoreException {
+ IFile file = project.getFile(fileLink);
+ file.createLink(realFile, IResource.REPLACE, null);
+ Assert.assertTrue(file.exists());
+ resourcesCreated.add(file);
+ return file;
+ }
+
+ /**
+ * Creates new eclipse file-link from project root to file system file. The filename
+ * can include relative path as a part of the name but the the path
+ * has to be present on disk.
+ *
+ * @param project - project where to create the file.
+ * @param fileLink - filename of the link being created.
+ * @param realFile - file on the file system, the target of the link.
+ * @return file handle.
+ * @throws CoreException if something goes wrong.
+ */
+ public static IFile createLinkedFile(IProject project, String fileLink, String realFile) throws CoreException {
+ return createLinkedFile(project, fileLink, new Path(realFile));
+ }
+
+ /**
+ * Creates new eclipse file-link from project root to EFS file.
+ *
+ * @param project - project where to create the file.
+ * @param fileLink - filename of the link being created.
+ * @param realFile - file on the EFS file system, the target of the link.
+ * @return file handle.
+ * @throws CoreException if something goes wrong.
+ */
+ public static IFile createEfsFile(IProject project, String fileLink, URI realFile) throws CoreException {
+ IFile file= project.getFile(fileLink);
+ file.createLink(realFile, IResource.ALLOW_MISSING_LOCAL, NULL_MONITOR);
+ resourcesCreated.add(file);
+ return file;
+ }
+
+ /**
+ * Creates new eclipse file-link from project root to EFS file.
+ *
+ * @param project - project where to create the file.
+ * @param fileLink - filename of the link being created.
+ * @param realFile - file on the EFS file system, the target of the link.
+ * @return file handle.
+ * @throws CoreException if something goes wrong.
+ * @throws URISyntaxException if wrong URI syntax
+ */
+ public static IFile createEfsFile(IProject project, String fileLink, String realFile) throws CoreException, URISyntaxException {
+ return createEfsFile(project,fileLink,new URI(realFile));
+ }
+
+ /**
+ * Creates new eclipse folder-link from project root to file system folder. The folder name
+ * can include relative path as a part of the name but the the path
+ * has to be present on disk.
+ *
+ * @param project - project where to create the file.
+ * @param folderLink - name of the link being created.
+ * @param realFolder - folder on the file system, the target of the link.
+ * @return file handle.
+ * @throws CoreException if something goes wrong.
+ */
+ public static IFolder createLinkedFolder(IProject project, String folderLink, IPath realFolder) throws CoreException {
+ IFolder folder = project.getFolder(folderLink);
+ folder.createLink(realFolder, IResource.REPLACE | IResource.ALLOW_MISSING_LOCAL, null);
+ Assert.assertTrue(folder.exists());
+ resourcesCreated.add(folder);
+ return folder;
+ }
+
+ /**
+ * Creates new eclipse folder-link from project root to file system folder. The folder name
+ * can include relative path as a part of the name but the the path
+ * has to be present on disk.
+ *
+ * @param project - project where to create the file.
+ * @param folderLink - name of the link being created.
+ * @param realFolder - folder on the file system, the target of the link.
+ * @return file handle.
+ * @throws CoreException if something goes wrong.
+ */
+ public static IFolder createLinkedFolder(IProject project, String folderLink, String realFolder) throws CoreException {
+ return createLinkedFolder(project, folderLink, new Path(realFolder));
+ }
+
+ /**
+ * Creates new eclipse folder-link from project root to EFS folder.
+ *
+ * @param project - project where to create the folder.
+ * @param folderLink - folder name of the link being created.
+ * @param realFolder - folder on the EFS file system, the target of the link.
+ * @return folder handle.
+ * @throws CoreException if something goes wrong.
+ */
+ public static IFolder createEfsFolder(IProject project, String folderLink, URI realFolder) throws CoreException {
+ IFolder folder= project.getFolder(folderLink);
+ if (folder.exists()) {
+ Assert.assertEquals("Folder with the same name but different location already exists",
+ realFolder, folder.getLocationURI());
+ return folder;
+ }
+
+ folder.createLink(realFolder, IResource.ALLOW_MISSING_LOCAL, new NullProgressMonitor());
+ resourcesCreated.add(folder);
+ return folder;
+ }
+
+ /**
+ * Creates new eclipse folder-link from project root to EFS folder.
+ *
+ * @param project - project where to create the folder.
+ * @param folderLink - folder name of the link being created.
+ * @param realFolder - folder on the EFS file system, the target of the link.
+ * @return folder handle.
+ * @throws CoreException if something goes wrong.
+ * @throws URISyntaxException if wrong URI syntax
+ */
+ public static IFolder createEfsFolder(IProject project, String folderLink, String realFolder) throws CoreException, URISyntaxException {
+ return createEfsFolder(project,folderLink,new URI(realFolder));
+ }
+
+ /**
+ * Checks if symbolic links are supported on the system.
+ * Used in particular by method {@link #createSymbolicLink(IPath, IPath)}
+ * and other flavors to create symbolic links.
+ *
+ * Note that Windows links .lnk are not supported here.
+ * @return {@code true} if symbolic links are suppoted, {@code false} otherwise.
+ */
+ public static boolean isSymbolicLinkSupported() {
+ return ! Platform.getOS().equals(Platform.OS_WIN32);
+ }
+
+ /**
+ * Creates new symbolic file system link from file or folder on project root
+ * to another file system file. The filename can include relative path
+ * as a part of the name but the the path has to be present on disk.
+ *
+ * @param project - project where to create the file.
+ * @param linkName - name of the link being created.
+ * @param realPath - file or folder on the file system, the target of the link.
+ * @return file handle.
+ *
+ * @throws UnsupportedOperationException on Windows where links are not supported.
+ * @throws IOException...
+ * @throws CoreException...
+ */
+ public static IResource createSymbolicLink(IProject project, String linkName, IPath realPath)
+ throws IOException, CoreException, UnsupportedOperationException {
+ if (!isSymbolicLinkSupported()) {
+ throw new UnsupportedOperationException("Windows links .lnk are not supported.");
+ }
+
+ Assert.assertTrue("Path for symbolic link does not exist: [" + realPath.toOSString() + "]",
+ new File(realPath.toOSString()).exists());
+
+ IPath linkedPath = project.getLocation().append(linkName);
+ createSymbolicLink(linkedPath, realPath);
+
+ IResource resource = project.getFile(linkName);
+ resource.refreshLocal(IResource.DEPTH_ZERO, null);
+
+ if (!resource.exists()) {
+ resource = project.getFolder(linkName);
+ resource.refreshLocal(IResource.DEPTH_ZERO, null);
+ }
+ Assert.assertTrue("Failed to create resource form symbolic link", resource.exists());
+
+ externalFilesCreated.add(linkedPath.toOSString());
+ ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, NULL_MONITOR);
+ return resource;
+ }
+
+ /**
+ * Creates new symbolic file system link from file or folder to another filesystem file.
+ * The target path has to be present on disk.
+ *
+ * @param linkPath - filesystem path of the link being created.
+ * @param realPath - file or folder on the file system, the target of the link.
+ *
+ * @throws UnsupportedOperationException on Windows where links are not supported.
+ * @throws IOException if execution of the command fails.
+ */
+ public static void createSymbolicLink(IPath linkPath, IPath realPath) throws IOException {
+ if (!isSymbolicLinkSupported()) {
+ throw new UnsupportedOperationException("Windows links .lnk are not supported.");
+ }
+
+ String command[] = { "ln", "-s", realPath.toOSString(), linkPath.toOSString()};
+ Process process = Runtime.getRuntime().exec(command);
+
+ // Wait for up to 2.5s...
+ for (int i = 0; i < 5; i++) {
+ try {
+ Assert.assertTrue("ln process exited with non-zero status", process.waitFor() == 0);
+ // If exitValue succeeded, then the process has exited successfully.
+ break;
+ } catch (InterruptedException e) {
+ // Clear interrupted state, see Java bug http://bugs.sun.com/view_bug.do?bug_id=6420270
+ Thread.interrupted();
+ }
+ // Wait for a 500ms before checking again.
+ try { Thread.sleep(500); } catch (InterruptedException e) {/*don't care*/}
+ }
+ Assert.assertTrue("Symbolic link not created, command=[" + command + "]", linkPath.toFile().exists());
+ }
+
+ /**
+ * Creates new symbolic file system link from file or folder on project root
+ * to another file system file. The filename can include relative path
+ * as a part of the name but the the path has to be present on disk.
+ *
+ * @param project - project where to create the file.
+ * @param linkName - name of the link being created.
+ * @param realPath - file or folder on the file system, the target of the link.
+ * @return file handle.
+ *
+ * @throws UnsupportedOperationException on Windows where links are not supported.
+ * @throws IOException...
+ * @throws CoreException...
+ */
+ public static IResource createSymbolicLink(IProject project, String linkName, String realPath)
+ throws IOException, CoreException, UnsupportedOperationException {
+ return createSymbolicLink(project, linkName, new Path(realPath));
+ }
+
+ /**
+ * Get contents of file on file-system.
+ *
+ * @param fullPath - full path to the file on the file-system.
+ * @return contents of the file.
+ * @throws IOException on IO problem.
+ */
+ public static String getContents(IPath fullPath) throws IOException {
+ FileInputStream stream = new FileInputStream(fullPath.toFile());
+ try {
+ // Avoid using java.nio.channels.FileChannel,
+ // see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4715154
+ Reader reader = new BufferedReader(new InputStreamReader(stream, Charset.defaultCharset()));
+ StringBuilder builder = new StringBuilder();
+ char[] buffer = new char[8192];
+ int read;
+ while ((read = reader.read(buffer, 0, buffer.length)) > 0) {
+ builder.append(buffer, 0, read);
+ }
+ return builder.toString();
+ } finally {
+ stream.close();
+ }
+ }
+
+ /**
+ * Get contents of file on file-system.
+ *
+ * @param fullPath - full path to the file on the file-system.
+ * @return contents of the file.
+ * @throws IOException on IO problem.
+ */
+ public static String getContents(String fullPath) throws IOException {
+ return getContents(new Path(fullPath));
+ }
+
+ /**
+ * Clean-up any files created as part of a unit test.
+ * This method removes *all* Workspace IResources and any external
+ * files / folders created with the #createWorkspaceFile #createWorkspaceFolder
+ * methods in this class
+ */
+ public static void cleanUp() throws CoreException, IOException {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ root.refreshLocal(IResource.DEPTH_INFINITE, NULL_MONITOR);
+
+ // Delete all external files & folders created using ResourceHelper
+ for (String loc : externalFilesCreated) {
+ File f = new File(loc);
+ if (f.exists())
+ deleteRecursive(f);
+ }
+ externalFilesCreated.clear();
+
+ // Remove IResources created by this helper
+ for (IResource r : resourcesCreated) {
+ if (r.exists()) {
+ try {
+ r.delete(true, NULL_MONITOR);
+ } catch (CoreException e) {
+ // Ignore
+ }
+ }
+ }
+ resourcesCreated.clear();
+ }
+
+ /**
+ * Recursively delete a directory / file
+ *
+ * For safety this method only deletes files created under the workspace
+ */
+ private static final void deleteRecursive(File f) throws IllegalArgumentException {
+ // Ensure that the file being deleted is a child of the workspace
+ // root to prevent anything nasty happening
+ if (!f.getAbsolutePath().startsWith(
+ ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile().getAbsolutePath())) {
+ throw new IllegalArgumentException("File must exist within the workspace!");
+ }
+
+ if (f.isDirectory()) {
+ for (File f1 : f.listFiles()) {
+ deleteRecursive(f1);
+ }
+ }
+ f.delete();
+ }
+}
diff --git a/org.eclipse.jdt.core/.classpath b/org.eclipse.jdt.core/.classpath
index 6add95f..cfba090 100644
--- a/org.eclipse.jdt.core/.classpath
+++ b/org.eclipse.jdt.core/.classpath
@@ -9,7 +9,7 @@
<classpathentry kind="src" path="formatter"/>
<classpathentry kind="src" path="model"/>
<classpathentry kind="src" path="search"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/org.eclipse.jdt.core/.options b/org.eclipse.jdt.core/.options
index 83d4c30..c50fb79 100644
--- a/org.eclipse.jdt.core/.options
+++ b/org.eclipse.jdt.core/.options
@@ -47,6 +47,33 @@
# Reports Java model elements opening/closing
org.eclipse.jdt.core/debug/javamodel/cache=false
+# Reports changes in the Java classpath and classpath resolution
+org.eclipse.jdt.core/debug/javamodel/classpath=false
+
+# Reports all insertions and removals from the java model cache
+org.eclipse.jdt.core/debug/javamodel/insertions=false
+
+# Records information about the invalid archive cache
+org.eclipse.jdt.core/debug/javamodel/invalid_archives=false
+
+# Prints information about when the indexer runs and what files are being indexed
+org.eclipse.jdt.core/debug/index/indexer=false
+
+# Prints a line whenever a class is added to or removed from the index
+org.eclipse.jdt.core/debug/index/insertions=false
+
+# Prints diagnostic information about index database locks
+org.eclipse.jdt.core/debug/index/locks=false
+
+# Prints statistics about database memory usage
+org.eclipse.jdt.core/debug/index/space=false
+
+# Performs self-testing during indexing by reading back every class and comparing it with the original .class file
+org.eclipse.jdt.core/debug/index/selftest=false
+
+# Prints statistics about indexing time
+org.eclipse.jdt.core/debug/index/timing=false
+
# Reports post actions addition/run
org.eclipse.jdt.core/debug/postaction=false
diff --git a/org.eclipse.jdt.core/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.jdt.core/.settings/org.eclipse.jdt.core.prefs
index c02097a..d2ef492 100644
--- a/org.eclipse.jdt.core/.settings/org.eclipse.jdt.core.prefs
+++ b/org.eclipse.jdt.core/.settings/org.eclipse.jdt.core.prefs
@@ -25,9 +25,9 @@
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
@@ -131,7 +131,7 @@
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.7
+org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
diff --git a/org.eclipse.jdt.core/META-INF/MANIFEST.MF b/org.eclipse.jdt.core/META-INF/MANIFEST.MF
index 4bb8b6f..0e9d5cf 100644
--- a/org.eclipse.jdt.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.core/META-INF/MANIFEST.MF
@@ -45,6 +45,13 @@
org.eclipse.jdt.internal.core.hierarchy;x-friends:="org.eclipse.objectteams.otdt",
org.eclipse.jdt.internal.core.index;x-internal:=true,
org.eclipse.jdt.internal.core.jdom;x-internal:=true,
+ org.eclipse.jdt.internal.core.nd;x-internal:=true,
+ org.eclipse.jdt.internal.core.nd.db;x-internal:=true,
+ org.eclipse.jdt.internal.core.nd.field;x-internal:=true,
+ org.eclipse.jdt.internal.core.nd.indexer;x-internal:=true,
+ org.eclipse.jdt.internal.core.nd.java;x-internal:=true,
+ org.eclipse.jdt.internal.core.nd.java.model;x-internal:=true,
+ org.eclipse.jdt.internal.core.nd.util;x-internal:=true,
org.eclipse.jdt.internal.core.search;x-internal:=true,
org.eclipse.jdt.internal.core.search.indexing;x-internal:=true,
org.eclipse.jdt.internal.core.search.matching;x-internal:=true,
@@ -79,7 +86,8 @@
org.eclipse.core.filesystem;bundle-version="[1.0.0,2.0.0)",
org.eclipse.text;bundle-version="[3.1.0,4.0.0)",
org.eclipse.team.core;bundle-version="[3.1.0,4.0.0)";resolution:=optional,
+ com.ibm.icu;bundle-version="54.1.1",
org.eclipse.jdt.annotation;bundle-version="[1.1.0,2.0.0)"
-Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Eclipse-ExtensibleAPI: true
Bundle-ActivationPolicy: lazy
diff --git a/org.eclipse.jdt.core/antadapter/org/eclipse/jdt/core/JDTCompilerAdapter.java b/org.eclipse.jdt.core/antadapter/org/eclipse/jdt/core/JDTCompilerAdapter.java
index 73664ae..c2bdf71 100644
--- a/org.eclipse.jdt.core/antadapter/org/eclipse/jdt/core/JDTCompilerAdapter.java
+++ b/org.eclipse.jdt.core/antadapter/org/eclipse/jdt/core/JDTCompilerAdapter.java
@@ -305,6 +305,7 @@
String source = this.attributes.getSource();
if (source != null) {
this.customDefaultOptions.put(CompilerOptions.OPTION_Source, source);
+ this.customDefaultOptions.put(CompilerOptions.OPTION_Compliance, source);
}
if (compilerArgs != null) {
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java
index 77ad903..6245837 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java
@@ -27,9 +27,12 @@
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
+import org.eclipse.jdt.internal.compiler.classfmt.ExternalAnnotationDecorator;
import org.eclipse.jdt.internal.compiler.classfmt.ExternalAnnotationProvider;
import org.eclipse.jdt.internal.compiler.env.AccessRuleSet;
+import org.eclipse.jdt.internal.compiler.env.IBinaryType;
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
+import org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.ExternalAnnotationStatus;
import org.eclipse.jdt.internal.compiler.util.ManifestAnalyzer;
import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
import org.eclipse.jdt.internal.compiler.util.Util;
@@ -102,15 +105,20 @@
return null; // most common case
try {
- ClassFileReader reader = ClassFileReader.read(this.zipFile, qualifiedBinaryFileName);
+ IBinaryType reader = ClassFileReader.read(this.zipFile, qualifiedBinaryFileName);
if (reader != null) {
if (this.annotationPaths != null) {
String qualifiedClassName = qualifiedBinaryFileName.substring(0, qualifiedBinaryFileName.length()-SuffixConstants.EXTENSION_CLASS.length()-1);
for (String annotationPath : this.annotationPaths) {
try {
- this.annotationZipFile = reader.setExternalAnnotationProvider(annotationPath, qualifiedClassName, this.annotationZipFile, null);
- if (reader.hasAnnotationProvider())
+ if (this.annotationZipFile == null) {
+ this.annotationZipFile = ExternalAnnotationDecorator.getAnnotationZipFile(annotationPath, null);
+ }
+ reader = ExternalAnnotationDecorator.create(reader, annotationPath, qualifiedClassName, this.annotationZipFile);
+
+ if (reader.getExternalAnnotationStatus() == ExternalAnnotationStatus.TYPE_IS_ANNOTATED) {
break;
+ }
} catch (IOException e) {
// don't let error on annotations fail class reading
}
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java
index b6d9e5f..7c7dbc3 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -24,6 +24,7 @@
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
+import org.eclipse.jdt.internal.compiler.classfmt.ExternalAnnotationDecorator;
import org.eclipse.jdt.internal.compiler.env.AccessRuleSet;
import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
@@ -275,9 +276,14 @@
for (int i = 0, length = this.classpaths.length; i < length; i++) {
Classpath classpathEntry = this.classpaths[i];
if (classpathEntry.hasAnnotationFileFor(qualifiedTypeName)) {
+ // in case of 'this.annotationsFromClasspath' we indeed search for .eea entries inside the main zipFile of the entry:
ZipFile zip = classpathEntry instanceof ClasspathJar ? ((ClasspathJar) classpathEntry).zipFile : null;
try {
- ((ClassFileReader) answer.getBinaryType()).setExternalAnnotationProvider(classpathEntry.getPath(), qualifiedTypeName, zip, null);
+ if (zip == null) {
+ zip = ExternalAnnotationDecorator.getAnnotationZipFile(classpathEntry.getPath(), null);
+ }
+ answer.setBinaryType(ExternalAnnotationDecorator.create(answer.getBinaryType(), classpathEntry.getPath(),
+ qualifiedTypeName, zip));
break;
} catch (IOException e) {
// ignore broken entry, keep searching
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 59b6c3a..5967f22 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
@@ -18,6 +18,7 @@
package org.eclipse.jdt.internal.codeassist;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
@@ -43,41 +44,171 @@
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.core.search.IJavaSearchConstants;
-import org.eclipse.jdt.internal.codeassist.complete.*;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionNodeDetector;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionNodeFound;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnAnnotationOfType;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnArgumentName;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnBranchStatementLabel;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnClassLiteralAccess;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnExplicitConstructorCall;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnFieldName;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnFieldType;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnImportReference;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnJavadoc;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnJavadocAllocationExpression;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnJavadocFieldReference;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnJavadocMessageSend;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnJavadocParamNameReference;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnJavadocQualifiedTypeReference;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnJavadocSingleTypeReference;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnJavadocTag;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnJavadocTypeParamReference;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnKeyword;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnKeyword3;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnLocalName;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnMarkerAnnotationName;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnMemberAccess;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnMemberValueName;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnMessageSend;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnMessageSendName;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnMethodName;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnMethodReturnType;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnPackageReference;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnParameterizedQualifiedTypeReference;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnQualifiedAllocationExpression;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnQualifiedNameReference;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnQualifiedTypeReference;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnReferenceExpressionName;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnSingleNameReference;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnSingleTypeReference;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionOnStringLiteral;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionParser;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionScanner;
+import org.eclipse.jdt.internal.codeassist.complete.InvalidCursorLocation;
import org.eclipse.jdt.internal.codeassist.impl.AssistParser;
import org.eclipse.jdt.internal.codeassist.impl.Engine;
import org.eclipse.jdt.internal.codeassist.impl.Keywords;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
import org.eclipse.jdt.internal.compiler.ExtraFlags;
-import org.eclipse.jdt.internal.compiler.ast.*;
+import org.eclipse.jdt.internal.compiler.ast.ASTNode;
+import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.AllocationExpression;
+import org.eclipse.jdt.internal.compiler.ast.Annotation;
+import org.eclipse.jdt.internal.compiler.ast.Argument;
+import org.eclipse.jdt.internal.compiler.ast.ArrayInitializer;
+import org.eclipse.jdt.internal.compiler.ast.ArrayReference;
+import org.eclipse.jdt.internal.compiler.ast.AssertStatement;
+import org.eclipse.jdt.internal.compiler.ast.Assignment;
+import org.eclipse.jdt.internal.compiler.ast.BinaryExpression;
+import org.eclipse.jdt.internal.compiler.ast.CaseStatement;
+import org.eclipse.jdt.internal.compiler.ast.CastExpression;
+import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.ConditionalExpression;
+import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.Expression;
+import org.eclipse.jdt.internal.compiler.ast.ExpressionContext;
+import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.FieldReference;
+import org.eclipse.jdt.internal.compiler.ast.ForStatement;
+import org.eclipse.jdt.internal.compiler.ast.IfStatement;
+import org.eclipse.jdt.internal.compiler.ast.ImportReference;
+import org.eclipse.jdt.internal.compiler.ast.Initializer;
+import org.eclipse.jdt.internal.compiler.ast.InstanceOfExpression;
+import org.eclipse.jdt.internal.compiler.ast.Javadoc;
+import org.eclipse.jdt.internal.compiler.ast.JavadocImplicitTypeReference;
+import org.eclipse.jdt.internal.compiler.ast.JavadocQualifiedTypeReference;
+import org.eclipse.jdt.internal.compiler.ast.JavadocSingleTypeReference;
+import org.eclipse.jdt.internal.compiler.ast.LambdaExpression;
+import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.MemberValuePair;
+import org.eclipse.jdt.internal.compiler.ast.MessageSend;
+import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.NameReference;
+import org.eclipse.jdt.internal.compiler.ast.NormalAnnotation;
+import org.eclipse.jdt.internal.compiler.ast.OperatorExpression;
+import org.eclipse.jdt.internal.compiler.ast.OperatorIds;
+import org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference;
+import org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference;
+import org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference;
+import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference;
+import org.eclipse.jdt.internal.compiler.ast.ReferenceExpression;
+import org.eclipse.jdt.internal.compiler.ast.ReturnStatement;
+import org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
+import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference;
+import org.eclipse.jdt.internal.compiler.ast.SuperReference;
+import org.eclipse.jdt.internal.compiler.ast.SwitchStatement;
+import org.eclipse.jdt.internal.compiler.ast.ThisReference;
+import org.eclipse.jdt.internal.compiler.ast.TryStatement;
+import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.TypeParameter;
+import org.eclipse.jdt.internal.compiler.ast.TypeReference;
+import org.eclipse.jdt.internal.compiler.ast.UnaryExpression;
+import org.eclipse.jdt.internal.compiler.ast.UnionTypeReference;
+import org.eclipse.jdt.internal.compiler.ast.WhileStatement;
+import org.eclipse.jdt.internal.compiler.ast.Wildcard;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.env.*;
+import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
+import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
+import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
+import org.eclipse.jdt.internal.compiler.env.ISourceType;
+import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
+import org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.Binding;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
+import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
+import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
+import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
+import org.eclipse.jdt.internal.compiler.lookup.ImportBinding;
+import org.eclipse.jdt.internal.compiler.lookup.InferenceContext18;
+import org.eclipse.jdt.internal.compiler.lookup.InvocationSite;
+import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
+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.ParameterizedMethodBinding;
+import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding;
+import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
+import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
+import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
+import org.eclipse.jdt.internal.compiler.lookup.Scope;
+import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TagBits;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
+import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
+import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.VariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.WildcardBinding;
+import org.eclipse.jdt.internal.compiler.parser.JavadocTagConstants;
import org.eclipse.jdt.internal.compiler.parser.ScannerHelper;
import org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter;
-import org.eclipse.jdt.internal.compiler.parser.JavadocTagConstants;
import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
-import org.eclipse.jdt.internal.compiler.util.SimpleSetOfCharArray;
-import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
import org.eclipse.jdt.internal.compiler.util.ObjectVector;
+import org.eclipse.jdt.internal.compiler.util.SimpleSetOfCharArray;
+import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
import org.eclipse.jdt.internal.core.BasicCompilationUnit;
+import org.eclipse.jdt.internal.core.BinaryTypeConverter;
import org.eclipse.jdt.internal.core.INamingRequestor;
import org.eclipse.jdt.internal.core.InternalNamingConventions;
import org.eclipse.jdt.internal.core.JavaModelManager;
+import org.eclipse.jdt.internal.core.SearchableEnvironment;
import org.eclipse.jdt.internal.core.SourceMethod;
import org.eclipse.jdt.internal.core.SourceMethodElementInfo;
import org.eclipse.jdt.internal.core.SourceType;
-import org.eclipse.jdt.internal.core.BinaryTypeConverter;
-import org.eclipse.jdt.internal.core.SearchableEnvironment;
import org.eclipse.jdt.internal.core.SourceTypeElementInfo;
-import org.eclipse.jdt.internal.core.search.matching.JavaSearchNameEnvironment;
+import org.eclipse.jdt.internal.core.search.matching.IndexBasedJavaSearchEnvironment;
import org.eclipse.jdt.internal.core.util.Messages;
import org.eclipse.jdt.internal.core.util.Util;
import org.eclipse.objectteams.otdt.core.IOTType;
@@ -581,7 +712,7 @@
CompletionRequestor requestor;
CompletionProblemFactory problemFactory;
ProblemReporter problemReporter;
- private JavaSearchNameEnvironment noCacheNameEnvironment;
+ private INameEnvironment noCacheNameEnvironment;
char[] source;
char[] completionToken;
char[] qualifiedCompletionToken;
@@ -12849,7 +12980,7 @@
private INameEnvironment getNoCacheNameEnvironment() {
if (this.noCacheNameEnvironment == null) {
JavaModelManager.getJavaModelManager().cacheZipFiles(this);
- this.noCacheNameEnvironment = new JavaSearchNameEnvironment(this.javaProject, this.owner == null ? null : JavaModelManager.getJavaModelManager().getWorkingCopies(this.owner, true/*add primary WCs*/));
+ this.noCacheNameEnvironment = IndexBasedJavaSearchEnvironment.create(Collections.singletonList(this.javaProject), this.owner == null ? null : JavaModelManager.getJavaModelManager().getWorkingCopies(this.owner, true/*add primary WCs*/));
}
return this.noCacheNameEnvironment;
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/RelevanceConstants.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/RelevanceConstants.java
index 53f1215..97f8a5e 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/RelevanceConstants.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/RelevanceConstants.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -21,7 +21,7 @@
* 4. The value of R_DEFAULT is maintained at a positive value such that the sum of all the negative relevance constants
* and R_DEFAULT must not be negative.
*/
- int R_DEFAULT = 5;
+ int R_DEFAULT = 30;
int R_INTERESTING = 5;
int R_CASE = 10;
int R_CAMEL_CASE = 5;
@@ -44,7 +44,7 @@
int R_NAME_FIRST_SUFFIX = 4;
int R_NAME_SUFFIX = 3;
int R_NAME_LESS_NEW_CHARACTERS = 15;
- int R_SUBSTRING = -1;
+ int R_SUBSTRING = -20;
int R_METHOD_OVERIDE = 3;
int R_NON_RESTRICTED = 3;
int R_TRUE_OR_FALSE = 1;
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java
index 94e796d..83777f1 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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,7 +17,6 @@
import java.util.Locale;
import java.util.Map;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jdt.core.IBuffer;
@@ -26,26 +25,76 @@
import org.eclipse.jdt.core.IOpenable;
import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
import org.eclipse.jdt.core.WorkingCopyOwner;
-import org.eclipse.jdt.core.compiler.*;
+import org.eclipse.jdt.core.compiler.CategorizedProblem;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.jdt.core.compiler.InvalidInputException;
import org.eclipse.jdt.core.search.IJavaSearchConstants;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchPattern;
import org.eclipse.jdt.core.search.TypeNameMatch;
import org.eclipse.jdt.core.search.TypeNameMatchRequestor;
-import org.eclipse.jdt.internal.codeassist.impl.*;
-import org.eclipse.jdt.internal.codeassist.select.*;
-import org.eclipse.jdt.internal.compiler.*;
+import org.eclipse.jdt.internal.codeassist.impl.AssistParser;
+import org.eclipse.jdt.internal.codeassist.impl.Engine;
+import org.eclipse.jdt.internal.codeassist.select.SelectionJavadocParser;
+import org.eclipse.jdt.internal.codeassist.select.SelectionNodeFound;
+import org.eclipse.jdt.internal.codeassist.select.SelectionOnImportReference;
+import org.eclipse.jdt.internal.codeassist.select.SelectionOnPackageReference;
+import org.eclipse.jdt.internal.codeassist.select.SelectionOnQualifiedTypeReference;
+import org.eclipse.jdt.internal.codeassist.select.SelectionOnSingleTypeReference;
+import org.eclipse.jdt.internal.codeassist.select.SelectionParser;
+import org.eclipse.jdt.internal.compiler.ASTVisitor;
+import org.eclipse.jdt.internal.compiler.CompilationResult;
+import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
+import org.eclipse.jdt.internal.compiler.ast.ASTNode;
+import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.Expression.DecapsulationState;
+import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.ImportReference;
+import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.TypeParameter;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
-import org.eclipse.jdt.internal.compiler.env.*;
-import org.eclipse.jdt.internal.compiler.ast.*;
-import org.eclipse.jdt.internal.compiler.ast.Expression.DecapsulationState;
-import org.eclipse.jdt.internal.compiler.lookup.*;
-import org.eclipse.jdt.internal.compiler.parser.*;
-import org.eclipse.jdt.internal.compiler.problem.*;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
+import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
+import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
+import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
+import org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.Binding;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
+import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
+import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
+import org.eclipse.jdt.internal.compiler.lookup.LocalTypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
+import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
+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.ParameterizedTypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.ProblemFieldBinding;
+import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
+import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
+import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
+import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.SyntheticMethodBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
+import org.eclipse.jdt.internal.compiler.parser.Scanner;
+import org.eclipse.jdt.internal.compiler.parser.ScannerHelper;
+import org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter;
+import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
+import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
+import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
+import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
import org.eclipse.jdt.internal.compiler.util.ObjectVector;
import org.eclipse.jdt.internal.core.BinaryTypeConverter;
@@ -55,6 +104,8 @@
import org.eclipse.jdt.internal.core.SelectionRequestor;
import org.eclipse.jdt.internal.core.SourceType;
import org.eclipse.jdt.internal.core.SourceTypeElementInfo;
+import org.eclipse.jdt.internal.core.nd.java.model.BinaryTypeDescriptor;
+import org.eclipse.jdt.internal.core.nd.java.model.BinaryTypeFactory;
import org.eclipse.jdt.internal.core.search.BasicSearchEngine;
import org.eclipse.jdt.internal.core.search.TypeNameMatchRequestorWrapper;
import org.eclipse.jdt.internal.core.util.ASTNodeFinder;
@@ -1350,7 +1401,7 @@
if(!isValuesOrValueOf && !methodBinding.isSynthetic()) {
//{ObjectTeams: retrench enhanced callin signature:
/* orig:
- TypeBinding[] parameterTypes = methodBinding.original().parameters;
+ TypeBinding[] parameterTypes = methodBinding.original().parameters;
:giro */
TypeBinding[] parameterTypes = methodBinding.original().getSourceParameters();
// SH}
@@ -1402,11 +1453,11 @@
declaringClass,
parsedUnit);
//haebor}
- this.requestor.acceptMethod(
+ this.requestor.acceptMethod(
//{ObjectTeams
/* orig:
- declaringClass.qualifiedPackageName(),
- declaringClass.qualifiedSourceName(),
+ declaringClass.qualifiedPackageName(),
+ declaringClass.qualifiedSourceName(),
:giro */
packTypeName.qualifiedPackageName,
packTypeName.qualifiedSourceName,
@@ -1666,7 +1717,18 @@
}
} else { // binary type
ClassFile classFile = (ClassFile) context.getClassFile();
- ClassFileReader reader = (ClassFileReader) classFile.getBinaryTypeInfo((IFile) classFile.resource(), false/*don't fully initialize so as to keep constant pool (used below)*/);
+ BinaryTypeDescriptor descriptor = BinaryTypeFactory.createDescriptor(classFile);
+ ClassFileReader reader = null;
+ try {
+ reader = BinaryTypeFactory.rawReadType(descriptor, false/*don't fully initialize so as to keep constant pool (used below)*/);
+ } catch (ClassFormatException e) {
+ if (JavaCore.getPlugin().isDebugging()) {
+ e.printStackTrace(System.err);
+ }
+ }
+ if (reader == null) {
+ throw classFile.newNotPresentException();
+ }
CompilationResult result = new CompilationResult(reader.getFileName(), 1, 1, this.compilerOptions.maxProblemsPerUnit);
parsedUnit = new CompilationUnitDeclaration(this.parser.problemReporter(), result, 0);
HashSetOfCharArrayArray typeNames = new HashSetOfCharArrayArray();
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
index fb21a11..d3fc337 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
@@ -92,6 +92,7 @@
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
+import org.eclipse.jdt.internal.compiler.lookup.PolymorphicMethodBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.SyntheticArgumentBinding;
@@ -3098,7 +3099,7 @@
this.contents[localContentsOffset++] = (byte) (functionalDescriptorIndex >> 8);
this.contents[localContentsOffset++] = (byte) functionalDescriptorIndex;
- int methodHandleIndex = this.constantPool.literalIndexForMethodHandle(functional.binding.original()); // Speak of " implementation" (erased) version here, adaptations described below.
+ int methodHandleIndex = this.constantPool.literalIndexForMethodHandle(functional.binding instanceof PolymorphicMethodBinding ? functional.binding : functional.binding.original()); // Speak of " implementation" (erased) version here, adaptations described below.
this.contents[localContentsOffset++] = (byte) (methodHandleIndex >> 8);
this.contents[localContentsOffset++] = (byte) methodHandleIndex;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayReference.java
index b816309..ca0453b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayReference.java
@@ -50,8 +50,9 @@
currentScope,
flowContext,
analyseCode(currentScope, flowContext, flowInfo).unconditionalInits());
- if ((this.resolvedType.tagBits & TagBits.AnnotationNonNull) != 0) {
- int nullStatus = assignment.expression.nullStatus(flowInfo, flowContext);
+ if ((this.resolvedType.tagBits & TagBits.AnnotationNonNull) != 0 ||
+ (this.resolvedType.isFreeTypeVariable() && !assignment.expression.resolvedType.isFreeTypeVariable())) {
+ int nullStatus = assignment.expression.nullStatus(flowInfo, flowContext);
if (nullStatus != FlowInfo.NON_NULL) {
currentScope.problemReporter().nullityMismatch(this, assignment.expression.resolvedType, this.resolvedType, nullStatus, currentScope.environment().getNonNullAnnotationName());
}
@@ -60,8 +61,8 @@
}
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
- this.receiver.checkNPE(currentScope, flowContext, flowInfo, 1);
flowInfo = this.receiver.analyseCode(currentScope, flowContext, flowInfo);
+ this.receiver.checkNPE(currentScope, flowContext, flowInfo, 1);
flowInfo = this.position.analyseCode(currentScope, flowContext, flowInfo);
this.position.checkNPEbyUnboxing(currentScope, flowContext, flowInfo);
// account for potential ArrayIndexOutOfBoundsException:
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BinaryExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BinaryExpression.java
index 9404a33..f4d9d99 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BinaryExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BinaryExpression.java
@@ -70,13 +70,13 @@
this.left.analyseCode(currentScope, flowContext, flowInfo).unconditionalInits())
.unconditionalInits();
} else {
- this.left.checkNPE(currentScope, flowContext, flowInfo);
flowInfo = this.left.analyseCode(currentScope, flowContext, flowInfo).unconditionalInits();
+ this.left.checkNPE(currentScope, flowContext, flowInfo);
if (((this.bits & OperatorMASK) >> OperatorSHIFT) != AND) {
flowContext.expireNullCheckedFieldInfo();
}
- this.right.checkNPE(currentScope, flowContext, flowInfo);
flowInfo = this.right.analyseCode(currentScope, flowContext, flowInfo).unconditionalInits();
+ this.right.checkNPE(currentScope, flowContext, flowInfo);
if (((this.bits & OperatorMASK) >> OperatorSHIFT) != AND) {
flowContext.expireNullCheckedFieldInfo();
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CombinedBinaryExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CombinedBinaryExpression.java
index 7ff2fec..51e2849 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CombinedBinaryExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CombinedBinaryExpression.java
@@ -125,26 +125,26 @@
}
try {
BinaryExpression cursor;
- if ((cursor = this.referencesTable[0]).resolvedType.id !=
- TypeIds.T_JavaLangString) {
+ cursor = this.referencesTable[0];
+ flowInfo = cursor.left.analyseCode(currentScope, flowContext, flowInfo).
+ unconditionalInits();
+ if (cursor.resolvedType.id != TypeIds.T_JavaLangString) {
cursor.left.checkNPE(currentScope, flowContext, flowInfo);
}
- flowInfo = cursor.left.analyseCode(currentScope, flowContext, flowInfo).
- unconditionalInits();
for (int i = 0, end = this.arity; i < end; i ++) {
- if ((cursor = this.referencesTable[i]).resolvedType.id !=
- TypeIds.T_JavaLangString) {
+ cursor = this.referencesTable[i];
+ flowInfo = cursor.right.
+ analyseCode(currentScope, flowContext, flowInfo).
+ unconditionalInits();
+ if (cursor.resolvedType.id != TypeIds.T_JavaLangString) {
cursor.right.checkNPE(currentScope, flowContext, flowInfo);
}
- flowInfo = cursor.right.
- analyseCode(currentScope, flowContext, flowInfo).
- unconditionalInits();
}
+ flowInfo = this.right.analyseCode(currentScope, flowContext, flowInfo).unconditionalInits();
if (this.resolvedType.id != TypeIds.T_JavaLangString) {
this.right.checkNPE(currentScope, flowContext, flowInfo);
}
- return this.right.analyseCode(currentScope, flowContext, flowInfo).
- unconditionalInits();
+ return flowInfo;
} finally {
// account for exception possibly thrown by arithmetics
flowContext.recordAbruptExit();
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java
index 94110e5..93b2020 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java
@@ -136,6 +136,9 @@
this.receiver
.analyseCode(currentScope, flowContext, flowInfo, !this.binding.isStatic())
.unconditionalInits();
+
+ this.receiver.checkNPE(currentScope, flowContext, flowInfo);
+
if (assignment.expression != null) {
flowInfo =
assignment
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java
index 6c18cc8..c590ba9 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java
@@ -107,9 +107,9 @@
int initialComplaintLevel = (flowInfo.reachMode() & FlowInfo.UNREACHABLE) != 0 ? Statement.COMPLAINED_FAKE_REACHABLE : Statement.NOT_COMPLAINED;
// process the element variable and collection
- this.collection.checkNPE(currentScope, flowContext, flowInfo, 1);
flowInfo = this.elementVariable.analyseCode(this.scope, flowContext, flowInfo);
FlowInfo condInfo = this.collection.analyseCode(this.scope, flowContext, flowInfo.copy());
+ this.collection.checkNPE(currentScope, flowContext, condInfo.copy(), 1);
LocalVariableBinding elementVarBinding = this.elementVariable.binding;
// element variable will be assigned when iterating
@@ -126,7 +126,7 @@
condInfo.nullInfoLessUnconditionalCopy();
actionInfo.markAsDefinitelyUnknown(elementVarBinding);
if (currentScope.compilerOptions().isAnnotationBasedNullAnalysisEnabled) {
- int elementNullStatus = FlowInfo.tagBitsToNullStatus(this.collectionElementType.tagBits);
+ int elementNullStatus = NullAnnotationMatching.nullStatusFromExpressionType(this.collectionElementType);
int nullStatus = NullAnnotationMatching.checkAssignment(currentScope, flowContext, elementVarBinding, null, // have no useful flowinfo for element var
elementNullStatus, this.collection, this.collectionElementType);
if ((elementVarBinding.type.tagBits & TagBits.IsBaseType) == 0) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java
index 2c76671..d6a9791 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java
@@ -878,7 +878,7 @@
this.genericTypeArguments = new TypeBinding[length];
for (int i = 0; i < length; i++) {
TypeReference typeReference = this.typeArguments[i];
- if ((this.genericTypeArguments[i] = typeReference.resolveType(scope, true /* check bounds*/)) == null) {
+ if ((this.genericTypeArguments[i] = typeReference.resolveType(scope, true /* check bounds*/, Binding.DefaultLocationTypeArgument)) == null) {
this.argumentsHaveErrors = true;
}
if (this.argumentsHaveErrors && typeReference instanceof Wildcard) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NullAnnotationMatching.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NullAnnotationMatching.java
index ef63d2a..0d57976 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NullAnnotationMatching.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NullAnnotationMatching.java
@@ -311,7 +311,7 @@
}
}
severity = severity.max(s);
- if (!severity.isAnyMismatch() && (providedBits & TagBits.AnnotationNonNull) != 0)
+ if (!severity.isAnyMismatch() && (providedBits & TagBits.AnnotationNullMASK) == TagBits.AnnotationNonNull)
okStatus = okNonNullStatus(providedExpression);
}
if (severity != Severity.MISMATCH && nullStatus != FlowInfo.NULL) { // null value has no details
@@ -479,6 +479,20 @@
return 0;
}
+ /**
+ * Use only if no suitable flowInfo is available.
+ */
+ public static int nullStatusFromExpressionType(TypeBinding type) {
+ if (type.isFreeTypeVariable())
+ return FlowInfo.FREE_TYPEVARIABLE;
+ long bits = type.tagBits & TagBits.AnnotationNullMASK;
+ if (bits == 0)
+ return FlowInfo.UNKNOWN;
+ if (bits == TagBits.AnnotationNonNull)
+ return FlowInfo.NON_NULL;
+ return FlowInfo.POTENTIALLY_NON_NULL | FlowInfo.POTENTIALLY_NULL;
+ }
+
public static long validNullTagBits(long bits) {
bits &= TagBits.AnnotationNullMASK;
return bits == TagBits.AnnotationNullMASK ? 0 : bits;
@@ -725,5 +739,5 @@
buf.append("Analysis result: severity="+this.severity);
buf.append(" nullStatus="+this.nullStatus);
return buf.toString();
- }
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java
index 331bd26..004ddaf 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java
@@ -55,7 +55,7 @@
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
import org.eclipse.jdt.internal.compiler.codegen.ConstantPool;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
-import org.eclipse.jdt.internal.compiler.flow.ExceptionHandlingFlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FieldInitsFakingFlowContext;
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.flow.UnconditionalFlowInfo;
@@ -243,7 +243,7 @@
IErrorHandlingPolicy oldPolicy = currentScope.problemReporter().switchErrorHandlingPolicy(silentErrorHandlingPolicy);
try {
implicitLambda.analyseCode(currentScope,
- new ExceptionHandlingFlowContext(null, this, Binding.NO_EXCEPTIONS, null, currentScope, FlowInfo.DEAD_END),
+ new FieldInitsFakingFlowContext(null, this, Binding.NO_EXCEPTIONS, null, currentScope, FlowInfo.DEAD_END),
UnconditionalFlowInfo.fakeInitializedFlowInfo(currentScope.outerMostMethodScope().analysisIndex, currentScope.referenceType().maxFieldCount));
} finally {
currentScope.problemReporter().switchErrorHandlingPolicy(oldPolicy);
@@ -288,7 +288,7 @@
if (this.binding != null && isMethodReference()) {
if (TypeBinding.notEquals(this.binding.declaringClass, this.lhs.resolvedType.erasure())) {
if (!this.binding.declaringClass.canBeSeenBy(currentScope)) {
- this.binding = new MethodBinding(this.binding, (ReferenceBinding) this.lhs.resolvedType.erasure());
+ this.binding = new MethodBinding(this.binding.original(), (ReferenceBinding) this.lhs.resolvedType.erasure());
}
}
}
@@ -415,8 +415,8 @@
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
// static methods with receiver value never get here
if (this.haveReceiver) {
- this.lhs.checkNPE(currentScope, flowContext, flowInfo);
this.lhs.analyseCode(currentScope, flowContext, flowInfo, true);
+ this.lhs.checkNPE(currentScope, flowContext, flowInfo);
} else if (isConstructorReference()) {
TypeBinding type = this.receiverType.leafComponentType();
if (type.isNestedType() &&
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/UnaryExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/UnaryExpression.java
index ed03863..e099594 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/UnaryExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/UnaryExpression.java
@@ -34,18 +34,18 @@
BlockScope currentScope,
FlowContext flowContext,
FlowInfo flowInfo) {
- this.expression.checkNPE(currentScope, flowContext, flowInfo);
if (((this.bits & OperatorMASK) >> OperatorSHIFT) == NOT) {
flowContext.tagBits ^= FlowContext.INSIDE_NEGATION;
flowInfo = this.expression.
analyseCode(currentScope, flowContext, flowInfo).
asNegatedCondition();
flowContext.tagBits ^= FlowContext.INSIDE_NEGATION;
- return flowInfo;
} else {
- return this.expression.
+ flowInfo = this.expression.
analyseCode(currentScope, flowContext, flowInfo);
}
+ this.expression.checkNPE(currentScope, flowContext, flowInfo);
+ return flowInfo;
}
public Constant optimizedBooleanConstant() {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java
index 9081769..3538098 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2012 BEA Systems, Inc.
+ * Copyright (c) 2005, 2016 BEA Systems, Inc.
* 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
@@ -377,20 +377,7 @@
return currentOffset;
}
public String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer.append('@');
- buffer.append(this.typename);
- if (this.pairs != null) {
- buffer.append('(');
- buffer.append("\n\t"); //$NON-NLS-1$
- for (int i = 0, len = this.pairs.length; i < len; i++) {
- if (i > 0)
- buffer.append(",\n\t"); //$NON-NLS-1$
- buffer.append(this.pairs[i]);
- }
- buffer.append(')');
- }
- return buffer.toString();
+ return BinaryTypeFormatter.annotationToString(this);
}
public int hashCode() {
final int prime = 31;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationMethodInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationMethodInfo.java
index 6ddba77..1a59874 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationMethodInfo.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationMethodInfo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 BEA Systems, Inc.
+ * Copyright (c) 2005, 2016 BEA Systems, Inc.
* 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
@@ -93,23 +93,4 @@
public Object getDefaultValue() {
return this.defaultValue;
}
-protected void toStringContent(StringBuffer buffer) {
- super.toStringContent(buffer);
- if (this.defaultValue != null) {
- buffer.append(" default "); //$NON-NLS-1$
- if (this.defaultValue instanceof Object[]) {
- buffer.append('{');
- Object[] elements = (Object[]) this.defaultValue;
- for (int i = 0, len = elements.length; i < len; i++) {
- if (i > 0)
- buffer.append(", "); //$NON-NLS-1$
- buffer.append(elements[i]);
- }
- buffer.append('}');
- } else {
- buffer.append(this.defaultValue);
- }
- buffer.append('\n');
- }
-}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationMethodInfoWithAnnotations.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationMethodInfoWithAnnotations.java
index bd1cce8..9ff47d3 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationMethodInfoWithAnnotations.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationMethodInfoWithAnnotations.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 BEA Systems, Inc.
+ * Copyright (c) 2005, 2016 BEA Systems, Inc.
* 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
@@ -34,11 +34,4 @@
this.annotations[i].reset();
super.reset();
}
-protected void toStringContent(StringBuffer buffer) {
- super.toStringContent(buffer);
- for (int i = 0, l = this.annotations == null ? 0 : this.annotations.length; i < l; i++) {
- buffer.append(this.annotations[i]);
- buffer.append('\n');
- }
-}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/BinaryTypeFormatter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/BinaryTypeFormatter.java
new file mode 100644
index 0000000..99c5111
--- /dev/null
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/BinaryTypeFormatter.java
@@ -0,0 +1,136 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 Google, Inc 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:
+ * Stefan Xenos (Google) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.compiler.classfmt;
+
+import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
+import org.eclipse.jdt.internal.compiler.env.IBinaryElementValuePair;
+import org.eclipse.jdt.internal.compiler.env.IBinaryMethod;
+import org.eclipse.jdt.internal.compiler.env.IBinaryTypeAnnotation;
+import org.eclipse.jdt.internal.compiler.util.Util;
+
+public class BinaryTypeFormatter {
+
+ public static String annotationToString(IBinaryAnnotation annotation) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append('@');
+ buffer.append(annotation.getTypeName());
+ IBinaryElementValuePair[] valuePairs = annotation.getElementValuePairs();
+ if (valuePairs != null) {
+ buffer.append('(');
+ buffer.append("\n\t"); //$NON-NLS-1$
+ for (int i = 0, len = valuePairs.length; i < len; i++) {
+ if (i > 0)
+ buffer.append(",\n\t"); //$NON-NLS-1$
+ buffer.append(valuePairs[i]);
+ }
+ buffer.append(')');
+ }
+ return buffer.toString();
+ }
+
+ public static String annotationToString(IBinaryTypeAnnotation typeAnnotation) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(typeAnnotation.getAnnotation());
+ buffer.append(' ');
+ // Not fully decoding it here, just including all the information in the string
+ buffer.append("target_type=").append(typeAnnotation.getTargetType()); //$NON-NLS-1$
+ buffer.append(", info=").append(typeAnnotation.getSupertypeIndex()); //$NON-NLS-1$
+ buffer.append(", info2=").append(typeAnnotation.getBoundIndex()); //$NON-NLS-1$
+ int[] theTypePath = typeAnnotation.getTypePath();
+ if (theTypePath != null && theTypePath.length != 0) {
+ buffer.append(", location=["); //$NON-NLS-1$
+ for (int i = 0, max = theTypePath.length; i < max; i += 2) {
+ if (i > 0) {
+ buffer.append(", "); //$NON-NLS-1$
+ }
+ switch (theTypePath[i]) {
+ case 0:
+ buffer.append("ARRAY"); //$NON-NLS-1$
+ break;
+ case 1:
+ buffer.append("INNER_TYPE"); //$NON-NLS-1$
+ break;
+ case 2:
+ buffer.append("WILDCARD"); //$NON-NLS-1$
+ break;
+ case 3:
+ buffer.append("TYPE_ARGUMENT(").append(theTypePath[i+1]).append(')'); //$NON-NLS-1$
+ break;
+ }
+ }
+ buffer.append(']');
+ }
+ return buffer.toString();
+ }
+
+ public static String methodToString(IBinaryMethod method) {
+ StringBuffer result = new StringBuffer();
+ methodToStringContent(result, method);
+ return result.toString();
+ }
+
+ public static void methodToStringContent(StringBuffer buffer, IBinaryMethod method) {
+ int modifiers = method.getModifiers();
+ char[] desc = method.getGenericSignature();
+ if (desc == null)
+ desc = method.getMethodDescriptor();
+ buffer
+ .append('{')
+ .append(
+ ((modifiers & ClassFileConstants.AccDeprecated) != 0 ? "deprecated " : Util.EMPTY_STRING) //$NON-NLS-1$
+ + ((modifiers & 0x0001) == 1 ? "public " : Util.EMPTY_STRING) //$NON-NLS-1$
+ + ((modifiers & 0x0002) == 0x0002 ? "private " : Util.EMPTY_STRING) //$NON-NLS-1$
+ + ((modifiers & 0x0004) == 0x0004 ? "protected " : Util.EMPTY_STRING) //$NON-NLS-1$
+ + ((modifiers & 0x0008) == 0x000008 ? "static " : Util.EMPTY_STRING) //$NON-NLS-1$
+ + ((modifiers & 0x0010) == 0x0010 ? "final " : Util.EMPTY_STRING) //$NON-NLS-1$
+ + ((modifiers & 0x0040) == 0x0040 ? "bridge " : Util.EMPTY_STRING) //$NON-NLS-1$
+ + ((modifiers & 0x0080) == 0x0080 ? "varargs " : Util.EMPTY_STRING)) //$NON-NLS-1$
+ .append(method.getSelector())
+ .append(desc)
+ .append('}');
+
+ Object defaultValue = method.getDefaultValue();
+ if (defaultValue != null) {
+ buffer.append(" default "); //$NON-NLS-1$
+ if (defaultValue instanceof Object[]) {
+ buffer.append('{');
+ Object[] elements = (Object[]) defaultValue;
+ for (int i = 0, len = elements.length; i < len; i++) {
+ if (i > 0)
+ buffer.append(", "); //$NON-NLS-1$
+ buffer.append(elements[i]);
+ }
+ buffer.append('}');
+ } else {
+ buffer.append(defaultValue);
+ }
+ buffer.append('\n');
+ }
+
+ IBinaryAnnotation[] annotations = method.getAnnotations();
+ for (int i = 0, l = annotations == null ? 0 : annotations.length; i < l; i++) {
+ buffer.append(annotations[i]);
+ buffer.append('\n');
+ }
+
+ int annotatedParameterCount = method.getAnnotatedParametersCount();
+ for (int i = 0; i < annotatedParameterCount; i++) {
+ buffer.append("param" + (i - 1)); //$NON-NLS-1$
+ buffer.append('\n');
+ IBinaryAnnotation[] infos = method.getParameterAnnotations(i, new char[0]);
+ for (int j = 0, k = infos == null ? 0 : infos.length; j < k; j++) {
+ buffer.append(infos[j]);
+ buffer.append('\n');
+ }
+ }
+ }
+
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java
index 5b5d2a1..526c325 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -19,29 +19,31 @@
package org.eclipse.jdt.internal.compiler.classfmt;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.codegen.AnnotationTargetTypeConstants;
import org.eclipse.jdt.internal.compiler.codegen.AttributeNamesConstants;
-import org.eclipse.jdt.internal.compiler.env.*;
+import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
+import org.eclipse.jdt.internal.compiler.env.IBinaryElementValuePair;
+import org.eclipse.jdt.internal.compiler.env.IBinaryField;
+import org.eclipse.jdt.internal.compiler.env.IBinaryMethod;
+import org.eclipse.jdt.internal.compiler.env.IBinaryNestedType;
+import org.eclipse.jdt.internal.compiler.env.IBinaryType;
+import org.eclipse.jdt.internal.compiler.env.IBinaryTypeAnnotation;
+import org.eclipse.jdt.internal.compiler.env.ITypeAnnotationWalker;
import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.ExternalAnnotationStatus;
import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
import org.eclipse.jdt.internal.compiler.lookup.TagBits;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.ExternalAnnotationStatus;
import org.eclipse.jdt.internal.compiler.util.Util;
import org.eclipse.objectteams.otdt.core.compiler.IOTConstants;
import org.eclipse.objectteams.otdt.internal.core.compiler.bytecode.*;
@@ -94,8 +96,6 @@
private char[][][] missingTypeNames;
private int enclosingNameAndTypeIndex;
private char[] enclosingMethod;
- private ExternalAnnotationProvider annotationProvider;
- private ExternalAnnotationStatus externalAnnotationStatus = ExternalAnnotationStatus.NOT_EEA_CONFIGURED;
private static String printTypeModifiers(int modifiers) {
java.io.ByteArrayOutputStream out = new java.io.ByteArrayOutputStream();
@@ -528,60 +528,9 @@
}
}
-/** Auxiliary interface for {@link #setExternalAnnotationProvider(String,String,ZipFile,ZipFileProducer)}. */
-public interface ZipFileProducer { ZipFile produce() throws IOException; }
-
-/**
- * Create and remember a provider for external annotations using the given basePath,
- * which is either a directory holding .eea text files, or a zip file of entries of the same format.
- * @param basePath resolved filesystem path of either directory or zip file
- * @param qualifiedBinaryTypeName slash-separated type name
- * @param zipFile an existing zip file for the same basePath, or null.
- * Output: wl be filled with
- * @param producer an optional helper to produce the zipFile when needed.
- * @return the client provided zip file;
- * or else a fresh new zip file, to let clients cache it, if desired;
- * or null to signal that basePath is not a zip file, but a directory.
- * @throws IOException any unexpected errors during file access. File not found while
- * accessing an individual file if basePath is a directory <em>is</em> expected,
- * and simply answered with null. If basePath is neither a directory nor a zip file,
- * this is unexpected.
- */
-public ZipFile setExternalAnnotationProvider(String basePath, String qualifiedBinaryTypeName, ZipFile zipFile, ZipFileProducer producer) throws IOException {
- this.externalAnnotationStatus = ExternalAnnotationStatus.NO_EEA_FILE;
- String qualifiedBinaryFileName = qualifiedBinaryTypeName + ExternalAnnotationProvider.ANNOTATION_FILE_SUFFIX;
- if (zipFile == null) {
- File annotationBase = new File(basePath);
- if (annotationBase.isDirectory()) {
- try {
- String filePath = annotationBase.getAbsolutePath()+'/'+qualifiedBinaryFileName;
- this.annotationProvider = new ExternalAnnotationProvider(new FileInputStream(filePath), String.valueOf(getName()));
- this.externalAnnotationStatus = ExternalAnnotationStatus.TYPE_IS_ANNOTATED;
- } catch (FileNotFoundException e) {
- // expected, no need to report an error here
- }
- return null; // no zipFile
- }
- if (!annotationBase.exists())
- return null; // no zipFile, treat as not-yet-created directory
- zipFile = (producer != null ? producer.produce() : new ZipFile(annotationBase));
- }
- ZipEntry entry = zipFile.getEntry(qualifiedBinaryFileName);
- if (entry != null) {
- this.annotationProvider = new ExternalAnnotationProvider(zipFile.getInputStream(entry), String.valueOf(getName()));
- this.externalAnnotationStatus = ExternalAnnotationStatus.TYPE_IS_ANNOTATED;
- }
- return zipFile;
-}
-public boolean hasAnnotationProvider() {
- return this.annotationProvider != null;
-}
-public void markAsFromSource() {
- this.externalAnnotationStatus = ExternalAnnotationStatus.FROM_SOURCE;
-}
@Override
public ExternalAnnotationStatus getExternalAnnotationStatus() {
- return this.externalAnnotationStatus;
+ return ExternalAnnotationStatus.NOT_EEA_CONFIGURED;
}
/**
* Conditionally add external annotations to the mix.
@@ -590,23 +539,6 @@
*/
@Override
public ITypeAnnotationWalker enrichWithExternalAnnotationsFor(ITypeAnnotationWalker walker, Object member, LookupEnvironment environment) {
- if (walker == ITypeAnnotationWalker.EMPTY_ANNOTATION_WALKER && this.annotationProvider != null) {
- if (member == null) {
- return this.annotationProvider.forTypeHeader(environment);
- } else if (member instanceof IBinaryField) {
- IBinaryField field = (IBinaryField) member;
- char[] fieldSignature = field.getGenericSignature();
- if (fieldSignature == null)
- fieldSignature = field.getTypeName();
- return this.annotationProvider.forField(field.getName(), fieldSignature, environment);
- } else if (member instanceof IBinaryMethod) {
- IBinaryMethod method = (IBinaryMethod) member;
- char[] methodSignature = method.getGenericSignature();
- if (methodSignature == null)
- methodSignature = method.getMethodDescriptor();
- return this.annotationProvider.forMethod(method.isConstructor() ? TypeConstants.INIT : method.getSelector(), methodSignature, environment);
- }
- }
return walker;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ElementValuePairInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ElementValuePairInfo.java
index 5a40c0d..b3a3872 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ElementValuePairInfo.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ElementValuePairInfo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2010 BEA Systems, Inc.
+ * Copyright (c) 2005, 2016 BEA Systems, Inc.
* 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
@@ -22,7 +22,7 @@
private char[] name;
private Object value;
-ElementValuePairInfo(char[] name, Object value) {
+public ElementValuePairInfo(char[] name, Object value) {
this.name = name;
this.value = value;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ExternalAnnotationDecorator.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ExternalAnnotationDecorator.java
new file mode 100644
index 0000000..f379a7e
--- /dev/null
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ExternalAnnotationDecorator.java
@@ -0,0 +1,290 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Google, Inc. 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:
+ * Stefan Xenos <sxenos@gmail.com> (Google) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.compiler.classfmt;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
+import org.eclipse.jdt.internal.compiler.env.IBinaryField;
+import org.eclipse.jdt.internal.compiler.env.IBinaryMethod;
+import org.eclipse.jdt.internal.compiler.env.IBinaryNestedType;
+import org.eclipse.jdt.internal.compiler.env.IBinaryType;
+import org.eclipse.jdt.internal.compiler.env.IBinaryTypeAnnotation;
+import org.eclipse.jdt.internal.compiler.env.ITypeAnnotationWalker;
+import org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.ExternalAnnotationStatus;
+import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
+import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
+
+/**
+ * A decorator for {@link IBinaryType} that allows external annotations to be attached. This can be used to change the
+ * result of {@link #enrichWithExternalAnnotationsFor} or {@link #getExternalAnnotationStatus}.
+ */
+public class ExternalAnnotationDecorator implements IBinaryType {
+ private IBinaryType inputType;
+ private ExternalAnnotationProvider annotationProvider;
+ private boolean isFromSource;
+
+ /** Auxiliary interface for {@link #getAnnotationZipFile(String, ZipFileProducer)}. */
+ public interface ZipFileProducer { ZipFile produce() throws IOException; }
+
+ public ExternalAnnotationDecorator(IBinaryType toDecorate, ExternalAnnotationProvider externalAnnotationProvider) {
+ if (toDecorate == null) {
+ throw new NullPointerException("toDecorate"); //$NON-NLS-1$
+ }
+ this.inputType = toDecorate;
+ this.annotationProvider = externalAnnotationProvider;
+ }
+
+ public ExternalAnnotationDecorator(IBinaryType toDecorate, boolean isFromSource) {
+ if (toDecorate == null) {
+ throw new NullPointerException("toDecorate"); //$NON-NLS-1$
+ }
+ this.isFromSource = isFromSource;
+ this.inputType = toDecorate;
+ }
+
+ @Override
+ public char[] getFileName() {
+ return this.inputType.getFileName();
+ }
+
+ @Override
+ public boolean isBinaryType() {
+ return this.inputType.isBinaryType();
+ }
+
+ @Override
+ public IBinaryAnnotation[] getAnnotations() {
+ return this.inputType.getAnnotations();
+ }
+
+ @Override
+ public IBinaryTypeAnnotation[] getTypeAnnotations() {
+ return this.inputType.getTypeAnnotations();
+ }
+
+ @Override
+ public char[] getEnclosingMethod() {
+ return this.inputType.getEnclosingMethod();
+ }
+
+ @Override
+ public char[] getEnclosingTypeName() {
+ return this.inputType.getEnclosingTypeName();
+ }
+
+ @Override
+ public IBinaryField[] getFields() {
+ return this.inputType.getFields();
+ }
+
+ @Override
+ public char[] getGenericSignature() {
+ return this.inputType.getGenericSignature();
+ }
+
+ @Override
+ public char[][] getInterfaceNames() {
+ return this.inputType.getInterfaceNames();
+ }
+
+ @Override
+ public IBinaryNestedType[] getMemberTypes() {
+ return this.inputType.getMemberTypes();
+ }
+
+ @Override
+ public IBinaryMethod[] getMethods() {
+ return this.inputType.getMethods();
+ }
+
+ @Override
+ public char[][][] getMissingTypeNames() {
+ return this.inputType.getMissingTypeNames();
+ }
+
+ @Override
+ public char[] getName() {
+ return this.inputType.getName();
+ }
+
+ @Override
+ public char[] getSourceName() {
+ return this.inputType.getSourceName();
+ }
+
+ @Override
+ public char[] getSuperclassName() {
+ return this.inputType.getSuperclassName();
+ }
+
+ @Override
+ public long getTagBits() {
+ return this.inputType.getTagBits();
+ }
+
+ @Override
+ public boolean isAnonymous() {
+ return this.inputType.isAnonymous();
+ }
+
+ @Override
+ public boolean isLocal() {
+ return this.inputType.isLocal();
+ }
+
+ @Override
+ public boolean isMember() {
+ return this.inputType.isMember();
+ }
+
+ @Override
+ public char[] sourceFileName() {
+ return this.inputType.sourceFileName();
+ }
+
+ @Override
+ public int getModifiers() {
+ return this.inputType.getModifiers();
+ }
+
+ /**
+ * Returns the zip file containing external annotations, if any. Returns null if there are no external annotations
+ * or if the basePath refers to a directory.
+ *
+ * @param basePath
+ * resolved filesystem path of either directory or zip file
+ * @param producer
+ * an optional helper to produce the zipFile when needed.
+ * @return the client provided zip file; or else a fresh new zip file, to let clients cache it, if desired; or null
+ * to signal that basePath is not a zip file, but a directory.
+ * @throws IOException
+ * any unexpected errors during file access. File not found while accessing an individual file if
+ * basePath is a directory <em>is</em> expected, and simply answered with null. If basePath is neither a
+ * directory nor a zip file, this is unexpected.
+ */
+ public static ZipFile getAnnotationZipFile(String basePath, ZipFileProducer producer) throws IOException {
+ File annotationBase = new File(basePath);
+ if (!annotationBase.isFile()) {
+ return null;
+ }
+ return (producer != null ? producer.produce() : new ZipFile(annotationBase));
+ }
+
+ /**
+ * Creates an external annotation provider for external annotations using the given basePath, which is either a
+ * directory holding .eea text files, or a zip file of entries of the same format.
+ *
+ * @param basePath
+ * resolved filesystem path of either directory or zip file
+ * @param qualifiedBinaryTypeName
+ * slash-separated type name
+ * @param zipFile
+ * an existing zip file for the same basePath, or null.
+ * @return the annotation provider or null if there are no external annotations.
+ * @throws IOException
+ * any unexpected errors during file access. File not found while accessing an individual file if
+ * basePath is a directory <em>is</em> expected, and simply answered with null. If basePath is neither a
+ * directory nor a zip file, this is unexpected.
+ */
+ public static ExternalAnnotationProvider externalAnnotationProvider(String basePath, String qualifiedBinaryTypeName,
+ ZipFile zipFile) throws IOException {
+ String qualifiedBinaryFileName = qualifiedBinaryTypeName + ExternalAnnotationProvider.ANNOTATION_FILE_SUFFIX;
+ if (zipFile == null) {
+ File annotationBase = new File(basePath);
+ if (annotationBase.isDirectory()) {
+ String filePath = annotationBase.getAbsolutePath() + '/' + qualifiedBinaryFileName;
+ try {
+ return new ExternalAnnotationProvider(new FileInputStream(filePath), qualifiedBinaryTypeName);
+ } catch (FileNotFoundException e) {
+ // Expected, no need to report an error here
+ return null;
+ }
+ }
+ } else {
+ ZipEntry entry = zipFile.getEntry(qualifiedBinaryFileName);
+ if (entry != null) {
+ return new ExternalAnnotationProvider(zipFile.getInputStream(entry), qualifiedBinaryTypeName);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Possibly wrap the provided binary type in a ClassWithExternalAnnotations to which a fresh provider for external
+ * annotations is associated. This provider is constructed using the given basePath, which is either a directory
+ * holding .eea text files, or a zip file of entries of the same format. If no such provider could be constructed,
+ * then the original binary type is returned unchanged.
+ *
+ * @param toDecorate
+ * the binary type to wrap, if needed
+ * @param basePath
+ * resolved filesystem path of either directory or zip file
+ * @param qualifiedBinaryTypeName
+ * slash-separated type name
+ * @param zipFile
+ * an existing zip file for the same basePath, or null.
+ * @return either a fresh ClassWithExternalAnnotations or the original binary type unchanged.
+ * @throws IOException
+ * any unexpected errors during file access. File not found while accessing an individual file if
+ * basePath is a directory <em>is</em> expected, and simply handled by not setting up an external
+ * annotation provider. If basePath is neither a directory nor a zip file, this is unexpected, resulting
+ * in an exception.
+ */
+ public static IBinaryType create(IBinaryType toDecorate, String basePath,
+ String qualifiedBinaryTypeName, ZipFile zipFile) throws IOException {
+ ExternalAnnotationProvider externalAnnotationProvider = externalAnnotationProvider(basePath, qualifiedBinaryTypeName, zipFile);
+ if (externalAnnotationProvider == null)
+ return toDecorate;
+ return new ExternalAnnotationDecorator(toDecorate, externalAnnotationProvider);
+ }
+
+ @Override
+ public ITypeAnnotationWalker enrichWithExternalAnnotationsFor(ITypeAnnotationWalker walker, Object member,
+ LookupEnvironment environment) {
+ if (walker == ITypeAnnotationWalker.EMPTY_ANNOTATION_WALKER && this.annotationProvider != null) {
+ if (member == null) {
+ return this.annotationProvider.forTypeHeader(environment);
+ } else if (member instanceof IBinaryField) {
+ IBinaryField field = (IBinaryField) member;
+ char[] fieldSignature = field.getGenericSignature();
+ if (fieldSignature == null)
+ fieldSignature = field.getTypeName();
+ return this.annotationProvider.forField(field.getName(), fieldSignature, environment);
+ } else if (member instanceof IBinaryMethod) {
+ IBinaryMethod method = (IBinaryMethod) member;
+ char[] methodSignature = method.getGenericSignature();
+ if (methodSignature == null)
+ methodSignature = method.getMethodDescriptor();
+ return this.annotationProvider.forMethod(
+ method.isConstructor() ? TypeConstants.INIT : method.getSelector(), methodSignature,
+ environment);
+ }
+ }
+ return walker;
+ }
+
+ @Override
+ public ExternalAnnotationStatus getExternalAnnotationStatus() {
+ if (this.annotationProvider == null) {
+ if (this.isFromSource) {
+ return ExternalAnnotationStatus.FROM_SOURCE;
+ }
+ return ExternalAnnotationStatus.NO_EEA_FILE;
+ }
+ return ExternalAnnotationStatus.TYPE_IS_ANNOTATED;
+ }
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java
index 4e2724d..6033dc8 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -36,7 +36,7 @@
import org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.util.Util;
+import org.eclipse.jdt.internal.core.nd.java.JavaNames;
import org.eclipse.objectteams.otdt.internal.core.compiler.bytecode.AbstractAttribute;
import org.eclipse.objectteams.otdt.internal.core.compiler.bytecode.AnchorListAttribute;
import org.eclipse.objectteams.otdt.internal.core.compiler.bytecode.CopyInheritanceSourceAttribute;
@@ -326,6 +326,7 @@
if (result != 0) return result;
return new String(getMethodDescriptor()).compareTo(new String(otherMethod.getMethodDescriptor()));
}
+@Override
public boolean equals(Object o) {
if (!(o instanceof MethodInfo)) {
return false;
@@ -334,6 +335,7 @@
return CharOperation.equals(getSelector(), otherMethod.getSelector())
&& CharOperation.equals(getMethodDescriptor(), otherMethod.getMethodDescriptor());
}
+@Override
public int hashCode() {
return CharOperation.hashCode(getSelector()) + CharOperation.hashCode(getMethodDescriptor());
}
@@ -457,16 +459,14 @@
* @return boolean
*/
public boolean isClinit() {
- char[] selector = getSelector();
- return selector[0] == '<' && selector.length == 8; // Can only match <clinit>
+ return JavaNames.isClinit(getSelector());
}
/**
* Answer true if the method is a constructor, false otherwise.
* @return boolean
*/
public boolean isConstructor() {
- char[] selector = getSelector();
- return selector[0] == '<' && selector.length == 6; // Can only match <init>
+ return JavaNames.isConstructor(getSelector());
}
/**
* Return true if the field is a synthetic method, false otherwise.
@@ -599,6 +599,7 @@
return this.attributeBytes;
}
+@Override
public String toString() {
StringBuffer buffer = new StringBuffer();
toString(buffer);
@@ -609,24 +610,7 @@
toStringContent(buffer);
}
protected void toStringContent(StringBuffer buffer) {
- int modifiers = getModifiers();
- char[] desc = getGenericSignature();
- if (desc == null)
- desc = getMethodDescriptor();
- buffer
- .append('{')
- .append(
- ((modifiers & ClassFileConstants.AccDeprecated) != 0 ? "deprecated " : Util.EMPTY_STRING) //$NON-NLS-1$
- + ((modifiers & 0x0001) == 1 ? "public " : Util.EMPTY_STRING) //$NON-NLS-1$
- + ((modifiers & 0x0002) == 0x0002 ? "private " : Util.EMPTY_STRING) //$NON-NLS-1$
- + ((modifiers & 0x0004) == 0x0004 ? "protected " : Util.EMPTY_STRING) //$NON-NLS-1$
- + ((modifiers & 0x0008) == 0x000008 ? "static " : Util.EMPTY_STRING) //$NON-NLS-1$
- + ((modifiers & 0x0010) == 0x0010 ? "final " : Util.EMPTY_STRING) //$NON-NLS-1$
- + ((modifiers & 0x0040) == 0x0040 ? "bridge " : Util.EMPTY_STRING) //$NON-NLS-1$
- + ((modifiers & 0x0080) == 0x0080 ? "varargs " : Util.EMPTY_STRING)) //$NON-NLS-1$
- .append(getSelector())
- .append(desc)
- .append('}');
+ BinaryTypeFormatter.methodToStringContent(buffer, this);
}
private void readCodeAttribute() {
int attributesCount = u2At(6);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfoWithAnnotations.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfoWithAnnotations.java
index 4db5b95..c2621f4 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfoWithAnnotations.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfoWithAnnotations.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 BEA Systems, Inc.
+ * Copyright (c) 2005, 2016 BEA Systems, Inc.
* 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
@@ -43,11 +43,4 @@
this.annotations[i].reset();
super.reset();
}
-protected void toStringContent(StringBuffer buffer) {
- super.toStringContent(buffer);
- for (int i = 0, l = this.annotations == null ? 0 : this.annotations.length; i < l; i++) {
- buffer.append(this.annotations[i]);
- buffer.append('\n');
- }
-}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfoWithParameterAnnotations.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfoWithParameterAnnotations.java
index d29206f..3fa81eb 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfoWithParameterAnnotations.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfoWithParameterAnnotations.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2015 BEA Systems, Inc.
+ * Copyright (c) 2005, 2016 BEA Systems, Inc.
* 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
@@ -61,16 +61,4 @@
}
super.reset();
}
-protected void toStringContent(StringBuffer buffer) {
- super.toStringContent(buffer);
- for (int i = 0, l = this.parameterAnnotations == null ? 0 : this.parameterAnnotations.length; i < l; i++) {
- buffer.append("param" + (i - 1)); //$NON-NLS-1$
- buffer.append('\n');
- AnnotationInfo[] infos = this.parameterAnnotations[i];
- for (int j = 0, k = infos == null ? 0 : infos.length; j < k; j++) {
- buffer.append(infos[j]);
- buffer.append('\n');
- }
- }
-}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfoWithTypeAnnotations.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfoWithTypeAnnotations.java
index 54c75dc..d2f7db6 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfoWithTypeAnnotations.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfoWithTypeAnnotations.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 GoPivotal, Inc. All Rights Reserved.
+ * Copyright (c) 2016 GoPivotal, Inc. All Rights Reserved.
* 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
@@ -36,12 +36,4 @@
}
super.reset();
}
-protected void toStringContent(StringBuffer buffer) {
- super.toStringContent(buffer);
- buffer.append("type annotations = \n");//$NON-NLS-1$
- for (int i = 0, l = this.typeAnnotations == null ? 0 : this.typeAnnotations.length; i < l; i++) {
- buffer.append(this.typeAnnotations[i].toString());
- buffer.append('\n');
- }
-}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/TypeAnnotationInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/TypeAnnotationInfo.java
index f58de40..1472b3c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/TypeAnnotationInfo.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/TypeAnnotationInfo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 GoPivotal, Inc. All Rights Reserved.
+ * Copyright (c) 2016 GoPivotal, Inc. All Rights Reserved.
* 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
@@ -123,40 +123,9 @@
}
public String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer.append(this.annotation);
- buffer.append(' ');
- // Not fully decoding it here, just including all the information in the string
- buffer.append("target_type=").append(this.targetType); //$NON-NLS-1$
- buffer.append(", info=").append(this.info); //$NON-NLS-1$
- buffer.append(", info2=").append(this.info2); //$NON-NLS-1$
- if (this.typePath != NO_TYPE_PATH) {
- buffer.append(", location=["); //$NON-NLS-1$
- for (int i = 0, max = this.typePath.length; i < max; i += 2) {
- if (i > 0) {
- buffer.append(", "); //$NON-NLS-1$
- }
- switch (this.typePath[i]) {
- case 0:
- buffer.append("ARRAY"); //$NON-NLS-1$
- break;
- case 1:
- buffer.append("INNER_TYPE"); //$NON-NLS-1$
- break;
- case 2:
- buffer.append("WILDCARD"); //$NON-NLS-1$
- break;
- case 3:
- buffer.append("TYPE_ARGUMENT(").append(this.typePath[i+1]).append(')'); //$NON-NLS-1$
- break;
- }
- }
- buffer.append(']');
- }
- return buffer.toString();
+ return BinaryTypeFormatter.annotationToString(this);
}
-
public int getTargetType() {
return this.targetType;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java
index f49d64c..f7709c4 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java
@@ -2716,6 +2716,8 @@
methodKind = ClassFileConstants.MethodHandleRefKindInvokeSpecial;
} else if (mb.isConstructor()) {
methodKind = ClassFileConstants.MethodHandleRefKindNewInvokeSpecial;
+ } else if (mb.declaringClass.isInterface()) {
+ methodKind = ClassFileConstants.MethodHandleRefKindInvokeInterface;
} else {
methodKind = ClassFileConstants.MethodHandleRefKindInvokeVirtual;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/NameEnvironmentAnswer.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/NameEnvironmentAnswer.java
index bc79c2f..03b8563 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/NameEnvironmentAnswer.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/NameEnvironmentAnswer.java
@@ -34,15 +34,44 @@
this.accessRestriction = accessRestriction;
this.externalAnnotationPath = externalAnnotationPath;
}
+
+ @Override
+ public String toString() {
+ String baseString = ""; //$NON-NLS-1$
+ if (this.binaryType != null) {
+ char[] fileNameChars = this.binaryType.getFileName();
+ String fileName = fileNameChars == null ? "" : new String(fileNameChars); //$NON-NLS-1$
+ baseString = "IBinaryType " + fileName; //$NON-NLS-1$
+ }
+ if (this.compilationUnit != null) {
+ baseString = "ICompilationUnit " + this.compilationUnit.toString(); //$NON-NLS-1$
+ }
+ if (this.sourceTypes != null) {
+ baseString = this.sourceTypes.toString();
+ }
+ if (this.accessRestriction != null) {
+ baseString += " " + this.accessRestriction.toString(); //$NON-NLS-1$
+ }
+ if (this.externalAnnotationPath != null) {
+ baseString += " extPath=" + this.externalAnnotationPath.toString(); //$NON-NLS-1$
+ }
+ return baseString;
+ }
+
/**
* Returns the associated access restriction, or null if none.
*/
public AccessRestriction getAccessRestriction() {
return this.accessRestriction;
}
+
+ public void setBinaryType(IBinaryType newType) {
+ this.binaryType = newType;
+ }
+
/**
- * Answer the resolved binary form for the type or null if the
- * receiver represents a compilation unit or source type.
+ * Answer the resolved binary form for the type or null if the receiver represents a compilation unit or source
+ * type.
*/
public IBinaryType getBinaryType() {
return this.binaryType;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ExceptionInferenceFlowContext.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ExceptionInferenceFlowContext.java
index a94d4d0..172e28e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ExceptionInferenceFlowContext.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ExceptionInferenceFlowContext.java
@@ -19,7 +19,7 @@
* try statements, exception handlers, etc...
*/
-public class ExceptionInferenceFlowContext extends ExceptionHandlingFlowContext {
+public class ExceptionInferenceFlowContext extends FieldInitsFakingFlowContext {
public ExceptionInferenceFlowContext(
FlowContext parent,
ASTNode associatedNode,
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FieldInitsFakingFlowContext.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FieldInitsFakingFlowContext.java
new file mode 100644
index 0000000..35e1b94
--- /dev/null
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FieldInitsFakingFlowContext.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Till Brychcy 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:
+ * Till Brychcy - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.compiler.flow;
+
+import org.eclipse.jdt.internal.compiler.ast.ASTNode;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
+
+/**
+ * For instances of this class,
+ * {@link FlowContext#getInitsForFinalBlankInitializationCheck(org.eclipse.jdt.internal.compiler.lookup.TypeBinding, FlowInfo)}
+ * will returns a {@link FlowInfo#DEAD_END}, which for which
+ * {@link FlowInfo#isDefinitelyAssigned(org.eclipse.jdt.internal.compiler.lookup.FieldBinding)} returns true for all
+ * fields.
+ */
+
+public class FieldInitsFakingFlowContext extends ExceptionHandlingFlowContext {
+ public FieldInitsFakingFlowContext(
+ FlowContext parent,
+ ASTNode associatedNode,
+ ReferenceBinding[] handledExceptions,
+ FlowContext initializationParent,
+ BlockScope scope,
+ UnconditionalFlowInfo flowInfo) {
+ super(parent, associatedNode, handledExceptions, initializationParent, scope, flowInfo);
+}
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java
index e75997d..ce65992 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java
@@ -514,6 +514,9 @@
inits = initializationContext.initsBeforeContext;
current = initializationContext.initializationParent;
} else if (current instanceof ExceptionHandlingFlowContext) {
+ if(current instanceof FieldInitsFakingFlowContext) {
+ return FlowInfo.DEAD_END; // isDefinitelyAssigned will return true for all fields
+ }
ExceptionHandlingFlowContext exceptionContext = (ExceptionHandlingFlowContext) current;
current = exceptionContext.initializationParent == null ? exceptionContext.parent : exceptionContext.initializationParent;
} else {
@@ -521,7 +524,7 @@
}
} while (current != null);
// not found
- return null;
+ throw new IllegalStateException(declaringType.debugName());
}
/*
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java
index 0cc4f11..11a78f3 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java
@@ -1648,8 +1648,7 @@
int length = end - start + 1;
int count = 0;
for (int i = start; i <= end; i++) {
- int len = this.methods[i].parameters.length;
- if (len <= suggestedParameterLength || (this.methods[i].isVarargs() && len == suggestedParameterLength + 1))
+ if (this.methods[i].doesParameterLengthMatch(suggestedParameterLength))
count++;
}
if (count == 0) {
@@ -1662,8 +1661,7 @@
MethodBinding[] result = new MethodBinding[count];
// iterate methods to resolve them
for (int i = start, index = 0; i <= end; i++) {
- int len = this.methods[i].parameters.length;
- if (len <= suggestedParameterLength || (this.methods[i].isVarargs() && len == suggestedParameterLength + 1))
+ if (this.methods[i].doesParameterLengthMatch(suggestedParameterLength))
result[index++] = resolveTypesFor(this.methods[i]);
}
return result;
@@ -1671,6 +1669,7 @@
}
return Binding.NO_METHODS;
}
+
public boolean hasMemberTypes() {
if (!isPrototype())
return this.prototype.hasMemberTypes();
@@ -2126,7 +2125,9 @@
}
}
if (useNullTypeAnnotations && this.externalAnnotationStatus.isPotentiallyUnannotatedLib()) {
- if (methodBinding.returnType.hasNullTypeAnnotations()) {
+ if (methodBinding.returnType.hasNullTypeAnnotations()
+ || (methodBinding.tagBits & TagBits.AnnotationNullMASK) != 0
+ || methodBinding.parameterNonNullness != null) {
this.externalAnnotationStatus = ExternalAnnotationStatus.TYPE_IS_ANNOTATED;
} else {
for (TypeBinding parameter : parameters) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java
index a004158..b8ebe83 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java
@@ -849,19 +849,27 @@
// α = S and T <: α imply ⟨T <: S⟩
InferenceVariable alpha = boundS.left;
TypeBinding s = boundS.right;
- if (TypeBinding.equalsEquals(alpha,boundT.left))
- return ConstraintTypeFormula.create(s, boundT.right, boundT.relation, boundT.isSoft||boundS.isSoft);
- if (TypeBinding.equalsEquals(alpha, boundT.right))
- return ConstraintTypeFormula.create(boundT.right, s, boundT.relation, boundT.isSoft||boundS.isSoft);
+ if (TypeBinding.equalsEquals(alpha, boundT.left)) {
+ TypeBinding t = boundT.right;
+ return ConstraintTypeFormula.create(s, t, boundT.relation, boundT.isSoft||boundS.isSoft);
+ }
+ if (TypeBinding.equalsEquals(alpha, boundT.right)) {
+ TypeBinding t = boundT.left;
+ return ConstraintTypeFormula.create(t, s, boundT.relation, boundT.isSoft||boundS.isSoft);
+ }
if (boundS.right instanceof InferenceVariable) {
// reverse:
alpha = (InferenceVariable) boundS.right;
s = boundS.left;
- if (TypeBinding.equalsEquals(alpha, boundT.left))
- return ConstraintTypeFormula.create(s, boundT.right, boundT.relation, boundT.isSoft||boundS.isSoft);
- if (TypeBinding.equalsEquals(alpha, boundT.right))
- return ConstraintTypeFormula.create(boundT.right, s, boundT.relation, boundT.isSoft||boundS.isSoft);
+ if (TypeBinding.equalsEquals(alpha, boundT.left)) {
+ TypeBinding t = boundT.right;
+ return ConstraintTypeFormula.create(s, t, boundT.relation, boundT.isSoft||boundS.isSoft);
+ }
+ if (TypeBinding.equalsEquals(alpha, boundT.right)) {
+ TypeBinding t = boundT.left;
+ return ConstraintTypeFormula.create(t, s, boundT.relation, boundT.isSoft||boundS.isSoft);
+ }
}
// α = U and S <: T imply ⟨S[α:=U] <: T[α:=U]⟩
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java
index 59baf79..d9d49ee 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java
@@ -147,6 +147,7 @@
* e.g. given X<U, V extends X<U, V>>, capture(X<E,?>) = X<E,capture>, where capture extends X<E,capture>
*/
public void initializeBounds(Scope scope, ParameterizedTypeBinding capturedParameterizedType) {
+ boolean is18plus = scope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_8;
TypeVariableBinding wildcardVariable = this.wildcard.typeVariable();
if (wildcardVariable == null) {
// error resilience when capturing Zork<?>
@@ -155,7 +156,9 @@
switch (this.wildcard.boundKind) {
case Wildcard.EXTENDS :
// still need to capture bound supertype as well so as not to expose wildcards to the outside (111208)
- TypeBinding capturedWildcardBound = originalWildcardBound.capture(scope, this.start, this.end);
+ TypeBinding capturedWildcardBound = is18plus
+ ? originalWildcardBound // as spec'd
+ : originalWildcardBound.capture(scope, this.start, this.end); // for compatibility with old behavior at 1.7-
if (originalWildcardBound.isInterface()) {
this.setSuperClass(scope.getJavaLangObject());
this.setSuperInterfaces(new ReferenceBinding[] { (ReferenceBinding) capturedWildcardBound });
@@ -207,7 +210,9 @@
switch (this.wildcard.boundKind) {
case Wildcard.EXTENDS :
// still need to capture bound supertype as well so as not to expose wildcards to the outside (111208)
- TypeBinding capturedWildcardBound = originalWildcardBound.capture(scope, this.start, this.end);
+ TypeBinding capturedWildcardBound = is18plus
+ ? originalWildcardBound // as spec'd
+ : originalWildcardBound.capture(scope, this.start, this.end); // for compatibility with old behavior at 1.7-
//{ObjectTeams: is the bound a role type requiring wrapping?
if (capturedWildcardBound.isRole())
capturedWildcardBound = RoleTypeCreator.maybeWrapUnqualifiedRoleType(scope, capturedWildcardBound.enclosingType(), capturedWildcardBound, scope.methodScope().referenceMethod(), scope.problemReporter());
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ConstraintTypeFormula.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ConstraintTypeFormula.java
index 7ce5578..f1a3933 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ConstraintTypeFormula.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ConstraintTypeFormula.java
@@ -108,6 +108,9 @@
if (this.left.kind() != Binding.WILDCARD_TYPE) {
return ConstraintTypeFormula.create(this.left, this.right, SAME, this.isSoft);
} else {
+ // TODO: speculative addition:
+ if (this.right instanceof InferenceVariable)
+ return new TypeBound((InferenceVariable) this.right, this.left, SAME, this.isSoft);
return FALSE;
}
} else {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ImplicitNullAnnotationVerifier.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ImplicitNullAnnotationVerifier.java
index ad48663..4d5d04e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ImplicitNullAnnotationVerifier.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ImplicitNullAnnotationVerifier.java
@@ -15,6 +15,7 @@
import java.util.List;
import java.util.Set;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Argument;
@@ -202,11 +203,15 @@
private void collectOverriddenMethods(MethodBinding original, char[] selector, int suggestedParameterLength,
ReferenceBinding superType, Set ifcsSeen, List result)
{
- MethodBinding [] ifcMethods = superType.getMethods(selector, suggestedParameterLength);
+ MethodBinding [] ifcMethods = superType.unResolvedMethods();
int length = ifcMethods.length;
boolean added = false;
for (int i=0; i<length; i++) {
MethodBinding currentMethod = ifcMethods[i];
+ if (!CharOperation.equals(selector, currentMethod.selector))
+ continue;
+ if (!currentMethod.doesParameterLengthMatch(suggestedParameterLength))
+ continue;
if (currentMethod.isStatic())
continue;
if (MethodVerifier.doesMethodOverride(original, currentMethod, this.environment)) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java
index 6451ae5..e3995ce 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java
@@ -1880,7 +1880,7 @@
// type must be a ReferenceBinding at this point, cannot be a BaseTypeBinding or ArrayTypeBinding
ReferenceBinding actualType = (ReferenceBinding) type;
if (actualType instanceof UnresolvedReferenceBinding)
- if (CharOperation.indexOf('$', actualType.compoundName[actualType.compoundName.length - 1]) > 0)
+ if (actualType.depth() > 0)
actualType = (ReferenceBinding) BinaryTypeBinding.resolveType(actualType, this, false /* no raw conversion */); // must resolve member types before asking for enclosingType
ReferenceBinding actualEnclosing = actualType.enclosingType();
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java
index e8b1119..a52c037 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java
@@ -1922,4 +1922,8 @@
public boolean isVoidMethod() {
return this.returnType == TypeBinding.VOID;
}
+public boolean doesParameterLengthMatch(int suggestedParameterLength) {
+ int len = this.parameters.length;
+ return len <= suggestedParameterLength || (isVarargs() && len == suggestedParameterLength + 1);
+}
}
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 35727fe..fd2072a 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
@@ -250,6 +250,7 @@
problemReporter().illegalModifierForAnnotationMember((AbstractMethodDeclaration) this.referenceContext);
else
problemReporter().illegalModifierForInterfaceMethod((AbstractMethodDeclaration) this.referenceContext, isJDK18orGreater);
+ methodBinding.modifiers &= (expectedModifiers | ~ExtraCompilerModifiers.AccJustFlag);
}
return;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java
index 31928d6..41307d3 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 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
@@ -207,20 +207,7 @@
if (packageBinding != null && packageBinding != LookupEnvironment.TheNotFoundPackage) {
return packageBinding;
}
-
- if (packageBinding == null) { // have not looked for it before
- if ((packageBinding = findPackage(name)) != null) {
- return packageBinding;
- }
- if (referenceBinding != null && referenceBinding != LookupEnvironment.TheNotFoundType) {
- return referenceBinding; // found cached missing type - check if package conflict
- }
- addNotFoundPackage(name);
- }
-
if (referenceBinding == null) { // have not looked for it before
- //This call (to askForType) should be the last option to call, because the call is very expensive regarding performance
- // (a search for secondary types may get triggered which requires to parse all classes of a package).
if ((referenceBinding = this.environment.askForType(this, name)) != null) {
if (referenceBinding.isNestedType()) {
return new ProblemReferenceBinding(new char[][]{name}, referenceBinding, ProblemReasons.InternalNameProvided);
@@ -233,6 +220,16 @@
addNotFoundType(name);
}
+ if (packageBinding == null) { // have not looked for it before
+ if ((packageBinding = findPackage(name)) != null) {
+ return packageBinding;
+ }
+ if (referenceBinding != null && referenceBinding != LookupEnvironment.TheNotFoundType) {
+ return referenceBinding; // found cached missing type - check if package conflict
+ }
+ addNotFoundPackage(name);
+ }
+
return null;
}
public final boolean isViewedAsDeprecated() {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SignatureWrapper.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SignatureWrapper.java
index c76163a..a967cf2 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SignatureWrapper.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SignatureWrapper.java
@@ -192,6 +192,15 @@
return CharOperation.subarray(this.signature, this.start, this.signature.length);
}
public String toString() {
+ if (this.start >= 0 && this.start <= this.signature.length) {
+ return new String(CharOperation.subarray(this.signature, 0, this.start)) + " ^ " //$NON-NLS-1$
+ + new String(CharOperation.subarray(this.signature, this.start, this.signature.length));
+ }
+
return new String(this.signature) + " @ " + this.start; //$NON-NLS-1$
}
+
+ public char charAtStart() {
+ return this.signature[this.start];
+ }
}
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 3a8231a..e059649 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
@@ -182,9 +182,9 @@
private int nullnessDefaultInitialized = 0; // 0: nothing; 1: type; 2: package
private int lambdaOrdinal = 0;
private ReferenceBinding containerAnnotationType = null;
+
+ public ExternalAnnotationProvider externalAnnotationProvider;
- public ExternalAnnotationProvider externalAnnotationProvider;
-
public SourceTypeBinding(char[][] compoundName, PackageBinding fPackage, ClassScope scope) {
//{ObjectTeams: // share model from TypeDeclaration:
super(scope.referenceContext.getModel());
@@ -2430,7 +2430,7 @@
}
public MethodBinding resolveTypesFor(MethodBinding method, boolean fromSynthetic) {
// SH}
-
+
if (!isPrototype())
return this.prototype.resolveTypesFor(method);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java
index 6cbccb6..6d95fe9 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java
@@ -75,8 +75,9 @@
}
public int depth() {
// we don't yet have our enclosing types wired, but we know the nesting depth from our compoundName:
+ // (NOTE: this an upper bound, because class names may contain '$')
int last = this.compoundName.length-1;
- return CharOperation.occurencesOf('$', this.compoundName[last]);
+ return CharOperation.occurencesOf('$', this.compoundName[last], 1); // leading '$' must be part of the class name, so start at 1.
}
public boolean hasTypeBit(int bit) {
// shouldn't happen since we are not called before analyseCode(), but play safe:
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredInitializer.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredInitializer.java
index 09290e1..fdc72b2 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredInitializer.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredInitializer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -62,9 +62,11 @@
this.foundOpeningBrace = true;
this.bracketBalance++;
}
- this.initializerBody = new RecoveredBlock(nestedBlockDeclaration, this, bracketBalanceValue);
+ if (this.initializerBody == null) {
+ return this.initializerBody = new RecoveredBlock(nestedBlockDeclaration, this, bracketBalanceValue);
+ }
if (nestedBlockDeclaration.sourceEnd == 0) return this.initializerBody;
- return this;
+ return this.initializerBody.add(nestedBlockDeclaration, bracketBalanceValue, true);
}
/*
* Record a field declaration (act like inside method body)
@@ -109,18 +111,26 @@
return this.parent.add(localDeclaration, bracketBalanceValue);
}
/* method body should have been created */
- Block block = new Block(0);
- block.sourceStart = ((Initializer)this.fieldDeclaration).sourceStart;
- RecoveredElement element = this.add(block, 1);
- if (this.initializerBody != null) {
- this.initializerBody.attachPendingModifiers(
+ if (this.initializerBody == null) {
+ Block block = new Block(0);
+ block.sourceStart = ((Initializer)this.fieldDeclaration).sourceStart;
+ RecoveredElement element = this.add(block, 1);
+ if (this.bracketBalance > 0){
+ for (int i = 0; i < this.bracketBalance - 1; i++){
+ element = element.add(new Block(0), 1);
+ }
+ this.bracketBalance = 1;
+ }
+ return element.add(localDeclaration, bracketBalanceValue);
+ }
+ this.initializerBody.attachPendingModifiers(
this.pendingAnnotations,
this.pendingAnnotationCount,
this.pendingModifiers,
this.pendingModifersSourceStart);
- }
resetPendingModifiers();
- return element.add(localDeclaration, bracketBalanceValue);
+
+ return this.initializerBody.add(localDeclaration, bracketBalanceValue, true);
}
/*
* Record a statement - regular method should have been created a block body
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredMethod.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredMethod.java
index 7dd7b54..7e79ea1 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredMethod.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredMethod.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -99,7 +99,11 @@
this.bracketBalance++;
}
- this.methodBody = new RecoveredBlock(nestedBlockDeclaration, this, bracketBalanceValue);
+ if (this.methodBody != null) {
+ this.methodBody.addBlockStatement(new RecoveredBlock(nestedBlockDeclaration, this, bracketBalanceValue));
+ } else {
+ this.methodBody = new RecoveredBlock(nestedBlockDeclaration, this, bracketBalanceValue);
+ }
if (nestedBlockDeclaration.sourceEnd == 0) return this.methodBody;
return this;
}
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 827613a..8e7d097 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
@@ -4,7 +4,7 @@
* 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
* Benjamin Muskalla - Contribution for bug 239066
@@ -10090,7 +10090,11 @@
nullityMismatchSpecdNullable(expression, requiredType, annotationName);
return;
}
- nullityMismatchPotentiallyNull(expression, requiredType, annotationName);
+ if (expression instanceof ArrayReference && expression.resolvedType.isFreeTypeVariable()) {
+ nullityMismatchingTypeAnnotation(expression, providedType, requiredType, NullAnnotationMatching.NULL_ANNOTATIONS_MISMATCH);
+ return;
+ }
+ nullityMismatchPotentiallyNull(expression, requiredType, annotationName);
return;
}
if (this.options.usesNullTypeAnnotations())
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/LineBreaksPreparator.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/LineBreaksPreparator.java
index 96540d0..a5a11f3 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/LineBreaksPreparator.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/LineBreaksPreparator.java
@@ -289,18 +289,14 @@
if (node.getBody() == null)
return true;
- if (node.isConstructor()) {
- handleBracedCode(node.getBody(), null, this.options.brace_position_for_constructor_declaration,
- this.options.indent_statements_compare_to_body,
- this.options.insert_new_line_in_empty_method_body);
- } else {
- handleBracedCode(node.getBody(), null, this.options.brace_position_for_method_declaration,
- this.options.indent_statements_compare_to_body,
- this.options.insert_new_line_in_empty_method_body);
- Token openBrace = this.tm.firstTokenIn(node.getBody(), TokenNameLBRACE);
- if (openBrace.getLineBreaksAfter() > 0) // if not, these are empty braces
- openBrace.putLineBreaksAfter(this.options.blank_lines_at_beginning_of_method_body + 1);
- }
+ String bracePosition = node.isConstructor() ? this.options.brace_position_for_constructor_declaration
+ : this.options.brace_position_for_method_declaration;
+ handleBracedCode(node.getBody(), null, bracePosition,
+ this.options.indent_statements_compare_to_body,
+ this.options.insert_new_line_in_empty_method_body);
+ Token openBrace = this.tm.firstTokenIn(node.getBody(), TokenNameLBRACE);
+ if (openBrace.getLineBreaksAfter() > 0) // if not, these are empty braces
+ openBrace.putLineBreaksAfter(this.options.blank_lines_at_beginning_of_method_body + 1);
return true;
}
@@ -448,10 +444,6 @@
@Override
public boolean visit(NormalAnnotation node) {
handleAnnotation(node);
-
- int lParen = this.tm.firstIndexAfter(node.getTypeName(), TokenNameLPAREN);
- int rParen = this.tm.lastIndexIn(node, TokenNameRPAREN);
- handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_annotation);
return true;
}
@@ -551,6 +543,12 @@
}
if (breakAfter)
this.tm.lastTokenIn(node, -1).breakAfter();
+
+ if (!(node instanceof MarkerAnnotation)) {
+ int lParen = this.tm.firstIndexAfter(node.getTypeName(), TokenNameLPAREN);
+ int rParen = this.tm.lastIndexIn(node, TokenNameRPAREN);
+ handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_annotation);
+ }
}
@Override
@@ -819,7 +817,7 @@
//$FALL-THROUGH$
case DefaultCodeFormatterConstants.SEPARATE_LINES:
case DefaultCodeFormatterConstants.PRESERVE_POSITIONS:
- boolean always = positionsSetting != DefaultCodeFormatterConstants.PRESERVE_POSITIONS;
+ boolean always = !positionsSetting.equals(DefaultCodeFormatterConstants.PRESERVE_POSITIONS);
Token afterOpening = this.tm.get(openingParenIndex + 1);
if (always || this.tm.countLineBreaksBetween(this.tm.get(openingParenIndex), afterOpening) > 0) {
afterOpening.setWrapPolicy(
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapExecutor.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapExecutor.java
index 9783803..bd12cf7 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapExecutor.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapExecutor.java
@@ -122,6 +122,7 @@
*/
public int analyzeLine(int startIndex, int indent) {
Token startToken = WrapExecutor.this.tm.get(startIndex);
+ assert startToken.getLineBreaksBefore() > 0;
this.counter = WrapExecutor.this.tm.toIndent(indent, startToken.isWrappable());
this.lineIndent = indent;
this.firstPotentialWrap = -1;
@@ -170,11 +171,11 @@
if (this.lineExceeded && this.firstPotentialWrap >= 0) {
return false;
}
- if (!token.isNextLineOnWrap())
- token.setIndent(this.lineIndent);
+ token.setIndent(this.lineIndent);
- boolean isLineEnd = getLineBreaksAfter() > 0 || getNext() == null;
- assert !(token.isNextLineOnWrap() && !isLineEnd);
+ boolean isLineEnd = getLineBreaksAfter() > 0 || getNext() == null
+ || (getNext().isNextLineOnWrap() && WrapExecutor.this.tm
+ .get(WrapExecutor.this.tm.findFirstTokenInLine(index)).isWrappable());
return !isLineEnd;
}
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapPreparator.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapPreparator.java
index f745dd8..d59106d 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapPreparator.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapPreparator.java
@@ -586,13 +586,18 @@
prepareElementsList(expressions, TokenNameCOMMA, TokenNameLBRACE);
handleWrap(this.options.alignment_for_expressions_in_array_initializer, node);
}
+ int openingBraceIndex = this.tm.firstIndexIn(node, TokenNameLBRACE);
+ Token openingBrace = this.tm.get(openingBraceIndex);
+ if (openingBrace.isNextLineOnWrap() && openingBrace.getWrapPolicy() == null && openingBraceIndex > 0) {
+ // add fake wrap policy to make sure the brace indentation is right
+ openingBrace.setWrapPolicy(new WrapPolicy(WrapMode.DISABLED, openingBraceIndex - 1, 0));
+ }
if (!this.options.join_wrapped_lines
&& !this.options.insert_new_line_before_closing_brace_in_array_initializer) {
// if there is a line break before the closing brace, formatter should treat it as a valid wrap to preserve
int closingBraceIndex = this.tm.lastIndexIn(node, TokenNameRBRACE);
Token closingBrace = this.tm.get(closingBraceIndex);
if (this.tm.countLineBreaksBetween(this.tm.get(closingBraceIndex - 1), closingBrace) == 1) {
- int openingBraceIndex = this.tm.firstIndexIn(node, TokenNameLBRACE);
closingBrace.setWrapPolicy(new WrapPolicy(WrapMode.WHERE_NECESSARY, openingBraceIndex,
closingBraceIndex, 0, this.currentDepth, 1, true, false));
}
@@ -899,7 +904,7 @@
if (policy == null)
return;
- setTokenWrapPolicy(this.wrapIndexes.get(0), policy, true);
+ setTokenWrapPolicy(0, policy, true);
boolean wrapPreceedingComments = !(parentNode instanceof InfixExpression)
|| !this.options.wrap_before_binary_operator;
@@ -907,7 +912,7 @@
penalty = this.wrapPenalties.size() > i ? this.wrapPenalties.get(i) : 1;
if (penalty != policy.penaltyMultiplier || i == 1)
policy = getWrapPolicy(wrappingOption, penalty, false, parentNode);
- setTokenWrapPolicy(this.wrapIndexes.get(i), policy, wrapPreceedingComments);
+ setTokenWrapPolicy(i, policy, wrapPreceedingComments);
}
boolean forceWrap = (wrappingOption & Alignment.M_FORCE) != 0;
@@ -939,7 +944,8 @@
}
}
- private void setTokenWrapPolicy(int index, WrapPolicy policy, boolean wrapPreceedingComments) {
+ private void setTokenWrapPolicy(int wrapIndexesIndex, WrapPolicy policy, boolean wrapPreceedingComments) {
+ int index = this.wrapIndexes.get(wrapIndexesIndex);
if (wrapPreceedingComments) {
for (int i = index - 1; i >= 0; i--) {
Token previous = this.tm.get(i);
@@ -950,6 +956,7 @@
if (previous.getLineBreaksBefore() > 0)
previous.setWrapPolicy(policy);
}
+ this.wrapIndexes.set(wrapIndexesIndex, index);
}
Token token = this.tm.get(index);
@@ -972,6 +979,8 @@
} else if (parentNode instanceof EnumDeclaration) {
// special behavior for compatibility with legacy formatter
extraIndent = ((wrappingOption & Alignment.M_INDENT_BY_ONE) != 0) ? 2 : 1;
+ if (!this.options.indent_body_declarations_compare_to_enum_declaration_header)
+ extraIndent--;
isAlreadyWrapped = isFirst;
} else if (parentNode instanceof IfStatement) {
extraIndent = 1;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IOpenable.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IOpenable.java
index 0702061..515a8ff 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IOpenable.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IOpenable.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.jdt.core;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
/**
@@ -46,7 +47,7 @@
* Closes this element and its buffer (if any).
* Closing an element which is not open has no effect.
*
- * <p>Note: although {@link #close} is exposed in the API, clients are
+ * <p>Note: Although {@link #close} is exposed in the API, clients are
* not expected to open and close elements - the Java model does this automatically
* as elements are accessed.
*
@@ -114,6 +115,13 @@
boolean isConsistent() throws JavaModelException;
/**
* Returns whether this openable is open. This is a handle-only method.
+ *
+ * <p>Note: This method doesn't tell whether an {@link IJavaProject}'s {@link IJavaProject#getProject() getProject()} is open.
+ * It is <b>not</b> equivalent to {@link IProject#isOpen()}!</p>
+ *
+ * <p>Note: Although {@link #isOpen} is exposed in the API, clients
+ * rarely have a need to rely on this internal state of the Java model.</p>
+
* @return true if this openable is open, false otherwise
*/
boolean isOpen();
@@ -142,7 +150,7 @@
* Opens this element and all parent elements that are not already open.
* For compilation units, a buffer is opened on the contents of the underlying resource.
*
- * <p>Note: although {@link #open} is exposed in the API, clients are
+ * <p>Note: Although {@link #open} is exposed in the API, clients are
* not expected to open and close elements - the Java model does this automatically
* as elements are accessed.
*
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IType.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IType.java
index 5ee63a6..f215642 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IType.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IType.java
@@ -36,6 +36,11 @@
* <code>IMethod</code>, <code>IInitializer</code> and <code>IType</code>.
* The children are listed in the order in which they appear in the source or class file.
* </p>
+ * <p>
+ * Caveat: The {@link #getChildren() children} of a {@link #isBinary() binary} type include
+ * nested types. However, the {@link #getParent() parent} of such a nested binary type is
+ * <em>not</em> the enclosing type, but that nested type's {@link IClassFile}!
+ * </p>
*
* @noimplement This interface is not intended to be implemented by clients.
*/
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 84bd065..5eef533 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
@@ -157,6 +157,7 @@
import org.eclipse.jdt.internal.core.*;
import org.eclipse.jdt.internal.core.builder.JavaBuilder;
import org.eclipse.jdt.internal.core.builder.State;
+import org.eclipse.jdt.internal.core.nd.indexer.Indexer;
import org.eclipse.jdt.internal.core.util.MementoTokenizer;
import org.eclipse.jdt.internal.core.util.Messages;
import org.eclipse.jdt.internal.core.util.Util;
@@ -5877,5 +5878,6 @@
super.start(context);
JavaModelManager.registerDebugOptionsListener(context);
JavaModelManager.getJavaModelManager().startup();
+ Indexer.getInstance().rescanAll();
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/compiler/CompilationParticipant.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/compiler/CompilationParticipant.java
index c40c139..34ae1a2 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/compiler/CompilationParticipant.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/compiler/CompilationParticipant.java
@@ -101,8 +101,11 @@
* given project should return <code>false</code> for that project.
* </p><p>
* Note: In {@link org.eclipse.jdt.core.WorkingCopyOwner#newWorkingCopy(String, org.eclipse.jdt.core.IClasspathEntry[], org.eclipse.core.runtime.IProgressMonitor)
- * special cases}, the project may be closed and not exist. Participants typically return false for projects that are
- * !{@link IJavaProject#isOpen()}.
+ * special cases}, the project may be closed and not exist. Participants typically return false when the
+ * underlying project is closed. I.e. when the following check returns false:
+ * <pre>
+ * javaProject.getProject().isOpen();
+ * </pre>
* </p>
* @param project the project to participate in
* @return whether this participant is active for a given project
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ExternalAnnotationUtil.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ExternalAnnotationUtil.java
index 6d15fb2..dad8397 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ExternalAnnotationUtil.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ExternalAnnotationUtil.java
@@ -294,7 +294,7 @@
newContent.append('\n');
continue;
}
- if (!Character.isJavaIdentifierStart(line.charAt(0))) {
+ if (!Character.isJavaIdentifierStart(line.charAt(0)) && line.charAt(0) != '<') {
newContent.append(line).append('\n');
continue;
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryType.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryType.java
index f895be9..978704c 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryType.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryType.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java
index 000c463..9871f47 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -37,11 +37,15 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.*;
import org.eclipse.jdt.core.compiler.IProblem;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
+import org.eclipse.jdt.internal.compiler.classfmt.ExternalAnnotationDecorator;
+import org.eclipse.jdt.internal.compiler.classfmt.ExternalAnnotationProvider;
import org.eclipse.jdt.internal.compiler.env.IBinaryType;
-import org.eclipse.jdt.internal.compiler.env.IDependent;
import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
+import org.eclipse.jdt.internal.core.nd.java.JavaNames;
+import org.eclipse.jdt.internal.core.nd.java.model.BinaryTypeDescriptor;
+import org.eclipse.jdt.internal.core.nd.java.model.BinaryTypeFactory;
+import org.eclipse.jdt.internal.core.nd.util.CharArrayUtils;
import org.eclipse.jdt.internal.core.util.MementoTokenizer;
import org.eclipse.jdt.internal.core.util.Util;
import org.eclipse.objectteams.otdt.core.OTModelManager;
@@ -93,8 +97,9 @@
* @see Openable
* @see Signature
*/
+@Override
protected boolean buildStructure(OpenableElementInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws JavaModelException {
- IBinaryType typeInfo = getBinaryTypeInfo((IFile) underlyingResource);
+ IBinaryType typeInfo = getBinaryTypeInfo();
if (typeInfo == null) {
// The structure of a class file is unknown if a class file format errors occurred
//during the creation of the diet class file representative of this ClassFile.
@@ -124,6 +129,7 @@
* @see ICodeAssist#codeComplete(int, ICompletionRequestor)
* @deprecated
*/
+@Deprecated
public void codeComplete(int offset, ICompletionRequestor requestor) throws JavaModelException {
codeComplete(offset, requestor, DefaultWorkingCopyOwner.PRIMARY);
}
@@ -131,6 +137,7 @@
* @see ICodeAssist#codeComplete(int, ICompletionRequestor, WorkingCopyOwner)
* @deprecated
*/
+@Deprecated
public void codeComplete(int offset, ICompletionRequestor requestor, WorkingCopyOwner owner) throws JavaModelException {
if (requestor == null) {
throw new IllegalArgumentException("Completion requestor cannot be null"); //$NON-NLS-1$
@@ -197,9 +204,11 @@
/**
* Returns a new element info for this element.
*/
+@Override
protected Object createElementInfo() {
return new ClassFileInfo();
}
+@Override
public boolean equals(Object o) {
if (!(o instanceof ClassFile)) return false;
ClassFile other = (ClassFile) o;
@@ -227,7 +236,7 @@
return false;
}
try {
- info = getJarBinaryTypeInfo((PackageFragment) getParent(), true/*fully initialize so as to not keep a reference to the byte array*/);
+ info = getJarBinaryTypeInfo();
} catch (CoreException e) {
// leave info null
} catch (IOException e) {
@@ -277,6 +286,7 @@
}
return null;
}
+@Override
public String getAttachedJavadoc(IProgressMonitor monitor) throws JavaModelException {
return getType().getAttachedJavadoc(monitor);
}
@@ -292,40 +302,26 @@
* @exception JavaModelException when the IFile resource or JAR is not available
* or when this class file is not present in the JAR
*/
-public IBinaryType getBinaryTypeInfo(IFile file) throws JavaModelException {
- return getBinaryTypeInfo(file, true/*fully initialize so as to not keep a reference to the byte array*/);
-}
-public IBinaryType getBinaryTypeInfo(IFile file, boolean fullyInitialize) throws JavaModelException {
- JavaElement pkg = (JavaElement) getParent();
- if (pkg instanceof JarPackageFragment) {
- try {
- IBinaryType info = getJarBinaryTypeInfo((PackageFragment) pkg, fullyInitialize);
- if (info == null) {
- throw newNotPresentException();
- }
- return info;
- } catch (ClassFormatException cfe) {
- //the structure remains unknown
- if (JavaCore.getPlugin().isDebugging()) {
- cfe.printStackTrace(System.err);
- }
- return null;
- } catch (IOException ioe) {
- throw new JavaModelException(ioe, IJavaModelStatusConstants.IO_EXCEPTION);
- } catch (CoreException e) {
- if (e instanceof JavaModelException) {
- throw (JavaModelException)e;
- } else {
- throw new JavaModelException(e);
- }
+public IBinaryType getBinaryTypeInfo() throws JavaModelException {
+ try {
+ IBinaryType info = getJarBinaryTypeInfo();
+ if (info == null) {
+ throw newNotPresentException();
}
- } else {
- byte[] contents = Util.getResourceContentsAsByteArray(file);
- try {
- return new ClassFileReader(contents, file.getFullPath().toString().toCharArray(), fullyInitialize);
- } catch (ClassFormatException cfe) {
- //the structure remains unknown
- return null;
+ return info;
+ } catch (ClassFormatException cfe) {
+ //the structure remains unknown
+ if (JavaCore.getPlugin().isDebugging()) {
+ cfe.printStackTrace(System.err);
+ }
+ return null;
+ } catch (IOException ioe) {
+ throw new JavaModelException(ioe, IJavaModelStatusConstants.IO_EXCEPTION);
+ } catch (CoreException e) {
+ if (e instanceof JavaModelException) {
+ throw (JavaModelException)e;
+ } else {
+ throw new JavaModelException(e);
}
}
}
@@ -359,44 +355,58 @@
return Util.getResourceContentsAsByteArray(file);
}
}
-private IBinaryType getJarBinaryTypeInfo(PackageFragment pkg, boolean fullyInitialize) throws CoreException, IOException, ClassFormatException {
- JarPackageFragmentRoot root = (JarPackageFragmentRoot) pkg.getParent();
- ZipFile zip = null;
- ZipFile annotationZip = null;
- try {
- zip = root.getJar();
- String entryName = Util.concatWith(pkg.names, getElementName(), '/');
- ZipEntry ze = zip.getEntry(entryName);
- if (ze != null) {
- byte contents[] = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(ze, zip);
- String fileName = root.getHandleIdentifier() + IDependent.JAR_FILE_ENTRY_SEPARATOR + entryName;
- ClassFileReader reader = new ClassFileReader(contents, fileName.toCharArray(), fullyInitialize);
- if (root.getKind() == IPackageFragmentRoot.K_BINARY) {
- JavaProject javaProject = (JavaProject) getAncestor(IJavaElement.JAVA_PROJECT);
- IClasspathEntry entry = javaProject.getClasspathEntryFor(getPath());
- if (entry != null) {
- IProject project = javaProject.getProject();
- IPath externalAnnotationPath = ClasspathEntry.getExternalAnnotationPath(entry, project, false); // unresolved for use in ExternalAnnotationTracker
- if (externalAnnotationPath != null) {
- setupExternalAnnotationProvider(project, externalAnnotationPath, annotationZip, reader,
- entryName.substring(0, entryName.length() - SuffixConstants.SUFFIX_CLASS.length));
- } else if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
- reader.markAsFromSource();
- }
- }
- }
- return reader;
- }
- } finally {
- JavaModelManager.getJavaModelManager().closeZipFile(zip);
- JavaModelManager.getJavaModelManager().closeZipFile(annotationZip);
- }
- return null;
+
+public String getName() {
+ return this.name;
}
-private void setupExternalAnnotationProvider(IProject project, final IPath externalAnnotationPath,
- ZipFile annotationZip, ClassFileReader reader, final String typeName)
+private IBinaryType getJarBinaryTypeInfo() throws CoreException, IOException, ClassFormatException {
+ BinaryTypeDescriptor descriptor = BinaryTypeFactory.createDescriptor(this);
+
+ if (descriptor == null) {
+ return null;
+ }
+
+ IBinaryType result = BinaryTypeFactory.readType(descriptor, null);
+
+ if (result == null) {
+ return null;
+ }
+
+ // TODO(sxenos): setup the external annotation provider if the IBinaryType came from the index
+ // TODO(sxenos): the old code always passed null as the third argument to setupExternalAnnotationProvider,
+ // but this looks like a bug. I've preserved it for now but we need to figure out what was supposed to go
+ // there.
+ PackageFragment pkg = (PackageFragment) getParent();
+ IJavaElement grandparent = pkg.getParent();
+ if (grandparent instanceof JarPackageFragmentRoot) {
+ JarPackageFragmentRoot root = (JarPackageFragmentRoot) grandparent;
+
+ if (root.getKind() == IPackageFragmentRoot.K_BINARY) {
+ JavaProject javaProject = (JavaProject) getAncestor(IJavaElement.JAVA_PROJECT);
+ IClasspathEntry entry = javaProject.getClasspathEntryFor(getPath());
+ if (entry != null) {
+ String entryName = new String(CharArrayUtils.concat(
+ JavaNames.fieldDescriptorToBinaryName(descriptor.fieldDescriptor), SuffixConstants.SUFFIX_CLASS));
+ IProject project = javaProject.getProject();
+ IPath externalAnnotationPath = ClasspathEntry.getExternalAnnotationPath(entry, project, false); // unresolved for use in ExternalAnnotationTracker
+ if (externalAnnotationPath != null) {
+ result = setupExternalAnnotationProvider(project, externalAnnotationPath, null, result,
+ entryName.substring(0, entryName.length() - SuffixConstants.SUFFIX_CLASS.length));
+ } else if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
+ result = new ExternalAnnotationDecorator(result, true);
+ }
+ }
+ }
+ }
+
+ return result;
+}
+
+private IBinaryType setupExternalAnnotationProvider(IProject project, final IPath externalAnnotationPath,
+ ZipFile annotationZip, IBinaryType reader, final String typeName)
{
+ IBinaryType result = reader;
// try resolve path within the workspace:
IWorkspaceRoot root = project.getWorkspace().getRoot();
IResource resource;
@@ -410,26 +420,32 @@
String resolvedPath;
if (resource.exists()) {
if (resource.isVirtual()) {
- Util.log(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID,
+ Util.log(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID,
"Virtual resource "+externalAnnotationPath+" cannot be used as annotationpath for project "+project.getName())); //$NON-NLS-1$ //$NON-NLS-2$
- return;
+ return reader;
}
resolvedPath = resource.getLocation().toString(); // workspace lookup succeeded -> resolve it
} else {
resolvedPath = externalAnnotationPath.toString(); // not in workspace, use as is
}
try {
- annotationZip = reader.setExternalAnnotationProvider(resolvedPath, typeName, annotationZip, new ClassFileReader.ZipFileProducer() {
- @Override public ZipFile produce() throws IOException {
- try {
- return JavaModelManager.getJavaModelManager().getZipFile(externalAnnotationPath); // use (absolute, but) unresolved path here
- } catch (CoreException e) {
- throw new IOException("Failed to read annotation file for "+typeName+" from "+externalAnnotationPath.toString(), e); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }});
+ if (annotationZip == null) {
+ annotationZip = ExternalAnnotationDecorator.getAnnotationZipFile(resolvedPath, new ExternalAnnotationDecorator.ZipFileProducer() {
+ @Override public ZipFile produce() throws IOException {
+ try {
+ return JavaModelManager.getJavaModelManager().getZipFile(externalAnnotationPath); // use (absolute, but) unresolved path here
+ } catch (CoreException e) {
+ throw new IOException("Failed to read annotation file for "+typeName+" from "+externalAnnotationPath.toString(), e); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }});
+ }
+
+ ExternalAnnotationProvider annotationProvider = ExternalAnnotationDecorator
+ .externalAnnotationProvider(resolvedPath, typeName, annotationZip);
+ result = new ExternalAnnotationDecorator(reader, annotationProvider);
} catch (IOException e) {
Util.log(e);
- return;
+ return result;
}
if (annotationZip == null) {
// Additional change listening for individual types only when annotations are in individual files.
@@ -437,6 +453,7 @@
this.externalAnnotationBase = externalAnnotationPath; // remember so we can unregister later
ExternalAnnotationTracker.registerClassFile(externalAnnotationPath, new Path(typeName), this);
}
+ return result;
}
void closeAndRemoveFromJarTypeCache() throws JavaModelException {
super.close();
@@ -451,6 +468,7 @@
}
super.close();
}
+@Override
public IBuffer getBuffer() throws JavaModelException {
IStatus status = validateClassFile();
if (status.isOK()) {
@@ -468,6 +486,7 @@
/**
* @see IMember
*/
+@Override
public IClassFile getClassFile() {
return this;
}
@@ -483,6 +502,7 @@
*
* @see IJavaElement
*/
+@Override
public IResource getCorrespondingResource() throws JavaModelException {
IPackageFragmentRoot root= (IPackageFragmentRoot)getParent().getParent();
if (root.isArchive()) {
@@ -554,6 +574,7 @@
return null;
}
}
+@Override
public String getElementName() {
return this.name + SuffixConstants.SUFFIX_STRING_class;
}
@@ -566,6 +587,7 @@
/*
* @see JavaElement
*/
+@Override
public IJavaElement getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner owner) {
switch (token.charAt(0)) {
case JEM_TYPE:
@@ -579,6 +601,7 @@
/**
* @see JavaElement#getHandleMemento()
*/
+@Override
protected char getHandleMementoDelimiter() {
return JavaElement.JEM_CLASSFILE;
}
@@ -596,6 +619,7 @@
/*
* @see IJavaElement
*/
+@Override
public IResource resource(PackageFragmentRoot root) {
return ((IContainer) ((Openable) this.parent).resource(root)).getFile(new Path(getElementName()));
}
@@ -707,15 +731,18 @@
* @see IClassFile
* @deprecated
*/
+@Deprecated
public IJavaElement getWorkingCopy(IProgressMonitor monitor, org.eclipse.jdt.core.IBufferFactory factory) throws JavaModelException {
return getWorkingCopy(BufferFactoryWrapper.create(factory), monitor);
}
/**
* @see Openable
*/
+@Override
protected boolean hasBuffer() {
return true;
}
+@Override
public int hashCode() {
return Util.combineHashCodes(this.name.hashCode(), this.parent.hashCode());
}
@@ -734,6 +761,7 @@
/**
* Returns true - class files are always read only.
*/
+@Override
public boolean isReadOnly() {
return true;
}
@@ -756,6 +784,7 @@
*
* @see Openable
*/
+@Override
protected IBuffer openBuffer(IProgressMonitor pm, Object info) throws JavaModelException {
// Check the cache for the top-level type first
IType outerMostEnclosingType = getOuterMostEnclosingType();
@@ -896,6 +925,7 @@
* @see ICodeAssist#codeComplete(int, ICodeCompletionRequestor)
* @deprecated - should use codeComplete(int, ICompletionRequestor) instead
*/
+@Deprecated
public void codeComplete(int offset, final org.eclipse.jdt.core.ICodeCompletionRequestor requestor) throws JavaModelException {
if (requestor == null){
@@ -951,6 +981,7 @@
});
}
+@Override
protected IStatus validateExistence(IResource underlyingResource) {
// check whether the class file can be opened
IStatus status = validateClassFile();
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessingState.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessingState.java
index 1854aee..a8e3b27 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessingState.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessingState.java
@@ -24,13 +24,16 @@
import org.eclipse.core.runtime.*;
import org.eclipse.jdt.core.*;
import org.eclipse.jdt.internal.core.JavaModelManager.PerProjectInfo;
+import org.eclipse.jdt.internal.core.nd.indexer.Indexer;
+import org.eclipse.jdt.internal.core.nd.indexer.IndexerEvent;
+import org.eclipse.jdt.internal.core.nd.java.JavaIndex;
import org.eclipse.jdt.internal.core.util.Util;
/**
* Keep the global states used during Java element delta processing.
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
-public class DeltaProcessingState implements IResourceChangeListener {
+public class DeltaProcessingState implements IResourceChangeListener, Indexer.Listener {
/*
* Collection of listeners for Java element deltas
@@ -643,4 +646,15 @@
}
}
+ @Override
+ public void consume(IndexerEvent event) {
+ if (JavaIndex.isEnabled()) {
+ DeltaProcessor processor = getDeltaProcessor();
+ JavaElementDelta delta = (JavaElementDelta) event.getDelta();
+ delta.ignoreFromTests = true;
+ processor.notifyAndFire(delta);
+ this.deltaProcessors.set(null);
+ }
+ }
+
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java
index 18f5b75..0e2c598 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java
@@ -502,8 +502,24 @@
break;
case IResource.FOLDER:
- if (delta.getKind() == IResourceDelta.CHANGED) { // look for .jar file change to update classpath
- children = delta.getAffectedChildren();
+ switch (delta.getKind()) {
+ case IResourceDelta.ADDED:
+ case IResourceDelta.REMOVED:
+ // Close the containing package fragment root to reset its cached children.
+ // See http://bugs.eclipse.org/500714
+ IPackageFragmentRoot root = findContainingPackageFragmentRoot(resource);
+ if (root != null && root.isOpen()) {
+ try {
+ root.close();
+ } catch (JavaModelException e) {
+ Util.log(e);
+ }
+ }
+ break;
+
+ case IResourceDelta.CHANGED: // look for .jar file change to update classpath
+ children = delta.getAffectedChildren();
+ break;
}
break;
case IResource.FILE :
@@ -548,6 +564,27 @@
}
}
+ private IPackageFragmentRoot findContainingPackageFragmentRoot(IResource resource) {
+ IProject project = resource.getProject();
+ if (JavaProject.hasJavaNature(project)) {
+ IJavaProject javaProject = JavaCore.create(project);
+ try {
+ IPath path = resource.getProjectRelativePath();
+ IPackageFragmentRoot[] roots = javaProject.getPackageFragmentRoots();
+ for (IPackageFragmentRoot root : roots) {
+ IResource rootResource = root.getUnderlyingResource();
+ if (rootResource != null && !resource.equals(rootResource) &&
+ rootResource.getProjectRelativePath().isPrefixOf(path)) {
+ return root;
+ }
+ }
+ } catch (JavaModelException e) {
+ Util.log(e);
+ }
+ }
+ return null;
+ }
+
private void checkExternalFolderChange(IProject project, JavaProject javaProject) {
ClasspathChange change = this.state.getClasspathChange(project);
this.state.addExternalFolderChange(javaProject, change == null ? null : change.oldResolvedClasspath);
@@ -1020,6 +1057,9 @@
if (VERBOSE){
System.out.println("- External JAR CHANGED, affecting root: "+root.getElementName()); //$NON-NLS-1$
}
+ // TODO(sxenos): this is causing each change event for an external jar file to be fired twice.
+ // We need to preserve the clearing of cached information in the jar but defer the actual firing of
+ // the event until after the indexer has processed the jar.
contentChanged(root);
deltaContainsModifiedJar = true;
hasDelta = true;
@@ -1908,7 +1948,7 @@
* caches and their dependents
*/
public void resetProjectCaches() {
- if (this.projectCachesToReset.size() == 0)
+ if (this.projectCachesToReset.isEmpty())
return;
JavaModelManager.getJavaModelManager().resetJarTypeCache();
@@ -2064,14 +2104,7 @@
this.sourceElementParserCache = null; // don't hold onto parser longer than necessary
startDeltas();
}
- IElementChangedListener[] listeners;
- int listenerCount;
- synchronized (this.state) {
- listeners = this.state.elementChangedListeners;
- listenerCount = this.state.elementChangedListenerCount;
- }
- notifyTypeHierarchies(listeners, listenerCount);
- fire(null, ElementChangedEvent.POST_CHANGE);
+ notifyAndFire(null);
} finally {
// workaround for bug 15168 circular errors not reported
this.state.resetOldJavaProjectNames();
@@ -2180,6 +2213,17 @@
}
}
+ public void notifyAndFire(IJavaElementDelta delta) {
+ IElementChangedListener[] listeners;
+ int listenerCount;
+ synchronized (this.state) {
+ listeners = this.state.elementChangedListeners;
+ listenerCount = this.state.elementChangedListenerCount;
+ }
+ notifyTypeHierarchies(listeners, listenerCount);
+ fire(delta, ElementChangedEvent.POST_CHANGE);
+ }
+
/*
* Returns the root info for the given path. Look in the old roots table if kind is REMOVED.
*/
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementDelta.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementDelta.java
index a7beb47..86abfaf 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementDelta.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementDelta.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -82,6 +82,8 @@
*/
Map<Key, Integer> childIndex;
+ public boolean ignoreFromTests = false;
+
/**
* The delta key
*/
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelCache.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelCache.java
index c2ad7c3..5c6ca12 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelCache.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelCache.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -28,6 +28,7 @@
@SuppressWarnings({"rawtypes", "unchecked"})
public class JavaModelCache {
public static boolean VERBOSE = false;
+ public static boolean DEBUG_CACHE_INSERTIONS = false;
public static final int DEFAULT_PROJECT_SIZE = 5; // average 25552 bytes per project.
public static final int DEFAULT_ROOT_SIZE = 50; // average 2590 bytes per root -> maximum size : 25900*BASE_VALUE bytes
@@ -224,6 +225,9 @@
* Remember the info for the element.
*/
protected void putInfo(IJavaElement element, Object info) {
+ if (DEBUG_CACHE_INSERTIONS) {
+ System.out.println(Thread.currentThread() + " cache putInfo (" + getElementType(element) + " " + element.toString() + ", " + info + ")"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
+ }
switch (element.getElementType()) {
case IJavaElement.JAVA_MODEL:
this.modelInfo = info;
@@ -248,10 +252,39 @@
this.childrenCache.put(element, info);
}
}
+
+public static String getElementType(IJavaElement element) {
+ String elementType;
+ switch (element.getElementType()) {
+ case IJavaElement.JAVA_PROJECT:
+ elementType = "project"; //$NON-NLS-1$
+ break;
+ case IJavaElement.PACKAGE_FRAGMENT_ROOT:
+ elementType = "root"; //$NON-NLS-1$
+ break;
+ case IJavaElement.PACKAGE_FRAGMENT:
+ elementType = "package"; //$NON-NLS-1$
+ break;
+ case IJavaElement.CLASS_FILE:
+ elementType = "class file"; //$NON-NLS-1$
+ break;
+ case IJavaElement.COMPILATION_UNIT:
+ elementType = "compilation unit"; //$NON-NLS-1$
+ break;
+ default:
+ elementType = "element"; //$NON-NLS-1$
+ }
+ return elementType;
+}
+
/**
* Removes the info of the element from the cache.
*/
protected void removeInfo(JavaElement element) {
+ if (DEBUG_CACHE_INSERTIONS) {
+ String elementToString = element.toString();
+ System.out.println(Thread.currentThread() + " cache removeInfo " + getElementType(element) + " " + elementToString); //$NON-NLS-1$//$NON-NLS-2$
+ }
switch (element.getElementType()) {
case IJavaElement.JAVA_MODEL:
this.modelInfo = null;
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 cdb4157..8b4feaa 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
@@ -130,6 +130,8 @@
import org.eclipse.jdt.internal.core.dom.SourceRangeVerifier;
import org.eclipse.jdt.internal.core.dom.rewrite.RewriteEventStore;
import org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy;
+import org.eclipse.jdt.internal.core.nd.Nd;
+import org.eclipse.jdt.internal.core.nd.indexer.Indexer;
import org.eclipse.jdt.internal.core.search.AbstractSearchScope;
import org.eclipse.jdt.internal.core.search.BasicSearchEngine;
import org.eclipse.jdt.internal.core.search.IRestrictedAccessTypeRequestor;
@@ -176,6 +178,14 @@
private static final String EXTERNAL_FILES_CACHE = "externalFilesCache"; //$NON-NLS-1$
private static final String ASSUMED_EXTERNAL_FILES_CACHE = "assumedExternalFilesCache"; //$NON-NLS-1$
+ public static enum ArchiveValidity {
+ BAD_FORMAT, UNABLE_TO_READ, VALID;
+
+ public boolean isValid() {
+ return this == VALID;
+ }
+ }
+
/**
* Define a zip cache object.
*/
@@ -333,8 +343,11 @@
private static final String INDEX_MANAGER_DEBUG = JavaCore.PLUGIN_ID + "/debug/indexmanager" ; //$NON-NLS-1$
private static final String INDEX_MANAGER_ADVANCED_DEBUG = JavaCore.PLUGIN_ID + "/debug/indexmanager/advanced" ; //$NON-NLS-1$
private static final String COMPILER_DEBUG = JavaCore.PLUGIN_ID + "/debug/compiler" ; //$NON-NLS-1$
+ private static final String JAVAMODEL_CLASSPATH = JavaCore.PLUGIN_ID + "/debug/javamodel/classpath" ; //$NON-NLS-1$
private static final String JAVAMODEL_DEBUG = JavaCore.PLUGIN_ID + "/debug/javamodel" ; //$NON-NLS-1$
+ private static final String JAVAMODEL_INVALID_ARCHIVES = JavaCore.PLUGIN_ID + "/debug/javamodel/invalid_archives" ; //$NON-NLS-1$
private static final String JAVAMODELCACHE_DEBUG = JavaCore.PLUGIN_ID + "/debug/javamodel/cache" ; //$NON-NLS-1$
+ private static final String JAVAMODELCACHE_INSERTIONS_DEBUG = JavaCore.PLUGIN_ID + "/debug/javamodel/insertions" ; //$NON-NLS-1$
private static final String CP_RESOLVE_DEBUG = JavaCore.PLUGIN_ID + "/debug/cpresolution" ; //$NON-NLS-1$
private static final String CP_RESOLVE_ADVANCED_DEBUG = JavaCore.PLUGIN_ID + "/debug/cpresolution/advanced" ; //$NON-NLS-1$
private static final String CP_RESOLVE_FAILURE_DEBUG = JavaCore.PLUGIN_ID + "/debug/cpresolution/failure" ; //$NON-NLS-1$
@@ -354,6 +367,12 @@
private static final String SEARCH_DEBUG = JavaCore.PLUGIN_ID + "/debug/search" ; //$NON-NLS-1$
private static final String SOURCE_MAPPER_DEBUG_VERBOSE = JavaCore.PLUGIN_ID + "/debug/sourcemapper" ; //$NON-NLS-1$
private static final String FORMATTER_DEBUG = JavaCore.PLUGIN_ID + "/debug/formatter" ; //$NON-NLS-1$
+ private static final String INDEX_INDEXER_DEBUG = JavaCore.PLUGIN_ID + "/debug/index/indexer" ; //$NON-NLS-1$
+ private static final String INDEX_INDEXER_INSERTIONS = JavaCore.PLUGIN_ID + "/debug/index/insertions" ; //$NON-NLS-1$
+ private static final String INDEX_INDEXER_SELFTEST = JavaCore.PLUGIN_ID + "/debug/index/selftest" ; //$NON-NLS-1$
+ private static final String INDEX_LOCKS_DEBUG = JavaCore.PLUGIN_ID + "/debug/index/locks" ; //$NON-NLS-1$
+ private static final String INDEX_INDEXER_SPACE = JavaCore.PLUGIN_ID + "/debug/index/space" ; //$NON-NLS-1$
+ private static final String INDEX_INDEXER_TIMING = JavaCore.PLUGIN_ID + "/debug/index/timing" ; //$NON-NLS-1$
public static final String COMPLETION_PERF = JavaCore.PLUGIN_ID + "/perf/completion" ; //$NON-NLS-1$
public static final String SELECTION_PERF = JavaCore.PLUGIN_ID + "/perf/selection" ; //$NON-NLS-1$
@@ -1290,6 +1309,16 @@
}
private ClasspathChange setClasspath(IClasspathEntry[] newRawClasspath, IClasspathEntry[] referencedEntries, IPath newOutputLocation, IJavaModelStatus newRawClasspathStatus, IClasspathEntry[] newResolvedClasspath, Map newRootPathToRawEntries, Map newRootPathToResolvedEntries, IJavaModelStatus newUnresolvedEntryStatus, boolean addClasspathChange) {
+ if (DEBUG_CLASSPATH) {
+ System.out.println("Setting resolved classpath for " + this.project.getFullPath()); //$NON-NLS-1$
+ if (newResolvedClasspath == null) {
+ System.out.println("New classpath = null"); //$NON-NLS-1$
+ } else {
+ for (IClasspathEntry next : newResolvedClasspath) {
+ System.out.println(" " + next); //$NON-NLS-1$
+ }
+ }
+ }
ClasspathChange classpathChange = addClasspathChange ? addClasspathChange() : null;
if (referencedEntries != null) this.referencedEntries = referencedEntries;
@@ -1510,6 +1539,8 @@
}
public static boolean VERBOSE = false;
+ public static boolean DEBUG_CLASSPATH = false;
+ public static boolean DEBUG_INVALID_ARCHIVES = false;
public static boolean CP_RESOLVE_VERBOSE = false;
public static boolean CP_RESOLVE_VERBOSE_ADVANCED = false;
public static boolean CP_RESOLVE_VERBOSE_FAILURE = false;
@@ -1531,10 +1562,29 @@
// The amount of time from when an invalid archive is first sensed until that state is considered stale.
private static long INVALID_ARCHIVE_TTL_MILLISECONDS = 2 * 60 * 1000;
+ private static class InvalidArchiveInfo {
+ /**
+ * Time at which this entry will be removed from the invalid archive list.
+ */
+ final long evictionTimestamp;
+
+ /**
+ * Reason the entry was added to the invalid archive list.
+ */
+ final ArchiveValidity reason;
+
+ InvalidArchiveInfo(long evictionTimestamp, ArchiveValidity reason) {
+ this.evictionTimestamp = evictionTimestamp;
+ this.reason = reason;
+ }
+ }
+
/*
* A map of IPaths for jars that are known to be invalid (such as not being in a valid/known format), to an eviction timestamp.
+ * Synchronize on invalidArchivesMutex before accessing.
*/
- private Map<IPath, Long> invalidArchives;
+ private final Map<IPath, InvalidArchiveInfo> invalidArchives = new HashMap<IPath, InvalidArchiveInfo>();
+ private final Object invalidArchivesMutex = new Object();
/*
* A set of IPaths for files that are known to be external to the workspace.
@@ -1698,12 +1748,13 @@
this.nonChainingJars.add(path);
}
- public void addInvalidArchive(IPath path) {
- // unlikely to be null
- if (this.invalidArchives == null) {
- this.invalidArchives = Collections.synchronizedMap(new HashMap());
+ public void addInvalidArchive(IPath path, ArchiveValidity reason) {
+ if (DEBUG_INVALID_ARCHIVES) {
+ System.out.println("Invalid JAR cache: adding " + path + ", reason: " + reason); //$NON-NLS-1$//$NON-NLS-2$
}
- this.invalidArchives.put(path, System.currentTimeMillis() + INVALID_ARCHIVE_TTL_MILLISECONDS);
+ synchronized (this.invalidArchivesMutex) {
+ this.invalidArchives.put(path, new InvalidArchiveInfo(System.currentTimeMillis() + INVALID_ARCHIVE_TTL_MILLISECONDS, reason));
+ }
}
/**
@@ -1773,8 +1824,11 @@
TypeHierarchy.DEBUG = debug && options.getBooleanOption(HIERARCHY_DEBUG, false);
JobManager.VERBOSE = debug && options.getBooleanOption(INDEX_MANAGER_DEBUG, false);
IndexManager.DEBUG = debug && options.getBooleanOption(INDEX_MANAGER_ADVANCED_DEBUG, false);
+ JavaModelManager.DEBUG_CLASSPATH = debug && options.getBooleanOption(JAVAMODEL_CLASSPATH, false);
+ JavaModelManager.DEBUG_INVALID_ARCHIVES = debug && options.getBooleanOption(JAVAMODEL_INVALID_ARCHIVES, false);
JavaModelManager.VERBOSE = debug && options.getBooleanOption(JAVAMODEL_DEBUG, false);
JavaModelCache.VERBOSE = debug && options.getBooleanOption(JAVAMODELCACHE_DEBUG, false);
+ JavaModelCache.DEBUG_CACHE_INSERTIONS = debug && options.getBooleanOption(JAVAMODELCACHE_INSERTIONS_DEBUG, false);
JavaModelOperation.POST_ACTION_VERBOSE = debug && options.getBooleanOption(POST_ACTION_DEBUG, false);
NameLookup.VERBOSE = debug && options.getBooleanOption(RESOLUTION_DEBUG, false);
BasicSearchEngine.VERBOSE = debug && options.getBooleanOption(SEARCH_DEBUG, false);
@@ -1782,6 +1836,12 @@
JavaModelManager.ZIP_ACCESS_VERBOSE = debug && options.getBooleanOption(ZIP_ACCESS_DEBUG, false);
SourceMapper.VERBOSE = debug && options.getBooleanOption(SOURCE_MAPPER_DEBUG_VERBOSE, false);
DefaultCodeFormatter.DEBUG = debug && options.getBooleanOption(FORMATTER_DEBUG, false);
+ Indexer.DEBUG = debug && options.getBooleanOption(INDEX_INDEXER_DEBUG, false);
+ Indexer.DEBUG_INSERTIONS = debug && options.getBooleanOption(INDEX_INDEXER_INSERTIONS, false);
+ Indexer.DEBUG_ALLOCATIONS = debug && options.getBooleanOption(INDEX_INDEXER_SPACE, false);
+ Indexer.DEBUG_TIMING = debug && options.getBooleanOption(INDEX_INDEXER_TIMING, false);
+ Indexer.DEBUG_SELFTEST = debug && options.getBooleanOption(INDEX_INDEXER_SELFTEST, false);
+ Nd.sDEBUG_LOCKS = debug && options.getBooleanOption(INDEX_LOCKS_DEBUG, false);
// configure performance options
if(PerformanceStats.ENABLED) {
@@ -2702,9 +2762,7 @@
}
public void verifyArchiveContent(IPath path) throws CoreException {
- if (isInvalidArchive(path)) {
- throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.status_IOException, new ZipException()));
- }
+ throwExceptionIfArchiveInvalid(path);
ZipFile file = getZipFile(path);
closeZipFile(file);
}
@@ -2724,16 +2782,47 @@
return getZipFile(path, true);
}
+ /**
+ * For use in the JDT unit tests only. Used for testing error handling. Causes an
+ * {@link IOException} to be thrown in {@link #getZipFile} whenever it attempts to
+ * read a zip file.
+ *
+ * @noreference This field is not intended to be referenced by clients.
+ */
+ public static boolean throwIoExceptionsInGetZipFile = false;
+
private ZipFile getZipFile(IPath path, boolean checkInvalidArchiveCache) throws CoreException {
- if (checkInvalidArchiveCache && isInvalidArchive(path))
- throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.status_IOException, new ZipException()));
-
+ if (checkInvalidArchiveCache) {
+ throwExceptionIfArchiveInvalid(path);
+ }
ZipCache zipCache;
ZipFile zipFile;
if ((zipCache = (ZipCache)this.zipFiles.get()) != null
&& (zipFile = zipCache.getCache(path)) != null) {
return zipFile;
}
+ File localFile = getLocalFile(path);
+
+ try {
+ if (ZIP_ACCESS_VERBOSE) {
+ System.out.println("(" + Thread.currentThread() + ") [JavaModelManager.getZipFile(IPath)] Creating ZipFile on " + localFile ); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ if (throwIoExceptionsInGetZipFile) {
+ throw new IOException();
+ }
+ zipFile = new ZipFile(localFile);
+ if (zipCache != null) {
+ zipCache.setCache(path, zipFile);
+ }
+ return zipFile;
+ } catch (IOException e) {
+ ArchiveValidity reason = (e instanceof ZipException) ? ArchiveValidity.BAD_FORMAT : ArchiveValidity.UNABLE_TO_READ;
+ addInvalidArchive(path, reason);
+ throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.status_IOException, e));
+ }
+ }
+
+ public static File getLocalFile(IPath path) throws CoreException {
File localFile = null;
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IResource file = root.findMember(path);
@@ -2750,19 +2839,19 @@
// external resource -> it is ok to use toFile()
localFile= path.toFile();
}
+ return localFile;
+ }
- try {
- if (ZIP_ACCESS_VERBOSE) {
- System.out.println("(" + Thread.currentThread() + ") [JavaModelManager.getZipFile(IPath)] Creating ZipFile on " + localFile ); //$NON-NLS-1$ //$NON-NLS-2$
+ private void throwExceptionIfArchiveInvalid(IPath path) throws CoreException {
+ ArchiveValidity validity = getArchiveValidity(path);
+ if (!validity.isValid()) {
+ IOException reason;
+ if (validity == ArchiveValidity.BAD_FORMAT) {
+ reason = new ZipException();
+ } else {
+ reason = new IOException();
}
- zipFile = new ZipFile(localFile);
- if (zipCache != null) {
- zipCache.setCache(path, zipFile);
- }
- return zipFile;
- } catch (IOException e) {
- addInvalidArchive(path);
- throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.status_IOException, e));
+ throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.status_IOException, reason));
}
}
@@ -3186,31 +3275,36 @@
return this.nonChainingJars != null && this.nonChainingJars.contains(path);
}
- public boolean isInvalidArchive(IPath path) {
- if (this.invalidArchives == null)
- return false;
- Long evictionTime = this.invalidArchives.get(path);
- if (evictionTime == null)
- return false;
+ public ArchiveValidity getArchiveValidity(IPath path) {
+ InvalidArchiveInfo invalidArchiveInfo;
+ synchronized (this.invalidArchivesMutex) {
+ invalidArchiveInfo = this.invalidArchives.get(path);
+ }
+ if (invalidArchiveInfo == null)
+ return ArchiveValidity.VALID;
long now = System.currentTimeMillis();
// If the TTL for this cache entry has expired, directly check whether the archive is still invalid.
// If it transitioned to being valid, remove it from the cache and force an update to project caches.
- if (now > evictionTime) {
+ if (now > invalidArchiveInfo.evictionTimestamp) {
try {
getZipFile(path, false);
removeFromInvalidArchiveCache(path);
- return false;
} catch (CoreException e) {
// Archive is still invalid, fall through to reporting it is invalid.
}
+ // Retry the test from the start, now that we have an up-to-date result
+ return getArchiveValidity(path);
}
- return true;
+ return invalidArchiveInfo.reason;
}
public void removeFromInvalidArchiveCache(IPath path) {
- if (this.invalidArchives != null) {
+ synchronized(this.invalidArchivesMutex) {
if (this.invalidArchives.remove(path) != null) {
+ if (DEBUG_INVALID_ARCHIVES) {
+ System.out.println("Invalid JAR cache: removed " + path); //$NON-NLS-1$
+ }
try {
// Bug 455042: Force an update of the JavaProjectElementInfo project caches.
for (IJavaProject project : getJavaModel().getJavaProjects()) {
@@ -3985,26 +4079,7 @@
boolean wasVerbose = false;
try {
if (JavaModelCache.VERBOSE) {
- String elementType;
- switch (element.getElementType()) {
- case IJavaElement.JAVA_PROJECT:
- elementType = "project"; //$NON-NLS-1$
- break;
- case IJavaElement.PACKAGE_FRAGMENT_ROOT:
- elementType = "root"; //$NON-NLS-1$
- break;
- case IJavaElement.PACKAGE_FRAGMENT:
- elementType = "package"; //$NON-NLS-1$
- break;
- case IJavaElement.CLASS_FILE:
- elementType = "class file"; //$NON-NLS-1$
- break;
- case IJavaElement.COMPILATION_UNIT:
- elementType = "compilation unit"; //$NON-NLS-1$
- break;
- default:
- elementType = "element"; //$NON-NLS-1$
- }
+ String elementType = JavaModelCache.getElementType(element);
System.out.println(Thread.currentThread() + " CLOSING "+ elementType + " " + element.toStringWithAncestors()); //$NON-NLS-1$//$NON-NLS-2$
wasVerbose = true;
JavaModelCache.VERBOSE = false;
@@ -4085,8 +4160,16 @@
public void resetClasspathListCache() {
if (this.nonChainingJars != null)
this.nonChainingJars.clear();
- if (this.invalidArchives != null)
+ if (DEBUG_INVALID_ARCHIVES) {
+ synchronized(this.invalidArchivesMutex) {
+ if (!this.invalidArchives.isEmpty()) {
+ System.out.println("Invalid JAR cache: clearing cache"); //$NON-NLS-1$
+ }
+ }
+ }
+ synchronized(this.invalidArchivesMutex) {
this.invalidArchives.clear();
+ }
if (this.externalFiles != null)
this.externalFiles.clear();
if (this.assumedExternalFiles != null)
@@ -5163,6 +5246,8 @@
| IResourceChangeEvent.PRE_CLOSE
| IResourceChangeEvent.PRE_REFRESH);
+ Indexer.getInstance().addListener(this.deltaState);
+
// listen to resource changes affecting external annotations
ExternalAnnotationTracker.start(workspace);
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavadocConstants.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavadocConstants.java
index ed53500..e52d2e1 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavadocConstants.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavadocConstants.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2014 IBM Corporation and others.
+ * Copyright (c) 2005, 2016 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
@@ -14,7 +14,9 @@
String ANCHOR_PREFIX_END = "\""; //$NON-NLS-1$
char[] ANCHOR_PREFIX_START = "<A NAME=\"".toCharArray(); //$NON-NLS-1$
- int ANCHOR_PREFIX_START_LENGHT = ANCHOR_PREFIX_START.length;
+ char[] ANCHOR_PREFIX_START_2 = "<A ID=\"".toCharArray(); //$NON-NLS-1$
+ int ANCHOR_PREFIX_START_LENGTH = ANCHOR_PREFIX_START.length;
+ int ANCHOR_PREFIX_START2_LENGTH = ANCHOR_PREFIX_START_2.length;
char[] ANCHOR_SUFFIX = "</A>".toCharArray(); //$NON-NLS-1$
int ANCHOR_SUFFIX_LENGTH = JavadocConstants.ANCHOR_SUFFIX.length;
char[] CONSTRUCTOR_DETAIL = "<!-- ========= CONSTRUCTOR DETAIL ======== -->".toCharArray(); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavadocContents.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavadocContents.java
index 02341d5..e29b96d 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavadocContents.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavadocContents.java
@@ -185,14 +185,15 @@
}
int fromIndex = this.tempLastAnchorFoundIndex;
- int index;
+ int[] index;
// check each next unknown anchor locations
- while ((index = CharOperation.indexOf(JavadocConstants.ANCHOR_PREFIX_START, this.content, false, fromIndex)) != -1 && (index < indexOfSectionBottom || indexOfSectionBottom == -1)) {
- fromIndex = index + 1;
-
- int anchorEndStart = index + JavadocConstants.ANCHOR_PREFIX_START_LENGHT;
-
+ index = getAnchorIndex(fromIndex);
+ while (index[0] != -1 && (index[0] < indexOfSectionBottom || indexOfSectionBottom == -1)) {
+ fromIndex = index[0] + 1;
+
+ int anchorEndStart = index[0] + index[1];
+
this.tempLastAnchorFoundIndex = anchorEndStart;
if (CharOperation.prefixEquals(anchor, this.content, false, anchorEndStart)) {
@@ -204,11 +205,25 @@
this.tempAnchorIndexes[this.tempAnchorIndexesCount++] = anchorEndStart;
}
+ index = getAnchorIndex(fromIndex);
}
return null;
}
-
+ private int[] getAnchorIndex(int fromIndex) {
+ int index = CharOperation.indexOf(JavadocConstants.ANCHOR_PREFIX_START, this.content, false, fromIndex);
+ if (index != -1) {
+ return new int[]{index, JavadocConstants.ANCHOR_PREFIX_START_LENGTH};
+ }
+ if (index == -1) {
+ index = CharOperation.indexOf(JavadocConstants.ANCHOR_PREFIX_START_2, this.content, false, fromIndex);
+ }
+ if (index == -1) {
+ return new int[]{-1, -1};
+ } else {
+ return new int[]{index, JavadocConstants.ANCHOR_PREFIX_START2_LENGTH};
+ }
+ }
private int[] computeChildRange(int anchorEndStart, char[] anchor, int indexOfBottom) {
int[] range = null;
@@ -218,7 +233,7 @@
int indexOfEndLink = CharOperation.indexOf(JavadocConstants.ANCHOR_SUFFIX, this.content, false, anchorEndStart + anchor.length);
if (indexOfEndLink != -1) {
// try to find the next anchor
- int indexOfNextElement = CharOperation.indexOf(JavadocConstants.ANCHOR_PREFIX_START, this.content, false, indexOfEndLink);
+ int indexOfNextElement = getAnchorIndex(indexOfEndLink)[0];
int javadocStart = indexOfEndLink + JavadocConstants.ANCHOR_SUFFIX_LENGTH;
int javadocEnd = indexOfNextElement == -1 ? indexOfBottom : Math.min(indexOfNextElement, indexOfBottom);
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathDirectory.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathDirectory.java
index 72917d5..fa1e11d 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathDirectory.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathDirectory.java
@@ -15,10 +15,10 @@
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
-
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
+import org.eclipse.jdt.internal.compiler.classfmt.ExternalAnnotationDecorator;
import org.eclipse.jdt.internal.compiler.env.AccessRuleSet;
+import org.eclipse.jdt.internal.compiler.env.IBinaryType;
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable;
import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
@@ -107,7 +107,7 @@
public NameEnvironmentAnswer findClass(String binaryFileName, String qualifiedPackageName, String qualifiedBinaryFileName) {
if (!doesFileExist(binaryFileName, qualifiedPackageName, qualifiedBinaryFileName)) return null; // most common case
- ClassFileReader reader = null;
+ IBinaryType reader = null;
try {
reader = Util.newClassFileReader(this.binaryFolder.getFile(new Path(qualifiedBinaryFileName)));
} catch (CoreException e) {
@@ -121,7 +121,12 @@
String fileNameWithoutExtension = qualifiedBinaryFileName.substring(0, qualifiedBinaryFileName.length() - SuffixConstants.SUFFIX_CLASS.length);
if (this.externalAnnotationPath != null) {
try {
- this.annotationZipFile = reader.setExternalAnnotationProvider(this.externalAnnotationPath, fileNameWithoutExtension, this.annotationZipFile, null);
+ if (this.annotationZipFile == null) {
+ this.annotationZipFile = ExternalAnnotationDecorator
+ .getAnnotationZipFile(this.externalAnnotationPath, null);
+ }
+ reader = ExternalAnnotationDecorator.create(reader, this.externalAnnotationPath,
+ fileNameWithoutExtension, this.annotationZipFile);
} catch (IOException e) {
// don't let error on annotations fail class reading
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java
index 1bda5fb..6575675 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -13,22 +13,27 @@
*******************************************************************************/
package org.eclipse.jdt.internal.core.builder;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.*;
+import java.io.File;
+import java.io.IOException;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
+import org.eclipse.jdt.internal.compiler.classfmt.ExternalAnnotationDecorator;
import org.eclipse.jdt.internal.compiler.env.AccessRuleSet;
+import org.eclipse.jdt.internal.compiler.env.IBinaryType;
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable;
import org.eclipse.jdt.internal.compiler.util.SimpleSet;
import org.eclipse.jdt.internal.compiler