Skip to content

Commit

Permalink
Minor polish
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Jan 23, 2025
1 parent d819f1a commit 39e734b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, Ex
if (classDeclAfterVisit != classDecl && allFieldsAnnotated) {
//Add annotation
JavaTemplate template = JavaTemplate.builder("@Setter\n")
.imports("lombok.Setter")
.javaParser(JavaParser.fromJavaVersion().classpath("lombok"))
.imports("lombok.Setter")
.javaParser(JavaParser.fromJavaVersion().classpath("lombok"))
.build();

return template.apply(
Expand All @@ -87,7 +87,7 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, Ex
}

@Override
public J.VariableDeclarations visitVariableDeclarations(J.VariableDeclarations variableDecls, ExecutionContext ctx){
public J.VariableDeclarations visitVariableDeclarations(J.VariableDeclarations variableDecls, ExecutionContext ctx) {

boolean allFieldsAnnotatedSoFar = getCursor().getNearestMessage(ALL_FIELDS_DECORATED_ACC);
if (!allFieldsAnnotatedSoFar) {
Expand All @@ -112,11 +112,8 @@ private J.VariableDeclarations fixFormat(J.VariableDeclarations initial, J.Varia
//as of August 2024 manual fixes to the format are necessary. Hopefully in the future this method becomes obsolete

boolean isAnnotationOnLineAbove = initial.toString().contains("@Setter\n");

boolean isTopAnnotationRemoved = !initial.getLeadingAnnotations().isEmpty() &&
initial.getLeadingAnnotations()
.get(0)
.getSimpleName().equals("Setter");
"Setter".equals(initial.getLeadingAnnotations().get(0).getSimpleName());

if (isAnnotationOnLineAbove && isTopAnnotationRemoved) {
String minus1NewLine = visited.getPrefix().getWhitespace().replaceFirst("\n", "");
Expand All @@ -127,7 +124,7 @@ private J.VariableDeclarations fixFormat(J.VariableDeclarations initial, J.Varia

@Override
public J.@Nullable Annotation visitAnnotation(J.Annotation annotation, ExecutionContext ctx) {
boolean isSetterAnnotated = annotation.getSimpleName().equals("Setter") &&
boolean isSetterAnnotated = "Setter".equals(annotation.getSimpleName()) &&
annotation.getArguments() == null; //no Access level, or other arguments

return isSetterAnnotated &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,4 @@ class A {
)
);
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,4 @@ class A {
)
);
}


}

0 comments on commit 39e734b

Please sign in to comment.