Skip to content

Commit

Permalink
add checkboxes for missing parts
Browse files Browse the repository at this point in the history
  • Loading branch information
carstenartur committed Nov 17, 2024
1 parent 9cc4f0f commit 67aeebe
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*******************************************************************************
* Copyright (c) 2021 Carsten Hammer.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Carsten Hammer
*******************************************************************************/
package org.sandbox.jdt.internal.corext.fix.helper;

import java.util.Map.Entry;
import java.util.Set;

import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.Annotation;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
import org.eclipse.jdt.core.dom.rewrite.ImportRewrite;
import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperationWithSourceRange;
import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
import org.eclipse.text.edits.TextEditGroup;
import org.sandbox.jdt.internal.common.HelperVisitor;
import org.sandbox.jdt.internal.common.ReferenceHolder;
import org.sandbox.jdt.internal.corext.fix.JUnitCleanUpFixCore;

/**
*
*
*/
public class FixMethodOrderJUnitPlugin extends AbstractTool<ReferenceHolder<Integer, JunitHolder>> {

@Override
public void find(JUnitCleanUpFixCore fixcore, CompilationUnit compilationUnit,
Set<CompilationUnitRewriteOperationWithSourceRange> operations, Set<ASTNode> nodesprocessed) {
ReferenceHolder<Integer, JunitHolder> dataholder= new ReferenceHolder<>();
HelperVisitor.callSingleMemberAnnotationVisitor("org.junit.FixMethodOrder", compilationUnit, dataholder, nodesprocessed,
(visited, aholder) -> processFoundNodeRunWith(fixcore, operations, visited, aholder));
}

private boolean processFoundNodeRunWith(JUnitCleanUpFixCore fixcore,
Set<CompilationUnitRewriteOperationWithSourceRange> operations, Annotation node,
ReferenceHolder<Integer, JunitHolder> dataholder) {

return false;
}

@Override
public void rewrite(JUnitCleanUpFixCore upp, final ReferenceHolder<Integer, JunitHolder> hit,
final CompilationUnitRewrite cuRewrite, TextEditGroup group) {
ASTRewrite rewrite= cuRewrite.getASTRewrite();
AST ast= cuRewrite.getRoot().getAST();
ImportRewrite importrewriter= cuRewrite.getImportRewrite();
for (Entry<Integer, JunitHolder> entry : hit.entrySet()) {
JunitHolder mh= entry.getValue();
@SuppressWarnings("unused")
Annotation minv= mh.getAnnotation();
}
}

@Override
public String getPreview(boolean afterRefactoring) {
if (afterRefactoring) {
return """
@FixMethodOrder({
})
"""; //$NON-NLS-1$
}
return """
@FixMethodOrder({
})
"""; //$NON-NLS-1$
}

@Override
public String toString() {
return "FixMethodOrder"; //$NON-NLS-1$
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public String getPreview(boolean afterRefactoring) {
return """
@Suite
@SelectClasses({
MyTest2.class
MyTest.class
})
"""; //$NON-NLS-1$
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP=JUNIT_CLEANUP
JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_ASSERT=Assert
JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_ASSUME=Assume
JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_IGNORE=Ignore
JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_TEST=Test
JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_BEFORE=Before
JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_AFTER=After
JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_BEFORECLASS=BeforeClass
JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_AFTERCLASS=AfterClass
JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_RULETEMPORARYFOLDER=Rule TemporaryFolder
JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_RULETESTNAME=Rule Testname
JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_EXTERNALRESOURCE=ExternalResource
JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_RUNWITH=RunWith
JavaFeatureTabPage_GroupName_JUnit=JUnit
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,67 @@ protected void doCreatePreferences(Composite composite, int numColumns) {
CleanUpMessages.JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP, MYCleanUpConstants.JUNIT_CLEANUP,
FALSE_TRUE);
intent(junitGroup);
final CheckboxPreference junit_assert= createCheckboxPref(junitGroup, numColumns,
final CheckboxPreference junit_assert= createCheckboxPref(junitGroup, numColumns-1,
CleanUpMessages.JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_ASSERT, MYCleanUpConstants.JUNIT_CLEANUP_4_ASSERT,
FALSE_TRUE);
final CheckboxPreference junit_assume= createCheckboxPref(junitGroup, numColumns,
intent(junitGroup);
final CheckboxPreference junit_assume= createCheckboxPref(junitGroup, numColumns-1,
CleanUpMessages.JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_ASSUME, MYCleanUpConstants.JUNIT_CLEANUP_4_ASSUME,
FALSE_TRUE);
final CheckboxPreference junit_ignore= createCheckboxPref(junitGroup, numColumns,
intent(junitGroup);
final CheckboxPreference junit_ignore= createCheckboxPref(junitGroup, numColumns-1,
CleanUpMessages.JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_IGNORE, MYCleanUpConstants.JUNIT_CLEANUP_4_IGNORE,
FALSE_TRUE);
final CheckboxPreference junit_test= createCheckboxPref(junitGroup, numColumns,
intent(junitGroup);
final CheckboxPreference junit_test= createCheckboxPref(junitGroup, numColumns-1,
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);
final CheckboxPreference junit_before= createCheckboxPref(junitGroup, numColumns-1,
CleanUpMessages.JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_BEFORE, MYCleanUpConstants.JUNIT_CLEANUP_4_BEFORE,
FALSE_TRUE);
intent(junitGroup);
final CheckboxPreference junit_after= createCheckboxPref(junitGroup, numColumns-1,
CleanUpMessages.JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_AFTER, MYCleanUpConstants.JUNIT_CLEANUP_4_AFTER,
FALSE_TRUE);
intent(junitGroup);
final CheckboxPreference junit_beforeclass= createCheckboxPref(junitGroup, numColumns-1,
CleanUpMessages.JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_BEFORECLASS, MYCleanUpConstants.JUNIT_CLEANUP_4_BEFORECLASS,
FALSE_TRUE);
intent(junitGroup);
final CheckboxPreference junit_afterclass= createCheckboxPref(junitGroup, numColumns-1,
CleanUpMessages.JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_AFTERCLASS, MYCleanUpConstants.JUNIT_CLEANUP_4_AFTERCLASS,
FALSE_TRUE);
intent(junitGroup);
final CheckboxPreference junit_ruletempfolder= createCheckboxPref(junitGroup, numColumns-1,
CleanUpMessages.JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_RULETEMPORARYFOLDER, MYCleanUpConstants.JUNIT_CLEANUP_4_RULETEMPORARYFOLDER,
FALSE_TRUE);
intent(junitGroup);
final CheckboxPreference junit_ruletestname= createCheckboxPref(junitGroup, numColumns-1,
CleanUpMessages.JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_RULETESTNAME, MYCleanUpConstants.JUNIT_CLEANUP_4_RULETESTNAME,
FALSE_TRUE);
intent(junitGroup);
final CheckboxPreference junit_externalresource= createCheckboxPref(junitGroup, numColumns-1,
CleanUpMessages.JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_EXTERNALRESOURCE, MYCleanUpConstants.JUNIT_CLEANUP_4_EXTERNALRESOURCE,
FALSE_TRUE);
intent(junitGroup);
final CheckboxPreference junit_runwith= createCheckboxPref(junitGroup, numColumns-1,
CleanUpMessages.JavaFeatureTabPage_CheckboxName_JUNIT_CLEANUP_RUNWITH, MYCleanUpConstants.JUNIT_CLEANUP_4_RUNWITH,
FALSE_TRUE);
registerSlavePreference(junitcb, new CheckboxPreference[] {
junit_assert,
junit_assume,
junit_ignore,
junit_test,
junit_before,
junit_after,
junit_beforeclass,
junit_afterclass,
junit_ruletempfolder,
junit_ruletestname,
junit_externalresource,
junit_runwith});
intent(junitGroup);

registerPreference(junitcb);
Expand Down

0 comments on commit 67aeebe

Please sign in to comment.