-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
New assist to add/edit hide
at import for ambiguous import
#56830
Comments
Summary: This issue proposes a new quick-fix for ambiguous imports. It suggests adding a "hide" combinator to the import statement to resolve the ambiguity, either by adding a new "hide" or editing an existing one. |
It's possible for an ambiguous name to be imported through more than 2 imports. For example, given three libraries, L1, L2, and L3, that all define a class named Probably more common is that a single definition of the ambiguous name might be imported from multiple libraries. For example, given the libraries, L1 and L2, that both define a class named That raises a question about the DX. Rather than require the user to select one fix for every import that should have a Or maybe the set of imports from which it shouldn't be hidden, such as in the second example, where there's no point in hiding it from either L1 or L3 if the declaration in L1 is the one the user wants to use. Or maybe what's important isn't the import(s) to be unchanged, but the declaration (element in API terms) to be used. Although identifying the declaration might be tricky because the defining library might be an internal library that the user wouldn't recognize. Of maybe those scenarios are too complex and we should just not offer the fix in those cases. Curious to hear your thoughts. |
Yes, thank you for the suggestion. I hadn't thought of the multi-step process. However, I believe this would probably be hard to happen unless multiple libraries which export (say L2 exports L1) each other (or something similar) suddenly received a new declaration (say you declare
Yes, I do believe that this is ideal. The error message for If we had something like the "Docs side panel" (not sure what to call that) that we have for auto-complete options, in assists, we could show the element in the assist text and make sure our user was aware of which imports was it coming from. But since that is not the case I don't believe this would be a good option.
Although I see your very valid point here, I don't believe it would be easy for everyone to understand why more than one import was left without the While I prefer the "hide every other import" option, I was wondering what should we do in cases where one of the other imports is |
This issue is to track https://dart-review.googlesource.com/c/sdk/+/386020.
This change would add a new quick-fix option to
ambiguous_import
to add ahide
combinator (or edit the current one to edit it). So cases like:a.dart
b.dart
c.dart
Would trigger this fix options to add
hide
to 'a.dart' or to edit thehide
at 'b.dart'.CC: @bwilkerson
The text was updated successfully, but these errors were encountered: