Skip to content

Commit

Permalink
Merge branch 'main' into add-dependency-to-parent-pom
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek authored Oct 22, 2024
2 parents 14a7f0b + 49524a7 commit 08ded76
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public TreeVisitor<?, ExecutionContext> getScanner(Integer acc) {
//noinspection NullableProblems
return new TreeVisitor<>() {
@Override
public Tree visit(Tree tree, ExecutionContext executionContext) {
public Tree visit(Tree tree, ExecutionContext ctx) {
if (tree.getMarkers().findFirst(RecipesThatMadeChanges.class).isPresent()) {
return tree;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,23 @@ class Test {
);
}

@Test
void enumFieldNames() {
rewriteRun(
baseTest("myType", "myType,TYPES"),
java(
"""
class Test {
TYPES myType;
}
enum TYPES {
VALUE, NUMBER, TEXT
}
"""
)
);
}

@Test
void allClassFieldsAreFound() {
rewriteRun(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,16 @@ public J.VariableDeclarations.NamedVariable visitVariable(J.VariableDeclarations
return super.visitVariable(variable, strings);
}

@Override
public J.Identifier visitIdentifier(J.Identifier identifier, Set<String> namesInScope) {
J.Identifier v = super.visitIdentifier(identifier, namesInScope);
if (v.getType() instanceof JavaType.Class &&
((JavaType.Class) v.getType()).getKind() == JavaType.FullyQualified.Kind.Enum) {
namesInScope.add(v.getSimpleName());
}
return v;
}

private void addImportedStaticFieldNames(@Nullable JavaSourceFile cu, Cursor classCursor) {
if (cu != null) {
List<J.Import> imports = cu.getImports();
Expand Down

0 comments on commit 08ded76

Please sign in to comment.