-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add new "Go to Import" option #56584
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
Summary: The user proposes adding a "See import line(s)" feature that allows users to navigate from a class, method, or variable to its corresponding import line, even when multiple imports exist. This feature would enhance code navigation and understanding. |
@FMorschel , how does this show up in the editor? Context menu? Code actions (an option in the light bulb menu)? |
@keertip the current CL (https://dart-review.googlesource.com/c/sdk/+/387387) should work with an action on the context menu. Similar to the Go To Super option. class A {}
class B extends A {} If you right-click on It would be something like this but with an optional list to see all imports. Similar to the "References" (F12) on VS Code where you can see every call to something, you would be able to see all imports that are importing that specific name. For the following case, both imports would show if you called it on import 'package:flutter/widgets.dart';
import 'package:flutter/material.dart';
class MyWidget extends StatelessWidget {
const MyWidget({super.key});
@override
Widget build(BuildContext context) {
return const Placeholder();
}
} @DanTup is there anything else? |
Yep, that sounds right to me. Note that it will require Dart-Code changes, it won't show up anywhere automatically. We can also choose whether it's in the context menu or not, or only in the command palette (the context menu is good for discoverability, but it's not particularly contextual in the VS Code editor, so opening the context menu anywhere will show it, even in blank spaces and comments). |
This is functionality that I think we should have in IntelliJ as well. I think it will be even more important when 'enhanced-parts' ships because there will potentially be multiple lists of imports spread across multiple files, making it harder for users to figure out where a given name is imported from. The current implementation defines a custom LSP protocol for this purpose. I don't know whether that would be sufficient for IntelliJ, but I'd appreciate it if you could think about it and let me know what kind of support would be required. |
I'm not sure that would work.. In the current legacy protocol implementation, all occurences must have the same length, and they all must be in the same file. For LSP (Document Highlights) they must also all be in the same file. But because of It's also not unclear to me from the screenshots above if you could see the full list of occurrences without them being on screen? I might be on line 1000 of a file with a diagnostic saying my reference of The way this will work in VS Code (the LSP command is done, but there's some work in the VS Code extension to do) is similar to things like Find References and Go to Super... it can be invoked explicitly and will provide a set of results that are ranges from the same or other files. |
@alexander-doroshko, do you think I should reopen this for this discussion? |
So far, I don't see the need to reopen |
Bug: #51357 Bug: #56584 Change-Id: Idc34b808ba083dae954a23bd159ebaadf31c9ff0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409800 Auto-Submit: Felipe Morschel <[email protected]> Reviewed-by: Samuel Rawlins <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
I'd like to propose a "See import line(s)" on classes/methods from classes or extensions/functions/global variables.
Like:
In the above example, there would be a way to access this in the "max" and it would take you to the import line (here you could alias it or whatever).
And if there was a conflict between multiple imports it could select all with multiple cursors.
The text was updated successfully, but these errors were encountered: