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
Analysis server has broken navigation link from enum .values
#46253
Comments
It looks like there is a similar problem for |
possibly related: dart-lang/dartdoc#2660 |
@jcollins-g Interesting! I discovered this issue in the process of trying to diagnose a similar issue with the migration tool. Perhaps we can find a way to have a single bug fix that is shared by all three tools. |
For the navigation piece, the problem is that each identifier is resolved to a synthetic element, which by definition has no source offset (so we return |
This is why I didn't file an analyzer issue originally; since it was a synthetic element causing the problem I simply assumed I'd have to special case it similarly to other synthetics. I don't know how to handle it generally -- I know what would work for me, which is referring to the location of the element that implied the synthetic element -- but I don't know what the consequences are outside of dartdoc to making such changes. |
That's an interesting possibility. I'm not sure whether it would make the API easier or harder to use. Some tools would still need to be aware of the fact that the element is synthetic and my concern is that it would be much easier to write invalid code that doesn't crash and hence gives no indication that it's producing the wrong results. Having a negative offset might actually allow bugs to be caught sooner. If we don't change the current semantics of |
I like the idea of having a |
One issue with What if we return the |
That's even better. It's more general than my original proposal, though, so perhaps a more general name such as |
Yes, some places in dartdoc could be cleaned up a bit with this too. Perhaps |
Maybe I'm being too picky, but in case we're not thinking of the same thing ... I was thinking that we'd want this getter on all elements and that non-synthetic elements would return themselves. Then clients don't need to ask whether the element is synthetic before using the getter. (Similar to |
Well, Ideally I'd like to avoid using the word |
Bug: #46253 Change-Id: I39beb4b75f3f63c7d0fea1655f1ccf03239686bb Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203080 Commit-Queue: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Repro: using an editor with Dart analysis server integration (like IntelliJ), find a reference to the
.values
getter of an enum class (for example,HintActionKind.values
on line 14 ofpkg/nnbd_migration/lib/src/hint_action.dart
). Click on the identifiervalues
and ask the editor to navigate to the definition.Expected result: the user should be navigated to the declaration of the enum.
Observed result: the user is directed to the top of the file containing the enum.
The text was updated successfully, but these errors were encountered: