diff --git a/sandbox_common/src/org/sandbox/jdt/internal/corext/fix2/MYCleanUpConstants.java b/sandbox_common/src/org/sandbox/jdt/internal/corext/fix2/MYCleanUpConstants.java index 7c86c2b8..5873996d 100644 --- a/sandbox_common/src/org/sandbox/jdt/internal/corext/fix2/MYCleanUpConstants.java +++ b/sandbox_common/src/org/sandbox/jdt/internal/corext/fix2/MYCleanUpConstants.java @@ -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$ /** * */ diff --git a/sandbox_junit_cleanup/src/org/sandbox/jdt/internal/ui/fix/JUnitCleanUpCore.java b/sandbox_junit_cleanup/src/org/sandbox/jdt/internal/ui/fix/JUnitCleanUpCore.java index 3e8feb61..fdfe5c53 100644 --- a/sandbox_junit_cleanup/src/org/sandbox/jdt/internal/ui/fix/JUnitCleanUpCore.java +++ b/sandbox_junit_cleanup/src/org/sandbox/jdt/internal/ui/fix/JUnitCleanUpCore.java @@ -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 options) { @@ -98,11 +99,29 @@ public String getPreview() { return sb.toString(); } + + private EnumSet computeFixSet() { - EnumSet fixSet= EnumSet.noneOf(JUnitCleanUpFixCore.class); - if (isEnabled(JUNIT_CLEANUP)) { - fixSet= EnumSet.allOf(JUnitCleanUpFixCore.class); - } + EnumSet fixSet = isEnabled(JUNIT_CLEANUP) + ? EnumSet.allOf(JUnitCleanUpFixCore.class) + : EnumSet.noneOf(JUnitCleanUpFixCore.class); + Map 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; } } diff --git a/sandbox_junit_cleanup/src/org/sandbox/jdt/internal/ui/preferences/cleanup/CleanUpMessages.java b/sandbox_junit_cleanup/src/org/sandbox/jdt/internal/ui/preferences/cleanup/CleanUpMessages.java index ca6684b7..16702af2 100644 --- a/sandbox_junit_cleanup/src/org/sandbox/jdt/internal/ui/preferences/cleanup/CleanUpMessages.java +++ b/sandbox_junit_cleanup/src/org/sandbox/jdt/internal/ui/preferences/cleanup/CleanUpMessages.java @@ -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 diff --git a/sandbox_junit_cleanup/src/org/sandbox/jdt/internal/ui/preferences/cleanup/CleanUpMessages.properties b/sandbox_junit_cleanup/src/org/sandbox/jdt/internal/ui/preferences/cleanup/CleanUpMessages.properties index 4434c43c..af0bab99 100644 --- a/sandbox_junit_cleanup/src/org/sandbox/jdt/internal/ui/preferences/cleanup/CleanUpMessages.properties +++ b/sandbox_junit_cleanup/src/org/sandbox/jdt/internal/ui/preferences/cleanup/CleanUpMessages.properties @@ -1,2 +1,2 @@ JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP=JUNIT_CLEANUP -JavaFeatureTabPage_GroupName_Java1d8=Java 8 \ No newline at end of file +JavaFeatureTabPage_GroupName_JUnit=JUnit \ No newline at end of file diff --git a/sandbox_junit_cleanup/src/org/sandbox/jdt/internal/ui/preferences/cleanup/DefaultCleanUpOptionsInitializer.java b/sandbox_junit_cleanup/src/org/sandbox/jdt/internal/ui/preferences/cleanup/DefaultCleanUpOptionsInitializer.java index 07060059..ec7a8f4e 100644 --- a/sandbox_junit_cleanup/src/org/sandbox/jdt/internal/ui/preferences/cleanup/DefaultCleanUpOptionsInitializer.java +++ b/sandbox_junit_cleanup/src/org/sandbox/jdt/internal/ui/preferences/cleanup/DefaultCleanUpOptionsInitializer.java @@ -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); } } diff --git a/sandbox_junit_cleanup/src/org/sandbox/jdt/internal/ui/preferences/cleanup/SandboxCodeTabPage.java b/sandbox_junit_cleanup/src/org/sandbox/jdt/internal/ui/preferences/cleanup/SandboxCodeTabPage.java index 0e9216d7..0acdbd6b 100644 --- a/sandbox_junit_cleanup/src/org/sandbox/jdt/internal/ui/preferences/cleanup/SandboxCodeTabPage.java +++ b/sandbox_junit_cleanup/src/org/sandbox/jdt/internal/ui/preferences/cleanup/SandboxCodeTabPage.java @@ -39,11 +39,26 @@ protected AbstractCleanUp[] createPreviewCleanUps(Map 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); } } \ No newline at end of file diff --git a/sandbox_junit_cleanup/src/org/sandbox/jdt/internal/ui/preferences/cleanup/SaveActionCleanUpOptionsInitializer.java b/sandbox_junit_cleanup/src/org/sandbox/jdt/internal/ui/preferences/cleanup/SaveActionCleanUpOptionsInitializer.java index 3acdacc0..f24a4f33 100644 --- a/sandbox_junit_cleanup/src/org/sandbox/jdt/internal/ui/preferences/cleanup/SaveActionCleanUpOptionsInitializer.java +++ b/sandbox_junit_cleanup/src/org/sandbox/jdt/internal/ui/preferences/cleanup/SaveActionCleanUpOptionsInitializer.java @@ -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); } }