We believe that it is not necessary anymore, with sound null safety.
Change-Id: I18741eafea1bd969139cdae3b94a294dde1b5abd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310769
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Add CONST_FOR_LOOP error message to be clearer that for loops are not
allowed in const contexts.
visitListLiteral handles Constants.
Change-Id: I84465ecf4e1f044c256db45c723fac081b50a40c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306917
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
I would like to use `Selection` for code completion, but the current
definition of `coveringNode` too often favors the parent node over the
child node. This will effectively cause the cursor to bind more closely
to an identifier token than to other tokens, making it more useful for
code completion.
If we don't like this change for the general case, I can make these changes in a specialized `coveringNodeForCompletion`, but I'd rather not have two approaches.
Change-Id: I39e70f83ad44d50cec55a8bee1f7061dd83746fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310060
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Initial commit at https://dart-review.googlesource.com/c/sdk/+/276100
used kb because that's what was reported by the system.
I wasn't allowed to add that to golem though, and then I forgot about
it.
This CL changes it to bytes so it can hopefully by allowed into golem.
Change-Id: Ia7fae9ed47e6d237648e266c26f4a644f13571d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310160
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Pointer.fromFunction returns a native function pointer to a Dart
function, but has the restriction that the native code must invoke it
on the same thread as the isolate that created it. RawVoidCallbacks is
a new API that is similar to Pointer.fromFunction. It returns a native
function pointer that can be invoked on any thread, with the
restriction that the Dart function must return void. Under the hood we
forward the function args over a port to the target isolate.
We're not 100% settled on the name of the class, but the overall API
design won't change. I'll make sure to get the naming finalized before
submitting this CL. Doc with discussion of naming:
https://docs.google.com/document/d/1z9Rgahoid2AhC9JXwsDAEODvlJS6dvBHCbcGkOxv_ws/edit?resourcekey=0-TbdNiSL-fdwskla02QaPwg#heading=h.te70ikwelbw8
Bug: https://github.com/dart-lang/sdk/issues/37022
Change-Id: Iba98f6f803c52919b942fa054df1060991574c8c
TEST=ffi_async_callback_test.dart
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308860
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Marya Belanger <mbelanger@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Danny gave a good idea that checking for availability of a refactoring
should be cheap. Change method signature refactoring mostly satisfied
this, with one exception - we cannot compute formal parameters for
an ExecutableElement, because we need resolved AST to do this, and
the invoked method can be declared in a different file. We cannot
afford resolving other files while checking.
So, this CL separates availability checking, and preparing formal
parameters, postponing expensive opertions until the time when the
action is invoked.
Change-Id: Ic703d70717e41de304c9dbcef66cadb22c139ad8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310041
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
If again and again editing, say, a `pubspec.yaml` with proper timing
there is a "temporary leak" that repairs itself once the analyzer
finishes (some time after the editing stops).
What happens is that old contexts are saved in the
`declarationsTracker` but eventually cleared in the
`afterContextsCreated` call.
In a test on Windows (on Linux I'd currently run into
https://dartbug.com/52703) I opened the entire "pkg" folder and edited
a `pubspec.yaml` file every 5 seconds.
The analyzer went from using something along the lines of 700MB of heap
to using around 2.5 GB of heap after 25 edits and 17GB (!) of heap
shortly before stopping at 250 `pubspec.yaml` edits.
After the editing stopped (and clicking the GC button in observatory)
the heap usage went down to ~650MB heap used.
This fixes the problem by clearing the `declarationsTracker` on the
`afterContextsDestroyed` call too. In the same test it stays at around
300-700MB of heap.
Possibly related to:
https://github.com/dart-lang/sdk/issues/48788https://github.com/dart-lang/sdk/issues/52447
Change-Id: Ia38cc946a1f36fa8c5b6804f79cbc8dd96c21030
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309722
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
For extra safety I want to ensure that the plugin is hosted on pub.dev.
Change-Id: I7f2a2f4b85ad6263a97a0927653fb0b688c79224
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309400
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Add new diagnostics for mixin subtypes since they can only be 'base'.
Bug: https://github.com/dart-lang/sdk/issues/52686
Change-Id: I8e4d6830c5c735c5b42d7fbe78d197c9506bbf4c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308806
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Analyzer adds watchers to all root folders it has opened.
When editing, say, a pubspec.yaml file it ~starts over, cancels the
old subscriptions and creates new ones. It keeps references to the old
subscriptions too though.
This in turn leaks data.
On Linux internally in package:watcher it clears some stuff as it's
cancelled, but it doesn't on Windows, nor on Mac.
The means it can leak an infinite amount of `_Entry` classes,
and for instance in https://github.com/dart-lang/sdk/issues/52447 a
user has 40+ million of those classes.
Reproducing this I got to 40+ million too, at which point the
"Retained size" of all the `_Entry` objects was 7.39GB.
This fixes the leak by clearing the list.
Change-Id: I718e8edc81b763b66affa16c3b3f6d4b8a97fd1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308940
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
I think this removes the no longer used test support classes, but let me
know if you know of any code I missed.
Change-Id: I42105b75862631e9f86458ebb7f47a6f8d9935ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308809
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
We allow missing named formal parameters and arguments, because
reordering them will not change the semantics. But we fail when a
positional formal parameter or argument is missing.
Change-Id: If3b3315407d2cf717aeaf1db219e6f1f84469224
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308807
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
It does not look to be used for anything else.
Change-Id: Iba283b93a84c2d1fe81685c07c8e81350759a48b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308521
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Currently the checks that we have are ironically both repetitive and
inconsistent. There are also tests that are not precise / demonstrative.
Change-Id: I1ad0de5b9fb982d8091e4f80a6e5c5ebbad0f418
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308580
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
This is convenient feature when building hierarchies of data classes.
Change-Id: Id4c7040e0515150661165079ad01d9d05e0c1185
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308541
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
On my Windows PC, the process never exits if we haven't subscribed to to the streams so this hands on awaiting exitCode (meaning the pub process never exits and the server never provides code completion for version numbers in pubspec.yaml).
Change-Id: I12a51d8fc50eee8c62d1ac1d4d51c9768a812ad8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308480
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
On my Windows PC using the Flutter repo (running `dartdev fix` from source) I see significant improvements:
flutter/packages/flutter/: 45s -> 15s
flutter/: 5m 23s -> 33s
These projects are clean so have no fixable errors, the improvements may be smaller where there are fixable errors and a larger proportion of time is spent resolving libraries.
Change-Id: Ie48baaa4ff8916112dab6639ae4e824e5b646ea8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308060
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
The new annotation is intended to be used on members of class, enum or mixin to opt out the @visibleForTemplate visibility restriction cascaded from class- / enum- / mixin- level.
1. Throw warning if the annotation is added to a invalid target.
2. Update @visibleForTemplate diagnostics logic to opt out members annotated with @visibleOutsideTemplate.
Change-Id: Iec546fc7785cd45f39a1b2a2cc8849ef1cf9d04a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304825
Reviewed-by: Marya Belanger <mbelanger@google.com>
Auto-Submit: Ludi Zhan <ludizhan@google.com>
Commit-Queue: Ludi Zhan <ludizhan@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Running the check for whether to prompt about "dart fix" in the LSP server with the whole Flutter repo open took around 45s before, and around 0.45s after. Almost all time was spent resolving libraries but now resolution is skipped for any libraries that don't contain fixable errors.
In my testing, "dart fix" (from source) didn't see any significant gains (around 46s down to around 43s for flutter/packages/flutter in my testing).
Fixes https://github.com/dart-lang/sdk/issues/52633
Change-Id: I0db63f5d54c7c262fe16aeb825f817cf526199c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308000
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
These tests can be quite slow (around 90 seconds on my machine, out of 4-5 mins for a test run) but aren't actually testing a lot. Opting out of them when running all tests repeatedly makes things much faster.
The default is still for them to run, you need to explicitly opt-out to skip them.
Change-Id: Id1aff44f48e71059f6ca44ff17acbf3f86427d61
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307480
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
The check normalises newlines from "actualContents", but "expectedContents" could also contain \r\n on Windows (at least it does for me), so this just normalises both.
The additional await/async is to prevent "Test failed after it already completed" warnings because this code is inside the call to test() (and not wrapping it, like the other .main() calls in the file).
Change-Id: Iac034efaf1a8a6dad4a21dc67a2dfdb74092dd22
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307301
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This is just a refactor with no functional changes.
To simplify future work of supporting both protocols against a single server, this removes some common functionality out of each server into the base server (or in this case, some base callbacks that operate on the base server).
It's important when the server runs with both protocols that we don't accidentally duplicate any work, so stripping down the servers (and callbacks) to only the protocol-specific parts should make this easier.
Change-Id: I040368078b992d0c41bd8de10b09e38d3957f004
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307081
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This allows more flexibility as we can configure the redirect overtime, compared to the GitHub hosted site which we have less control over. It could even redirect to the old linter site in the meantime if desired.
Contributes to https://github.com/dart-lang/linter/issues/4411 and https://github.com/dart-lang/site-www/issues/4498
Change-Id: I3512002cdf7f62c0338d67cec0d7091f1166479d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307000
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
So that we don't attempt to process it as part of LSP.
Change-Id: I29a297e40f038ea48ef25a0af86c73a165fc17dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305520
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
So, we don't have to recompute it at every symbol search.
For Flutter repository, searching for 'ButtonStyle' is 40% faster.
SHA: 47fe150674
Description: before
[mean: 56.4][stdDev: 1.471][min: 54.0][max: 61.0]
Description: own files
[mean: 35.0][stdDev: 1.308][min: 33.0][max: 38.0]
Change-Id: Id497bf4117bdfafeeccd04601fd0198e22624c0d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305843
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This CL adds a quick fix for `avoid_multiple_declarations_per_line`. This fix work for var/const/final/late variables, both typed and untyped. The declarations are also correctly indented and comments between the declarations are kept.
Change-Id: Ic614e264a199405cc0b9ceaea55a27c848970cfa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304600
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Before this change, using fix-all-on-save in VS Code would also remove unused imports:
```
"editor.codeActionsOnSave": {
"source.fixAll": true
}
```
This behaviour was a little inconsistent without iterative fix-all (it would not remove the imports if other fixes were applied). Iterative fix-all made it consistent, but this behaviour is not what many users want (for example if they'd temporarily commented out code).
With this change, imports will not be touched when using fix-all if it was invoked automatically by save. However, it's possible to retain the original behaviour by invoked listing the original fix, or (more efficiently) `source.organizeImports`) to run on-save:
```
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true
}
```
Fixes https://github.com/dart-lang/sdk/issues/52046
Fixes https://github.com/Dart-Code/Dart-Code/issues/4561
Change-Id: If68a5d13c2c1c9a494be61872c942fca8a4dd35c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305021
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
I'm not sure how to convert the doc tests. They're currently depending
on being able to set up some state in the server that I can't reach
from the new test framework. I'm guessing that I might be able to define
dartdoc comments that would populate the data structures in the same way,
but if you can think of an easier approach I'd love to hear about it.
Change-Id: I20afcf0865c1a45b682444f8bce8c4e3c7fdc45c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305782
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>