From 9c9d4c38ce35297fc35782534c7f53cfe1a8649e Mon Sep 17 00:00:00 2001 From: aboyko Date: Thu, 25 Jul 2024 16:20:43 -0400 Subject: [PATCH] Correct problem and quick fix labels --- .../ImplicitWebAnnotationNamesReconciler.java | 12 +++++++----- .../NoAutowiredOnConstructorReconciler.java | 7 ++++--- .../java/reconcilers/NoRepoAnnotationReconciler.java | 11 ++++++----- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/reconcilers/ImplicitWebAnnotationNamesReconciler.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/reconcilers/ImplicitWebAnnotationNamesReconciler.java index 73c152fe3..6e0dc7ea0 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/reconcilers/ImplicitWebAnnotationNamesReconciler.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/reconcilers/ImplicitWebAnnotationNamesReconciler.java @@ -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 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); diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/reconcilers/NoAutowiredOnConstructorReconciler.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/reconcilers/NoAutowiredOnConstructorReconciler.java index 9b25172bc..6d88c91e5 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/reconcilers/NoAutowiredOnConstructorReconciler.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/reconcilers/NoAutowiredOnConstructorReconciler.java @@ -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); diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/reconcilers/NoRepoAnnotationReconciler.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/reconcilers/NoRepoAnnotationReconciler.java index 7b0aed423..76a3ee917 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/reconcilers/NoRepoAnnotationReconciler.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/reconcilers/NoRepoAnnotationReconciler.java @@ -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);