Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests12.java42
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java9
2 files changed, 44 insertions, 7 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests12.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests12.java
index 78394e7f66..d197a84b28 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests12.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests12.java
@@ -358,7 +358,7 @@ public class CompletionTests12 extends AbstractJavaModelCompletionTests {
this.workingCopies[0] = getWorkingCopy(
"/Completion/src/Switch.java",
"public class Switch {\n" +
- " public static void bar(int arg0 day) {\n" +
+ " public static void bar(int arg0) {\n" +
" foo(\n" +
" switch (arg) {\n" +
" case 1 -> 1;\n" +
@@ -384,7 +384,7 @@ public class CompletionTests12 extends AbstractJavaModelCompletionTests {
this.workingCopies[0] = getWorkingCopy(
"/Completion/src/Switch.java",
"public class Switch {\n" +
- " public static void bar(int arg0 day) {\n" +
+ " public static void bar(int arg0) {\n" +
" foo(\n" +
" switch (arg0) {\n" +
" case 1 -> arg;\n" +
@@ -410,7 +410,7 @@ public class CompletionTests12 extends AbstractJavaModelCompletionTests {
this.workingCopies[0] = getWorkingCopy(
"/Completion/src/Switch.java",
"public class Switch {\n" +
- " public static void bar(int arg0 day) {\n" +
+ " public static void bar(int arg0) {\n" +
" foo(\n" +
" switch (0 + arg) {\n" +
" case 1 -> 1;\n" +
@@ -436,7 +436,7 @@ public class CompletionTests12 extends AbstractJavaModelCompletionTests {
this.workingCopies[0] = getWorkingCopy(
"/Completion/src/X.java",
"public class X {\n" +
- " public static void bar(int arg0 day) {\n" +
+ " public static void bar(int arg0) {\n" +
" foo(\n" +
" swi);\n" +
" public static void foo(int arg0) {\n" +
@@ -458,7 +458,7 @@ public class CompletionTests12 extends AbstractJavaModelCompletionTests {
this.workingCopies[0] = getWorkingCopy(
"/Completion/src/X.java",
"public class Switch {\n" +
- " public static void bar(int arg0 day) {\n" +
+ " public static void bar(int arg0) {\n" +
" foo(\n" +
" switch (0 + arg0) {\n" +
" case 1 -> {break ar;}\n" +
@@ -484,7 +484,7 @@ public class CompletionTests12 extends AbstractJavaModelCompletionTests {
this.workingCopies[0] = getWorkingCopy(
"/Completion/src/X.java",
"public class Switch {\n" +
- " public static void bar(int arg0 day) {\n" +
+ " public static void bar(int arg0) {\n" +
" foo(\n" +
" switch (0 + arg0) {\n" +
" case 1 -> {break 1;}\n" +
@@ -510,7 +510,8 @@ public class CompletionTests12 extends AbstractJavaModelCompletionTests {
this.workingCopies[0] = getWorkingCopy(
"/Completion/src/X.java",
"public class Switch {\n" +
- " public static void bar(int arg0 day) {\n" +
+ " public static void bar(int arg0) {\n" +
+ " int arg1 = 0;\n" +
" foo(\n" +
" switch (0 + arg0) {\n" +
" case 1 -> 1;\n" +
@@ -531,6 +532,33 @@ public class CompletionTests12 extends AbstractJavaModelCompletionTests {
"arg0[LOCAL_VARIABLE_REF]{arg0, null, I, arg0, null, 52}",
requestor.getResults());
}
+ public void test017a() throws JavaModelException {
+ this.workingCopies = new ICompilationUnit[1];
+ this.workingCopies[0] = getWorkingCopy(
+ "/Completion/src/X.java",
+ "public class Switch {\n" +
+ " public static void bar(int arg0) {\n" +
+ " foo(\n" +
+ " argLabel: switch (0 + arg0) {\n" +
+ " case 1 -> 1;\n" +
+ " default -> {break ar;}\n" +
+ " }\n" +
+ " });\n" +
+ " public static void foo(int arg0) {\n" +
+ " bar(MyDay.SUNDAY);\n" +
+ " }\n" +
+ "}\n");
+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
+ requestor.allowAllRequiredProposals();
+ String str = this.workingCopies[0].getSource();
+ String completeBehind = "break ar";
+ int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
+ assertResults(
+ "arg0[LOCAL_VARIABLE_REF]{arg0, null, I, arg0, null, 52}\n" +
+ "argLabel[LABEL_REF]{argLabel, null, null, argLabel, null, 49}",
+ requestor.getResults());
+ }
public void test018a() throws JavaModelException {
this.workingCopies = new ICompilationUnit[1];
this.workingCopies[0] = getWorkingCopy(
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java
index 1714d7fe8e..60065a5b01 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java
@@ -5126,6 +5126,15 @@ protected NameReference getUnspecifiedReference(boolean rejectTypeAnnotations) {
return nameReference;
}
@Override
+protected void consumePostfixExpression() {
+ // PostfixExpression ::= Name
+ if(this.topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_INSIDE_BREAK_STATEMENT) {
+ // Do nothing, just let checkLabelStatement() do the job
+ } else {
+ super.consumePostfixExpression();
+ }
+}
+@Override
protected NameReference getUnspecifiedReferenceOptimized() {
if (this.identifierLengthStack[this.identifierLengthPtr] > 1) { // reducing a qualified name
// potential receiver is being poped, so reset potential receiver

Back to the top