From 754889cfbf125f026e0d7de7ab828a185c36d140 Mon Sep 17 00:00:00 2001 From: Andrey Loskutov Date: Thu, 25 Jul 2024 21:26:36 +0200 Subject: [PATCH] Fixed tests failing after requiring minimal 1.8 compliance, part 3 - GenerateToStringTest - AnnotateAssistTest1d5 - AnnotateAssistTest1d8 - AssistQuickFixTest - AssistQuickFixTest1d7 See https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2536 --- .../core/source/GenerateToStringTest.java | 17 ++- .../tests/quickfix/AnnotateAssistTest1d5.java | 16 +-- .../tests/quickfix/AnnotateAssistTest1d8.java | 2 +- .../ui/tests/quickfix/AssistQuickFixTest.java | 117 ++---------------- .../tests/quickfix/AssistQuickFixTest1d7.java | 33 ----- 5 files changed, 33 insertions(+), 152 deletions(-) diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/source/GenerateToStringTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/source/GenerateToStringTest.java index d08667d1a8e..40a2f91e1b6 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/source/GenerateToStringTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/source/GenerateToStringTest.java @@ -116,10 +116,10 @@ private void setCompilerLevels(boolean is50orHigher, boolean is60orHigher) throw jp.setRawClasspath(newCP.toArray(new IClasspathEntry[newCP.size()]), null); } if (is60orHigher) { - JavaProjectHelper.addRTJar16(jp); + JavaProjectHelper.addRTJar18(jp); } if (!is50orHigher) { - JavaProjectHelper.addRTJar13(jp); + JavaProjectHelper.addRTJar18(jp); } } @@ -511,6 +511,7 @@ public void concatArrayLimit1_4() throws Exception { + " HashMap hashMap;\r\n" + " Collection wildCollection;\r\n" + " Collection integerCollection;\r\n" + + " @Override\r\n" + " public String toString() {\r\n" + " final int maxLen = 10;\r\n" + " return \"A [AArray=\" + (AArray != null ? arrayToString(AArray, AArray.length, maxLen) : null) + \", aBool=\" + aBool + \", anA=\" + anA + \", floatArray=\" + (floatArray != null ? arrayToString(floatArray, floatArray.length, maxLen) : null) + \", hashMap=\" + (hashMap != null ? toString(hashMap.entrySet(), maxLen) : null) + \", intArray=\" + (intArray != null ? arrayToString(intArray, intArray.length, maxLen) : null) + \", integerCollection=\" + (integerCollection != null ? toString(integerCollection, maxLen) : null) + \", list=\" + (list != null ? toString(list, maxLen) : null) + \", object=\" + object + \", stringArray=\" + (stringArray != null ? arrayToString(stringArray, stringArray.length, maxLen) : null) + \", wildCollection=\" + (wildCollection != null ? toString(wildCollection, maxLen) : null) + \", charArrayMethod()=\" + (charArrayMethod() != null ? arrayToString(charArrayMethod(), charArrayMethod().length, maxLen) : null) + \", floatArrayMethod()=\"\r\n" @@ -571,6 +572,7 @@ public void concatArrayLimit1_4Unique() throws Exception { + " Object len;\r\n" + " Object collection;\r\n" + " Object array;\r\n" + + " @Override\r\n" + " public String toString() {\r\n" + " final int maxLen2 = 10;\r\n" + " return \"A [aBool=\" + aBool + \", intArray=\" + (intArray != null ? arrayToString(intArray, intArray.length, maxLen2) : null) + \", stringArray=\" + (stringArray != null ? arrayToString(stringArray, stringArray.length, maxLen2) : null) + \", AArray=\" + (AArray != null ? arrayToString(AArray, AArray.length, maxLen2) : null) + \", list=\" + (list != null ? toString(list, maxLen2) : null) + \", hashMap=\" + (hashMap != null ? toString(hashMap.entrySet(), maxLen2) : null) + \", wildCollection=\" + (wildCollection != null ? toString(wildCollection, maxLen2) : null) + \", integerCollection=\" + (integerCollection != null ? toString(integerCollection, maxLen2) : null) + \", builder=\" + builder + \", buffer=\" + buffer + \", maxLen=\" + maxLen + \", len=\" + len + \", collection=\" + collection + \", array=\" + array + \"]\";\r\n" @@ -1351,7 +1353,9 @@ public void builderArrayLimit1_4() throws Exception { String expected= "package p;\r\n" + "\r\n" + "import java.util.Collection;\r\n" + "import java.util.HashMap;\r\n" + "import java.util.Iterator;\r\n" + "import java.util.List;\r\n" + "\r\n" + "public class A {\r\n" + "\r\n" + " boolean aBool;\r\n" + " Object object;\r\n" + " A anA;\r\n" + " int[] intArray;\r\n" + " float[] floatArray;\r\n" + " String[] stringArray;\r\n" + " A[] AArray;\r\n" + " char[] charArrayMethod() {\r\n" + " return new char[0];\r\n" + " }\r\n" + " float[] floatArrayMethod() {\r\n" + " return null;\r\n" + " }\r\n" - + " List list;\r\n" + " HashMap hashMap;\r\n" + " Collection wildCollection;\r\n" + " Collection integerCollection;\r\n" + " public String toString() {\r\n" + + " List list;\r\n" + " HashMap hashMap;\r\n" + " Collection wildCollection;\r\n" + " Collection integerCollection;\r\n" + + " @Override\r\n" + + " public String toString() {\r\n" + " final int maxLen = 10;\r\n" + " StringBuffer buffer = new StringBuffer();\r\n" + " buffer.append(\"A [AArray=\");\r\n" + " buffer.append(AArray != null ? arrayToString(AArray, AArray.length, maxLen) : null);\r\n" + " buffer.append(\", aBool=\");\r\n" + " buffer.append(aBool);\r\n" + " buffer.append(\", anA=\");\r\n" + " buffer.append(anA);\r\n" + " buffer.append(\", floatArray=\");\r\n" @@ -1403,7 +1407,9 @@ public void builderArrayLimit1_4Unique() throws Exception { String expected= "package p;\r\n" + "\r\n" + "import java.util.Collection;\r\n" + "import java.util.HashMap;\r\n" + "import java.util.Iterator;\r\n" + "import java.util.List;\r\n" + "\r\n" + "public class A {\r\n" + "\r\n" + " boolean aBool;\r\n" + " int[] intArray;\r\n" + " String[] stringArray;\r\n" + " A[] AArray;\r\n" + " List list;\r\n" + " HashMap hashMap;\r\n" + " Collection wildCollection;\r\n" + " Collection integerCollection;\r\n" + " Object builder;\r\n" + " Object buffer;\r\n" + " Object maxLen;\r\n" + " Object len;\r\n" - + " Object collection;\r\n" + " Object array;\r\n" + " public String toString() {\r\n" + " final int maxLen2 = 10;\r\n" + " StringBuffer buffer2 = new StringBuffer();\r\n" + + " Object collection;\r\n" + " Object array;\r\n" + + " @Override\r\n" + + " public String toString() {\r\n" + " final int maxLen2 = 10;\r\n" + " StringBuffer buffer2 = new StringBuffer();\r\n" + " buffer2.append(\"A [aBool=\");\r\n" + " buffer2.append(aBool);\r\n" + " buffer2.append(\", intArray=\");\r\n" + " buffer2.append(intArray != null ? arrayToString(intArray, intArray.length, maxLen2) : null);\r\n" + " buffer2.append(\", stringArray=\");\r\n" + " buffer2.append(stringArray != null ? arrayToString(stringArray, stringArray.length, maxLen2) : null);\r\n" + " buffer2.append(\", AArray=\");\r\n" @@ -1883,6 +1889,7 @@ public void chainedBuilderArrayLimit1_4() throws Exception { + " HashMap hashMap;\r\n" + " Collection wildCollection;\r\n" + " Collection integerCollection;\r\n" + + " @Override\r\n" + " public String toString() {\r\n" + " final int maxLen = 10;\r\n" + " StringBuffer buffer = new StringBuffer();\r\n" @@ -2452,6 +2459,7 @@ public void formatLimit1_4() throws Exception { + " HashMap hashMap;\r\n" + " Collection wildCollection;\r\n" + " Collection integerCollection;\r\n" + + " @Override\r\n" + " public String toString() {\r\n" + " final int maxLen = 10;\r\n" + " return MessageFormat.format(\"A [AArray={0}, aBool={1}, anA={2}, floatArray={3}, hashMap={4}, intArray={5}, integerCollection={6}, list={7}, object={8}, stringArray={9}, wildCollection={10}, charArrayMethod()={11}, floatArrayMethod()={12}]\", new Object[]{AArray, new Boolean(aBool), anA, floatArray, hashMap != null ? toString(hashMap.entrySet(), maxLen) : null, intArray, integerCollection != null ? toString(integerCollection, maxLen) : null, list != null ? toString(list, maxLen) : null, object, stringArray, wildCollection != null ? toString(wildCollection, maxLen) : null, charArrayMethod(), floatArrayMethod()});\r\n" @@ -3418,6 +3426,7 @@ public void builderArrayLimit1_4Prefixes() throws Exception { + " HashMap hashMap;\r\n" + " Collection wildCollection;\r\n" + " Collection integerCollection;\r\n" + + " @Override\r\n" + " public String toString() {\r\n" + " final int l_maxLen_l = 10;\r\n" + " StringBuffer l_buffer_l = new StringBuffer();\r\n" diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AnnotateAssistTest1d5.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AnnotateAssistTest1d5.java index c2835c2e7e1..45b1e6446fc 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AnnotateAssistTest1d5.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AnnotateAssistTest1d5.java @@ -93,7 +93,7 @@ public interface MyMap { } """ }; - addLibrary(fJProject1, "lib.jar", "lib.zip", pathAndContents, ANNOTATION_PATH, JavaCore.VERSION_1_5, null); + addLibrary(fJProject1, "lib.jar", "lib.zip", pathAndContents, ANNOTATION_PATH, JavaCore.VERSION_1_8, null); IType type= fJProject1.findType(MY_MAP_PATH.replace('/', '.')); JavaEditor javaEditor= (JavaEditor) JavaUI.openInEditor(type); @@ -173,7 +173,7 @@ public interface MyMap { } """ }; - addLibrary(fJProject1, "lib.jar", "lib.zip", pathAndContents, ANNOTATION_PATH, JavaCore.VERSION_1_5, null); + addLibrary(fJProject1, "lib.jar", "lib.zip", pathAndContents, ANNOTATION_PATH, JavaCore.VERSION_1_8, null); IType type= fJProject1.findType(MY_MAP_PATH.replace('/', '.')); JavaEditor javaEditor= (JavaEditor) JavaUI.openInEditor(type); @@ -239,7 +239,7 @@ public interface MyMap { } """ }; - addLibrary(fJProject1, "lib.jar", "lib.zip", pathAndContents, ANNOTATION_PATH, JavaCore.VERSION_1_5, null); + addLibrary(fJProject1, "lib.jar", "lib.zip", pathAndContents, ANNOTATION_PATH, JavaCore.VERSION_1_8, null); IType type= fJProject1.findType(MY_MAP_PATH.replace('/', '.')); IFile annotationFile= fJProject1.getProject().getFile(new Path(ANNOTATION_PATH).append(MY_MAP_PATH + ".eea")); String initialContent= @@ -395,7 +395,7 @@ public interface X { } """ }; - addLibrary(fJProject1, "lib.jar", "lib.zip", pathAndContents, ANNOTATION_PATH, JavaCore.VERSION_1_5, null); + addLibrary(fJProject1, "lib.jar", "lib.zip", pathAndContents, ANNOTATION_PATH, JavaCore.VERSION_1_8, null); IFile annotationFile= fJProject1.getProject().getFile(new Path(ANNOTATION_PATH).append(X_PATH + ".eea")); String initialContent= @@ -472,7 +472,7 @@ public X(String p) {} } """ }; - addLibrary(fJProject1, "lib.jar", "lib.zip", pathAndContents, ANNOTATION_PATH, JavaCore.VERSION_1_5, null); + addLibrary(fJProject1, "lib.jar", "lib.zip", pathAndContents, ANNOTATION_PATH, JavaCore.VERSION_1_8, null); IFile annotationFile= fJProject1.getProject().getFile(new Path(ANNOTATION_PATH).append(X_PATH + ".eea")); String initialContent= @@ -548,7 +548,7 @@ public class Node { } """ }; - addLibrary(fJProject1, "lib.jar", "lib.zip", pathAndContents, ANNOTATION_PATH, JavaCore.VERSION_1_5, null); + addLibrary(fJProject1, "lib.jar", "lib.zip", pathAndContents, ANNOTATION_PATH, JavaCore.VERSION_1_8, null); IType type= fJProject1.findType(NODE_PATH.replace('/', '.')); JavaEditor javaEditor= (JavaEditor) JavaUI.openInEditor(type); @@ -613,7 +613,7 @@ public class Node { } """ }; - addLibrary(fJProject1, "lib.jar", "lib.zip", pathAndContents, ANNOTATION_PATH, JavaCore.VERSION_1_5, null); + addLibrary(fJProject1, "lib.jar", "lib.zip", pathAndContents, ANNOTATION_PATH, JavaCore.VERSION_1_8, null); IType type= fJProject1.findType(NODE_PATH.replace('/', '.')); JavaEditor javaEditor= (JavaEditor) JavaUI.openInEditor(type); @@ -682,7 +682,7 @@ public class Missing { "}\n" }; - addLibrary(fJProject1, "lib.jar", "lib.zip", pathAndContents, ANNOTATION_PATH, JavaCore.VERSION_1_5, unitResult -> !new Path(MISSINGPATH + ".java").equals(new Path(String.valueOf(unitResult.getFileName())))); + addLibrary(fJProject1, "lib.jar", "lib.zip", pathAndContents, ANNOTATION_PATH, JavaCore.VERSION_1_8, unitResult -> !new Path(MISSINGPATH + ".java").equals(new Path(String.valueOf(unitResult.getFileName())))); IType type= fJProject1.findType(CLASS2_PATH.replace('/', '.')); JavaEditor javaEditor= (JavaEditor) JavaUI.openInEditor(type); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AnnotateAssistTest1d8.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AnnotateAssistTest1d8.java index 47064dc25b1..d1fbf9f88df 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AnnotateAssistTest1d8.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AnnotateAssistTest1d8.java @@ -1303,7 +1303,7 @@ public class Node { } """ }; - addLibrary(fJProject1, "lib.jar", "lib.zip", pathAndContents, ANNOTATION_PATH, JavaCore.VERSION_1_5, null); + addLibrary(fJProject1, "lib.jar", "lib.zip", pathAndContents, ANNOTATION_PATH, JavaCore.VERSION_1_8, null); IType type= fJProject1.findType(NODE_PATH.replace('/', '.')); JavaEditor javaEditor= openInClassfileEditor(type, true, true); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java index e64cc023aa8..22dee729a2a 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java @@ -2990,7 +2990,7 @@ public void run() {\s AssistContext context= getCorrectionContext(cu, str1.indexOf(str), 0); List proposals= collectAssists(context, false); - assertNumberOfProposals(proposals, 1); + assertNumberOfProposals(proposals, 2); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); @@ -7374,7 +7374,7 @@ public void run() { AssistContext context= getCorrectionContext(cu, offset, 1); List proposals= collectAssists(context, false); - assertNumberOfProposals(proposals, 1); + assertNumberOfProposals(proposals, 2); assertCorrectLabels(proposals); String str1= """ @@ -7789,48 +7789,6 @@ public void foo() { assertProposalPreviewEquals(str1, NLS.bind(CorrectionMessages.QuickAssistProcessor_convert_to_string_buffer_description, "StringBuilder"), proposals); } - @Test - public void testConvertToStringBufferJava14() throws Exception { - - Map oldOptions= fJProject1.getOptions(false); - Map newOptions= new HashMap<>(oldOptions); - JavaCore.setComplianceOptions(JavaCore.VERSION_1_4, newOptions); - fJProject1.setOptions(newOptions); - - try { - IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); - String str= """ - package test1; - public class A { - public void foo() { - System.out.println("foo"+"bar"); - } - } - """; - ICompilationUnit cu= pack1.createCompilationUnit("A.java", str, false, null); - - AssistContext context= getCorrectionContext(cu, str.indexOf("\"+\""), 0); - List proposals= collectAssists(context, false); - - assertCorrectLabels(proposals); - - String str1= """ - package test1; - public class A { - public void foo() { - StringBuffer stringBuffer = new StringBuffer(); - stringBuffer.append("foo"); - stringBuffer.append("bar"); - System.out.println(stringBuffer.toString()); - } - } - """; - assertProposalPreviewEquals(str1, NLS.bind(CorrectionMessages.QuickAssistProcessor_convert_to_string_buffer_description, "StringBuffer"), proposals); - } finally { - fJProject1.setOptions(oldOptions); - } - } - @Test public void testConvertToStringBufferExisting1() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); @@ -7928,7 +7886,7 @@ public void foo(Object o1, Object o2) { public class A { public void foo(Object o1, Object o2) { - System.out.println(MessageFormat.format("foo{0} \\"bar\\" {1}", new Object[]{o1, o2})); + System.out.println(MessageFormat.format("foo{0} \\"bar\\" {1}", o1, o2)); } } """; @@ -7991,7 +7949,7 @@ public void foo(Object o1, Object o2) { public class A { public void foo(Object o1, Object o2) { - System.out.println(MessageFormat.format("foo{0} \\"bar\\" ", new Object[]{new Integer(1)})); + System.out.println(MessageFormat.format("foo{0} \\"bar\\" ", 1)); } } """; @@ -9435,7 +9393,7 @@ & Comparable> Iterable getIterabl import java.util.List; public class E { void foo() { - for (Iterable iterable : getIterable()) { + for (Comparable comparable : getIterable()) { \s } } @@ -9451,9 +9409,9 @@ & Comparable> Iterable getIterabl import java.util.List; public class E { void foo() { - for (Iterator> iterator = getIterable() - .iterator(); iterator.hasNext();) { - Iterable iterable = iterator.next(); + for (Iterator iterator = getIterable().iterator(); iterator + .hasNext();) { + Comparable comparable = iterator.next(); \s } } @@ -9754,59 +9712,6 @@ void foo(Collection collection) { } } - @Test - public void testGenerateForLowVersion() throws Exception { - IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); - String str= """ - package test1; - import java.util.Collection; - public class E { - void foo(Collection collection) { - collection - } - } - """; - ICompilationUnit cu= pack1.createCompilationUnit("E.java", str, false, null); - - Map saveOptions= fJProject1.getOptions(false); - Map newOptions= new HashMap<>(); - JavaCore.setComplianceOptions(JavaCore.VERSION_1_4, newOptions); - newOptions.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, "true"); - try { - fJProject1.setOptions(newOptions); - - String selection= "collection"; - AssistContext context= getCorrectionContext(cu, str.lastIndexOf(selection) + selection.length(), 0); - List proposals= collectAssists(context, false); - - assertNumberOfProposals(proposals, 5); - assertProposalDoesNotExist(proposals, CorrectionMessages.QuickAssistProcessor_generate_enhanced_for_loop); - assertCorrectLabels(proposals); - - String[] expected= new String[1]; - - // no generics should be added to iterator since the version is too low - String str1= """ - package test1; - import java.util.Collection; - import java.util.Iterator; - public class E { - void foo(Collection collection) { - for (Iterator iterator = collection.iterator(); iterator.hasNext();) { - Object object = iterator.next(); - \s - } - } - } - """; - expected[0]= str1; - - assertExpectedExistInProposals(proposals, expected); - } finally { - fJProject1.setOptions(saveOptions); - } - } - @Test public void testGenerateForArray() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); @@ -10005,7 +9910,7 @@ static Set raw(int i) { Map saveOptions= fJProject1.getOptions(false); Map newOptions= new HashMap<>(); - JavaCore.setComplianceOptions(JavaCore.VERSION_1_5, newOptions); + JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, newOptions); newOptions.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, "true"); try { fJProject1.setOptions(newOptions); @@ -10103,7 +10008,7 @@ static Set raw(int i) { Map saveOptions= fJProject1.getOptions(false); Map newOptions= new HashMap<>(); - JavaCore.setComplianceOptions(JavaCore.VERSION_1_5, newOptions); + JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, newOptions); newOptions.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, "true"); try { fJProject1.setOptions(newOptions); @@ -10175,7 +10080,7 @@ static Date[] get() { Map saveOptions= fJProject1.getOptions(false); Map newOptions= new HashMap<>(); - JavaCore.setComplianceOptions(JavaCore.VERSION_1_5, newOptions); + JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, newOptions); newOptions.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, "true"); try { fJProject1.setOptions(newOptions); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest1d7.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest1d7.java index 3627d609075..6dbad9d3a93 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest1d7.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest1d7.java @@ -277,39 +277,6 @@ void foo() { assertProposalDoesNotExist(proposals, CONVERT_TO_A_SINGLE_MULTI_CATCH_BLOCK); } - @Test - public void testConvertToMultiCatch6() throws Exception { - //Quick assist should not be offered in 1.5 mode - JavaProjectHelper.set15CompilerOptions(fJProject1); - try { - IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); - String str= """ - package test1; - public class E { - void foo() { - try { - System.out.println("foo"); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } catch (NullPointerException e) { - e.printStackTrace(); - } - } - } - """; - ICompilationUnit cu= pack1.createCompilationUnit("E.java", str, false, null); - - int offset= str.indexOf("catch"); - AssistContext context= getCorrectionContext(cu, offset, 0); - assertNoErrors(context); - List proposals= collectAssists(context, false); - - assertProposalDoesNotExist(proposals, CONVERT_TO_A_SINGLE_MULTI_CATCH_BLOCK); - } finally { - JavaProjectHelper.set17CompilerOptions(fJProject1); - } - } - @Test public void testUnrollMultiCatch1() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);