Skip to content

Commit

Permalink
Correct problem and quick fix labels
Browse files Browse the repository at this point in the history
  • Loading branch information
BoykoAlex committed Jul 25, 2024
1 parent aca47bc commit 9c9d4c3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@

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(
Expand Down Expand Up @@ -79,18 +81,18 @@ public boolean visit(SingleMemberAnnotation node) {

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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@

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;

Expand Down Expand Up @@ -82,10 +83,10 @@ public boolean visit(TypeDeclaration typeDecl) {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@

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;
Expand Down Expand Up @@ -67,18 +68,18 @@ public boolean visit(TypeDeclaration typeDecl) {
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);
Expand Down

0 comments on commit 9c9d4c3

Please sign in to comment.