Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2012-04-28 21:46:59 +0000
committerStephan Herrmann2012-04-28 21:46:59 +0000
commit4f3f3d13b87ffe30bb8a3d87892c723df45d3a31 (patch)
tree1f7a028c15b14ec3021608c1646df1ec81d01605 /org.eclipse.jdt.core.tests.model
parentd8abd7a48f15582d678a011924b3dbe14119efa0 (diff)
downloadorg.eclipse.objectteams-4f3f3d13b87ffe30bb8a3d87892c723df45d3a31.tar.gz
org.eclipse.objectteams-4f3f3d13b87ffe30bb8a3d87892c723df45d3a31.tar.xz
org.eclipse.objectteams-4f3f3d13b87ffe30bb8a3d87892c723df45d3a31.zip
Update jdt.core & tests to v20120428-0556.
Diffstat (limited to 'org.eclipse.jdt.core.tests.model')
-rw-r--r--org.eclipse.jdt.core.tests.model/.settings/org.eclipse.core.resources.prefs2
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15JLS4Test.java1
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java1
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CodeCorrectionTests.java3
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java36
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests2.java46
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java124
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java416
8 files changed, 602 insertions, 27 deletions
diff --git a/org.eclipse.jdt.core.tests.model/.settings/org.eclipse.core.resources.prefs b/org.eclipse.jdt.core.tests.model/.settings/org.eclipse.core.resources.prefs
index e36f4c59a..947b88f74 100644
--- a/org.eclipse.jdt.core.tests.model/.settings/org.eclipse.core.resources.prefs
+++ b/org.eclipse.jdt.core.tests.model/.settings/org.eclipse.core.resources.prefs
@@ -1,3 +1,3 @@
-#Wed Nov 25 13:03:46 CET 2009
eclipse.preferences.version=1
+encoding//src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java=UTF-8
encoding//workspace/Encoding/src/testUTF8/Test.java=UTF-8
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15JLS4Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15JLS4Test.java
index 9b73eb2b3..48b71d848 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15JLS4Test.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15JLS4Test.java
@@ -4767,7 +4767,6 @@ public class ASTConverter15JLS4Test extends ConverterTestSetup {
" RED, GREEN(), BLUE(17);\n" +
" X() {}\n" +
" X(int i) {}\n" +
- " @SuppressWarnings(\"incomplete-switch\")\n" +
" public static void main(String[] args) {\n" +
" for (X x : X.values()) {\n" +
" switch(x) {\n" +
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java
index dac0e8dad..e67367d99 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java
@@ -4770,7 +4770,6 @@ public class ASTConverter15Test extends ConverterTestSetup {
" RED, GREEN(), BLUE(17);\n" +
" X() {}\n" +
" X(int i) {}\n" +
- " @SuppressWarnings(\"incomplete-switch\")\n" +
" public static void main(String[] args) {\n" +
" for (X x : X.values()) {\n" +
" switch(x) {\n" +
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CodeCorrectionTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CodeCorrectionTests.java
index 62da35b2e..972f5918e 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CodeCorrectionTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CodeCorrectionTests.java
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Stephan Herrmann - Contribution for bug 374605 - Unreasonable warning for enum-based switch statements
*******************************************************************************/
package org.eclipse.jdt.core.tests.model;
@@ -804,7 +805,9 @@ public void testWarningTokens() {
assertEquals("wrong token", "hiding", CorrectionEngine.getWarningToken(IProblem.TypeParameterHidingType));
assertEquals("wrong token", "nls", CorrectionEngine.getWarningToken(IProblem.NonExternalizedStringLiteral));
assertEquals("wrong token", "incomplete-switch", CorrectionEngine.getWarningToken(IProblem.MissingEnumConstantCase));
+ assertEquals("wrong token", "incomplete-switch", CorrectionEngine.getWarningToken(IProblem.MissingEnumConstantCaseDespiteDefault));
assertEquals("wrong token", "incomplete-switch", CorrectionEngine.getWarningToken(IProblem.MissingEnumDefaultCase));
+ assertEquals("wrong token", "incomplete-switch", CorrectionEngine.getWarningToken(IProblem.MissingDefaultCase));
assertEquals("wrong token", "unused", CorrectionEngine.getWarningToken(IProblem.UnusedImport));
assertEquals("wrong token", "unused", CorrectionEngine.getWarningToken(IProblem.LocalVariableIsNeverUsed));
assertEquals("wrong token", "unused", CorrectionEngine.getWarningToken(IProblem.ArgumentIsNeverUsed));
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java
index 758e89a1d..014fb9a57 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -24839,9 +24839,9 @@ public void testBug350652d() throws JavaModelException {
" }\n" +
" }" +
"}\n" +
- "public class IZZException extends Exception {\n" +
+ "class IZZException extends Exception {\n" +
"}\n" +
- "public class IZZAException extends IZZException {\n" +
+ "class IZZAException extends IZZException {\n" +
"}\n");
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
@@ -24968,9 +24968,9 @@ public void testBug350652g() throws JavaModelException {
" }\n" +
" }" +
"}\n" +
- "public class IZZException extends Exception {\n" +
+ "class IZZException extends Exception {\n" +
"}\n" +
- "public class IZZAException extends IZZException {\n" +
+ "class IZZAException extends IZZException {\n" +
"}\n");
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
@@ -25093,10 +25093,7 @@ public void testBug350652j() throws JavaModelException {
requestor.getResults());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=350652
-// superclass exception type not allowed in multi-catch
-// Test filtration of supertype from expected types when no prefix before caret (IZZException is expected here because of the
-// throw, yet is not a valid proposal anymore since a child, IZZAException is present in the same multi-catch).
-// types in same CU
+// according to comment 5, supertypes of exceptions should also be proposed
public void testBug350652k() throws JavaModelException {
Map options = COMPLETION_PROJECT.getOptions(true);
Object savedOptionCompliance = options.get(CompilerOptions.OPTION_Compliance);
@@ -25106,7 +25103,7 @@ public void testBug350652k() throws JavaModelException {
this.workingCopies = new ICompilationUnit[1];
this.workingCopies[0] = getWorkingCopy(
"/Completion/src/test/Test.java",
- "package test;"+
+ "package test;\n"+
"public class Test {\n" +
" public void foo() {\n" +
" try {\n" +
@@ -25116,19 +25113,20 @@ public void testBug350652k() throws JavaModelException {
" }\n" +
" }" +
"}\n" +
- "public class IZZException extends Exception {\n" +
+ "class IZZException extends Exception {\n" +
"}\n" +
- "public class IZZAException extends IZZException {\n" +
+ "class IZZAException extends IZZException {\n" +
"}\n");
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
String str = this.workingCopies[0].getSource();
- String completeBehind = "IZZException |";
+ String completeBehind = "catch (IZZAException |";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults(
- "",
+ "Exception[TYPE_REF]{Exception, java.lang, Ljava.lang.Exception;, null, null, " + (R_DEFAULT + R_EXACT_EXPECTED_TYPE + R_RESOLVED + R_UNQUALIFIED + R_EXCEPTION + R_NON_RESTRICTED) + "}\n" +
+ "IZZException[TYPE_REF]{IZZException, test, Ltest.IZZException;, null, null, " + (R_DEFAULT + R_EXACT_EXPECTED_TYPE + R_RESOLVED + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_NON_RESTRICTED) + "}",
requestor.getResults());
} finally {
// Restore compliance settings.
@@ -25137,11 +25135,7 @@ public void testBug350652k() throws JavaModelException {
}
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=350652
-// subclass exception type not allowed in multi-catch
-// Test relevance of sub-type from expected types when no prefix before caret (IZZAException is expected here because of the
-// throw, yet is a less relevant proposal since a child, IZZException is present in the same multi-catch).
-// Also, sub-type should not be an expected type.
-// types in same CU
+// according to comment 5, subtypes of exceptions should also be proposed
public void testBug350652l() throws JavaModelException {
Map options = COMPLETION_PROJECT.getOptions(true);
Object savedOptionCompliance = options.get(CompilerOptions.OPTION_Compliance);
@@ -25161,9 +25155,9 @@ public void testBug350652l() throws JavaModelException {
" }\n" +
" }" +
"}\n" +
- "public class IZZException extends Exception {\n" +
+ "class IZZException extends Exception {\n" +
"}\n" +
- "public class IZZAException extends IZZException {\n" +
+ "class IZZAException extends IZZException {\n" +
"}\n");
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests2.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests2.java
index 8cf9c88c3..42c075532 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests2.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests2.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -48,7 +48,7 @@ import org.eclipse.jdt.internal.core.search.indexing.IndexManager;
public class CompletionTests2 extends ModifyingResourceTests implements RelevanceConstants {
static {
-// TESTS_NAMES = new String[]{"testBug340945"};
+// TESTS_NAMES = new String[]{"testBug326610"};
}
public static class CompletionContainerInitializer implements ContainerInitializer.ITestInitializer {
@@ -5852,4 +5852,46 @@ public void testBug340945d() throws JavaModelException {
"static void foo() \n",
requestor.getVisibleMethods());
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=326610
+// Test if annotations can be added on package declaration in package-info
+public void testBug326610() throws Exception {
+ try {
+ // create P1
+ IFile f = getFile("/Completion/org.eclipse.jdt.annotation_1.0.0.v20120312-1601.jar");
+ IJavaProject p = this.createJavaProject(
+ "P1",
+ new String[]{"src"},
+ new String[]{"JCL_LIB"},
+ "bin",
+ "1.5");
+
+ this.createFolder("/P1/src/p");
+ this.createFile("/P1/lib.jar", f.getContents());
+ this.addLibraryEntry(p, "/P1/lib.jar", true);
+
+ this.createFile(
+ "/P1/src/p/package-info.java",
+ "@No\n" +
+ "package p;\n");
+
+ waitUntilIndexesReady();
+
+ // do completion
+ CompletionTestsRequestor requestor = new CompletionTestsRequestor();
+ ICompilationUnit cu= getCompilationUnit("P1", "src", "p", "package-info.java");
+
+ String str = cu.getSource();
+ String completeBehind = "@No";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ cu.codeComplete(cursorLocation, requestor);
+
+ assertEquals(
+ "element:NonNullByDefault completion:org.eclipse.jdt.annotation.NonNullByDefault relevance:"+ (R_DEFAULT + R_INTERESTING + R_CASE + R_QUALIFIED + R_EXACT_NAME + R_NON_RESTRICTED + R_ANNOTATION),
+ requestor.getResults());
+
+
+ } finally {
+ this.deleteProject("P1");
+ }
+}
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java
index 652161417..bad720840 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java
@@ -14306,4 +14306,128 @@ public void test361963() throws JavaModelException {
"X<T>[TYPE_REF]{, , LX<TT;>;, null, null, replace[116, 116], token[116, 116], 51}",
requestor.getResults());
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=326610
+public void testBug326610() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/test/package-info.java",
+ "package test;\n");
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "package test;";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "import[KEYWORD]{import, null, null, import, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}",
+ requestor.getResults());
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=326610
+public void testBug326610a() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/test/Try.java",
+ "package test;\n");
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "package test;";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "abstract[KEYWORD]{abstract, null, null, abstract, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}\n" +
+ "class[KEYWORD]{class, null, null, class, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}\n" +
+ "enum[KEYWORD]{enum, null, null, enum, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}\n" +
+ "final[KEYWORD]{final, null, null, final, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}\n" +
+ "import[KEYWORD]{import, null, null, import, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}\n" +
+ "interface[KEYWORD]{interface, null, null, interface, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}\n" +
+ "public[KEYWORD]{public, null, null, public, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}",
+ requestor.getResults());
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=326610
+public void testBug326610b() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/test/package-info.java",
+ "/*Complete here*/\n");
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "/*Complete here*/";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "package[KEYWORD]{package, null, null, package, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}",
+ requestor.getResults());
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=326610
+public void testBug326610c() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/test/Try.java",
+ "/*Complete here*/\n");
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "/*Complete here*/";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "abstract[KEYWORD]{abstract, null, null, abstract, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}\n" +
+ "class[KEYWORD]{class, null, null, class, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}\n" +
+ "enum[KEYWORD]{enum, null, null, enum, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}\n" +
+ "final[KEYWORD]{final, null, null, final, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}\n" +
+ "import[KEYWORD]{import, null, null, import, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}\n" +
+ "interface[KEYWORD]{interface, null, null, interface, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}\n" +
+ "package[KEYWORD]{package, null, null, package, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}\n" +
+ "public[KEYWORD]{public, null, null, public, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}",
+ requestor.getResults());
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=326610
+public void testBug326610d() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[2];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/test/package-info.java",
+ "@Non\n" +
+ "package test");
+ this.workingCopies[1] = getWorkingCopy(
+ "/Completion/src/j/NonNull.java",
+ "package j;\n" +
+ "import static java.lang.annotation.ElementType.PACKAGE;\n" +
+ "import java.lang.annotation.Target;\n" +
+ "@Target({PACKAGE})\n" +
+ "public @interface NonNull{}\n");
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "@Non";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "NonNull[TYPE_REF]{j.NonNull, j, Lj.NonNull;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_QUALIFIED + R_EXACT_NAME + R_NON_RESTRICTED + R_ANNOTATION) + "}",
+ requestor.getResults());
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=326610
+public void testBug326610e() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/test/package-info.java",
+ "/*Complete here*/\n" +
+ "package test;");
+
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "/*Complete here*/";
+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "",
+ requestor.getResults());
+}
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java
index 0052f7a6b..cde8aa0c0 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests2.java
@@ -12,11 +12,13 @@
package org.eclipse.jdt.core.tests.model;
import java.io.IOException;
+import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import junit.framework.Test;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
@@ -37,7 +39,7 @@ public class JavaSearchBugsTests2 extends AbstractJavaSearchTests {
}
static {
- //TESTS_NAMES = new String[] {"testBug123836"};
+ //TESTS_NAMES = new String[] {"testBug123836j", "testBug376673"};
}
public static Test suite() {
@@ -481,4 +483,416 @@ public class JavaSearchBugsTests2 extends AbstractJavaSearchTests {
deleteProject("P");
}
}
+
+ /**
+ * @bug 376673: DBCS4.2 Can not rename the class names when DBCS (Surrogate e.g. U+20B9F) is in it
+ * @test Search for DBCS type should report the match
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=376673"
+ */
+ public void testBug376673a() throws CoreException {
+ try {
+ IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL17_LIB"}, "bin", "1.7");
+ String content = "package pkg;\n" +
+ "class 𠮟1 {}\n";
+ createFolder("/P/pkg");
+ try {
+ IFile file = createFile("/P/pkg/𠮟1.java", content, "UTF-8");
+ file.setCharset("UTF-8", null);
+ } catch (UnsupportedEncodingException e) {
+ System.out.println("unsupported encoding");
+ }
+ waitUntilIndexesReady();
+ IJavaSearchScope scope = SearchEngine. createJavaSearchScope(
+ new IJavaElement[] { project }, IJavaSearchScope.SOURCES);
+ search("𠮟1", TYPE, DECLARATIONS, EXACT_RULE, scope, this.resultCollector);
+ assertSearchResults("pkg/𠮟1.java pkg.𠮟1 [𠮟1] EXACT_MATCH");
+ } finally {
+ deleteProject("P");
+ }
+ }
+ // Search for DBCS method should report the match
+ public void testBug376673b() throws CoreException {
+ try {
+ IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL17_LIB"}, "bin", "1.7");
+ String content = "package pkg;\n" +
+ "class 𠮟1 {" +
+ " public void 𠮟m() {}\n" +
+ "}\n";
+ createFolder("/P/pkg");
+ try {
+ IFile file = createFile("/P/pkg/𠮟1.java", content, "UTF-8");
+ file.setCharset("UTF-8", null);
+ } catch (UnsupportedEncodingException e) {
+ System.out.println("unsupported encoding");
+ }
+ waitUntilIndexesReady();
+ IJavaSearchScope scope = SearchEngine. createJavaSearchScope(
+ new IJavaElement[] { project }, IJavaSearchScope.SOURCES);
+ search("𠮟m", METHOD, DECLARATIONS, EXACT_RULE, scope, this.resultCollector);
+ assertSearchResults("pkg/𠮟1.java void pkg.𠮟1.𠮟m() [𠮟m] EXACT_MATCH");
+ } finally {
+ deleteProject("P");
+ }
+ }
+ // Search for DBCS constructor should report the match
+ public void testBug376673c() throws CoreException {
+ try {
+ IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL17_LIB"}, "bin", "1.7");
+ String content = "package pkg;\n" +
+ "class 𠮟1 {" +
+ " public 𠮟1() {}\n" +
+ "}\n";
+ createFolder("/P/pkg");
+ try {
+ IFile file = createFile("/P/pkg/𠮟1.java", content, "UTF-8");
+ file.setCharset("UTF-8", null);
+ } catch (UnsupportedEncodingException e) {
+ System.out.println("unsupported encoding");
+ }
+ waitUntilIndexesReady();
+ IJavaSearchScope scope = SearchEngine. createJavaSearchScope(
+ new IJavaElement[] { project }, IJavaSearchScope.SOURCES);
+ search("𠮟1", CONSTRUCTOR, DECLARATIONS, EXACT_RULE, scope, this.resultCollector);
+ assertSearchResults("pkg/𠮟1.java pkg.𠮟1() [𠮟1] EXACT_MATCH");
+ } finally {
+ deleteProject("P");
+ }
+ }
+ // Search for DBCS field should report the match
+ public void testBug376673d() throws CoreException {
+ try {
+ IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL17_LIB"}, "bin", "1.7");
+ String content = "package pkg;\n" +
+ "class 𠮟1 {" +
+ " public int 𠮟f;\n" +
+ "}\n";
+ createFolder("/P/pkg");
+ try {
+ IFile file = createFile("/P/pkg/𠮟1.java", content, "UTF-8");
+ file.setCharset("UTF-8", null);
+ } catch (UnsupportedEncodingException e) {
+ System.out.println("unsupported encoding");
+ }
+ waitUntilIndexesReady();
+ IJavaSearchScope scope = SearchEngine. createJavaSearchScope(
+ new IJavaElement[] { project }, IJavaSearchScope.SOURCES);
+ search("𠮟f", FIELD, DECLARATIONS, EXACT_RULE, scope, this.resultCollector);
+ assertSearchResults("pkg/𠮟1.java pkg.𠮟1.𠮟f [𠮟f] EXACT_MATCH");
+ } finally {
+ deleteProject("P");
+ }
+ }
+ // Search for DBCS package name from a jar also should report the match
+ public void testBug376673e() throws CoreException, IOException {
+ try {
+ IJavaProject p = createJavaProject("P", new String[] {}, new String[] { "/P/lib376673.jar", "JCL17_LIB" }, "", "1.7");
+
+ org.eclipse.jdt.core.tests.util.Util.createJar(
+ new String[] {
+ "p𠮟/i𠮟/Test.java",
+ "package p𠮟.i𠮟;\n" +
+ "public class Test{}\n" },
+ p.getProject().getLocation().append("lib376673.jar").toOSString(),
+ "1.7");
+ refresh(p);
+ waitUntilIndexesReady();
+ int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES;
+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p }, mask);
+ search("Test", TYPE, DECLARATIONS, scope, this.resultCollector);
+ assertSearchResults("lib376673.jar p𠮟.i𠮟.Test [No source] EXACT_MATCH");
+ } finally {
+ deleteProject("P");
+ }
+ }
+ /**
+ * @bug 357547: [search] Search for method references is returning methods as overriden even if the superclass's method is only package-visible
+ * @test Search for a non-overriden method because of package visibility should not be found
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=357547"
+ */
+ public void testBug357547a() throws CoreException {
+ IJavaProject project = null;
+ try
+ {
+ project = createJavaProject("P");
+ createFolder("/P/p1");
+ createFile("/P/p1/B.java",
+ "package p1;\n" +
+ "import p2.*;\n" +
+ "public class B extends A {\n" +
+ "long k(){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "}\n");
+ createFolder("/P/p2");
+ createFile("/P/p2/A.java",
+ "package p2;\n" +
+ "public class A {\n" +
+ "long k(){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "public long m(){\n"+
+ "return new A().k();\n" +
+ "}\n"+
+ "}\n");
+ IType type = getCompilationUnit("/P/p1/B.java").getType("B");
+ IMethod method = type.getMethod("k", new String[]{});
+ search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector);
+ assertSearchResults("Should not get any results", "", this.resultCollector);
+ } finally {
+ deleteProject(project);
+ }
+ }
+
+ // search for the method name should also not return matches if not-overriden because of package-visible
+ public void testBug357547b() throws CoreException {
+ IJavaProject project = null;
+ try
+ {
+ project = createJavaProject("P");
+ createFolder("/P/p1");
+ createFile("/P/p1/B.java",
+ "package p1;\n" +
+ "import p2.*;\n" +
+ "public class B extends A {\n" +
+ "long k(){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "}\n");
+ createFolder("/P/p2");
+ createFile("/P/p2/A.java",
+ "package p2;\n" +
+ "public class A {\n" +
+ "long k(){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "public long m(){\n"+
+ "return new A().k();\n" +
+ "}\n"+
+ "}\n");
+ waitUntilIndexesReady();
+ // search
+ SearchPattern pattern = SearchPattern.createPattern("p*.B.k()", METHOD, REFERENCES , 0 );
+ search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }), this.resultCollector);
+ assertSearchResults("Should not get any results", "", this.resultCollector);
+ } finally {
+ deleteProject(project);
+ }
+ }
+
+ // search for the method name should return the match if same package
+ public void testBug357547c() throws CoreException {
+ IJavaProject project = null;
+ try
+ {
+ project = createJavaProject("P");
+ createFolder("/P/p2");
+ createFile("/P/p2/B.java",
+ "package p2;\n" +
+ "public class B extends A {\n" +
+ "long k(){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "}\n");
+ createFile("/P/p2/A.java",
+ "package p2;\n" +
+ "public class A {\n" +
+ "long k(){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "public long m(){\n"+
+ "return new A().k();\n" +
+ "}\n"+
+ "}\n");
+ waitUntilIndexesReady();
+ // search
+ SearchPattern pattern = SearchPattern.createPattern("B.k()", METHOD, REFERENCES, EXACT_RULE);
+ search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }), this.resultCollector);
+ assertSearchResults("Wrong results", "p2/A.java long p2.A.m() [k()] EXACT_MATCH", this.resultCollector);
+ } finally {
+ deleteProject(project);
+ }
+ }
+
+
+ public void testBug357547d() throws CoreException {
+ IJavaProject project = null;
+ try
+ {
+ project = createJavaProject("P");
+ createFolder("/P/p1");
+ createFile("/P/p1/B.java",
+ "package p1;\n" +
+ "import p2.*;\n" +
+ "public class B extends A {\n" +
+ "long k(){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "}\n");
+ createFolder("/P/p2");
+ createFile("/P/p2/A.java",
+ "package p2;\n" +
+ "public class A{ \n" +
+ "long k(){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "public long m(){\n"+
+ "return new A().k();\n" +
+ "}\n"+
+ "}\n");
+ createFile("/P/p2/B.java",
+ "package p2;\n" +
+ "public class B {\n" +
+ "}\n");
+ waitUntilIndexesReady();
+ // search
+ SearchPattern pattern = SearchPattern.createPattern("B.k()", METHOD, REFERENCES, EXACT_RULE);
+ search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }), this.resultCollector);
+ assertSearchResults("Should not get any results", "", this.resultCollector);
+ } finally {
+ deleteProject(project);
+ }
+ }
+ // search for the method name should also not return matches if not-overriden because of package-visible
+ // even if they are in jars
+ public void testBug357547e() throws CoreException, IOException {
+ IJavaProject project = null;
+ try
+ {
+ project = createJavaProject("P", new String[] {""}, new String[] { "/P/lib357547.jar", "JCL15_LIB" }, "", "1.5");
+ org.eclipse.jdt.core.tests.util.Util.createJar(new String[] {
+ "p2/A.java",
+ "package p2;\n" +
+ "public class A{}\n" },
+ project.getProject().getLocation().append("libStuff.jar").toOSString(), "1.5");
+
+ org.eclipse.jdt.core.tests.util.Util.createJar(
+ new String[] {
+ "p1/B.java",
+ "package p1;\n"+
+ "import p2.*;\n"+
+ "public class B extends A {\n" +
+ "long k(){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "}\n"},
+ null,
+ project.getProject().getLocation().append("lib357547.jar").toOSString(),
+ new String[] { project.getProject().getLocation().append("libStuff.jar").toOSString() },
+ "1.5");
+ refresh(project);
+ createFolder("/P/p2");
+ createFile("/P/p2/A.java",
+ "package p2;\n" +
+ "public class A {\n" +
+ "long k(){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "public long m(){\n"+
+ "return new A().k();\n" +
+ "}\n"+
+ "}\n");
+ waitUntilIndexesReady();
+ // search
+ SearchPattern pattern = SearchPattern.createPattern("B.k()", METHOD, REFERENCES, EXACT_RULE);
+ search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES), this.resultCollector);
+ assertSearchResults("Wrong results", "", this.resultCollector);
+ } finally {
+ deleteProject(project);
+ }
+ }
+ // search for the method name should also not return matches if not-overriden because of package-visible
+ // even if they are in jars
+ public void testBug357547f() throws CoreException, IOException {
+ IJavaProject project = null;
+ try
+ {
+ project = createJavaProject("P", new String[] {""}, new String[] { "/P/lib357547.jar", "JCL15_LIB" }, "", "1.5");
+ org.eclipse.jdt.core.tests.util.Util.createJar(new String[] {
+ "p2/A.java",
+ "package p2;\n" +
+ "public class A{}\n" },
+ project.getProject().getLocation().append("libStuff.jar").toOSString(), "1.5");
+
+ org.eclipse.jdt.core.tests.util.Util.createJar(
+ new String[] {
+ "p2/B.java",
+ "package p2;\n" +
+ "import p2.*;\n" +
+ "public class B extends A {\n" +
+ "long k(){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "}\n"},
+ null,
+ project.getProject().getLocation().append("lib357547.jar").toOSString(),
+ new String[] { project.getProject().getLocation().append("libStuff.jar").toOSString() },
+ "1.5");
+ refresh(project);
+ createFolder("/P/p2");
+ createFile("/P/p2/A.java",
+ "package p2;\n" +
+ "public class A {\n" +
+ "long k(){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "public long m(){\n"+
+ "return new A().k();\n" +
+ "}\n"+
+ "}\n");
+ waitUntilIndexesReady();
+ // search
+ SearchPattern pattern = SearchPattern.createPattern("B.k()", METHOD, REFERENCES, EXACT_RULE);
+ search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES), this.resultCollector);
+ assertSearchResults("Wrong results", "p2/A.java long p2.A.m() [k()] EXACT_MATCH", this.resultCollector);
+ } finally {
+ deleteProject(project);
+ }
+ }
+
+ // search for declarations also should take care of default
+ public void testBug357547g() throws CoreException {
+ IJavaProject project = null;
+ try
+ {
+ project = createJavaProject("P");
+ createFolder("/P/p1");
+ createFile("/P/p1/B.java",
+ "package p1;\n" +
+ "import p2.*;\n" +
+ "public class B extends A {\n" +
+ "long k(int a){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "}\n");
+ createFile("/P/p1/C.java",
+ "package p1;\n" +
+ "public class C extends B {\n" +
+ "long k(int a){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "}\n");
+ createFolder("/P/p2");
+ createFile("/P/p2/A.java",
+ "package p2;\n" +
+ "public class A{ \n" +
+ "long k(int a){\n" +
+ "return 0;\n" +
+ "}\n" +
+ "public long m(){\n"+
+ "return new A().k(0);\n" +
+ "}\n"+
+ "}\n");
+ createFile("/P/p2/B.java",
+ "package p2;\n" +
+ "public class B {\n" +
+ "}\n");
+ waitUntilIndexesReady();
+ // search
+ SearchPattern pattern = SearchPattern.createPattern("A.k(int)", METHOD, DECLARATIONS, EXACT_RULE);
+ search(pattern, SearchEngine.createJavaSearchScope(new IJavaElement[] { project }), this.resultCollector);
+ assertSearchResults("Wrong results", "p2/A.java long p2.A.k(int) [k] EXACT_MATCH", this.resultCollector);
+ } finally {
+ deleteProject(project);
+ }
+ }
}

Back to the top