fix: support annotations for runtime package model #4210
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, packages where only visited from type references. This means the package of the type given to the
scan
method isn't necessarily visited, and its annotations aren't visited either.This fixes it. The test case assumes that the package has the
@Deprecated
annotation declared in thepackage-info.java
:spoon/src/test/java/spoon/test/pkg/package-info.java
Lines 5 to 6 in 63104c7
When debugging, I saw that packages (
java.util
,java.lang
) are visited multiple times, as they are always visited whenever a type (new) or type reference (before) is visited. As the values of a package don't change at runtime (well, at least within a module), this doesn't seem necessary. Should we skip that by making sure that packages are only visited once here:spoon/src/main/java/spoon/support/visitor/java/JavaReflectionTreeBuilder.java
Lines 121 to 129 in 9ff8194