This accepts the flag without a suffix because I'm fairly confident we can ship this support without breaking changes to the API.
For a short period, the old flag is still supported so that Dart-Code + SDK don't need to be updated at the same time to avoid the support disappearing. I will remove the old flag in a few weeks (after a beta SDK branch and a stable Dart-Code release).
Change-Id: I246a33f37a5d5fc5c05c15daab7d87d4cc4fd9e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/359064
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This is mostly a very tidy extraction of `getTypeSource`. This method
relied on a handful of helper functions, all of which were _only_
present in order to help `getTypeSource`. This method also does not
rely on `_buffer` or `eol`. And it is only used by one piece of code,
`extract_method`. Almost a slam dunk!
However, there appeared some strange caveats that I must document
here:
CorrectionUtils also featured two mutable fields, `targetClassElement`
and `targetExecutableElement`. Theoretically, these fields are
supposed to be set before calling `getTypeSource`, to help understand
whether a TypeParameter will be visible when extracting a method, or
something like that. But it appears to be totally broken:
* The singular caller of `getTypeSource`, `ExtractMethodRefactoring`,
_never sets those fields_.
* Two other pieces of code, the AddTypeAnnotation fix, and the
CreateField, CreateFunction, and CreateOverrides fixes, all set the
fields, but _never call getTypeSource_.
Since this all looked like just very stale / rotten code, I removed
everything which looks to be dead: `targetClassElement` and
`targetExecutableElement`, and lo and behold: no tests fail! I've kept
those things deleted, and added a TODO for TypeParameters.
Lastly, since I was trying to figure out ExtractMethodRefactoring, I
tidied it up:
* Make it final
* Rename `ERROR_EXITS` to `errorExits`
* Privatize `searchEngine`, `resolveResult`, `selectionOffset`,
`selectionLength`, `librariesToImport`, and `variableType`.
* Both `selectionRange` and `utils` could be final as they were set
in the constructor body, so move that to initializers, make final,
and make private.
Change-Id: Ia3fb948e5424971eb4250e711c179707552ad8aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/358663
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This adds a custom command similar to `dart/textDocument/super` but for augmentations.
This won't show up anywhere on its own, but it will be added to the command palette in Dart-Code based on the server capabilities (and in the future, maybe CodeLens - although that will require some additional work in the server first since it will be the source of CodeLens even if they trigger client-side actions).
See https://github.com/dart-lang/sdk/issues/54742
Change-Id: Ib3a3fd08702e14b8bd251991035ef0b8d06ad996
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/358452
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
This adds a custom command similar to `dart/textDocument/super` but for augmentation targets ("augmented").
This won't show up anywhere on its own, but it will be added to the command palette in Dart-Code based on the server capabilities (and in the future, maybe CodeLens - although that will require some additional work in the server first since it will be the source of CodeLens even if they trigger client-side actions).
See https://github.com/dart-lang/sdk/issues/54742
Change-Id: I11ca115c61ade40bf51478f58b39b7caedac19c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/358451
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
`CorrectionUtils.findPossibleLocalVariableConflicts` actually does not
use the `eol` utility or the `_buffer` field; it turns out it is a
good candidate for an extension method on CompilationUnit. It is moved
to the existing extension.
In refactoring call sites, PostfixCompletionProcessor didn't have a
perfectly obvious CompilationUnit field, so I refactored it a bit, and
cleaned up it's fields:
* Make the class final.
* Rename `NO_COMPLETION` to `_noCompletion`
* Privatize `node`, `completion`, `eol`, `file`, `key`,
`selectionOffset`, `typeProvider`, and `typeSystem`.
* While checking whether `change`, `linkedPositionGroups`, and
`exitPosition` could be private, it turns out they are unused; this
would have been flagged by static analysis if they had been private.
Change-Id: I29c48c362261b11402cee43464386c3152df7158
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/358641
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
This changes Go-to-Super to handle augmentations (jumping to a super-member will go the last augmentation in the chain) and constructors (will jump to the actual super constructor that is called, regardless of name).
Change-Id: I7439fd42ef81983e7a052f250f7ba272fe8c2c86
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357608
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
The big one is `getIndent`, which I think can be simpler, and also used a handwritten implementation of `String.operator *`. It turns out:
* > 90% of calls to `getIndent` were `getIndent(1)`, which can be
replaced with a constant `' '`.
* Then 4 calls to `getIndent` were `getIndent(2)`, which can be replaced
with a constant `' ' + ' '`.
* Then one last call, in CorrectionUtils itself, used a variable number
of indents which can be replaced with `' ' * n`. This is in the
`indentRight` function.
Also:
* Privatize `getInsertionLocationTop`, `isClassWithEmptyBody`, `isJustWhitespaceOrComment`, `skipEmptyLinesLeft`
* Rewrite CorrectionUtils.findSimplePrintInvocation as an extension
method on AstNode; does not need the `_buffer`.
Change-Id: I15c19b8c0cc354adcd4ffea5803b3a182cf28336
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/358400
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
For package:collection, computing measures.
Before: 0:01:00.236000
After: 0:00:55.977000
So, about 7% faster.
I think this translates into actual completion speed up.
Change-Id: I45f0c0186d5988e6e1b043d465030668cd61335b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357982
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
For LSP we sometimes split the display text to populate a number of different fields (for example when the display text is `foo => bar` we only want `foo` in the `filterText`).
We previously split on spaces but that fails for the new `override foo()` display texts, so this was changed to split on equals instead (and trim to remove any trailing spaces).
Fixes https://github.com/dart-lang/sdk/issues/32677
Change-Id: I7494426cfcc95388f0f1f91f7f9ff7bcac0f23ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357320
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>