File tree Expand file tree Collapse file tree
rewrite-java/src/main/java/org/openrewrite/java Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -649,11 +649,11 @@ public J visit(@Nullable Tree tree, ExecutionContext ctx) {
649649 String oldPath = cu .getSourcePath ().toString ().replace ('\\' , '/' );
650650 String oldFqn = fqnToPath (originalType .getFullyQualifiedName ());
651651 String newFqn = fqnToPath (targetType .getFullyQualifiedName ());
652-
653- // Only update the path when it ends with oldFqn + ".java" (this file is the old type's source).
652+ int lastDot = oldPath . lastIndexOf ( '.' );
653+ String extension = lastDot >= 0 ? oldPath . substring ( lastDot ) : "" ;
654654 String newPathStr = oldPath ;
655- if (oldPath .endsWith (oldFqn + ".java" )) {
656- newPathStr = oldPath .substring (0 , oldPath .length () - (oldFqn + ".java" ).length ()) + newFqn + ".java" ;
655+ if (! extension . isEmpty () && oldPath .endsWith (oldFqn + extension )) {
656+ newPathStr = oldPath .substring (0 , oldPath .length () - (oldFqn + extension ).length ()) + newFqn + extension ;
657657 }
658658 Path newPath = Paths .get (newPathStr );
659659 if (updatePath (cu , oldPath , newPath .toString ())) {
You can’t perform that action at this time.
0 commit comments