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

Go to Imports with static declarations not working #59823

Closed
FMorschel opened this issue Dec 30, 2024 · 7 comments
Closed

Go to Imports with static declarations not working #59823

FMorschel opened this issue Dec 30, 2024 · 7 comments
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@FMorschel
Copy link
Contributor

FMorschel commented Dec 30, 2024

Repro:

a.dart

class A {
  static const a = 1;
}

main.dart

import 'a.dart';

void foo(A a) {}

void bar() {
  A.a;
}

On foo parameter, I can use the Go to Imports command, but not inside bar.

I'll work on this.

CC @DanTup


Edit

Continued work for #56584.

@FMorschel FMorschel added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Dec 30, 2024
@keertip keertip added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) P3 A lower priority bug or feature request labels Dec 30, 2024
@FMorschel
Copy link
Contributor Author

@bwilkerson should this command work only on the type name or on the static declaration too (thinking of dart-lang/language#3835 and #57036)?

@FMorschel
Copy link
Contributor Author

@bwilkerson
Copy link
Member

While I can see an argument for having the command work for any member in a declaration that might come from an extension, it seems odd to me for this command to work for anything other than top-level declarations because I can't see a use case for the functionality. What would prompt a user to want to know which import made visible the extension in which the member is declared?

@FMorschel
Copy link
Contributor Author

Say I'm starting to work on a new project (monorepo) and I'm not familiar with its structure still. If I see something being used somewhere and I can't auto-import somewhere else, I'd like to know how that is on scope of that original file.

Also, the current behaviour shows the import for an instance extension method so we might as well do the same then. If you agree I can open a new issue to track this specifically. If you disagree with the current behaviour for the extensions we can open another issue for removing this support.

@bwilkerson
Copy link
Member

... and I can't auto-import somewhere else ...

That sounds like a failure we should address, unless there's a case I'm not thinking of where it can't be addressed.

@FMorschel
Copy link
Contributor Author

I was thinking of something inside /src that in this hypothetical case maybe shouldn't be there. That is why I mentioned monorepo but I guess I wasn't clear enough, sorry.

@bwilkerson
Copy link
Member

I suppose that makes sense. I'd still just go to the declaration and figure it out that way, but that doesn't mean it's the only valid way to figure out why you can't reference a member you know is defined.

But I'd probably wait to add this feature until we know whether we will support static extension methods and if so exactly what the semantics are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

3 participants