Commit graph

7454 commits

Author SHA1 Message Date
Brian Wilkerson abda30f198 Replace NodeLocator in two more places
Change-Id: I34a67ae8b370ec4c400ac5b9195d537380aca3c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274080
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-12-09 01:13:28 +00:00
Kallen Tu b58f1b4ef3 [analyzer] Report error when mixing in a sealed mixin outside of its library.
Change-Id: I62be6c21bc2bf2a5af35203137aa75c7fd1ba934
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274142
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2022-12-08 21:18:24 +00:00
Brian Wilkerson 44e11d9dd4 Add a utility to find adjacent siblings in a selection
This will be used to allow multiple top-level declarations to be moved
together.

Change-Id: Ib1c59e9ff3e01891f8cb29b74e78183c36b1f02d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273828
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-12-08 20:48:58 +00:00
Ahmed Ashour 66990edcf5 [analysis_server] fix RemoveDeadCode with forParts
Bug #43511

Change-Id: I82854382928cd29bfc7c646f0c202d28603f8836
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271200
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-12-08 06:33:09 +00:00
Brian Wilkerson 8569d24f3e Attempt to fix the windows bot
Change-Id: Id1743f8998c2cb2553b5cfed801e9caef9c1d7c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274264
Auto-Submit: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2022-12-08 02:20:17 +00:00
Brian Wilkerson de36e1cfb7 Enable patterns in server tests
Change-Id: I1d256b4c1c0cc20cb3e46087cd896d0920f82690
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274084
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-12-08 02:12:14 +00:00
Konstantin Shcheglov aea639bd03 Issue 50604. Fix renaming extension at its declaration.
Bug: https://github.com/dart-lang/sdk/issues/50604
Change-Id: I1c685ea7545ef120e5fc23fe6a507ded8c4f4cb9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274083
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-12-07 22:38:19 +00:00
Konstantin Shcheglov 356d15a3fc Issue 50603. Fix element kind to EXTENSION in search.getElementDeclarations
Bug: https://github.com/dart-lang/sdk/issues/50603
Change-Id: I22b4d827bc9472544cf3c3aad3473de8050e2f6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274085
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-12-07 22:37:37 +00:00
Konstantin Shcheglov 52be8e0f3e Issue 50496. Add mixin super invoked names to the unlinked signature.
Bug: https://github.com/dart-lang/sdk/issues/50496
Change-Id: I09c6dbc025cecc52e8f0340388bbf2b79ea78057
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273831
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-12-07 22:17:22 +00:00
Kallen Tu 7ff20a67ca [analyzer] Report error when subtyping a sealed class outside of its library.
Change-Id: Iee6c9120d096ed49592ca3d155c81c876ceb5c34
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273832
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-12-07 22:00:28 +00:00
Danny Tuppeny df3df89fd9 [analysis_server] Include type in extract-local-variable if always_specify_types is enabled
Fixes https://github.com/Dart-Code/Dart-Code/issues/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>
2022-12-07 21:11:47 +00:00
Danny Tuppeny 092bdb17d3 [analysis_server] Improve Snippet performance with caching and earlier filtering
This shares a cache for mapping Elements to their public LibraryElements across each snippet producer, and also skips snippet producers that produce snippets that won't match any typed prefix.

Change-Id: I6b64b3c55f1030a5eaa7ca1afdcd6c416e4baa08
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273962
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-12-07 20:31:12 +00:00
Danny Tuppeny c24f36d470 [analysis_server] Use public (non-src) URIs for Flutter snippet imports
Fixes https://github.com/dart-lang/sdk/issues/49081.

Change-Id: I0734b4f45c72d70f7b32640bed6b6ec2e8130c01
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273841
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-12-05 22:32:19 +00:00
Brian Wilkerson 7953da5cf1 Fix the windows bot
Change-Id: I4d71fd70b2f0b4a4a3af3446f56fbd9b79fd0954
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273821
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-12-05 18:00:16 +00:00
Ahmed Ashour bea7045517 [analyzer] add failing test case
Bug #50496

Change-Id: Iaa6007af1b9dbbf7bac3f2ad835dece3eb64b189
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271520
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-12-05 17:37:43 +00:00
Jens Johansen b812517fac [analyzer] Don't ask for subtypes for the same elements several times when searching for references
When asking for all references of a member it starts by finding all
supertypes for the class, then for each supertype (including itself)
(that has a member with the same name as the one we're querying for)
it searches for all subtypes.

We recall that when getting all subtypes, it really gets all direct
subtypes, then for each of those, their direct subtypes etc.
Naturally, then, with getting all subtypes for all supertypes we
will often ask for all direct subtypes of the same class several times.

In fact, it's O(n^2):

As an example, if asking for references to `foo` on this
(in a file in analyzer, with 8 workspaces):
```
class X0 { void foo() { print('hello'); } }
class X1 extends X0 { void foo() { print('hello'); } }
class X2 extends X1 { void foo() { print('hello'); } }
[...]
class X149 extends X148 { void foo() { print('hello'); } }
```
we ask for subtypes 90600 (150 classes * 151 / 2 * 8 workspaces) times.

This CL stops that from happening and in the example from above we
"only" asks for subtypes 1200 (150 classes * 8 workspaces) times.

For the `newFile` from `AbstractSingleUnitTest` example, for instance,
we go from 28,264 asks to 17,432 asks (a ~38% reduction).

Non-first runtimes when asking for references:

Before:
0:00:03.074853
0:00:03.021881
0:00:03.034707
0:00:03.115596
0:00:03.032574

After:
0:00:02.223978
0:00:02.149937
0:00:02.150236
0:00:02.104704
0:00:02.175859

Difference at 95.0% confidence
        -0.894979 +/- 0.060283
        -29.2867% +/- 1.97266%
        (Student's t, pooled s = 0.0413338)

Change-Id: Id792a595e74de01c7186ab1263c38728f051f603
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272623
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-12-05 08:03:24 +00:00
Brian Wilkerson 6346e7fcd1 Update imports in files other than the source and destination when moving declarations
Change-Id: I3675bddc9479744a4642bdbb66b8de013f0f01df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273524
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-12-02 23:22:16 +00:00
Konstantin Shcheglov 48d0d95edb Report CONSTANT_PATTERN_WITH_NON_CONSTANT_EXPRESSION
Change-Id: Idb6d0963515457e1748362dbda1441d5820a040a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273521
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-12-02 22:56:57 +00:00
Konstantin Shcheglov 70b994e54f Test rest element with subpattern in map pattern.
Change-Id: I348ce8bfb6b32b3fcd1a63427d0a82a33dfa2c1a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273520
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-12-02 21:50:50 +00:00
Konstantin Shcheglov 46bffdabb1 Test logical-and in variable declaration, report REFUTABLE_PATTERN_IN_IRREFUTABLE_CONTEXT.
Change-Id: I7fcffea3b591fbe3a181a8bb8a8a461d18ec3d64
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273340
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-12-02 17:53:19 +00:00
Sam Rawlins 987c7503d1 Move DAS tutorial dir, and add light mode icons
The tutorial doc was mistakenly _not_ in the doc/ directory.

The icons show up as way too big, so I use inline HTML to specify
their width, so that they look good inline.

I add light mode icons, and use GitHub (and dartdoc)'s support for
switching between light mode and dark mode images.
https://www.stefanjudis.com/notes/how-to-define-dark-light-mode-images-in-github-markdown/

Change-Id: I1a368bfc6628adf941ba5e7a752317f9757d2538
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273460
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-12-02 17:16:08 +00:00
Jens Johansen 8cc984cd45 [analyzer] More timings and keep track of number of invocations
Before we might get something that looks like this:
```
(name: request, elapsed: 0:00:00.732983, elapsedSelf: 0:00:00.002428)
  (name: requireResolvedUnit, elapsed: 0:00:00.037635, elapsedSelf: 0:00:00.037635)
  (name: _getImplementations, elapsed: 0:00:00.692920, elapsedSelf: 0:00:00.000135)
    (name: searchAllSubtypes, elapsed: 0:00:00.691494, elapsedSelf: 0:00:00.691494)
    (name: filter and get location, elapsed: 0:00:00.001291, elapsedSelf: 0:00:00.001291)
```

With this CL we get this:
```
(name: request, count: 1, elapsed: 0:00:00.739592, elapsedSelf: 0:00:00.008764)
  (name: requireResolvedUnit, count: 1, elapsed: 0:00:00.104381, elapsedSelf: 0:00:00.104381)
  (name: _getImplementations, count: 1, elapsed: 0:00:00.626447, elapsedSelf: 0:00:00.000350)
    (name: searchAllSubtypes, count: 1, elapsed: 0:00:00.624650, elapsedSelf: 0:00:00.001226)
      (name: _searchDirectSubtypes, count: 428, elapsed: 0:00:00.623424, elapsedSelf: 0:00:00.023618)
        (name: discoverAvailableFiles, count: 8, elapsed: 0:00:00.000422, elapsedSelf: 0:00:00.000422)
        (name: subTypes, count: 3424, elapsed: 0:00:00.599384, elapsedSelf: 0:00:00.599384)
    (name: filter and get location, count: 1, elapsed: 0:00:00.001447, elapsedSelf: 0:00:00.001447)
```

Change-Id: Ia6ff3a55d7d0467b41a036ecdfb86f7e7b436b55
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272622
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-12-02 08:58:23 +00:00
Sam Rawlins 14d553ad9d Add a tutorial for collecting instrumentation, and analyzer diagnostics
Change-Id: Icdf8480cf9954b6181bed320ccc1764055bd6640
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273301
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-12-02 07:31:18 +00:00
Konstantin Shcheglov 73721f7654 Report PATTERN_TYPE_MISMATCH_IN_IRREFUTABLE_CONTEXT
Mostly to don't crash when running co19 tests.

Change-Id: I62838d04872642b2e3a9ed01a1be120aec1c0608
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273081
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-12-02 02:58:16 +00:00
Oleh Prypin 328c261397 Expand RemoveReturnedValue fix to turn => null into {}
This is targeted at the lint `avoid_returning_null_for_void` which already complains about expression function bodies but the fix doesn't do anything for them.

Change-Id: I14f3d7659301edae08482d9ffa6b72b483737e59
Bug: https://github.com/dart-lang/sdk/issues/45920
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272940
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Oleh Prypin <oprypin@google.com>
Commit-Queue: Oleh Prypin <oprypin@google.com>
2022-12-01 22:04:48 +00:00
Danny Tuppeny a7baf9309f [analysis_server] Ensure plugin protocol classes only use types valid for Isolate.send()
Fixes https://github.com/dart-lang/sdk/issues/50594.

Change-Id: I5550239dbce4a1ed7fbd844dd53642989289c899
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273200
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-12-01 16:57:56 +00:00
Konstantin Shcheglov e89d93f48c Support for 'final' in PatternVariableDeclarationImpl.
Change-Id: I0ea3952e502f5e1ce4bfea412bb9c0a4471da6f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273008
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-12-01 01:59:09 +00:00
Konstantin Shcheglov 212eae02de Resolve MapPattern(s).
Change-Id: I1f80c7f919018a74525948bd4dbec879fc3e0672
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272744
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2022-11-30 17:44:28 +00:00
Brian Wilkerson 63b779533f Add a flag that will allow plugin support to be disabled when necessary
Change-Id: Ifa80f14a58501054a72a9e82ff66aa35de37b4fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272490
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2022-11-30 16:02:50 +00:00
Jens Johansen e70befdcbd [analyzer] Only search the same files for the same thing once
TL;DR:

56c416430e vs this CL:

textDocument/implementation (non-first runs):
```
Difference at 95.0% confidence
        -3.6465 +/- 0.307413
        -82.3689% +/- 6.94398%
        (Student's t, pooled s = 0.238983)
```
I.e. from ~4.4s to ~0.78s on non-first runs.

textDocument/references (non-first runs):
```
Difference at 95.0% confidence
        -33.1856 +/- 0.789512
        -91.4283% +/- 2.17515%
        (Student's t, pooled s = 0.613768)
```
I.e. from ~36.2s to ~3.11s on non-first runs.

Raw data below.


Details:

When having multiple workspace folders open, sometimes the drivers
representing these folders will have overlapping files.
For instance in my "analyzer" workspace there are a total of ~7000
unique files but if just adding each drives known files there’s
40,000+ files.

When asking for all direct subtypes of a class the a
`_FilesReferencingNameTask` does a lookup in a set for every known file
of that drive, meaning that in practice, often the same set is queried
for the same thing many times.

This CL instead assigns each `Drive` the files it was to look at,
each set will therefore only be querues once per type.

This takes the number of operations (per type) from `N*M` where `N` and
`M` are number of drives and number of files respectively (as each drive
could know all the same files) to just `M`, i.e. number of files.

This CL takes the runtime for asking for implementations of 'ToJsonable'
from package:analysis_server/lsp_protocol/protocol_special.dart in my
analyzer workspace (with 8 workspace folders / drivers) from ~4.4 seconds
to ~0.8 seconds (see below for details).
It also takes a call for "find all references" ("textDocument/references")
on method "newFile" in class "AbstractSingleUnitTest" in
"analysis_server/test/abstract_single_unit.dart" from ~36 seconds
to ~3.2 seconds (see below for details).


Raw data:

HEAD as of 56c416430e

textDocument/implementation
===========================
(notice the first query taking a long time)

(restart analyzer process)
Got answer to query in 0:00:28.921389
Got answer to query in 0:00:04.270255
Got answer to query in 0:00:04.248489

(restart analyzer process)
Got answer to query in 0:00:08.319562
Got answer to query in 0:00:04.232582
Got answer to query in 0:00:04.102793

(restart analyzer process)
Got answer to query in 0:00:09.186371
Got answer to query in 0:00:04.867653
Got answer to query in 0:00:04.840468


textDocument/references
=======================
(notice the first query taking slightly longer)

(restart analyzer process)
Got answer to query in 0:00:41.916106
Got answer to query in 0:00:36.619501
Got answer to query in 0:00:36.502156

(restart analyzer process)
Got answer to query in 0:00:40.353819
Got answer to query in 0:00:37.709369
Got answer to query in 0:00:36.086530

(restart analyzer process)
Got answer to query in 0:00:40.052997
Got answer to query in 0:00:35.273826
Got answer to query in 0:00:35.589722



WITH CL

textDocument/implementation
===========================
(notice the first query taking a long time)

(restart analyzer process)
Got answer to query in 0:00:11.902654
Got answer to query in 0:00:00.742324
Got answer to query in 0:00:00.730748

(restart analyzer process)
Got answer to query in 0:00:04.966440
Got answer to query in 0:00:00.795087
Got answer to query in 0:00:00.820526

(restart analyzer process)
Got answer to query in 0:00:04.838173
Got answer to query in 0:00:00.810417
Got answer to query in 0:00:00.784124

textDocument/references
=======================
(notice the first query taking a long time)

(restart analyzer process)
Got answer to query in 0:00:07.632822
Got answer to query in 0:00:03.098794
Got answer to query in 0:00:03.008570

(restart analyzer process)
Got answer to query in 0:00:07.690932
Got answer to query in 0:00:03.062484
Got answer to query in 0:00:03.088793

(restart analyzer process)
Got answer to query in 0:00:07.786218
Got answer to query in 0:00:03.160477
Got answer to query in 0:00:03.248359

Change-Id: I18a3cbd870f62e87937f92942460baccf8bce088
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272560
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-11-30 09:03:39 +00:00
pq 636eec185b linter 1.31.0
Cherry-picks update of `prefer_equal_for_default_values` to be a no-op in SDKs `>=2.19`.

See: https://github.com/dart-lang/linter/pull/3865

Change-Id: I2669f0279a0913bc8b3c5b0501a9869608883a14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272543
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2022-11-30 02:11:07 +00:00
Konstantin Shcheglov 7e97d695f8 Fix highlighting FunctionTypedFormalParameter name.
Change-Id: I476711afa5c44c0eb7cb177e85bd67e57b024421
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272544
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-11-29 23:02:58 +00:00
Nate Bosch b2485c549f Allow AddExplicitCall for bulk and file fixes
The edit regions should not overlap and the fixes are independent.

- Add `canBeAppliedInBulk` and `canBeAppliedToFile`.
- Add a BulkFixProcessorTest with multiple fixes in the same file.
- Add a FixKind for fixing implicit call tearofffs across the file.

Change-Id: I14260e4082fcd47c3a50514416b1c15b2c7e12c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271540
Reviewed-by: Oleh Prypin <oprypin@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2022-11-29 22:14:35 +00:00
Sam Rawlins e1acab8071 [analysis server] add fix for dangling_library_doc_comments
Change-Id: I5bd3ce04fc85a698983cbbd04bab61fedadfca6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272481
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2022-11-29 20:00:41 +00:00
Jens Johansen 56c416430e [analyzer] LSP 'get implementations': get lineInfo directly
Asking for implementations of 'ToJsonable' from
package:analysis_server/lsp_protocol/protocol_special.dart takes
8+ seconds both on first request and on subsequent requests.

Turns out most of that is spent on getting line info data for each
result via `server.getLineInfo`.

This CL rewrites how the search is performed, getting all subtypes
directly via `searchAllSubtypes`, from which one can cheaply get the
line info.

On my machine, the call that always took 8+ seconds before now takes
<2 seconds (at least on subsequent runs).
Notice that the time also depends on how much is open by the editor and
that calls from my editor with many folders open still takes ~6 seconds.

This CL furthermore adds more performance measurements that's available
via the "Analysis Server Diagnostics" page "Timing" for
"textDocument/implementation" requests.

Change-Id: I2e5ef20238901fb4734cc182aeb53adfc96f79b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272360
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2022-11-29 08:19:42 +00:00
Dmitry Zhifarsky 2b7b4dc777 [analysis_server] Fix CodeAction LSP dynamic registration config
Bug: https://github.com/dart-lang/sdk/issues/50531
Change-Id: I35a3c05a70a4ffe9ae0bbfb13874eddfaa302b25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272260
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-11-28 18:53:47 +00:00
Danny Tuppeny f2b4152159 [analysis_server] Include pubspec+analysis_options fixes in LSP Code Actions
Fixes https://github.com/dart-lang/sdk/issues/50306.

Change-Id: Ia9331887ee72c7ecff757557e3903ed1711ada39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271364
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-11-28 16:46:04 +00:00
Sam Rawlins 01fba618ed New fix: RemoveNameFromDeclarationClause
Change-Id: I5a877e9dcc54b4c42b37bca5de89ea7f94a1fe6b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271563
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-11-23 20:24:00 +00:00
Danny Tuppeny 019fb7a214 [analysis_server] Fix auto-imports not working for plugin completions
Fixes https://github.com/Dart-Code/Dart-Code/issues/4275.

Change-Id: I8c5e80eeebfe814fb95220edcd94da3059cc1b14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271701
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-11-23 19:53:13 +00:00
Danny Tuppeny e5b8089c27 [analysis_server] Refactor LSP code actions handling
This is mostly* a no-op refactor. This code handler had grown quite messy and all of the quick-fixes code only ran for Dart files (and assumed it had a resolved unit) which complicates fixing https://github.com/dart-lang/sdk/issues/50306 (quick-fixes for non-Dart files).

This change splits the handling into separate classes for each source of code actions (currently just "server Dart" and "plugins" but soon there will be pubspec/analysis_options producers too), then merges each group and sorts that group by priority.

* the one minor change is a code-path that was producing CodeAction literals where the client had not advertised supported this. This is now fixed and the related test updated.

Change-Id: I8837610c64aba3f2c3dcb2f1eb0bc9bf5c43ad62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271360
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-11-23 19:50:58 +00:00
Sam Rawlins a030c643cb New fix: move_annotation_to_library_directive
Change-Id: Ifef0a4d5a9c81faf21a6cb39b5fb0fbb525db139
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270780
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-11-23 02:27:31 +00:00
Sam Rawlins f6d66b6ea7 Update fix status file
Change-Id: I9ac3d082720f9176704f1c600d96238f55778a63
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271240
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2022-11-22 16:24:29 +00:00
Sam Rawlins c5729b36d5 Fix runtime errors in instrumentation log_viewer
I encountered these errors while trying the log_viewer on some recent
log files.

Change-Id: If0207659eae717e4fbba28455ceee8815671f081
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270801
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-11-22 00:04:35 +00:00
Ahmed Ashour 208d65324a [analysis_server] fix AddMissingEnumCaseClauses with prefix
Fixes #50484

Change-Id: I1bd325d460f0e286e602e215c0cce6a86eae2a3b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270700
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-11-21 22:29:37 +00:00
Ahmed Ashour 9bea89246a Fix grammar
Fixes #50509

TEST=ci

Change-Id: I7ca115bbe6f436e9df126afddcc08eaba79af2f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270740
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-11-21 20:07:29 +00:00
Ahmed Ashour 3556eb571e [analysis_server] RemoveDeadCode to handle forParts updaters
Fixes #43511

Change-Id: I8d717038356444c70e082aab37911791de63bd6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266389
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-11-21 19:59:27 +00:00
Sam Rawlins 8e743ca83c Add fix for CompileTimeErrorCode.SUPER_FORMAL_PARAMETER_TYPE_IS_NOT_SUBTYPE_OF_ASSOCIATED
Fixes https://github.com/dart-lang/sdk/issues/50524

Change-Id: I0d2a32c3c93e48979872592ba371865c695e76cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271060
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-11-21 19:44:02 +00:00
Sam Rawlins 6eef2c0649 Add fix for NON_FINAL_FIELD_IN_ENUM
Change-Id: I4eb8125468290af44b65343d620ee2646c2594c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270800
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2022-11-21 18:42:51 +00:00
Danny Tuppeny 699b42c8e3 [analysis_server] Support adding multiple imports for @overrides completions
Related to https://github.com/Dart-Code/Dart-Code/issues/4116.

Change-Id: I81b9e7bfbe4bbd093770925f9dcb640b72487142
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270181
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-11-21 18:06:35 +00:00
Sam Rawlins 100f78daf6 Enforce new lint rules in pkg/analysis_server
Change-Id: I2fd938e5bc44f0798429b68524abc5718211c0ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270482
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2022-11-18 22:36:57 +00:00