-
Notifications
You must be signed in to change notification settings - Fork 1.7k
consider updating has{*}
annotation getters to consider augmentations
#55579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Unfortunately, you're not overthinking it. According to the spec, annotations / metadata are cumulative across augmentations, for any kind of declaration that can be augmented. The We decided that all of our existing element classes refer to a single declaration in the augmentation chain, and we introduced new It probably still makes sense to be able to ask each declaration in the chain whether it has a given annotation, so I suspect the "only" thing that needs to be done is to duplicate those getters. |
@scheglov: I'd be curious to get your thoughts? |
Yes,
What are use cases? |
Somewhat speculative, but I can imagine wanting to write fixes where we'd need to know exactly which declarations have (or don't have) the annotation. For example, I could imagine a style in which non-generated annotations are all expected to be on the base declaration so that they can be found in one place, and a fix that would move misplaced annotations. |
But fixes would look at AST, not the element model, because they need to know which portion of code to (re)move? |
In a world in which the declaration of an element can be spread across multiple files, we'll need a way to identify which files we need to get an AST for. It would be inefficient to get all of the ASTs in order to figure out which ones we actually need. The other option I can think of is for |
I guess you are talking about a fix for a reported lint like "Put @deprecated at the declaration". |
Ok, but I think we usually do that by looking at the element model, not by looking at the AST. Maybe that needs to change, but maybe not. I'm just not convinced that it's a bad idea to be able to ask each of the declarations in the chain which annotations are associated introduced by them. Given that it's a breaking change to remove them and that they might have value, I have to wonder whether we shouldn't just leave them. |
We need AST to report the lint at the correct location, I think?
Introduced annotations, i.e. |
If the annotations are in I suspect that our difference of opinion might be a result of thinking of |
I still don't see how |
FWIW, this is one of the issues that got me thinking that maybe we have the wrong element model for annotations. |
I believe that this has been addressed in the new element model. |
Follow-up from https://dart-review.googlesource.com/c/sdk/+/363142 where @bwilkerson notes:
Aside: I imagine this generalizes too to other annotations? For example,
@Deprecated
,@Immutable
,@UseResult
... Oiiiii...Or (maybe hopefully?) I'm overthinking?
The text was updated successfully, but these errors were encountered: