Skip to content

Commit

Permalink
Update preVisit's
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurens-W committed Nov 13, 2024
1 parent b84950e commit 6ad31cd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public Validated<Object> validate() {
public TreeVisitor<?, ExecutionContext> getVisitor() {
TreeVisitor<?, ExecutionContext> condition = new TreeVisitor<Tree, ExecutionContext>() {
@Override
public @Nullable Tree preVisit(Tree tree, ExecutionContext ctx) {
public @Nullable Tree preVisit(@Nullable Tree tree, ExecutionContext ctx) {
stopAfterPreVisit();
if (tree instanceof JavaSourceFile) {
JavaSourceFile cu = (JavaSourceFile) tree;
Expand Down Expand Up @@ -124,7 +124,7 @@ public TreeVisitor<?, ExecutionContext> getVisitor() {
}
}
}
return super.preVisit(tree, ctx);
return tree;
}
};

Expand All @@ -135,7 +135,7 @@ public boolean isAcceptable(SourceFile sourceFile, ExecutionContext ctx) {
}

@Override
public @Nullable Tree preVisit(Tree tree, ExecutionContext ctx) {
public @Nullable Tree preVisit(@Nullable Tree tree, ExecutionContext ctx) {
stopAfterPreVisit();
if (tree instanceof JavaSourceFile) {
return new JavaChangePackageVisitor().visit(tree, ctx, requireNonNull(getCursor().getParent()));
Expand All @@ -150,7 +150,7 @@ public boolean isAcceptable(SourceFile sourceFile, ExecutionContext ctx) {
}
return new ReferenceChangePackageVisitor(matches, matcher, newPackageName).visit(tree, ctx, requireNonNull(getCursor().getParent()));
}
return super.preVisit(tree, ctx);
return tree;
}
});
}
Expand Down Expand Up @@ -393,13 +393,13 @@ private static class ReferenceChangePackageVisitor extends TreeVisitor<Tree, Exe
String newPackageName;

@Override
public @Nullable Tree preVisit(Tree tree, ExecutionContext ctx) {
public @Nullable Tree preVisit(@Nullable Tree tree, ExecutionContext ctx) {
stopAfterPreVisit();
Reference reference = matches.get(tree);
if (reference != null && reference.supportsRename()) {
return reference.rename(renamer, newPackageName).visit(tree, ctx, getCursor().getParent());
}
return super.preVisit(tree, ctx);
return tree;
}
}

Expand Down
12 changes: 6 additions & 6 deletions rewrite-java/src/main/java/org/openrewrite/java/ChangeType.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public String getDescription() {
public TreeVisitor<?, ExecutionContext> getVisitor() {
TreeVisitor<?, ExecutionContext> condition = new TreeVisitor<Tree, ExecutionContext>() {
@Override
public @Nullable Tree preVisit(Tree tree, ExecutionContext ctx) {
public @Nullable Tree preVisit(@Nullable Tree tree, ExecutionContext ctx) {
stopAfterPreVisit();
if (tree instanceof JavaSourceFile) {
JavaSourceFile cu = (JavaSourceFile) tree;
Expand All @@ -94,7 +94,7 @@ public TreeVisitor<?, ExecutionContext> getVisitor() {
SourceFileWithReferences cu = (SourceFileWithReferences) tree;
return new UsesType<>(oldFullyQualifiedTypeName, true).visitNonNull(cu, ctx);
}
return super.preVisit(tree, ctx);
return tree;
}
};

Expand All @@ -105,7 +105,7 @@ public boolean isAcceptable(SourceFile sourceFile, ExecutionContext ctx) {
}

@Override
public @Nullable Tree preVisit(Tree tree, ExecutionContext ctx) {
public @Nullable Tree preVisit(@Nullable Tree tree, ExecutionContext ctx) {
stopAfterPreVisit();
if (tree instanceof JavaSourceFile) {
return new JavaChangeTypeVisitor(oldFullyQualifiedTypeName, newFullyQualifiedTypeName, ignoreDefinition).visit(tree, ctx, requireNonNull(getCursor().getParent()));
Expand All @@ -119,7 +119,7 @@ public boolean isAcceptable(SourceFile sourceFile, ExecutionContext ctx) {
}
return new ReferenceChangeTypeVisitor(matches, matcher, newFullyQualifiedTypeName).visit(tree, ctx, requireNonNull(getCursor().getParent()));
}
return super.preVisit(tree, ctx);
return tree;
}
});
}
Expand Down Expand Up @@ -563,13 +563,13 @@ private static class ReferenceChangeTypeVisitor extends TreeVisitor<Tree, Execut
String newFullyQualifiedName;

@Override
public @Nullable Tree preVisit(Tree tree, ExecutionContext ctx) {
public @Nullable Tree preVisit(@Nullable Tree tree, ExecutionContext ctx) {
stopAfterPreVisit();
Reference reference = matches.get(tree);
if (reference != null && reference.supportsRename()) {
return reference.rename(renamer, newFullyQualifiedName).visit(tree, ctx, getCursor().getParent());
}
return super.preVisit(tree, ctx);
return tree;
}
}

Expand Down

0 comments on commit 6ad31cd

Please sign in to comment.