-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix prefix hover and go to definition for parts with imports #60645
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
A part can't currently have imports, so you may be assuming that the feature parts with imports is available. That document has some rather detailed discussions about this particular topic. There was some discussion here, too: dart-lang/language#4082. |
From the specification you mentioned:
I got under the impression from the above quote that in |
I think the example that I unfolded in dart-lang/language#4082 still uses the rules as specified (just double checked, but it is rather complex, so caveat emptor). This means that the prefix scopes are chained such that you don't shadow an entire prefix, you shadow individual names in there. For example, 'part.dart' can use In your example, |
I see. Thanks for the explanation! In that case, I'll keep this open (and rename) to make sure prefix hover and "Go to Definition" work as intended. Both only work inside the current file (if defined there), but should show all results from the current file up the chain. |
Can someone also update the tags? Thanks! I was testing it a bit just now, and I have one more question, but for the devexp team (@bwilkerson): main.dart import 'dart:math' as math;
part 'part.dart'; part.dart part of 'main.dart';
int math = 0; This currently triggers I'm not sure we should trigger |
The compilation error
I haven't looked closely enough at the feature spec to know whether this error is still enforced when the enhanced-parts feature is enabled. If the feature spec removes this error then we ought to not produce it when the experiment is enabled, but should still produce it when the experiment is not enabled. If there's a bug when the feature is enabled, then we should add a shared test for this case and fix the bug (whether it's just in the analyzer or in both the analyzer and the front end). If we add a shared test, then we don't need an issue because we'll have a failing test to remind us of the work to be done. As for where the diagnostic is reported, the fix is to rename either the prefix or the top-level declaration, but I don't think we can say that either choice is the most likely or most common choice. Therefore, the choice of where to put the diagnostic is kind of arbitrary. (Though someone might have decided that renaming the prefix is more likely given that doing so is generally more localized that renaming a top-level declaration.) But I agree that it seems more reasonable for it to be reported at the location of the top-level declaration. Whether it's worth changing the current choice is questionable. I doubt that many users run into this diagnostic, and those that do probably aren't too confused by it. It would be interesting to see where the CFE reports the error. It would be good if all of our tools were consistent. |
After some thought about your answer, I figured out what my problem was with the errors above and opened #60668. About fixing the title of this issue, the problem is that the fragments provided only span the current unit. I've not really done much under the analyzer package, so I may need some guidance on this. Can someone tag this correctly now? Remove the "question" and add whatever tag this needs for the fix on the issue title? If you prefer, I can open a new one, but I don't think it is necessary. Thanks anyway! |
I don't know what "fragments provided" means. Provided by what? If we're talking about an API then it's possible the API isn't working yet. The feature isn't complete and we're not actively working on it while the language team decides whether it's currently spec'd correctly given that we're not doing macros. It's also possible that the code asking for the fragments is using the wrong API. |
Actually, the first one (CL - hovers) uses the sdk/pkg/analyzer/lib/src/dart/element/display_string_builder.dart Lines 261 to 277 in f59751f
sdk/pkg/analyzer_plugin/lib/src/utilities/navigation/navigation_dart.dart Lines 442 to 448 in f59751f
It sure could be using the API the wrong way. But I take it that it is probably because it is not finished in this case. Either way, I'll leave this open until that is defined then. After that, I'll see if this still needs any work. |
Consider:
main.dart:
part.dart
I was under the impression that when creating
alias
insidepart
, it would override themain
definition for it. But I might be mistaken.If this is intended, then the "Go to definition" and hover for the import prefix should take this into consideration.
The text was updated successfully, but these errors were encountered: