Skip to content

Commit

Permalink
Unpleasant diff which appears to fix the issue
Browse files Browse the repository at this point in the history
  • Loading branch information
somethingvague committed Apr 19, 2024
1 parent c9dd352 commit 4561fa4
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ private class ChangePackageVisitor extends JavaVisitor<ExecutionContext> {
public J visitFieldAccess(J.FieldAccess fieldAccess, ExecutionContext ctx) {
J f = super.visitFieldAccess(fieldAccess, ctx);

J.FieldAccess visitedFieldAccess = (J.FieldAccess) f;
if (visitedFieldAccess.getTarget() instanceof J.Identifier) {
if (((J.Identifier) visitedFieldAccess.getTarget()).getSimpleName().equals(oldPackageName)) {
JavaType.ShallowClass newType = JavaType.ShallowClass.build(newPackageName + "." + ((J.FieldAccess) f).getName().getSimpleName());
return TypeTree.build(((JavaType.FullyQualified) newType).getFullyQualifiedName())
.withPrefix(f.getPrefix());
}
}

if (((J.FieldAccess) f).isFullyQualifiedClassReference(oldPackageName)) {
Cursor parent = getCursor().getParent();
if (parent != null &&
Expand Down

0 comments on commit 4561fa4

Please sign in to comment.