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 type definition should go to typedef #57013

Closed
FMorschel opened this issue Nov 1, 2024 · 8 comments
Closed

Go to type definition should go to typedef #57013

FMorschel opened this issue Nov 1, 2024 · 8 comments
Labels
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-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@FMorschel
Copy link
Contributor

Even after the fix for #56844 I'm still having an issue when working on the SDK. This is the link for the base change I made to see the problem https://github.com/FMorschel/sdk/tree/go-to-type-definition-inside-expanded.

Here is a repro of that part inside pkg/analysis_server_plugin/lib/src/correction/fix_in_file_processor.dart:

return [
  ...?registeredFixGenerators.nonLintProducers[errorCode],
  ...?registeredFixGenerators.nonLintMultiProducers[errorCode]
      ?.expand((multiProducer) {
    multiProducer;
    return [];
  }),
];

In here, with the latest SDK (got mine updated today actually to see if this was solved) I can't seem to activate Go to Type Definition on either multiProducer from the parameter or the one from the useless statement.

I can activate it with no problem on registeredFixGenerators or nonLintMultiProducers.

I'm still looking at this to try and find a better repro but in the meantime, I was instructed by @DanTup to create this issue so that others can take a look as well.

@dart-github-bot
Copy link
Collaborator

Summary: The "Go to Type Definition" functionality is not working for variables within a lambda function, specifically for multiProducer in the provided code snippet. This issue persists despite the fix for a previous issue related to type definition navigation.

@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-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Nov 1, 2024
@FMorschel
Copy link
Contributor Author

I was thinking this would give me instances but it actually gives me constructors so because it is a Function there is no actual type here.

@FMorschel
Copy link
Contributor Author

FMorschel commented Nov 1, 2024

I was thinking of why I got confused there, and then I remembered that I only saw the type like a Function on the variable itself. The generics is tied to a typedef. I think in this case it could move us to the typedef definition (when it is defined by one, not when it matches). I'm not sure if that is possible but anyway, here is my proposal.

image

@FMorschel FMorschel reopened this Nov 1, 2024
@bwilkerson
Copy link
Member

I think what you're proposing is that "Go to type definition", at least for a function type, should navigate to the typedef, when there is one. If so, I think that's reasonable.

For consistency we should probably do that for any type that was defined using a typedef.

I'm not sure whether we have that information available, but I think we do at least some times.

@FMorschel FMorschel changed the title Go to type definition not working Go to type definition should go to typedef Nov 1, 2024
@DanTup
Copy link
Collaborator

DanTup commented Nov 1, 2024

#39332 is a similar issue where showing the typedef is requested instead of the base type. I don't know if the cause or fixes are the same, but they might be.

@FMorschel
Copy link
Contributor Author

I think I'll close this in favour of that one then since it is older and has more discussion. Thanks!

@DanTup
Copy link
Collaborator

DanTup commented Nov 4, 2024

(I'm not certain one fix will fix both, one is about hovers and one is about Type Def... but they're similar enough that the fix could be the same even if it has to be made in two places)

@FMorschel
Copy link
Contributor Author

If needed we can always reopen this again, I'll keep that in mind though

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. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

4 participants