Correct problem and quick fix labels

This commit is contained in:
aboyko
2024-07-25 16:20:43 -04:00
parent aca47bc72a
commit 9c9d4c38ce
3 changed files with 17 additions and 13 deletions

View File

@@ -30,7 +30,9 @@ import org.springframework.ide.vscode.commons.rewrite.java.FixDescriptor;
public class ImplicitWebAnnotationNamesReconciler implements JdtAstReconciler {
private static final String LABEL = "Remove Implicit Web Annotation Names";
private static final String PROBLEM_LABEL = "Implicit Web Annotation Name";
private static final String FIX_LABEL = "Remove Implicit Web Annotation Name";
private static final String FIX_LABEL_PLURAL = "Remove Implicit Web Annotation Names";
private static final Set<String> PARAM_ANNOTATIONS = new HashSet<>(
Arrays.asList(
@@ -79,18 +81,18 @@ public class ImplicitWebAnnotationNamesReconciler implements JdtAstReconciler {
private void processWebAnnotation(Annotation a) {
if (isApplicableWebAnnotation(a)) {
ReconcileProblemImpl problem = new ReconcileProblemImpl(getProblemType(), LABEL, a.getStartPosition(), a.getLength());
ReconcileProblemImpl problem = new ReconcileProblemImpl(getProblemType(), PROBLEM_LABEL, a.getStartPosition(), a.getLength());
String uri = docUri.toASCIIString();
Range range = ReconcileUtils.createOpenRewriteRange(cu, a);
ReconcileUtils.setRewriteFixes(registry, problem, List.of(
new FixDescriptor(org.openrewrite.java.spring.ImplicitWebAnnotationNames.class.getName(), List.of(uri), "Remove Implicit Web Annotation Name")
new FixDescriptor(org.openrewrite.java.spring.ImplicitWebAnnotationNames.class.getName(), List.of(uri), FIX_LABEL)
.withRangeScope(range)
.withRecipeScope(RecipeScope.NODE),
new FixDescriptor(org.openrewrite.java.spring.ImplicitWebAnnotationNames.class.getName(), List.of(uri),
ReconcileUtils.buildLabel(LABEL, RecipeScope.FILE))
ReconcileUtils.buildLabel(FIX_LABEL_PLURAL, RecipeScope.FILE))
.withRecipeScope(RecipeScope.FILE),
new FixDescriptor(org.openrewrite.java.spring.ImplicitWebAnnotationNames.class.getName(), List.of(uri),
ReconcileUtils.buildLabel(LABEL, RecipeScope.PROJECT))
ReconcileUtils.buildLabel(FIX_LABEL_PLURAL, RecipeScope.PROJECT))
.withRecipeScope(RecipeScope.PROJECT)
));
problemCollector.accept(problem);

View File

@@ -36,7 +36,8 @@ import org.springframework.ide.vscode.commons.rewrite.java.FixDescriptor;
public class NoAutowiredOnConstructorReconciler implements JdtAstReconciler {
private static final String LABEL = "Remove Unnecessary @Autowired";
private static final String PROBLEM_LABEL = "Unnecessary @Autowired";
private static final String FIX_LABEL = "Remove Unnecessary @Autowired";
private QuickfixRegistry registry;
@@ -82,10 +83,10 @@ public class NoAutowiredOnConstructorReconciler implements JdtAstReconciler {
Annotation autowiredAnnotation = ReconcileUtils.findAnnotation(constructor,
Annotations.AUTOWIRED, false);
if (autowiredAnnotation != null) {
ReconcileProblemImpl problem = new ReconcileProblemImpl(getProblemType(), LABEL,
ReconcileProblemImpl problem = new ReconcileProblemImpl(getProblemType(), PROBLEM_LABEL,
autowiredAnnotation.getStartPosition(), autowiredAnnotation.getLength());
ReconcileUtils.setRewriteFixes(registry, problem,
List.of(new FixDescriptor(NoAutowiredOnConstructor.class.getName(), List.of(docUri.toASCIIString()), LABEL)
List.of(new FixDescriptor(NoAutowiredOnConstructor.class.getName(), List.of(docUri.toASCIIString()), FIX_LABEL)
.withRecipeScope(RecipeScope.NODE)
.withRangeScope(ReconcileUtils.createOpenRewriteRange(cu, typeDecl))));
problemCollector.accept(problem);

View File

@@ -34,7 +34,8 @@ import org.springframework.ide.vscode.commons.rewrite.java.FixDescriptor;
public class NoRepoAnnotationReconciler implements JdtAstReconciler {
private static final String LABEL = "Remove Unnecessary @Repository";
private static final String PROBLEM_LABEL = "Unnecessary @Repository";
private static final String FIX_LABEL = "Remove Unnecessary @Repository";
private static final String INTERFACE_REPOSITORY = "org.springframework.data.repository.Repository";
private QuickfixRegistry registry;
@@ -67,18 +68,18 @@ public class NoRepoAnnotationReconciler implements JdtAstReconciler {
if (isApplicableRepoAnnotation(a)) {
ITypeBinding type = typeDecl.resolveBinding();
if (type != null && isRepo(type)) {
ReconcileProblemImpl problem = new ReconcileProblemImpl(getProblemType(), LABEL, a.getStartPosition(), a.getLength());
ReconcileProblemImpl problem = new ReconcileProblemImpl(getProblemType(), PROBLEM_LABEL, a.getStartPosition(), a.getLength());
String uri = docUri.toASCIIString();
String id = NoRepoAnnotationOnRepoInterface.class.getName();
ReconcileUtils.setRewriteFixes(registry, problem, List.of(
// new FixDescriptor(ID, List.of(uri), LABEL)
// new FixDescriptor(ID, List.of(uri), FIX_LABEL)
// .withRangeScope(RewriteQuickFixUtils.createOpenRewriteRange(cu, typeDecl))
// .withRecipeScope(RecipeScope.NODE),
new FixDescriptor(id, List.of(uri),
ReconcileUtils.buildLabel(LABEL, RecipeScope.FILE))
ReconcileUtils.buildLabel(FIX_LABEL, RecipeScope.FILE))
.withRecipeScope(RecipeScope.FILE),
new FixDescriptor(id, List.of(uri),
ReconcileUtils.buildLabel(LABEL, RecipeScope.PROJECT))
ReconcileUtils.buildLabel(FIX_LABEL, RecipeScope.PROJECT))
.withRecipeScope(RecipeScope.PROJECT)
));
problemCollector.accept(problem);