Skip to content

Commit

Permalink
use setter/getter for fSourcefile
Browse files Browse the repository at this point in the history
  • Loading branch information
carstenartur committed Mar 24, 2024
1 parent e50d9ec commit ba20f09
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -375,15 +375,15 @@ 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);
}

@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" //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ 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);
}

@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" //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -93,8 +93,8 @@ public void beforeEach(ExtensionContext context) throws CoreException {
Map<String, String> 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<String, String> settings= new HashMap<>();
fProfile= new ProfileManager.CustomProfile("testProfile", settings, CleanUpProfileVersioner.CURRENT_VERSION, //$NON-NLS-1$
CleanUpProfileVersioner.PROFILE_KIND);
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 });
Expand Down

0 comments on commit ba20f09

Please sign in to comment.