From ba20f09e60fd7ae57cc519dde3612b750cb602bf Mon Sep 17 00:00:00 2001 From: Carsten Hammer Date: Sun, 24 Mar 2024 16:54:40 +0100 Subject: [PATCH] use setter/getter for fSourcefile --- .../jdt/ui/tests/quickfix/Java9CleanUpTest.java | 4 ++-- .../jdt/ui/tests/quickfix/Java8CleanUpTest.java | 4 ++-- .../jdt/ui/tests/quickfix/Java8CleanUpTest.java | 4 ++-- .../jdt/ui/tests/quickfix/Java8CleanUpTest.java | 4 ++-- .../jdt/ui/tests/quickfix/Java9CleanUpTest.java | 4 ++-- .../quickfix/rules/AbstractEclipseJava.java | 16 ++++++++++++---- .../jdt/ui/tests/quickfix/Java8CleanUpTest.java | 4 ++-- .../jdt/ui/tests/quickfix/Java8CleanUpTest.java | 4 ++-- 8 files changed, 26 insertions(+), 18 deletions(-) diff --git a/sandbox_encoding_quickfix_test/src/org/sandbox/jdt/ui/tests/quickfix/Java9CleanUpTest.java b/sandbox_encoding_quickfix_test/src/org/sandbox/jdt/ui/tests/quickfix/Java9CleanUpTest.java index 305e0786..54ebe8d0 100644 --- a/sandbox_encoding_quickfix_test/src/org/sandbox/jdt/ui/tests/quickfix/Java9CleanUpTest.java +++ b/sandbox_encoding_quickfix_test/src/org/sandbox/jdt/ui/tests/quickfix/Java9CleanUpTest.java @@ -375,7 +375,7 @@ enum ExplicitEncodingPatterns { @ParameterizedTest @EnumSource(ExplicitEncodingPatterns.class) public void testExplicitEncodingParametrized(ExplicitEncodingPatterns test) throws CoreException { - IPackageFragment pack= context.fSourceFolder.createPackageFragment("test1", false, null); + IPackageFragment pack= context.getfSourceFolder().createPackageFragment("test1", false, null); ICompilationUnit cu= pack.createCompilationUnit("E1.java", test.given, false, null); context.enable(MYCleanUpConstants.EXPLICITENCODING_CLEANUP); context.assertRefactoringResultAsExpected(new ICompilationUnit[] {cu}, new String[] {test.expected}, null); @@ -383,7 +383,7 @@ public void testExplicitEncodingParametrized(ExplicitEncodingPatterns test) thro @Test public void testExplicitEncoding_donttouch() throws CoreException{ - IPackageFragment pack= context.fSourceFolder.createPackageFragment("test1", false, null); + IPackageFragment pack= context.getfSourceFolder().createPackageFragment("test1", false, null); ICompilationUnit cu= pack.createCompilationUnit("E2.java", "" // + "package test1;\n" // diff --git a/sandbox_functional_converter_test/src/org/sandbox/jdt/ui/tests/quickfix/Java8CleanUpTest.java b/sandbox_functional_converter_test/src/org/sandbox/jdt/ui/tests/quickfix/Java8CleanUpTest.java index 17dcf4e3..cc327114 100644 --- a/sandbox_functional_converter_test/src/org/sandbox/jdt/ui/tests/quickfix/Java8CleanUpTest.java +++ b/sandbox_functional_converter_test/src/org/sandbox/jdt/ui/tests/quickfix/Java8CleanUpTest.java @@ -1150,7 +1150,7 @@ enum UseFunctionalLoop { @ParameterizedTest @EnumSource(UseFunctionalLoop.class) public void testExplicitEncodingParametrized(UseFunctionalLoop test) throws CoreException { - IPackageFragment pack= context.fSourceFolder.createPackageFragment("test1", false, null); + IPackageFragment pack= context.getfSourceFolder().createPackageFragment("test1", false, null); ICompilationUnit cu= pack.createCompilationUnit("TestDemo.java", test.given, false, null); context.enable(MYCleanUpConstants.USEFUNCTIONALLOOP_CLEANUP); context.assertRefactoringResultAsExpected(new ICompilationUnit[] {cu}, new String[] {test.expected}, null); @@ -1610,7 +1610,7 @@ public void testExplicitEncodingParametrized(UseFunctionalLoop test) throws Core }) public void testExplicitEncoding_donttouch(String dontchange) throws CoreException { - IPackageFragment pack= context.fSourceFolder.createPackageFragment("testdemo", false, null); + IPackageFragment pack= context.getfSourceFolder().createPackageFragment("testdemo", false, null); ICompilationUnit cu= pack.createCompilationUnit("TestDemo.java", dontchange, false, null); diff --git a/sandbox_jface_cleanup_test/src/org/sandbox/jdt/ui/tests/quickfix/Java8CleanUpTest.java b/sandbox_jface_cleanup_test/src/org/sandbox/jdt/ui/tests/quickfix/Java8CleanUpTest.java index e45a34b5..79c1d12a 100644 --- a/sandbox_jface_cleanup_test/src/org/sandbox/jdt/ui/tests/quickfix/Java8CleanUpTest.java +++ b/sandbox_jface_cleanup_test/src/org/sandbox/jdt/ui/tests/quickfix/Java8CleanUpTest.java @@ -107,7 +107,7 @@ enum JFaceCleanupCases{ @ParameterizedTest @EnumSource(JFaceCleanupCases.class) public void testJFaceCleanupParametrized(JFaceCleanupCases test) throws CoreException { - IPackageFragment pack= context.fSourceFolder.createPackageFragment("test", false, null); + IPackageFragment pack= context.getfSourceFolder().createPackageFragment("test", false, null); ICompilationUnit cu= pack.createCompilationUnit("Test.java", test.given, false, null); context.enable(MYCleanUpConstants.JFACE_CLEANUP); context.assertRefactoringResultAsExpected(new ICompilationUnit[] {cu}, new String[] {test.expected}, null); @@ -144,7 +144,7 @@ enum NO_JFaceCleanupCases { @ParameterizedTest @EnumSource(NO_JFaceCleanupCases.class) public void testJFaceCleanup_donttouch(NO_JFaceCleanupCases test) throws CoreException { - IPackageFragment pack= context.fSourceFolder.createPackageFragment("test", false, null); + IPackageFragment pack= context.getfSourceFolder().createPackageFragment("test", false, null); ICompilationUnit cu= pack.createCompilationUnit("Test.java",test.given,false, null); context.enable(MYCleanUpConstants.JFACE_CLEANUP); context.assertRefactoringHasNoChange(new ICompilationUnit[] { cu }); diff --git a/sandbox_platform_helper_test/src/org/sandbox/jdt/ui/tests/quickfix/Java8CleanUpTest.java b/sandbox_platform_helper_test/src/org/sandbox/jdt/ui/tests/quickfix/Java8CleanUpTest.java index 9ba87b02..ca5a0a43 100644 --- a/sandbox_platform_helper_test/src/org/sandbox/jdt/ui/tests/quickfix/Java8CleanUpTest.java +++ b/sandbox_platform_helper_test/src/org/sandbox/jdt/ui/tests/quickfix/Java8CleanUpTest.java @@ -125,7 +125,7 @@ enum PlatformStatusPatterns { @ParameterizedTest @EnumSource(PlatformStatusPatterns.class) public void testPlatformStatusParametrized(PlatformStatusPatterns test) throws CoreException { - IPackageFragment pack= context.fSourceFolder.createPackageFragment("test1", false, null); + IPackageFragment pack= context.getfSourceFolder().createPackageFragment("test1", false, null); ICompilationUnit cu= pack.createCompilationUnit("E1.java", test.given, false, null); context.enable(MYCleanUpConstants.SIMPLIFY_STATUS_CLEANUP); context.assertRefactoringResultAsExpected(new ICompilationUnit[] {cu}, new String[] {test.expected}, null); @@ -133,7 +133,7 @@ public void testPlatformStatusParametrized(PlatformStatusPatterns test) throws C @Test public void testPlatformStatus_donttouch() throws CoreException { - IPackageFragment pack= context.fSourceFolder.createPackageFragment("test1", false, null); + IPackageFragment pack= context.getfSourceFolder().createPackageFragment("test1", false, null); ICompilationUnit cu= pack.createCompilationUnit("E2.java", "" // + "package test1;\n" // diff --git a/sandbox_platform_helper_test/src/org/sandbox/jdt/ui/tests/quickfix/Java9CleanUpTest.java b/sandbox_platform_helper_test/src/org/sandbox/jdt/ui/tests/quickfix/Java9CleanUpTest.java index c26f5db1..c2cb7075 100644 --- a/sandbox_platform_helper_test/src/org/sandbox/jdt/ui/tests/quickfix/Java9CleanUpTest.java +++ b/sandbox_platform_helper_test/src/org/sandbox/jdt/ui/tests/quickfix/Java9CleanUpTest.java @@ -103,7 +103,7 @@ enum PlatformStatusPatterns { @ParameterizedTest @EnumSource(PlatformStatusPatterns.class) public void testPlatformStatusParametrized(PlatformStatusPatterns test) throws CoreException { - IPackageFragment pack= context.fSourceFolder.createPackageFragment("test1", false, null); + IPackageFragment pack= context.getfSourceFolder().createPackageFragment("test1", false, null); ICompilationUnit cu= pack.createCompilationUnit("E1.java", test.given, false, null); context.enable(MYCleanUpConstants.SIMPLIFY_STATUS_CLEANUP); context.assertRefactoringResultAsExpected(new ICompilationUnit[] {cu}, new String[] {test.expected}, null); @@ -146,7 +146,7 @@ enum PlatformStatusPatternsDontTouch { @ParameterizedTest @EnumSource(PlatformStatusPatternsDontTouch.class) public void testPlatformStatus_donttouch(PlatformStatusPatternsDontTouch test) throws CoreException { - IPackageFragment pack= context.fSourceFolder.createPackageFragment("test1", false, null); + IPackageFragment pack= context.getfSourceFolder().createPackageFragment("test1", false, null); ICompilationUnit cu= pack.createCompilationUnit("E2.java", test.given, false, null); context.enable(MYCleanUpConstants.SIMPLIFY_STATUS_CLEANUP); context.assertRefactoringHasNoChange(new ICompilationUnit[] { cu }); diff --git a/sandbox_test_commons/src/org/sandbox/jdt/ui/tests/quickfix/rules/AbstractEclipseJava.java b/sandbox_test_commons/src/org/sandbox/jdt/ui/tests/quickfix/rules/AbstractEclipseJava.java index 4915b93c..fdf34ef4 100644 --- a/sandbox_test_commons/src/org/sandbox/jdt/ui/tests/quickfix/rules/AbstractEclipseJava.java +++ b/sandbox_test_commons/src/org/sandbox/jdt/ui/tests/quickfix/rules/AbstractEclipseJava.java @@ -78,7 +78,7 @@ public class AbstractEclipseJava implements AfterEachCallback, BeforeEachCallbac private final String testresources_stubs; private final String compliance; private static final String TEST_SETUP_PROJECT= "TestSetupProject"; //$NON-NLS-1$ - public IPackageFragmentRoot fSourceFolder; + private IPackageFragmentRoot fSourceFolder; private CustomProfile fProfile; public AbstractEclipseJava(String stubs, String compilerversion) { @@ -93,8 +93,8 @@ public void beforeEach(ExtensionContext context) throws CoreException { Map options= javaProject.getOptions(false); JavaCore.setComplianceOptions(compliance, options); javaProject.setOptions(options); - fSourceFolder= AbstractEclipseJava.addSourceContainer(getProject(TEST_SETUP_PROJECT), "src", new Path[0], //$NON-NLS-1$ - new Path[0], null, new IClasspathAttribute[0]); + setfSourceFolder(AbstractEclipseJava.addSourceContainer(getProject(TEST_SETUP_PROJECT), "src", new Path[0], //$NON-NLS-1$ + new Path[0], null, new IClasspathAttribute[0])); Map settings= new HashMap<>(); fProfile= new ProfileManager.CustomProfile("testProfile", settings, CleanUpProfileVersioner.CURRENT_VERSION, //$NON-NLS-1$ CleanUpProfileVersioner.PROFILE_KIND); @@ -106,7 +106,7 @@ public void beforeEach(ExtensionContext context) throws CoreException { @Override public void afterEach(ExtensionContext context) throws CoreException { - delete(fSourceFolder); + delete(getfSourceFolder()); } public IJavaProject getProject(String projectname) { @@ -464,4 +464,12 @@ private void commitProfile() throws CoreException { profileStore.writeProfiles(profiles, InstanceScope.INSTANCE); CleanUpPreferenceUtil.saveSaveParticipantOptions(InstanceScope.INSTANCE, fProfile.getSettings()); } + + public IPackageFragmentRoot getfSourceFolder() { + return fSourceFolder; + } + + public void setfSourceFolder(IPackageFragmentRoot fSourceFolder) { + this.fSourceFolder = fSourceFolder; + } } diff --git a/sandbox_tools_test/src/org/sandbox/jdt/ui/tests/quickfix/Java8CleanUpTest.java b/sandbox_tools_test/src/org/sandbox/jdt/ui/tests/quickfix/Java8CleanUpTest.java index 4aed1231..1b526da0 100644 --- a/sandbox_tools_test/src/org/sandbox/jdt/ui/tests/quickfix/Java8CleanUpTest.java +++ b/sandbox_tools_test/src/org/sandbox/jdt/ui/tests/quickfix/Java8CleanUpTest.java @@ -306,7 +306,7 @@ enum While2EnhancedForLoop { @ParameterizedTest @EnumSource(While2EnhancedForLoop.class) public void testWhile2enhancedForLoopParametrized(While2EnhancedForLoop test) throws CoreException { - IPackageFragment pack= context.fSourceFolder.createPackageFragment("test1", false, null); + IPackageFragment pack= context.getfSourceFolder().createPackageFragment("test1", false, null); ICompilationUnit cu= pack.createCompilationUnit("TestDemo.java", test.given, false, null); context.enable(CleanUpConstants.CONTROL_STATEMENTS_CONVERT_FOR_LOOP_TO_ENHANCED); context.assertRefactoringResultAsExpected(new ICompilationUnit[] {cu}, new String[] {test.expected}, null); @@ -402,7 +402,7 @@ enum NO_While2EnhancedForLoop { @ParameterizedTest @EnumSource(NO_While2EnhancedForLoop.class) public void testWhile2enhancedForLoop_donttouch(NO_While2EnhancedForLoop test) throws CoreException { - IPackageFragment pack= context.fSourceFolder.createPackageFragment("test", false, null); + IPackageFragment pack= context.getfSourceFolder().createPackageFragment("test", false, null); ICompilationUnit cu= pack.createCompilationUnit("Test.java",test.given,false, null); context.enable(CleanUpConstants.CONTROL_STATEMENTS_CONVERT_FOR_LOOP_TO_ENHANCED); context.assertRefactoringHasNoChange(new ICompilationUnit[] { cu }); diff --git a/sandbox_xml_cleanup_test/src/org/sandbox/jdt/ui/tests/quickfix/Java8CleanUpTest.java b/sandbox_xml_cleanup_test/src/org/sandbox/jdt/ui/tests/quickfix/Java8CleanUpTest.java index 3ff0b6f2..b5ccd6e3 100644 --- a/sandbox_xml_cleanup_test/src/org/sandbox/jdt/ui/tests/quickfix/Java8CleanUpTest.java +++ b/sandbox_xml_cleanup_test/src/org/sandbox/jdt/ui/tests/quickfix/Java8CleanUpTest.java @@ -66,7 +66,7 @@ enum XMLCleanupCases{ @ParameterizedTest @EnumSource(XMLCleanupCases.class) public void testXMLCleanupParametrized(XMLCleanupCases test) throws CoreException { - IPackageFragment pack= context.fSourceFolder.createPackageFragment("test", false, null); + IPackageFragment pack= context.getfSourceFolder().createPackageFragment("test", false, null); ICompilationUnit cu= pack.createCompilationUnit("Test.java", test.given, false, null); context.enable(CleanUpConstants.CONTROL_STATEMENTS_CONVERT_FOR_LOOP_TO_ENHANCED); context.assertRefactoringResultAsExpected(new ICompilationUnit[] {cu}, new String[] {test.expected}, null); @@ -103,7 +103,7 @@ enum NO_XMLCleanupCases { @ParameterizedTest @EnumSource(NO_XMLCleanupCases.class) public void testXMLCleanup_donttouch(NO_XMLCleanupCases test) throws CoreException { - IPackageFragment pack= context.fSourceFolder.createPackageFragment("test", false, null); + IPackageFragment pack= context.getfSourceFolder().createPackageFragment("test", false, null); ICompilationUnit cu= pack.createCompilationUnit("Test.java",test.given,false, null); context.enable(CleanUpConstants.CONTROL_STATEMENTS_CONVERT_FOR_LOOP_TO_ENHANCED); context.assertRefactoringHasNoChange(new ICompilationUnit[] { cu });