[DAS] Fixes regression in completion for unnamed parameters in closures
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
bool inlcudeDisplayText = false;nit: typo `inlcude`
Maybe also include a comment explaining what this does like the others.
Is this actually used (set) anywhere?
f((p1) => ^,);I think originally these would start at 0 instead of 1. I don't know if it matters, but if there is other code generating similar names that still start from 0, maybe this should be consistent?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Auto-Submit | +1 |
nit: typo `inlcude`
Maybe also include a comment explaining what this does like the others.
Is this actually used (set) anywhere?
I'll remove this, I was testing this out but I found other tests that filled this role for this fix. Thanks! If anyone else wants to re add this in the future is simple enough to do so.
I think originally these would start at 0 instead of 1. I don't know if it matters, but if there is other code generating similar names that still start from 0, maybe this should be consistent?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
| Commit-Queue | +2 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Auto-Submit | +1 |
(item1.sortText == item2.sortText)This ensures that when two completions have the same priority (as the ones presented by the new LSP test) then we sort them by the text we show to the user.
expectCompletions: ['^2.1.0', '^2.3.4'],Necessary after the change at `pkg/analysis_server/test/lsp/completion.dart`
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
(item1.sortText == item2.sortText)This ensures that when two completions have the same priority (as the ones presented by the new LSP test) then we sort them by the text we show to the user.
Do we want this? If I understand correctly, this isn't sorting what the user sees, it's just sorting what the tests look at. I think it would be best if tests could assert the ordering of the returned items even when the sort text is the same - I'm not sure what the advantage of doing this here is.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
(item1.sortText == item2.sortText)Danny TuppenyThis ensures that when two completions have the same priority (as the ones presented by the new LSP test) then we sort them by the text we show to the user.
Do we want this? If I understand correctly, this isn't sorting what the user sees, it's just sorting what the tests look at. I think it would be best if tests could assert the ordering of the returned items even when the sort text is the same - I'm not sure what the advantage of doing this here is.
I'm not sure we could handle how the clients sort the text after `sortText` sorting (which we expect them to but obviously could be ignored).
The latest [failing bot](https://logs.chromium.org/logs/dart/buildbucket/cr-buildbucket/8703375698794674353/+/u/test_results/new_test_failures__logs_) showed an error at `pkg/analysis_server/test/lsp/completion_dart_test.dart:1341` with the sorting being different than what I wrote. But locally, if I swapped them I got the error and this way I didn't (not sure why).
But the thing is, I don't expect this difference to be relevant to the users considering the clients use at least `sortText`. If we wan't to be sure, then we probably need to enhance that value for the cases I had to change here (that and related tests and at `pkg/analysis_server/test/lsp/completion_yaml_test.dart`). I don't see any real value between sorting them "better" to the end user at this point, but of course I could be wrong.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
(item1.sortText == item2.sortText)Danny TuppenyThis ensures that when two completions have the same priority (as the ones presented by the new LSP test) then we sort them by the text we show to the user.
Felipe MorschelDo we want this? If I understand correctly, this isn't sorting what the user sees, it's just sorting what the tests look at. I think it would be best if tests could assert the ordering of the returned items even when the sort text is the same - I'm not sure what the advantage of doing this here is.
I'm not sure we could handle how the clients sort the text after `sortText` sorting (which we expect them to but obviously could be ignored).
The latest [failing bot](https://logs.chromium.org/logs/dart/buildbucket/cr-buildbucket/8703375698794674353/+/u/test_results/new_test_failures__logs_) showed an error at `pkg/analysis_server/test/lsp/completion_dart_test.dart:1341` with the sorting being different than what I wrote. But locally, if I swapped them I got the error and this way I didn't (not sure why).
But the thing is, I don't expect this difference to be relevant to the users considering the clients use at least `sortText`. If we wan't to be sure, then we probably need to enhance that value for the cases I had to change here (that and related tests and at `pkg/analysis_server/test/lsp/completion_yaml_test.dart`). I don't see any real value between sorting them "better" to the end user at this point, but of course I could be wrong.
Odd, I would expect the sorting to be deterministic. I'd be interested to understand why it was different for you, but I don't think it's worth holding this fix up.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
(item1.sortText == item2.sortText)Danny TuppenyThis ensures that when two completions have the same priority (as the ones presented by the new LSP test) then we sort them by the text we show to the user.
Felipe MorschelDo we want this? If I understand correctly, this isn't sorting what the user sees, it's just sorting what the tests look at. I think it would be best if tests could assert the ordering of the returned items even when the sort text is the same - I'm not sure what the advantage of doing this here is.
Danny TuppenyI'm not sure we could handle how the clients sort the text after `sortText` sorting (which we expect them to but obviously could be ignored).
The latest [failing bot](https://logs.chromium.org/logs/dart/buildbucket/cr-buildbucket/8703375698794674353/+/u/test_results/new_test_failures__logs_) showed an error at `pkg/analysis_server/test/lsp/completion_dart_test.dart:1341` with the sorting being different than what I wrote. But locally, if I swapped them I got the error and this way I didn't (not sure why).
But the thing is, I don't expect this difference to be relevant to the users considering the clients use at least `sortText`. If we wan't to be sure, then we probably need to enhance that value for the cases I had to change here (that and related tests and at `pkg/analysis_server/test/lsp/completion_yaml_test.dart`). I don't see any real value between sorting them "better" to the end user at this point, but of course I could be wrong.
Odd, I would expect the sorting to be deterministic. I'd be interested to understand why it was different for you, but I don't think it's worth holding this fix up.
I had a quick look but couldn't explain why the sort would differ - for me it seemed to always come out as the server set it if the `sortText`s are the same (including if I flipped `_addClosureSuggestion` to put the `=>` version first).
However, the sort we use in the handler doesn't appear to be stable, so it's not guaranteed to be the same and we probably shouldn't have the tests depend on it, so I think this change probably makes sense (either that, or making it stable in the handler, but since the client is going to re-sort and may be unstable, that's probably not worth it).
switchI can't think of any reasonable use for `true`, `false`, or `const`, but `null` should be included if the parameter is nullable (and I think it won't be, so please add the following as a test, but without the comment):
```dart
typedef void callback(int k);
void x(callback? q){}
void r() {
callback v;
x(^); // null is valid here
}
```
and I can see a use case for a `switch` expression, so that should be offered
```dart
typedef void callback(int k);
void x(callback q){}
void r(int i) {
callback u, v;
x(^); // could be
// switch (i) {
// < 0 => u,
// _ => v,
// }
}
```
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Auto-Submit | +1 |
// TODO(FMorschel): Determine if the expected type is bool and onlyI'll do this on a follow up CL since this might be a bigger change to the tests expected outputs.
// TODO(FMorschel): Determine if the parameter type has a constantI'm not sure I can do that reliably yet but I'll look into it in another CL too.
I can't think of any reasonable use for `true`, `false`, or `const`, but `null` should be included if the parameter is nullable (and I think it won't be, so please add the following as a test, but without the comment):
```dart
typedef void callback(int k);
void x(callback? q){}
void r() {
callback v;
x(^); // null is valid here
}
```
and I can see a use case for a `switch` expression, so that should be offered
```dart
typedef void callback(int k);
void x(callback q){}
void r(int i) {
callback u, v;
x(^); // could be
// switch (i) {
// < 0 => u,
// _ => v,
// }
}
```
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Sorry, I commented on this a while back, but appear to have forgotten to send my comments.
null`null` is a reasonable suggestion. The parameter has type `dynamic`, which is nullable even though it doesn't have a `?` after it.
nullDitto: the parameter is nullable because it's `dynamic`.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Auto-Submit | +1 |
`null` is a reasonable suggestion. The parameter has type `dynamic`, which is nullable even though it doesn't have a `?` after it.
Done
Ditto: the parameter is nullable because it's `dynamic`.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Auto-Submit | +1 |
Felipe MorschelI'm opening a comment here after also pinging you on the issue so you can find this either here or on GitHub.
@brianwi...@google.com @sraw...@google.com
I had to rebase and refactor this a bit because of https://dart-review.googlesource.com/c/sdk/+/453041. We should be good now.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
[DAS] Fixes regression in completion for unnamed parameters in closures
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Felipe MorschelI'm opening a comment here after also pinging you on the issue so you can find this either here or on GitHub.
@brianwi...@google.com @sraw...@google.com
I had to rebase and refactor this a bit because of https://dart-review.googlesource.com/c/sdk/+/453041. We should be good now.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |