From 2fd9321450d584cd11ca90442d0242242ea70632 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Wed, 22 Jan 2025 09:19:57 -0500 Subject: [PATCH] Rewrite for-each pattern variable completion tests to use regular for The syntax used in these tests was withdrawn before the feature was delivered (see #1907). I've altered the tests to use a regular for loop with an `instanceof` in it, so that the tests still check that the scoping of the pattern variables is working properly for completion. Fixes #3589 Signed-off-by: David Thompson --- .../core/tests/model/CompletionTestsForRecordPattern.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsForRecordPattern.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsForRecordPattern.java index b8c2342bbad..36426f584af 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsForRecordPattern.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsForRecordPattern.java @@ -466,7 +466,7 @@ public void test012() throws JavaModelException { + " public static boolean foo(Object o) {\n" + " boolean ret = false;\n" + " R[] recArray = {new R(0)};\n" - + " for (R(int x_1) : recArray) {\n" + + " for (int i = 0; i < recArray.length && recArray[i] instanceof R(int x_1); i++) {\n" + " System.out.println(x_); \n" + " ret = true;\n" + " }\n" @@ -490,7 +490,7 @@ public void test013() throws JavaModelException { "/Completion/src/X.java", "public class X {\n" + " public static void foo(ColoredRectangle[] array) {\n" - + " for(ColoredRectangle(int x_1, int y_1, Color col) : array) {\n" + + " for(int i = 0; i < array.length && array[i] instanceof ColoredRectangle(int x_1, int y_1, Color col); i++) {\n" + " int per = 2 * x_ + 2 * y_1;\n" + " }\n" + " }\n" @@ -515,7 +515,7 @@ public void test014() throws JavaModelException { "/Completion/src/X.java", "public class X {\n" + " public static void foo(ColoredRectangle[] array) {\n" - + " for(ColoredRectangle(int x_1, int y_1, Color col) : array) {\n" + + " for(int i = 0; i < array.length && array[i] instanceof ColoredRectangle(int x_1, int y_1, Color col); i++) {\n" + " int per = 2 * x_1 + 2 * y_;\n" + " }\n" + " }\n" @@ -540,7 +540,7 @@ public void test015() throws JavaModelException { "/Completion/src/X.java", "public class X {\n" + " public static void foo(ColoredRectangle[] ar_ray) {\n" - + " for(ColoredRectangle(int x_1, int y_1, Color col) : ar_) {\n" + + " for(int i = 0; i < ar_ray.length && ar_ray[i] instanceof ColoredRectangle(int x_1, int y_1, Color col); i++) {\n" + " int per = 2 * x_1 + 2 * y_1;\n" + " }\n" + " }\n"