Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suboptimal/No code completion suggestions for switching on sealed interfaces #3302

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class CompletionTests17 extends AbstractJavaModelCompletionTests {
private static int nonVoid_Rel = R_DEFAULT+R_RESOLVED+ R_CASE+ R_INTERESTING +R_NON_STATIC+R_NON_RESTRICTED;
private static int unqualified_Rel = R_DEFAULT+R_RESOLVED+ R_CASE+ R_INTERESTING +R_UNQUALIFIED+R_NON_RESTRICTED;
private static int unqualifiedExact_Rel = R_DEFAULT+R_RESOLVED+R_EXACT_EXPECTED_TYPE+ R_CASE+ R_INTERESTING +R_UNQUALIFIED+R_NON_RESTRICTED;
private static int keyword_Rel= R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED;
static {
// TESTS_NAMES = new String[]{"test034"};
}
Expand Down Expand Up @@ -413,245 +412,7 @@ public void test010() throws JavaModelException {
requestor.getResults());

}
public void test011() throws JavaModelException {
this.workingCopies = new ICompilationUnit[1];
this.workingCopies[0] = getWorkingCopy(
"/Completion/src/X.java",
"public class X {\n" +
"public static void main(String[] args) {\n" +
"foo(Integer.valueOf(5));\n" +
"foo(new Object());\n" +
"}\n" +
"private static void foo(Object o) {\n" +
" switch (o) {\n" +
" case : System.out.println(\"Integer:\" + i);break;\n" +
" }\n" +
"}\n" +
"}\n"
);
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
requestor.allowAllRequiredProposals();
String str = this.workingCopies[0].getSource();
String completeBehind = "case ";
int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults("default[KEYWORD]{default, null, null, default, null, "+keyword_Rel+"}\n"
+ "null[KEYWORD]{null, null, null, null, null, "+keyword_Rel+"}",
requestor.getResults());

}
public void test012() throws JavaModelException {
this.workingCopies = new ICompilationUnit[1];
this.workingCopies[0] = getWorkingCopy(
"/Completion/src/X.java",
"public class X {\n" +
"public static void main(String[] args) {\n" +
"foo(Integer.valueOf(5));\n" +
"foo(new Object());\n" +
"}\n" +
"private static void foo(Object o) {\n" +
" switch (o) {\n" +
" case nu : System.out.println(\"Integer:\" + i);break;\n" +
" }\n" +
"}\n" +
"}\n"
);
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
requestor.allowAllRequiredProposals();
String str = this.workingCopies[0].getSource();
String completeBehind = "case nu";
int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults("null[KEYWORD]{null, null, null, null, null, "+keyword_Rel+"}",
requestor.getResults());

}
public void test013() throws JavaModelException {
this.workingCopies = new ICompilationUnit[1];
this.workingCopies[0] = getWorkingCopy(
"/Completion/src/X.java",
"public class X {\n" +
"public static void main(String[] args) {\n" +
"foo(Integer.valueOf(5));\n" +
"foo(new Object());\n" +
"}\n" +
"private static void foo(Object o) {\n" +
" switch (o) {\n" +
" case de : System.out.println(\"Integer:\" + i);break;\n" +
" }\n" +
"}\n" +
"}\n"
);
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
requestor.allowAllRequiredProposals();
String str = this.workingCopies[0].getSource();
String completeBehind = "case de";
int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults("default[KEYWORD]{default, null, null, default, null, "+keyword_Rel+"}",
requestor.getResults());

}
public void test014() throws JavaModelException {
this.workingCopies = new ICompilationUnit[1];
this.workingCopies[0] = getWorkingCopy(
"/Completion/src/X.java",
"public class X {\n" +
"public static void main(String[] args) {\n" +
"foo(Integer.valueOf(5));\n" +
"foo(new Object());\n" +
"}\n" +
"private static void foo(Object o) {\n" +
" switch (o) {\n" +
" case null : System.out.println(\"Integer:\" + i);break;\n" +
" /*here*/case nu : System.out.println(\"Integer:\" + i);break;\n" +
" }\n" +
"}\n" +
"}\n"
);
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
requestor.allowAllRequiredProposals();
String str = this.workingCopies[0].getSource();
String completeBehind = "/*here*/case nu";
int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults("",
requestor.getResults());

}
public void test015() throws JavaModelException {
this.workingCopies = new ICompilationUnit[1];
this.workingCopies[0] = getWorkingCopy(
"/Completion/src/X.java",
"public class X {\n" +
"public static void main(String[] args) {\n" +
"foo(Integer.valueOf(5));\n" +
"foo(new Object());\n" +
"}\n" +
"private static void foo(Object o) {\n" +
" switch (o) {\n" +
" case default : System.out.println(\"Integer:\" + i);break;\n" +
" /*here*/case de : System.out.println(\"Integer:\" + i);break;\n" +
" }\n" +
"}\n" +
"}\n"
);
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
requestor.allowAllRequiredProposals();
String str = this.workingCopies[0].getSource();
String completeBehind = "/*here*/case de";
int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults("",
requestor.getResults());

}
public void test016() throws JavaModelException {
this.workingCopies = new ICompilationUnit[1];
this.workingCopies[0] = getWorkingCopy(
"/Completion/src/X.java",
"public class X {\n" +
"public static void main(String[] args) {\n" +
"foo(Integer.valueOf(5));\n" +
"foo(new Object());\n" +
"}\n" +
"private static void foo(Object o) {\n" +
" switch (o) {\n" +
" case nu -> System.out.println(\"Integer:\" + i);\n" +
" }\n" +
"}\n" +
"}\n"
);
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
requestor.allowAllRequiredProposals();
String str = this.workingCopies[0].getSource();
String completeBehind = "case nu";
int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults("null[KEYWORD]{null, null, null, null, null, "+keyword_Rel+"}",
requestor.getResults());

}
public void test017() throws JavaModelException {
this.workingCopies = new ICompilationUnit[1];
this.workingCopies[0] = getWorkingCopy(
"/Completion/src/X.java",
"public class X {\n" +
"public static void main(String[] args) {\n" +
"foo(Integer.valueOf(5));\n" +
"foo(new Object());\n" +
"}\n" +
"private static void foo(Object o) {\n" +
" switch (o) {\n" +
" case de -> System.out.println(\"Integer:\" + i);\n" +
" }\n" +
"}\n" +
"}\n"
);
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
requestor.allowAllRequiredProposals();
String str = this.workingCopies[0].getSource();
String completeBehind = "case de";
int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults("default[KEYWORD]{default, null, null, default, null, "+keyword_Rel+"}",
requestor.getResults());

}
public void test018() throws JavaModelException {
this.workingCopies = new ICompilationUnit[1];
this.workingCopies[0] = getWorkingCopy(
"/Completion/src/X.java",
"public class X {\n" +
"public static void main(String[] args) {\n" +
"foo(Integer.valueOf(5));\n" +
"foo(new Object());\n" +
"}\n" +
"private static void foo(Object o) {\n" +
" switch (o) {\n" +
" case Integer i -> System.out.println(\"Integer:\" +i);\n" +
" case de -> System.out.println(\"Integer:\" + i);\n" +
" }\n" +
"}\n" +
"}\n"
);
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
requestor.allowAllRequiredProposals();
String str = this.workingCopies[0].getSource();
String completeBehind = "case de";
int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults("default[KEYWORD]{default, null, null, default, null, "+keyword_Rel+"}",
requestor.getResults());

}
public void test019() throws JavaModelException {
this.workingCopies = new ICompilationUnit[1];
this.workingCopies[0] = getWorkingCopy(
"/Completion/src/X.java",
"public class X {\n" +
"public static void main(String[] args) {\n" +
"foo(Integer.valueOf(5));\n" +
"foo(new Object());\n" +
"}\n" +
"private static void foo(Object o) {\n" +
" switch (o) {\n" +
" case Integer i -> System.out.println(\"Integer:\" +i);\n" +
" case n -> System.out.println(\"Integer:\" + i);\n" +
" }\n" +
"}\n" +
"}\n"
);
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
requestor.allowAllRequiredProposals();
String str = this.workingCopies[0].getSource();
String completeBehind = "case n";
int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults("null[KEYWORD]{null, null, null, null, null, "+keyword_Rel+"}",
requestor.getResults());

}
// https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1100
// ContentAssist / CompletionScanner running into deadlock
public void testGH1100() throws JavaModelException {
Expand Down
Loading
Loading