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

Incorrect completions after : in object and record patterns #51961

Closed
stereotype441 opened this issue Apr 5, 2023 · 8 comments
Closed

Incorrect completions after : in object and record patterns #51961

stereotype441 opened this issue Apr 5, 2023 · 8 comments
Assignees
Labels
analyzer-completion Issues with the analysis server's code completion feature analyzer-language-patterns Issues with analyzer's support for the patterns language feature area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P1 A high priority bug; for example, a single project is unusable or has many test failures
Milestone

Comments

@stereotype441
Copy link
Member

Reproduced in IntelliJ, but since completions are provided by the analysis server, I believe this is an analysis server issue.

Given the following code:

abstract class MyClass {
  int get foo;
}

f(Object o) {
  switch (o) {
    case MyClass(:var ) // (1)
  }
}

Place the cursor after :var on the line marked (1), and request completions.

Expected result: the only completions should be the names of getters available on MyClass, for example foo.

Observed result: top level names are offered as completions (these would be invalid), and foo is not.

Note that things are worse in a declarartion context. With this code:

abstract class MyClass {
  int get foo;
}

f(MyClass o) {
  var MyClass(:) = o; // (1)
}

if I place the cursor after the : on the line marked (1), no completions are offered.

Similar problems happen for record patterns. In:

abstract class MyClass {
  int get foo;
}

f(({int foo, String bar}) o) {
  var (:) = o; // (1)
  switch (o) {
    case (:var ) // (2)
  }
}

if I place my cursor after the : on the line marked (1), or after :var on the line marked (2), I would expect to be offered just foo and bar as completions, but instead I get top level names.

@stereotype441 stereotype441 added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-completion Issues with the analysis server's code completion feature labels Apr 5, 2023
@bwilkerson bwilkerson added this to the Dart 3 beta 3 milestone Apr 5, 2023
@pq pq added the P1 A high priority bug; for example, a single project is unusable or has many test failures label Apr 5, 2023
@scheglov scheglov self-assigned this Apr 5, 2023
@scheglov
Copy link
Contributor

scheglov commented Apr 5, 2023

https://dart-review.googlesource.com/c/sdk/+/293901 should help for completion inside object pattern.

I think record pattern completion was not yet implemented with enough coverage.
So, I will leave it out for now.

copybara-service bot pushed a commit that referenced this issue Apr 5, 2023
…d without name, inside ObjectPattern.

Bug: #51961
Change-Id: Ibd6f762f4e363f26daaca21515a9c23c748f8cc9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293901
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
@scheglov
Copy link
Contributor

scheglov commented Apr 6, 2023

https://dart-review.googlesource.com/c/sdk/+/293863 for record the record pattern example.

@leafpetersen
Copy link
Member

Can I close this, or should I move it to stable to track possible further work that might need cherry picks?

copybara-service bot pushed a commit that referenced this issue Apr 6, 2023
…d without name, inside RecordPattern.

Bug: #51961
Change-Id: I33b499829887dc221c2d18fe4586ec08207c026f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293863
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
@scheglov
Copy link
Contributor

scheglov commented Apr 6, 2023

I was able to finish and land https://dart-review.googlesource.com/c/sdk/+/293863 only today, so for record patterns completion is not fully implemented. We might consider cherry picking this change. Other than that, I don't plan further work here.

@itsjustkevin
Copy link
Contributor

itsjustkevin commented Apr 10, 2023

Moving this to the Dart 3 stable milestone for cherry-pick consideration.

@vsmenon
Copy link
Member

vsmenon commented Apr 17, 2023

What's the status? Is this fixed and just under CP consideration?

@scheglov
Copy link
Contributor

Yes, it is implemented, but should be CPed.

@pq pq added the analyzer-language-patterns Issues with analyzer's support for the patterns language feature label Apr 17, 2023
copybara-service bot pushed a commit that referenced this issue Apr 21, 2023
…ernField without name, inside RecordPattern.

Bug: #51961
Change-Id: I33b499829887dc221c2d18fe4586ec08207c026f
Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/293863
Fixes: #52101
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296360
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
@scheglov
Copy link
Contributor

CP landed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-completion Issues with the analysis server's code completion feature analyzer-language-patterns Issues with analyzer's support for the patterns language feature area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P1 A high priority bug; for example, a single project is unusable or has many test failures
Projects
None yet
Development

No branches or pull requests

7 participants