Skip to content
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

Add new "See import line(s)" option #56584

Open
FMorschel opened this issue Aug 27, 2024 · 4 comments
Open

Add new "See import line(s)" option #56584

FMorschel opened this issue Aug 27, 2024 · 4 comments
Labels
analyzer-server area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P4 type-enhancement A request for a change that isn't a bug

Comments

@FMorschel
Copy link
Contributor

FMorschel commented Aug 27, 2024

I'd like to propose a "See import line(s)" on classes/methods from classes or extensions/functions/global variables.

Like:

import 'dart:math';

void main() {
  max(1, 2);
}

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.

@dart-github-bot
Copy link
Collaborator

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.

@dart-github-bot dart-github-bot added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-enhancement A request for a change that isn't a bug labels Aug 27, 2024
@lrhn lrhn removed the triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. label Aug 28, 2024
@keertip
Copy link
Contributor

keertip commented Oct 1, 2024

@FMorschel , how does this show up in the editor? Context menu? Code actions (an option in the light bulb menu)?

@FMorschel
Copy link
Contributor Author

@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 B you will get an option Go to Super Class/Member. It will change your selection to the declaration of A.

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 StatelessWidget, Widget, BuildContext or Placeholder.

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?

@DanTup
Copy link
Collaborator

DanTup commented Oct 1, 2024

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-server area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P4 type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

6 participants