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

Extract variable should include type when always_include_types lint is enabled #4177

Closed
h-unterp opened this issue Sep 26, 2022 · 4 comments
Closed
Labels
in editor Relates to code editing or language features in lsp/analysis server Something to be fixed in the Dart analysis server is enhancement relies on sdk changes Something that requires changes in the Dart/Flutter SDK to ship before it will become available
Milestone

Comments

@h-unterp
Copy link

h-unterp commented Sep 26, 2022

Is your feature request related to a problem? Please describe.
I prefer to avoid var whenever possible. When I use the extract local variable feature, it only extracts it as var:

text.split(" ")

becomes

var text2 = text.split(" ")

Describe the solution you'd like
Use the types, if provided. So:

List<String> text2 = text.split(" ")
@DanTup
Copy link
Member

DanTup commented Sep 26, 2022

@h-unterp is there a reason you closed this? It seems like a reasonable request to me, and could probably be triggered by the always_specify_types lint being enabled?

@h-unterp
Copy link
Author

h-unterp commented Sep 26, 2022

I closed because I found a solution to my issue.

I did not realize that you first need to

  1. extract local variable
  2. Then you get "Add type annotation"
    Screen Shot 2022-09-26 at 5 42 23 AM

While I do agree it would be convenient to have the add type annotation option available on the first click. I did not want to be a burden now that I have a solution.

@DanTup
Copy link
Member

DanTup commented Sep 26, 2022

Ah, gotcha. I think it may still be reasonable to expect the server to automatically include these when the always_specify_types lint is enabled (to avoid it generating code that immediately violates the lint), so I'll re-open this as a request for that.

@DanTup DanTup reopened this Sep 26, 2022
@DanTup DanTup changed the title Allow for explicit typing when using extract variable, Extract variable should include type when always_include_types lint is enabled Sep 26, 2022
@DanTup DanTup added in editor Relates to code editing or language features in lsp/analysis server Something to be fixed in the Dart analysis server labels Sep 26, 2022
@DanTup DanTup added this to the On Deck milestone Sep 26, 2022
@DanTup DanTup modified the milestones: On Deck, v3.56.0 Dec 7, 2022
copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Dec 7, 2022
…ecify_types is enabled

Fixes Dart-Code/Dart-Code#4177.

Change-Id: I8da492c947466677e84d7892113f0bbfbdacfb87
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274240
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
@DanTup
Copy link
Member

DanTup commented Dec 7, 2022

Fixed by dart-lang/sdk@df3df89.

The fix is in the Dart language server so will ship with a future Dart/Flutter SDK update (not a VS Code extension update).

@DanTup DanTup closed this as completed Dec 7, 2022
@DanTup DanTup added the relies on sdk changes Something that requires changes in the Dart/Flutter SDK to ship before it will become available label Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in editor Relates to code editing or language features in lsp/analysis server Something to be fixed in the Dart analysis server is enhancement relies on sdk changes Something that requires changes in the Dart/Flutter SDK to ship before it will become available
Projects
None yet
Development

No branches or pull requests

2 participants