Skip to content

Recipe ReplaceAnnotation doesn't replace full qualified name #4314

Answered by timtebeek
rregout asked this question in Q&A
Discussion options

You must be logged in to vote

Hoi @rregout , No idea why the import isn't shortened in your particular case. The recipe does contain instructions to shorten those imports where possible.

maybeRemoveImport(TypeUtils.asFullyQualified(a.getType()));
JavaCoordinates replaceCoordinate = a.getCoordinates().replace();
a = replacement.apply(getCursor(), replaceCoordinate);
doAfterVisit(service(ImportService.class).shortenFullyQualifiedTypeReferencesIn(a));
return a;

If you look at our unit tests you'll see that we do shorten the imports for the cases seen there.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@rregout
Comment options

@timtebeek
Comment options

Answer selected by timtebeek
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants