Skip to content

Commit

Permalink
add separate constants for each migration piece
Browse files Browse the repository at this point in the history
  • Loading branch information
carstenartur committed Nov 5, 2024
1 parent 29c0c60 commit ad23fab
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,58 @@ public class MYCleanUpConstants {
*
*/
public static final String JUNIT_CLEANUP= "cleanup.junitcleanup"; //$NON-NLS-1$
/**
*
*/
public static final String JUNIT_CLEANUP_4_ASSERT= "cleanup.junitcleanup_4_assert"; //$NON-NLS-1$
/**
*
*/
public static final String JUNIT_CLEANUP_4_ASSUME= "cleanup.junitcleanup_4_assume"; //$NON-NLS-1$
/**
*
*/
public static final String JUNIT_CLEANUP_4_SUITE= "cleanup.junitcleanup_4_suite"; //$NON-NLS-1$
/**
*
*/
public static final String JUNIT_CLEANUP_4_BEFORE= "cleanup.junitcleanup_4_before"; //$NON-NLS-1$
/**
*
*/
public static final String JUNIT_CLEANUP_4_AFTER= "cleanup.junitcleanup_4_after"; //$NON-NLS-1$
/**
*
*/
public static final String JUNIT_CLEANUP_4_BEFORECLASS= "cleanup.junitcleanup_4_beforeclass"; //$NON-NLS-1$
/**
*
*/
public static final String JUNIT_CLEANUP_4_AFTERCLASS= "cleanup.junitcleanup_4_afterclass"; //$NON-NLS-1$
/**
*
*/
public static final String JUNIT_CLEANUP_4_IGNORE= "cleanup.junitcleanup_4_ignore"; //$NON-NLS-1$
/**
*
*/
public static final String JUNIT_CLEANUP_4_TEST= "cleanup.junitcleanup_4_test"; //$NON-NLS-1$
/**
*
*/
public static final String JUNIT_CLEANUP_4_RULETEMPORARYFOLDER= "cleanup.junitcleanup_4_ruletemporaryfolder"; //$NON-NLS-1$
/**
*
*/
public static final String JUNIT_CLEANUP_4_RULETESTNAME= "cleanup.junitcleanup_4_ruletestname"; //$NON-NLS-1$
/**
*
*/
public static final String JUNIT_CLEANUP_4_EXTERNALRESOURCE= "cleanup.junitcleanup_4_externalresource"; //$NON-NLS-1$
/**
*
*/
public static final String JUNIT_CLEANUP_4_RUNWITH= "cleanup.junitcleanup_4_runwith"; //$NON-NLS-1$
/**
*
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.eclipse.jdt.ui.cleanup.CleanUpRequirements;
import org.eclipse.jdt.ui.cleanup.ICleanUpFix;
import org.sandbox.jdt.internal.corext.fix.JUnitCleanUpFixCore;
import org.sandbox.jdt.internal.corext.fix2.MYCleanUpConstants;

public class JUnitCleanUpCore extends AbstractCleanUp {
public JUnitCleanUpCore(final Map<String, String> options) {
Expand Down Expand Up @@ -98,11 +99,29 @@ public String getPreview() {
return sb.toString();
}



private EnumSet<JUnitCleanUpFixCore> computeFixSet() {
EnumSet<JUnitCleanUpFixCore> fixSet= EnumSet.noneOf(JUnitCleanUpFixCore.class);
if (isEnabled(JUNIT_CLEANUP)) {
fixSet= EnumSet.allOf(JUnitCleanUpFixCore.class);
}
EnumSet<JUnitCleanUpFixCore> fixSet = isEnabled(JUNIT_CLEANUP)
? EnumSet.allOf(JUnitCleanUpFixCore.class)
: EnumSet.noneOf(JUnitCleanUpFixCore.class);
Map<String, JUnitCleanUpFixCore> cleanupMappings = Map.of(
MYCleanUpConstants.JUNIT_CLEANUP_4_ASSERT, JUnitCleanUpFixCore.ASSERT,
MYCleanUpConstants.JUNIT_CLEANUP_4_ASSUME, JUnitCleanUpFixCore.ASSUME,
MYCleanUpConstants.JUNIT_CLEANUP_4_AFTER, JUnitCleanUpFixCore.AFTER,
MYCleanUpConstants.JUNIT_CLEANUP_4_BEFORE, JUnitCleanUpFixCore.BEFORE,
MYCleanUpConstants.JUNIT_CLEANUP_4_AFTERCLASS, JUnitCleanUpFixCore.AFTERCLASS,
MYCleanUpConstants.JUNIT_CLEANUP_4_BEFORECLASS, JUnitCleanUpFixCore.BEFORECLASS,
MYCleanUpConstants.JUNIT_CLEANUP_4_TEST, JUnitCleanUpFixCore.TEST,
MYCleanUpConstants.JUNIT_CLEANUP_4_IGNORE, JUnitCleanUpFixCore.IGNORE,
MYCleanUpConstants.JUNIT_CLEANUP_4_RULETEMPORARYFOLDER, JUnitCleanUpFixCore.RULETEMPORARYFOLDER,
MYCleanUpConstants.JUNIT_CLEANUP_4_RULETESTNAME, JUnitCleanUpFixCore.RULETESTNAME
);
cleanupMappings.forEach((config, fix) -> {
if (!isEnabled(config)) {
fixSet.remove(fix);
}
});
return fixSet;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,21 @@

public class CleanUpMessages {
private static final String BUNDLE_NAME= "org.sandbox.jdt.internal.ui.preferences.cleanup.CleanUpMessages"; //$NON-NLS-1$
public static String JavaFeatureTabPage_GroupName_Java1d8;
public static String JavaFeatureTabPage_GroupName_JUnit;
public static String JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP;
public static String JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_ASSERT;
public static String JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_ASSUME;
public static String JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_IGNORE;
public static String JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_TEST;
public static String JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_BEFORE;
public static String JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_AFTER;
public static String JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_BEFORECLASS;
public static String JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_AFTERCLASS;
public static String JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_RULETEMPORARYFOLDER;
public static String JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_RULETESTNAME;
public static String JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_EXTERNALRESOURCE;
public static String JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_RUNWITH;


static {
// initialize resource bundle
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP=JUNIT_CLEANUP
JavaFeatureTabPage_GroupName_Java1d8=Java 8
JavaFeatureTabPage_GroupName_JUnit=JUnit
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,17 @@ public class DefaultCleanUpOptionsInitializer implements ICleanUpOptionsInitiali
@Override
public void setDefaultOptions(CleanUpOptions options) {
options.setOption(MYCleanUpConstants.JUNIT_CLEANUP, CleanUpOptions.FALSE);
options.setOption(MYCleanUpConstants.JUNIT_CLEANUP_4_AFTER, CleanUpOptions.FALSE);
options.setOption(MYCleanUpConstants.JUNIT_CLEANUP_4_BEFORE, CleanUpOptions.FALSE);
options.setOption(MYCleanUpConstants.JUNIT_CLEANUP_4_AFTERCLASS, CleanUpOptions.FALSE);
options.setOption(MYCleanUpConstants.JUNIT_CLEANUP_4_BEFORECLASS, CleanUpOptions.FALSE);
options.setOption(MYCleanUpConstants.JUNIT_CLEANUP_4_ASSUME, CleanUpOptions.FALSE);
options.setOption(MYCleanUpConstants.JUNIT_CLEANUP_4_ASSERT, CleanUpOptions.FALSE);
options.setOption(MYCleanUpConstants.JUNIT_CLEANUP_4_IGNORE, CleanUpOptions.FALSE);
options.setOption(MYCleanUpConstants.JUNIT_CLEANUP_4_TEST, CleanUpOptions.FALSE);
options.setOption(MYCleanUpConstants.JUNIT_CLEANUP_4_RULETESTNAME, CleanUpOptions.FALSE);
options.setOption(MYCleanUpConstants.JUNIT_CLEANUP_4_RULETEMPORARYFOLDER, CleanUpOptions.FALSE);
options.setOption(MYCleanUpConstants.JUNIT_CLEANUP_4_EXTERNALRESOURCE, CleanUpOptions.FALSE);
options.setOption(MYCleanUpConstants.JUNIT_CLEANUP_4_RUNWITH, CleanUpOptions.FALSE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,26 @@ protected AbstractCleanUp[] createPreviewCleanUps(Map<String, String> values) {

@Override
protected void doCreatePreferences(Composite composite, int numColumns) {
Group java1d8Group= createGroup(numColumns, composite, CleanUpMessages.JavaFeatureTabPage_GroupName_Java1d8);
final CheckboxPreference junitcb= createCheckboxPref(java1d8Group, numColumns,
Group junitGroup= createGroup(numColumns, composite, CleanUpMessages.JavaFeatureTabPage_GroupName_JUnit);
final CheckboxPreference junitcb= createCheckboxPref(junitGroup, numColumns,
CleanUpMessages.JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP, MYCleanUpConstants.JUNIT_CLEANUP,
FALSE_TRUE);
intent(java1d8Group);
intent(junitGroup);
final CheckboxPreference junit_assert= createCheckboxPref(junitGroup, numColumns,
CleanUpMessages.JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_ASSERT, MYCleanUpConstants.JUNIT_CLEANUP_4_ASSERT,
FALSE_TRUE);
final CheckboxPreference junit_assume= createCheckboxPref(junitGroup, numColumns,
CleanUpMessages.JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_ASSUME, MYCleanUpConstants.JUNIT_CLEANUP_4_ASSUME,
FALSE_TRUE);
final CheckboxPreference junit_ignore= createCheckboxPref(junitGroup, numColumns,
CleanUpMessages.JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_IGNORE, MYCleanUpConstants.JUNIT_CLEANUP_4_IGNORE,
FALSE_TRUE);
final CheckboxPreference junit_test= createCheckboxPref(junitGroup, numColumns,
CleanUpMessages.JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_TEST, MYCleanUpConstants.JUNIT_CLEANUP_4_TEST,
FALSE_TRUE);
registerSlavePreference(junitcb, new CheckboxPreference[] {junit_assert, junit_assume,junit_ignore,junit_test});
intent(junitGroup);

registerPreference(junitcb);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,17 @@ public class SaveActionCleanUpOptionsInitializer implements ICleanUpOptionsIniti
@Override
public void setDefaultOptions(CleanUpOptions options) {
options.setOption(MYCleanUpConstants.JUNIT_CLEANUP, CleanUpOptions.FALSE);
options.setOption(MYCleanUpConstants.JUNIT_CLEANUP_4_AFTER, CleanUpOptions.FALSE);
options.setOption(MYCleanUpConstants.JUNIT_CLEANUP_4_BEFORE, CleanUpOptions.FALSE);
options.setOption(MYCleanUpConstants.JUNIT_CLEANUP_4_AFTERCLASS, CleanUpOptions.FALSE);
options.setOption(MYCleanUpConstants.JUNIT_CLEANUP_4_BEFORECLASS, CleanUpOptions.FALSE);
options.setOption(MYCleanUpConstants.JUNIT_CLEANUP_4_ASSUME, CleanUpOptions.FALSE);
options.setOption(MYCleanUpConstants.JUNIT_CLEANUP_4_ASSERT, CleanUpOptions.FALSE);
options.setOption(MYCleanUpConstants.JUNIT_CLEANUP_4_IGNORE, CleanUpOptions.FALSE);
options.setOption(MYCleanUpConstants.JUNIT_CLEANUP_4_TEST, CleanUpOptions.FALSE);
options.setOption(MYCleanUpConstants.JUNIT_CLEANUP_4_RULETESTNAME, CleanUpOptions.FALSE);
options.setOption(MYCleanUpConstants.JUNIT_CLEANUP_4_RULETEMPORARYFOLDER, CleanUpOptions.FALSE);
options.setOption(MYCleanUpConstants.JUNIT_CLEANUP_4_EXTERNALRESOURCE, CleanUpOptions.FALSE);
options.setOption(MYCleanUpConstants.JUNIT_CLEANUP_4_RUNWITH, CleanUpOptions.FALSE);
}
}

0 comments on commit ad23fab

Please sign in to comment.