Skip to content

shortenFullyQualifiedTypes: also shorten annotation names (fixes #3159) - #3186

Open
ARAYN7011 wants to merge 1 commit into
diffplug:mainfrom
ARAYN7011:fix/shorten-annotation-fqn
Open

ARAYN7011 wants to merge 1 commit into
diffplug:mainfrom
ARAYN7011:fix/shorten-annotation-fqn

Conversation

@ARAYN7011

Copy link
Copy Markdown

Fixes #3159.

shortenFullyQualifiedTypes only looked at type nodes and expression scopes, so @com.fasterxml.jackson.annotation.JsonCreator was never shortened. Annotation names are always types, so the step now shortens them with the same safety rules as other references (no change when the simple name clashes with a declared/imported/unqualified name, or inside types with unknown inheritance). Unqualified annotation names are now also counted as in-use simple names so a same-package annotation can't be shadowed by a new import.

Test plan:

  • New issue3159_annotationsShortened (marker, single-member, normal and parameter annotations) fails before the change and passes after.
  • New annotationNotShortenedWhenSimpleNameClashes.
  • ./gradlew spotlessCheck :testlib:test --tests '*ShortenFullyQualifiedTypesStepTest' passes.
  • CHANGES entries added in lib, plugin-gradle and plugin-maven.

AI disclosure: this change was written with AI assistance (Claude) and verified by running the tests above.

🤖 Generated with Claude Code

Fixes diffplug#3159

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The "shortenFullyQualifiedTypes" function is unable to abbreviate the annotations.

1 participant