Commit graph

8130 commits

Author SHA1 Message Date
Konstantin Shcheglov d856c6a460 Move FuzzyMatcher to analyzer.
In a future CL I'd like to filter out whole libraries depending
on whether they could have a match. At this point the search, filtering,
and matching become entangled too much to bind them with outside
code in the server. Instead, it all will be the analyzer's concern.

Change-Id: Iefdadbf92046218b3a2607fbeadd37494522112e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304841
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-05-22 23:10:07 +00:00
Konstantin Shcheglov 4bd2d5b58c Issue 52473. Fix NPE in SortUnnamedConstructorFirst.
Bug: https://github.com/dart-lang/sdk/issues/52473
Change-Id: I492b2c7fc896db615ec316d6e335795363db2110
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304820
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-22 20:50:41 +00:00
Konstantin Shcheglov 7086cf687a Issue 52470. Fix RangeError in AddKeyToConstructors.
Bug: https://github.com/dart-lang/sdk/issues/52470
Change-Id: I0ab2630ac74cff42cb0f6e526a2f518c8e4cd918
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304768
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-22 20:15:33 +00:00
Polina Cherkasova c192336dde Add auto-snapshotting and usage reporting.
Change-Id: I84b48cc750638ab3bcc138f2a0425442559e6d54
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304212
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Polina Cherkasova <polinach@google.com>
Reviewed-by: Ilya Yanok <yanok@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-05-22 18:00:26 +00:00
Brian Wilkerson 7419e25966 Convert local library completion tests
Change-Id: I565572911964a683d203d8a40ccfd8e96845ca0b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304288
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-05-20 15:27:53 +00:00
pq 19b28a76dc fix error status typos
Change-Id: I8b73d1a37630ca310ba4fb67f836cf670c8d059c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304562
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-19 21:40:43 +00:00
Keerti Parthasarathy cce552594e Add support for fix on replacing an element and the corresponding target.
BUG=50698

Change-Id: Ib6dc5557a5b6db83316d61e3243c7541a3652965
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304104
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2023-05-19 20:38:59 +00:00
Brian Wilkerson d53b494bd7 Convert type member completion tests
Change-Id: Ic6f8a249f9082818c710e3660650f9fccce483a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304205
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-05-19 18:48:09 +00:00
Danny Tuppeny 9a455c809b [analysis_server] Add a utility to merge SourceFileEdits from multiple passes of edits
This is work towards https://github.com/dart-lang/sdk/issues/47968. The fix processor may need to be called multiple times to fix all issues because some fixes may produce code that can be fixed by another (for example one inserting "final" and then another replacing it with "const").

In order to be able to provide multiple passes of edits to LSP, we need to merge them together because LSP's edits are not applied sequentially but must all represent valid locations in the original source file.

This class is currently unused (besides tests).

Change-Id: Ia006ff8044505c6d109f6480f7bcce4da4669cdb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304180
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-05-19 15:30:46 +00:00
Konstantin Shcheglov c9557fe568 Reduce instrumentation for WorkspaceSymbolHandler.
I played with it some more, and found that the overhead of measuring
too fine grainly, when we have tens and hundreds thousands of relatively
inexpensive operations, is too high.

Change-Id: I4038e3972efff860d568c02008120092f99b8298
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304368
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-19 14:38:38 +00:00
Sigmund Cherem cc8b3f792e [analyzer] minor updates to the quick_fix.md documentation
The changes are:
* Use the current tear-off syntax for constuctors in the example
* Add references to the code where certain maps are defined.

Change-Id: I5710090c1ecb2939d74a3822b8c7b35090be378c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304323
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-18 18:53:39 +00:00
Danny Tuppeny 34a21f5691 [analysis_server] Switch to using FuzzyMatcher instead of RegExp for LSP workspace symbols
See https://github.com/Dart-Code/Dart-Code/issues/4106#issuecomment-1552948926.

In my tests on the Flutter repo, this reduces the matching from around 200ms to around 40ms.

Before:
(name: request, count: 1, elapsed: 0:00:00.708230, elapsedSelf: 0:00:00.000487)
  (name: findDeclarations, count: 1, elapsed: 0:00:00.707656, elapsedSelf: 0:00:00.002735)
    (name: discoverAvailableFiles, count: 1, elapsed: 0:00:00.000187, elapsedSelf: 0:00:00.000187)
    (name: ownKnown, count: 1, elapsed: 0:00:00.023311, elapsedSelf: 0:00:00.023311)
    (name: findDeclarations, count: 1, elapsed: 0:00:00.681423, elapsedSelf: 0:00:00.016362)
      (name: getLibraryByUri, count: 7276, elapsed: 0:00:00.295596, elapsedSelf: 0:00:00.295596)
      (name: finder, count: 7272, elapsed: 0:00:00.369465, elapsedSelf: 0:00:00.055566)
        (name: addDeclaration, count: 317711, elapsed: 0:00:00.313899, elapsedSelf: 0:00:00.080608)
          (name: doNothing, count: 317711, elapsed: 0:00:00.020405, elapsedSelf: 0:00:00.020405)
          (name: regExp, count: 317711, elapsed: 0:00:00.212886, elapsedSelf: 0:00:00.212886)
  (name: convert, count: 1, elapsed: 0:00:00.000087, elapsedSelf: 0:00:00.000087)(declarations: 1)


After:
(name: request, count: 1, elapsed: 0:00:00.522033, elapsedSelf: 0:00:00.003331)
  (name: findDeclarations, count: 1, elapsed: 0:00:00.518648, elapsedSelf: 0:00:00.002939)
    (name: discoverAvailableFiles, count: 1, elapsed: 0:00:00.000213, elapsedSelf: 0:00:00.000213)
    (name: ownKnown, count: 1, elapsed: 0:00:00.021037, elapsedSelf: 0:00:00.021037)
    (name: findDeclarations, count: 1, elapsed: 0:00:00.494459, elapsedSelf: 0:00:00.016197)
      (name: getLibraryByUri, count: 7276, elapsed: 0:00:00.292021, elapsedSelf: 0:00:00.292021)
      (name: finder, count: 7272, elapsed: 0:00:00.186241, elapsedSelf: 0:00:00.050400)
        (name: addDeclaration, count: 317711, elapsed: 0:00:00.135841, elapsedSelf: 0:00:00.072235)
          (name: doNothing, count: 317711, elapsed: 0:00:00.019244, elapsedSelf: 0:00:00.019244)
          (name: isMatch, count: 317711, elapsed: 0:00:00.044362, elapsedSelf: 0:00:00.044362)
  (name: convert, count: 1, elapsed: 0:00:00.000054, elapsedSelf: 0:00:00.000054)(declarations: 1)
Change-Id: Ib8775536fb7b16b9d29c2839167ce41de9ecc874
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304341
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-18 18:31:28 +00:00
Konstantin Shcheglov c207dafe77 Instrument WorkspaceSymbolHandler.
Change-Id: Ia822b253124b53e5ee283f7b3cce15db050eedb5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304280
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-18 15:43:17 +00:00
Konstantin Shcheglov 64fcb8de1b Prepare for removing deprecated methods from NamedType.
The actual removal will happen in (to be rebased on top of this):
https://dart-review.googlesource.com/c/sdk/+/303280

Fixing direct uses of the deprecated `Identifier get name` is apparently
only about a half of the work. I should have followed my own advice to
the clients and prepared better.

These changes are necessary because we will stop creating and
visiting `Identifier`, and so `NamedType` should be handled directly.

Change-Id: Ie07b75b15eab277ed6c9b29a838561a7eb71f588
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303425
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-18 01:54:21 +00:00
Ilya Yanok 0c5e1e8e48 Revert "Add auto-snapshotting and usage reporting."
This reverts commit 5fa6c5ed2a.

Reason for revert: breaks G3, we need to update //third_party/dart/leak_tracker first

Original change's description:
> Add auto-snapshotting and usage reporting.
>
> First attempt merged without passing bots and was rolled back: https://dart-review.googlesource.com/c/sdk/+/300862
>
> Change-Id: I782bf4d92394055e1f60a4275b5045e3622e239f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304101
> Reviewed-by: Samuel Rawlins <srawlins@google.com>
> Commit-Queue: Polina Cherkasova <polinach@google.com>

Change-Id: I8f1643e20f8d134cbf917dc43731798a1234cc2b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304181
Commit-Queue: Ilya Yanok <yanok@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-05-17 22:03:17 +00:00
Konstantin Shcheglov 44de52b412 Issue 52427. Fix AddEnumConstant when the target enum has no constants.
Bug: https://github.com/dart-lang/sdk/issues/52427
Change-Id: Ia86928155dd63d81bf90cbae8cac669e8c02b79b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304144
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-17 18:54:32 +00:00
Brian Wilkerson 5bf2e8c782 Convert closure completion tests
This also removes the tests converted in the previous CL because I
forgot to delete the file.

Change-Id: I306d64d227e2b5f632a9da9b547ce649e5d33767
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304142
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-05-17 18:48:58 +00:00
Konstantin Shcheglov 464235a29e Issue 52426. Handle InvalidType in CorrectionUtils.getTypeSource()
Bug: https://github.com/dart-lang/sdk/issues/52426
Change-Id: I34fde1bf0836990ecb41a75c1684795d75d286fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304103
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-17 18:32:26 +00:00
Polina Cherkasova 5fa6c5ed2a Add auto-snapshotting and usage reporting.
First attempt merged without passing bots and was rolled back: https://dart-review.googlesource.com/c/sdk/+/300862

Change-Id: I782bf4d92394055e1f60a4275b5045e3622e239f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304101
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Polina Cherkasova <polinach@google.com>
2023-05-17 17:56:47 +00:00
pq 1178e96bc1 add quick fix for cast_nullable_to_non_nullable
See: https://github.com/dart-lang/lints/issues/28

Change-Id: Ic0dac81467a3a3fbe7f7bf805ee59e3844edb6a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303681
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-05-17 16:18:54 +00:00
Daco Harkes dba0758120 Revert "Add auto-snapshotting and analytics for memory usage."
This reverts commit 5f1e7ade45.

Reason for revert: bots are failing

Original change's description:
> Add auto-snapshotting and analytics for memory usage.
>
> See video linked to issue: https://github.com/flutter/devtools/issues/5606
>
> Change-Id: I9f22031871e30bc7160e2c49b0423fb64df62223
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300862
> Reviewed-by: Samuel Rawlins <srawlins@google.com>
> Reviewed-by: Jacob Richman <jacobr@google.com>

Change-Id: I54cb3943230ab1229cc8b2c9df40e9c71765df19
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303881
Auto-Submit: Polina Cherkasova <polinach@google.com>
Reviewed-by: Polina Cherkasova <polinach@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-05-17 07:43:26 +00:00
Brian Wilkerson 614de8dddf Convert the named constructor completion tests
Change-Id: I095571f486feead2ee4dad0a700bac46901e16a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303903
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-05-17 00:31:43 +00:00
Polina Cherkasova 630cec473e Update AUTOSNAPSHOTTING.md
Change-Id: I363993bd54ddc01c1224f2ec53ce7c383aac2a68
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303801
Commit-Queue: Polina Cherkasova <polinach@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-05-16 22:08:47 +00:00
Polina Cherkasova 5f1e7ade45 Add auto-snapshotting and analytics for memory usage.
See video linked to issue: https://github.com/flutter/devtools/issues/5606

Change-Id: I9f22031871e30bc7160e2c49b0423fb64df62223
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300862
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Jacob Richman <jacobr@google.com>
2023-05-16 20:15:12 +00:00
pq 8d6bc8dd60 quick fix for unnecessary_to_list_in_spreads
See: https://github.com/dart-lang/lints/issues/80

Change-Id: I4c77c69e8449a4db1f267143d3dcad19b89d3bed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303785
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-05-16 18:08:28 +00:00
Brian Wilkerson 85221a9ba6 Convert variable name contributor tests
Change-Id: I21983e7492420a93e562a94e7907707b90d1938e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303780
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-05-16 17:33:47 +00:00
Danny Tuppeny dff000708f [analysis_server] Copy the original imports from source when moving top-levels to new files
Previously we would just import the library containing the declaration (which for other packages could be in `src/`).

See https://github.com/dart-lang/sdk/issues/30310#issuecomment-1508226776.

Change-Id: I1f2c8f480b60240bd7f88e037fd768e157f96f17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301400
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-15 22:55:01 +00:00
Simone Stasi c8ad2102b1 [analysis_server] fix 'add await' quick fix with parser error
When there's a parser error (like a missing semicolon) the 'add await' quick fix writes 'await' in the wrong place (right after 'async'). This CL simply writes 'await' in the correct place by using errorOffset.

Bug: #52390
Change-Id: I2f59433054826b492c448e2f35e2c2a00b2a775c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303240
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-15 22:45:18 +00:00
pq 12851f730d fix convert_to_boolean_expression for as-expressions
Fixes: https://github.com/dart-lang/sdk/issues/52368


Change-Id: I9196aebd17305c1d65c178a8c90270ff8eb733ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303147
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-05-15 22:02:18 +00:00
Danny Tuppeny f74132e636 [analysis_server] Handle postfix/prefix operators, compound assignments in Move to File
+ some additional tests for extension operators.

Change-Id: I32b705c4e0fa96c785e55b41aba713c6026eecca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301060
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-15 21:54:07 +00:00
Brian Wilkerson 7f1a5cc20f Attempt to fix the windows bot
This reverts the changes to ResourceProviderMixin that made it possible
for a test to explicitly set the context type of the resource provider.
I don't believe that's necessary because we run all of the tests on the
windows bot with that context type anyway.

It also removed the windows-specific subclasses of the URI suggestion
tests. They were duplicates of the non-windows-specific tests that were
probably added before we had a windows bot.

Change-Id: I4547cc768992c4d272871032a6939cd216dc5e96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303422
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-05-15 20:30:25 +00:00
Danny Tuppeny 465d65d657 [analysis_server] Handle prefixed functions in move_to_file
See https://github.com/dart-lang/sdk/issues/30310#issuecomment-1524282552.

Change-Id: I26c2ff905a474d24b85ca970dda0f67398ca7adb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298822
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-05-15 20:23:28 +00:00
Konstantin Shcheglov f4af6af85d Prepare for removing deprecated methods from ExtensionOverride.
The removal itself will happen in a separate CL, as a breaking change.
But we still had a few places that relied on `SimpleIdentifier` being visited.

Change-Id: I8f554cec77858cb8bc7deb29d98f0d6def8685ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303008
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-05-12 21:24:49 +00:00
Brian Wilkerson d40890582c Convert uri completion tests
I am concerned about the tests marked with TODOs because I don't know
why the behavior changed. It's possible that the contributor is still
producing the suggestions but that they're being filtered out later.

I checked using the debugger, and they're not in the list of results
that we're getting back, so it seems likely that they represent real
bugs. If we just weren't detecting the bug before then we're good.

But I can't think how rewriting the tests could effect what the user
is seeing, so I think it's safe to make these changes.

Change-Id: If72042b7ec24b97994a12449c811213b8f708f72
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303000
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-05-12 18:08:15 +00:00
Konstantin Shcheglov 42c79709a4 Separate isDynamicBounded() and isInvalidBounded().
Also includes https://dart-review.googlesource.com/c/sdk/+/302680
that was reverted because of adding extre diagnostics for Flutter.

Change-Id: I4cf7cedfcb67a5af226e609d279551fea0b0dee1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302844
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-12 15:12:38 +00:00
Brian Wilkerson 57b11688ae Convert static member completion tests
I'm becoming concerned that the filtering is making it difficult to
verify the results. We can look at the textual output to see whether all
of the printed suggestions are valid, but we can't know what other
suggestions are being produced and whether they're valid, nor can we be
sure that suggestions that shouldn't be produced are not being produced.

Change-Id: Id131b9b53740b625ba74a9b5bdb690da21fcdbfc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302901
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-05-11 23:28:23 +00:00
pq 88a71f7b7b add quick fix for unnecessary_null_checks
Change-Id: Ia51273c3036f627825ae01bb3bb57b1bd5c648b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302902
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-11 23:02:14 +00:00
pq b8f28f576c + quick fix for implicit_reopen
Change-Id: If12dc7c079d3024047379453ddfd715e854034e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302840
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-05-11 21:18:40 +00:00
Danny Tuppeny 2d43bc319d [analysis_server] Fix LSP references on initializing formals
Fixes https://github.com/Dart-Code/Dart-Code/issues/4535.

Change-Id: Id2cfc6abba756afc10d8b67bde86c0aae6ae5659
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302786
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-11 15:38:02 +00:00
Emmanuel Pellereau d3c7e183e9 Revert "Issue 35828. Don't report COULD_NOT_INFER when InvalidType, make it a subtype of everything."
This reverts commit 838c926f64.

Reason for revert: breaks google3. See b/281948666

Original change's description:
> Issue 35828. Don't report COULD_NOT_INFER when InvalidType, make it a subtype of everything.
>
> Bug: https://github.com/dart-lang/sdk/issues/35828
> Change-Id: Ie7757cb2e0cbc0cfdd1530b75f34ffb3dd3156dd
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302680
> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
> Reviewed-by: Samuel Rawlins <srawlins@google.com>

Bug: https://github.com/dart-lang/sdk/issues/35828
Change-Id: I05ddcf7657069b1e889b5b0019faaf7301f6643b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302781
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Emmanuel Pellereau <emmanuelp@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-11 14:00:06 +00:00
Konstantin Shcheglov 838c926f64 Issue 35828. Don't report COULD_NOT_INFER when InvalidType, make it a subtype of everything.
Bug: https://github.com/dart-lang/sdk/issues/35828
Change-Id: Ie7757cb2e0cbc0cfdd1530b75f34ffb3dd3156dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302680
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-05-11 01:05:51 +00:00
Konstantin Shcheglov 25b2a4c989 Issue 52340. When inline method, check for string interpolation of parameters.
Bug: https://github.com/dart-lang/sdk/issues/52340
Change-Id: Ic8d74778e62b3bee2152bf921fbb48d2febd3701
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302641
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-10 20:57:37 +00:00
Konstantin Shcheglov a3956e49d0 Use InvalidType instead of DynamicType when unresolved.
Bug: https://github.com/dart-lang/sdk/issues/36697
Change-Id: If982ca46030959160f21950c5b5e3127895d937b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300181
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-10 20:38:48 +00:00
Konstantin Shcheglov a240d5c463 Fix for extra diagnostics when now all files created at the start.
Change-Id: Icda792b55a1381294c4e3490694fb99ee2c4ca3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302446
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-10 18:04:49 +00:00
Danny Tuppeny 86bd5c86dc [anaysis_server] Preserve ordering of fixes with the same priority in LSP server
See https://github.com/Dart-Code/Dart-Code/issues/4522.

Change-Id: I6bd10af40c77cd10c7897ae4d4ce3bf8e8988454
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302620
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-10 16:54:58 +00:00
Danny Tuppeny dd72682815 [analysis_server] Handle completion for conditional imports
Fixes https://github.com/Dart-Code/Dart-Code/issues/4530.

Change-Id: Iac1ec0467fa9d1838f75ff2512e1ca79f02fade8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302205
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-05-10 16:19:32 +00:00
Paul Berry a83a1a4c55 Revert "Update comments and readmes to specify dart run --no-pub when necessary."
This reverts commit d2df7ce24a.

Reason for revert: https://dart-review.googlesource.com/c/sdk/+/291500 was reverted

Original change's description:
> Update comments and readmes to specify `dart run --no-pub` when necessary.
>
> Now that https://dart-review.googlesource.com/c/sdk/+/291500 has
> landed, `dart run` now tries to invoke `dart pub` before execution.
> This doesn't work when running scripts inside the SDK, because the SDK
> doesn't use pub to get its dependencies.  So scripts in the SDK now
> need to be run with `--no-pub`.
>
> Change-Id: Ic320b717b2d45278cd26d373ae0823c2935ce102
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292720
> Reviewed-by: Johnni Winther <johnniwinther@google.com>

Change-Id: I6c13510abde17f71694f362a8071c9c7fa519a88
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302364
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-09 20:38:49 +00:00
Danny Tuppeny 334ce04906 [analysis_server] Fix LSP implementations that are provided by mixins
Fixes https://github.com/Dart-Code/Dart-Code/issues/4531.

Change-Id: I1b02dcacab03590012401087e2c2c6f28f690df0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302400
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-05-09 19:48:21 +00:00
Brian Wilkerson d4052a3e7e Convert library member completion tests
Change-Id: I51cbc242181ae71b2630a0d0fce0c40d79d72a85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302361
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-05-09 18:07:56 +00:00
Danny Tuppeny b7f5e200f3 [analysis_server] Fix highlights/occurrences for for-in loop variables
Fixes https://github.com/Dart-Code/Dart-Code/issues/4521.

Change-Id: Ic2d7d81d07b22212e1ad0f29f556c2bbf926dd43
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302325
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-05-09 17:59:53 +00:00
Konstantin Shcheglov 4f7295ad26 Record elements and types parts of missing patterns for AddMissingSwitchCases fix.
Bug: https://github.com/dart-lang/sdk/issues/51985
Change-Id: I48e04e992ccab5cb5dedb5df328ba13ffcf6b560
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302200
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-09 16:29:20 +00:00
pq 23d65641fb + convert_to_boolean_expression correction
Fixes: https://github.com/dart-lang/sdk/issues/52304

Change-Id: Ic080188be5abc70fe1f0da0a7117f31d64a16aa2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302121
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-09 03:44:37 +00:00
Brian Wilkerson 5a046ceedd Convert library prefix completion tests
Change-Id: I2c433ed634d70bb3e03f343503c4e0052ef4df4d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302140
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-05-08 22:34:54 +00:00
Keerti Parthasarathy 261fa6fb3a Wire up argument_type_not_assignable for data driven fixes.
Fix nits in documentation.

Add support for data driven fix for change parameter to non null.


Change-Id: I3120c74eb13e06640aa6ff0b9538e5552f7ae9f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298261
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-08 22:02:20 +00:00
Brian Wilkerson b6ecad0f03 Convert label completion tests
Change-Id: I35fad846602bf23116c499272068728176f9efbf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301729
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-05-08 21:40:29 +00:00
Paul Berry 3713c0e264 Patterns parser: prohibit variable/identifier patterns named when/as.
In https://dart-review.googlesource.com/c/sdk/+/299400, the parser was
adjusted so that it no longer accepts `when` and `as` as the names for
variable patterns in cases where there is a possible ambiguity
(e.g. `int when` is not accepted as a pattern because `int` is a
legitimate pattern, therefore `when` could introduce a guard
clause). This change further prohibits `when` and `as` from being the
names of variable patterns or identifier patterns even in the case
where there is no ambiguity. This is in line with the discussion at
https://github.com/dart-lang/sdk/issues/52199#issuecomment-1526297771,
and the spec change at
https://github.com/dart-lang/language/pull/3033.

Three new error codes are introduced, to cover the three circumstances
in which `when` or `as` might be used illegally: in a declared
variable pattern, in an assigned variable pattern, or in an identifier
pattern. I've also added analyzer tests to ensure that the parser
recovers from these errors nicely. Unfortunately, nice error recovery
is only feasible in the non-ambiguous cases.

I've also updated the language test expectations in
`tests/language/patterns/version_2_32_changes_error_test.dart` to
reflect the new error messages, and added a few more examples of uses
of `when` and `as` that are still permitted.

Fixes #52260.

Bug: https://github.com/dart-lang/sdk/issues/52260
Change-Id: I229f627aa639659c30b83c74895759207da279f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301482
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-05-08 19:06:02 +00:00
Konstantin Shcheglov bf5bdc97ff Issue 52296. Fix NPE in AddTypeAnnotation, when formal parameter without name.
Bug: https://github.com/dart-lang/sdk/issues/52296
Change-Id: I6f3952faa9f3fc9e7f9e1d83c4699222be8dbcdc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301731
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-08 14:54:48 +00:00
Konstantin Shcheglov 8c97d0cfe3 Add static invocation case for EXTENSION highlighting.
Change-Id: Ibc4065b95ac8902f50fafe14ecd451abf8fb3c8d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301733
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-08 14:40:38 +00:00
Konstantin Shcheglov 036b8cafad Add AnalysisError.tmp() constructor, deprecate the default one.
Bug: https://github.com/dart-lang/sdk/issues/51985
Change-Id: I1204c71a4c5ea62d32d65662ecb5274dacb0bfae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301730
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-08 14:39:29 +00:00
Brian Wilkerson 1906adea11 Rewrite completion tests for extension methods
Change-Id: Icda038d078519f7eb5018d7f6089620dd6931c52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301660
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-05-05 21:17:19 +00:00
Brian Wilkerson aa75db8cb2 Fix race condition in analytics
I don't know how to write a test that ensures that we will attempt to
modify the collections after entering the for loop. Suggestions welcome.

Bug: https://github.com/dart-lang/sdk/issues/52263
Change-Id: Ifc13e80594bd08f6c485d8898eb7c75b31172992
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301780
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-05-05 21:02:29 +00:00
pq f03e5b424a remove invalid failing test
(This test makes no sense.)

Fixes: https://github.com/dart-lang/sdk/issues/44871

Change-Id: I9fb25a9f6252f1b67e9b559997d26683fd8f758b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301720
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-05-05 17:56:00 +00:00
pq 7e175b7863 + completion suggestions for pubspec "screenshots"
Fixes: https://github.com/dart-lang/sdk/issues/50179

Change-Id: I34a07d3ad28085d75d4ac2fa24f5b4d2e2dad7b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301483
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-05 16:54:24 +00:00
Konstantin Shcheglov 4d6f49b1cd Update ExtensionOverride to use ImportPrefixReference and name token.
Change-Id: Ifc5852c775a95908992d33a7949b4f4bea396d66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/299920
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-05 15:42:36 +00:00
pq 3edd793682 + pubspec "topics" code completion suggestions
See: https://github.com/dart-lang/sdk/issues/52256

Change-Id: I06ed28bf7280e5c6d8762d73b0d7b085a6ca08c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301181
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-04 22:28:19 +00:00
Konstantin Shcheglov 193316584f Issue 52255. Avoid crashing in AddExplicitCast when the expression is not real.
Bug: https://github.com/dart-lang/sdk/issues/52255
Change-Id: I7ae2fd183cbd73b9d9bb4e5c4dc13e1c0c0ef062
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301201
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-04 16:19:29 +00:00
Konstantin Shcheglov 12b7d257d8 Issue 52226. Fix AddSwitchCaseBreak for shared case bodies.
Bug: https://github.com/dart-lang/sdk/issues/52226
Change-Id: Ia330b7db7de3f38ec7c0849f760bbbaf0d009012
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300160
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-02 19:35:33 +00:00
Konstantin Shcheglov 3828c641ff Issue 52219. Fix AddTypeAnnotation for const literals.
Bug: https://github.com/dart-lang/sdk/issues/52219
Change-Id: Iab4d63142f08789fa7bd1b46e2f4ba8e696a1fe8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300162
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-01 17:15:02 +00:00
Konstantin Shcheglov ec330b47de Deprecate 'DartType.isDynamic', use 'is DynamicType' instead.
Change-Id: Ia3660a0d38f01a590dd3e034f40dbdb5a432638a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300042
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-01 16:09:08 +00:00
Konstantin Shcheglov 4756d077ed Update NamedType to use ImportPrefixReference and name token.
Using Identifier expression inside NamedType does not make sense.

Change-Id: I4a61d2b472fd66fb7c5e6e92a80cccb391b06d49
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294920
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-28 17:31:46 +00:00
Paul Berry 637dd76c7f Patterns parsing: fix ambiguity resolution for when and as.
This change fixes parsing of case clauses such as:

    case foo when !flag:

Constructions like this require some lookahead in order to parse
correctly, because the token `when` is valid both as an identifier and
as a part of the grammar for a case clause. Therefore, at the time
`foo` is encountered, the parser must decide whether it is looking at
a variable pattern (`foo when`, where `when` is the name of the
variable) or an identifier pattern (`foo`, where `when` begins the
case's guard clause). Previous to this fix, the algorithm for
disambiguating these two choices was as follows:

- If the token sequence starting at `foo` looked like a type, and the
  token that follows was an identifier, the parser assumed it was
  looking at a variable pattern with a type; otherwise it assumed it
  was looking at an identifier pattern.

- EXCEPT that if the token that followed the supposed type was `when`
  or `as` (both of which are valid identifiers), then it probed
  further:

- If the token that followed `when` or `as` was a token that could
  legitimately follow a pattern, then it assumed that it was looking
  at a variable pattern with a type. (The tokens that could
  legitimately follow a pattern are `,`, `:`, `||`, `&&`, `)`, `}`,
  `]`, `as`, `when`, `?`, `!`).

- Otherwise it assumed that it was looking at an identifier pattern.

This didn't fully disambiguate, because the third bullet didn't
account for the fact that the tokens `as`, `when`, and `!` could
_either_ legitimately follow a pattern _or_ legitimately begin an
expression (or, in the case of `when`, a type), therefore constructs
like the following were incorrectly parsed:

- `case foo when as:` (where `as` is a local boolean variable)
- `case foo when when:` (where `when` is a local boolean variable)
- `case foo when !flag:` (where `flag` is a local boolean variable)
- `case foo as when:` (where `when` is the name of a type)

The solution is to simplify the disambiguation logic so that if if the
token that follows the supposed type is `when` or `as`, then the
parser assumes that it's looking at an identifier pattern, _not_ a
typed variable pattern.

The consequence of this is that the above four constructions are
parsed correctly; however it is no longer possible for a typed
variable pattern to name a variable `when` or `as`.

For consistency we would like to prohibit _any_ variable pattern from
naming a variable `when` or `as`, however to keep this change as small
as possible (and reduce the risk involved in a possible cherry-pick)
that will be postponed until a later CL.

Fixes #52199.

Bug: https://github.com/dart-lang/sdk/issues/52199
Change-Id: Ibab9b92f01e3e4020d7d64f1ff000a9b964a4564
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/299400
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2023-04-28 13:22:28 +00:00
Brian Wilkerson 7d9340156e Add a missed todo comment
Change-Id: I48dd729555861e87240be137d7a35d76dabeca6a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/299360
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Brian Wilkerson <brianwilkerson@google.com>
2023-04-27 21:53:38 +00:00
Konstantin Shcheglov 310f854c24 Issue 52177. Add rename refactoring for type parameters.
Bug: https://github.com/dart-lang/sdk/issues/52177
Change-Id: I4ae5bb7d72c8956af6dcd91ad28fb1d7397bf424
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/299280
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-27 21:43:48 +00:00
Konstantin Shcheglov a0218e916c Issue 52176. Support for ojbect pattern in 'Create Getter' and 'CCreate Field'.
Bug: https://github.com/dart-lang/sdk/issues/52176
Change-Id: Ic9c97bec1981c5613b23206e872f6f708d53792d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298920
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-27 20:52:39 +00:00
Konstantin Shcheglov 58e48de282 Issue 52175. Support for ConstructorDeclaration in 'Remove unused element' quick fix.
Bug: https://github.com/dart-lang/sdk/issues/52175
Change-Id: I7c5a237fc9a358488e4431d4785ec51b0322f66a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298800
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-27 16:00:12 +00:00
Danny Tuppeny 0588afe783 [analysis_server] Add a script to print tests marked @FailingTest() referencing closed GitHub issues
Change-Id: I8e68b70c4f271d1610f955cf22dfe9523d7f7ca2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298861
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-04-27 14:46:48 +00:00
Konstantin Shcheglov ea2d6a7659 Issue 52177. Fix rename refactoring for type parameter of a class.
It does not work for function / method type parameters though.

Bug: https://github.com/dart-lang/sdk/issues/52177
Change-Id: I51ae5379425e156640ae32d0cea6fd59cdc62b15
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298960
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-04-27 04:51:26 +00:00
Konstantin Shcheglov 97a762b083 Remove debug output from analysis_server/ tests.
Change-Id: Ia358d4f51c605ca66e5111769d1f716559251f63
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298780
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-26 19:58:48 +00:00
Brian Wilkerson 03270f748b Convert the tests for the combinator contributor
Change-Id: Ic165bf7fed1f045f489998ecf9dec9edbd516274
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298480
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-04-26 18:42:37 +00:00
Konstantin Shcheglov 8d2bafa624 Use OpenUriNotificationSender to replace separate flag and sending method.
If the sender is not `null`, then we can send.
No need for a flag, and assert() in the sending method.
If the sender is `null`, then the sending code will not able to invoke it.
Types FTW :-)

Change-Id: I7d153ba014c578a73dce2eab28aceedbb8814711
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298440
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-26 18:17:37 +00:00
Danny Tuppeny a0d6b2daed [analysis_server] Switch some code from package:collection to Dart 3 APIs
- change forEachIndexed to `.indexed`
- remove `package:collection` imports for files only using `.firstOrNull`, `.singleOrNull`, `.lastOrNull` that is now available in `dart:core`
- switch from `Pair` to records
- use switch expressions

Change-Id: Id1ae22db427b4cd955f26e0d6c852944a540a05f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298061
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-04-25 14:28:26 +00:00
Danny Tuppeny 528c75acd2 [analysis_server] Support folding switch statements/expressions/cases
Fixes https://github.com/Dart-Code/Dart-Code/issues/4506.

Change-Id: Idd5924d04e9ffffc49f088ca6884393ea72e9bea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298120
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-04-25 14:18:04 +00:00
Danny Tuppeny c4d2d2d7c2 Reland "[analysis_server] Use fixDataYamlFolder constant instead of string literals"
This is a reland of commit ccb02fa8fc

Original change's description:
> [analysis_server] Use fixDataYamlFolder constant instead of string literals
>
> Follow-up from https://dart-review.googlesource.com/c/sdk/+/296801.
>
> Change-Id: I72ea8a42ec64c4bd6c6cee021a1464167ec368e6
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296862
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>

Change-Id: I202392de3444556dc2baa9ed9e1b82c3a1ede4aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298060
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-04-25 14:17:00 +00:00
Danny Tuppeny 86e3305538 Reland "[analysis_server] Analyze fix data in fix_data folder"
This is a reland of commit bbacf39e9c

Original change's description:
> [analysis_server] Analyze fix data in fix_data folder
>
> Fixes part of https://github.com/dart-lang/sdk/issues/52126.
>
> Change-Id: Ib4bd7830a2f644eacedccd375c7c8dc60f040d33
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296801
> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>

Change-Id: I571c1e4f87fdf0095d003d496f3c5d88e5cf0ff8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297940
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-25 00:08:54 +00:00
Konstantin Shcheglov 39cb6acb88 Issue 52149. Fix to support rename refactoring for declared identifier with LSP.
Bug: https://github.com/dart-lang/sdk/issues/52149
Change-Id: Ia4c5c564cc44583741722c658389ea674a5643c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297900
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-24 22:04:39 +00:00
Konstantin Shcheglov 887e6da4a5 Issue 52150. Support for unused variable patterns in logical-and patterns.
Bug: https://github.com/dart-lang/sdk/issues/52150
Change-Id: I9efb2f8ece0ccb3d3c2e276ff708a671dea80fa3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297841
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-24 21:53:38 +00:00
Konstantin Shcheglov a868a5bfa6 Issue 52148. Disable invert 'if' when 'case'.
Disable a few assists that require 'patterns', when it is not enabled.

Bug: https://github.com/dart-lang/sdk/issues/52148
Change-Id: I3c3816f4a944c59698543e37f15e024249545952
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297880
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-04-24 21:16:48 +00:00
Konstantin Shcheglov 2cdfc05568 Issue 52146. Fix ConvertToIfCaseStatementChain for a case without statements.
Bug: https://github.com/dart-lang/sdk/issues/52146
Change-Id: I2947111a0e1a4c6e739bda851f1f91c9637a745a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297420
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-04-24 19:28:56 +00:00
Danny Tuppeny d3460e0855 [analysis_server] Don't produce diagnostics for empty/commented fix_data files
Previous changes to analyze the fix_data/**.yaml files failed to roll into Flutter because it has a template for these files that contains only comments.

See https://dart-review.googlesource.com/c/sdk/+/297320 and https://github.com/flutter/flutter/pull/125363.

Change-Id: I098a5b336371bab7f80ac84c556efe118c70e74f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297340
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-04-24 18:47:21 +00:00
Brian Wilkerson e8e4980b4c Rewrite keyword contributor tests
I did not change any of the test cases. I did change the names of the
tests to be more consistent, and in the process I found a couple of
tests where the test code was identical, so I deleted the duplicates.

I expect that there will be more cleanup that we'll want to do after
all of the contributor tests have been converted and merged together,
but I wanted this CL to be as straightforward as possible given its
size.

Change-Id: I2cbb6b5c0718fbbc36da521ee3c4fc7d00c36dcb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297720
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-04-24 17:36:22 +00:00
Brian Wilkerson 71d4e1478e Clean up some tests to make conversion of contributor tests easier
Change-Id: I801970b4b88b883b2219badcefb7e1c84517d592
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297780
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-04-24 17:35:27 +00:00
Danny Tuppeny d75a4e162e [analysis_server] Update LSP generated classes to latest published version of the spec
No functional changes here but there have been some refactors inside the meta model that required some minor tweaks (URI moved from a type alias to string to a spec-defined base type).

I also improved the handling of some type references in the comments we bring in so they're clickable in more places.

Change-Id: I7c725d01b6d7bc0925979b8118dbfd8952f78724
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297482
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-24 15:09:20 +00:00
Zach Anderson e34daa818b Revert "[analysis_server] Analyze fix data in fix_data folder"
This reverts commit bbacf39e9c.

Reason for revert: Causing flutter/engine to fail to roll into flutter/flutter. See https://github.com/flutter/flutter/pull/125363.

Original change's description:
> [analysis_server] Analyze fix data in fix_data folder
>
> Fixes part of https://github.com/dart-lang/sdk/issues/52126.
>
> Change-Id: Ib4bd7830a2f644eacedccd375c7c8dc60f040d33
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296801
> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>

Change-Id: I109a4b2c596ad22d73eaf0ac3e25f53a35ba5e28
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297320
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2023-04-22 22:10:12 +00:00
Zach Anderson 7575e2c5be Revert "[analysis_server] Use fixDataYamlFolder constant instead of string literals"
This reverts commit ccb02fa8fc.

Reason for revert: Blocking revert in https://dart-review.googlesource.com/c/sdk/+/297320

Original change's description:
> [analysis_server] Use fixDataYamlFolder constant instead of string literals
>
> Follow-up from https://dart-review.googlesource.com/c/sdk/+/296801.
>
> Change-Id: I72ea8a42ec64c4bd6c6cee021a1464167ec368e6
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296862
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>

Change-Id: I8ed39fc343b9121c40de83038e97c43cac669ca1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297321
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2023-04-22 21:22:47 +00:00
Konstantin Shcheglov b5d63cb67f Add quick assist to convert SwitchStatement (with patterns) into if-case chain.
Bug: https://github.com/dart-lang/sdk/issues/52068
Change-Id: Ia20b943dfc5212764f31cd94f4f8cce8755628bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297140
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-04-21 22:07:02 +00:00
Konstantin Shcheglov 529adda42e Issue 52131. Find implicit constructor invocations from other constructors.
Bug: https://github.com/dart-lang/sdk/issues/52131
Change-Id: I7f28e4664f18196f978cb9dd38f878b1240d46a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297080
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-21 22:04:16 +00:00
Konstantin Shcheglov 81ab76124f Support for pattern variables in RemoveUnusedLocalVariable.
Change-Id: I67ed0892a96f911bfae7a4fda91e2e6e55927fc9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296761
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-21 19:18:59 +00:00
Paul Berry 5d7dd58d41 Ignore TODO in pkg/analyzer and pkg/analysis_server.
The analyzer team has decided to adopt the convention of using `TODO`
comments to document long term issues that should persist in the
codebase, and `FIXME` comments to document short term issues that need
immediate attention.  They may even consider adding a presubmit hook
to ensure that `FIXME` comments are only used during local
development.

Accordingly, it makes sense to suppress `TODO` comments from being
surfaced to the IDE "problems" view (since there are hundreds of them,
and they're not immediately actionable).  This makes VSCode's
"problems" view much more usable in "tree" mode.

Change-Id: I11a0c59132fb98c1c86fb4adf22d1fdf3b547c80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295662
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-04-21 19:16:04 +00:00
Danny Tuppeny ccb02fa8fc [analysis_server] Use fixDataYamlFolder constant instead of string literals
Follow-up from https://dart-review.googlesource.com/c/sdk/+/296801.

Change-Id: I72ea8a42ec64c4bd6c6cee021a1464167ec368e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296862
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-04-21 18:50:50 +00:00
Paul Berry 3516c86ae5 Add dependency overrides for pkg/analysis_server
These dependency overrides prevent pub from getting confused about the
fact that our SDK development is in a mono-repo; that in turn will
allow unit tests to be run from inside vscode using the standard test
integration (see https://github.com/Dart-Code/Dart-Code/issues/4502).

Change-Id: I8ea709984b03927e67f119d147338203d7e80811
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296980
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-04-21 18:43:33 +00:00
Danny Tuppeny ee178b273b [analysis_server] Switch TypeMemberContributor to using InheritanceManager3
Fixes https://github.com/Dart-Code/Dart-Code/issues/4499.

Change-Id: I339f975894f6734c634df5dbc2df9695ecc999a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296580
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-04-21 17:31:12 +00:00
Danny Tuppeny bbacf39e9c [analysis_server] Analyze fix data in fix_data folder
Fixes part of https://github.com/dart-lang/sdk/issues/52126.

Change-Id: Ib4bd7830a2f644eacedccd375c7c8dc60f040d33
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296801
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-21 15:18:56 +00:00
Konstantin Shcheglov 9070c7baf1 Don't suggest UseCurlyBraces for else-if
Change-Id: I2e29565fe67fbe8e412306ef0b8fd3c3188a970b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296661
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-20 19:37:37 +00:00
Ahmed Ashour 6e821873fd [analysis_server] renameParameter data-driven fix
to handle a method with a diagnostic

Fixes #51198

Change-Id: I6a1921747912318d81121d58c88fccc35d1f809a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282261
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2023-04-20 16:22:54 +00:00
Konstantin Shcheglov e8622f2d63 Issue 52059. Don't suggest final/var in ObjectPattern in ForEachPartsWithPattern, suggest getters instead.
Bug: https://github.com/dart-lang/sdk/issues/52059
Change-Id: If5e1c40fa75735077b2b77a5941d16fe2c767f3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296501
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-20 16:14:58 +00:00
Konstantin Shcheglov 1df4267a7e Issue 47562. Suggest only *.dart files in 'package:' URIs.
Bug: https://github.com/dart-lang/sdk/issues/47562
Change-Id: I4f575bca1377b8f5065d4c4ff95f326b6a2a168b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296442
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-04-20 01:28:53 +00:00
Brian Wilkerson 2da2520bd6 Stop suggesting methods in object patterns
Fixes: 52058
Change-Id: I031fcd2b48975729cca48f640c3d86f5d2cfc0b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296420
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-04-20 00:52:20 +00:00
pq 76f76b05bb use existing CorrectionUtils instance
Change-Id: Ia9c20fb70cd665b6c4a024c2f83d6e7ca5b0220a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296422
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-04-20 00:05:02 +00:00
Konstantin Shcheglov 6dcca7824a Produce InvertIfStatement only when both then/else branches are Block(s).
Other cases are outliers and nobody actually want it there.
Specifically, the way it works for if-then-elseIf does not make sense.

Change-Id: I8d16e689e057fa79ecfaa2c3155086cf36f1954c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296406
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-04-19 23:21:36 +00:00
Konstantin Shcheglov 6a50756f98 Remove 'Introduce new local with tested type' assist.
If the type checked expression is a local variable, it is useless.
The variable is already type promoted.

If the type checked expression is not a local variable, it produces
code that has a compile-time error because of downcard, which does
not work anymore with null safety.

Even generating `final x = expression as MyType` would be bad IMHO.
Unproven type casts are dangerous.
What the user should do, it to extract into a local variable, and
type check it. Or use patterns. But this is a different story.

Change-Id: Ifd3dc71894d17c5a07b7f1389a8143363697eda2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296384
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-19 21:53:09 +00:00
pq 4451d5d9f5 follow ups from https://dart-review.googlesource.com/c/sdk/+/296066
(The last change was prematurely merged.)

Change-Id: Idc161ef596fa43927cf7eda223635a798d3292af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296402
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-19 20:13:03 +00:00
pq 45ec8be7aa reference rewriting for destructured object pattern variables
I'll do some tidying up and restructuring when I add similar support for records...

Change-Id: I4124cdc5e6ecb12e54ab4570636e1f8cc9afa6c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296066
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-04-19 18:59:59 +00:00
Konstantin Shcheglov ac1bdebff7 Support for converting 'if' statements with bool conditions into patterns.
Bug: https://github.com/dart-lang/sdk/issues/52068
Change-Id: I187b3e3cad66eff7a266478df0c09ffb3d642e34
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296067
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-19 17:24:54 +00:00
Konstantin Shcheglov dc34fe9f86 Deprecate IfElement/IfStatement.condition, use 'expression'.
Change-Id: If43b4b71a21fd256ce8d1367d4b233e1cff764b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296122
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-04-19 17:17:28 +00:00
Konstantin Shcheglov 7880fd4ce5 Remove UnwrapIfBody assist.
After using DAS with it for a few days, I find it more distracting
than useful.

Change-Id: I20da35e06958c79a6d458546937b616d45b0c909
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296281
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-19 16:56:43 +00:00
Konstantin Shcheglov c948d37f97 Add CONVERT_TO_SWITCH_STATEMENT for if-case statement.
Bug: https://github.com/dart-lang/sdk/issues/52068
Change-Id: Ia561a8e711272cfcae690a4de1ea3e39906bef47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295724
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-18 21:26:02 +00:00
Janice Collins 7c1e2fee70 Fix analytics logic to report on analysis complete transitions.
Bug: https://github.com/dart-lang/sdk/issues/52089
Change-Id: If9fe7d702cd70c3e8804a59e47870d6aad7cf680
Fixes: https://github.com/dart-lang/sdk/issues/52089
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296023
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Janice Collins <jcollins@google.com>
Commit-Queue: Janice Collins <jcollins@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2023-04-18 20:48:58 +00:00
pq fffd7e8c6f support destructuring local object pattern variable declarations
See: https://github.com/dart-lang/sdk/issues/52025

Change-Id: I6dc5d2f0c8391d8ad719c23b47aadeac9a8ab969
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295722
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-04-18 20:47:57 +00:00
Sam Rawlins 008ef8c1a9 Bump linter
Change-Id: If108d01736a6fb7a07e4c894752934ea9fc952bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295802
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-04-18 19:25:48 +00:00
Sam Rawlins 25348fb95c [analyzer] Move 2 more HintCodes to be WarningCodes, UNNECESSARY_*
Bug: https://github.com/dart-lang/sdk/issues/50796
Change-Id: Iddcb1b6d035e9590600e6bfbd8d2133da39bcc35
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295803
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-04-18 16:55:30 +00:00
Danny Tuppeny 39fc15a0b4 [analysis_server] Add missing declaration semantic token modifier on classes/constructors
Fixes https://github.com/Dart-Code/Dart-Code/issues/4498.

Change-Id: Ia1c89d02a12fd51fe6f18ce4208ff88a7fbd7ba3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295621
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-04-17 21:19:25 +00:00
Konstantin Shcheglov 609db33dc7 Issue 51985. Quick fix to add missing pattern case to switch expression/pattern.
Bug: https://github.com/dart-lang/sdk/issues/51985
Change-Id: I43a24e889789da962a8ee1359702ea04db2a36f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295391
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-17 20:34:13 +00:00
Konstantin Shcheglov 8fa08ae80b Add 'Convert to if-case statement' quick assist.
Change-Id: I6c65060029c5cf474c59a05b0330a89ebf16082a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295502
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-17 20:27:24 +00:00
pq 17d92f90d0 offer wildcard suggestions for destructured record fields
See: https://github.com/dart-lang/sdk/issues/52025

Change-Id: I298c7f5b82b47b8cb02ca1a401e0658aab8f40a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295680
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-17 20:25:36 +00:00
Danny Tuppeny 3069c4f3e2 [analysis_server] Add missing "constructor" semantic token modifiers on constructor declarations
Fixes https://github.com/Dart-Code/Dart-Code/issues/4495.

Change-Id: I5fa21504562f7437be30118e5dc96fd5b49f2853
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295544
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-17 19:12:46 +00:00
Konstantin Shcheglov f88e3bd77c Issue 51903. Test fixes for ParserErrorCode.VAR_AND_TYPE
I think DartFixKind.REMOVE_VARwas already available.

This CL adds DartFixKind.REMOVE_TYPE_ANNOTATION support.

Bug: https://github.com/dart-lang/sdk/issues/51903
Change-Id: Ie582cc22fad038edb8b58c1f260afab1595fdcac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295388
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-17 17:51:38 +00:00
Danny Tuppeny f4d42303ad [analysis_server] Handle completion in whitespace after string values
Fixes https://github.com/dart-lang/sdk/issues/52049.

Change-Id: Idf594cd528065939b49aa55acf362fe9d909e22a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295543
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-17 17:19:08 +00:00
Danny Tuppeny 453647022f [analysis_server] Don't fail on invalid/complex setters in LSP code completion
Fixes https://github.com/dart-lang/sdk/issues/52050.

Change-Id: I6cf5420d5e017b501481cb436a7d1b17f46c0e44
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295542
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-17 17:11:03 +00:00
Konstantin Shcheglov b78d89ce0c Fix DynamicTypeImpl to InterfaceTypeImpl cast exception in AddTypeAnnotation, when ambiguous SetOrMapLiteral.
Saw it in crash logs.

Change-Id: I631e4da816b689ec017f44ecd2a5dc70122ceec1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295501
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-17 16:34:37 +00:00
Brian Wilkerson 2197c81060 Add documentation for data-driven fixes
Let me know if any of this is unclear or if there's missing information.
Of course, you might not know that until you start trying to enhance the
support, but we can also refine the doc when issues are discovered. I'm
mostly just interested in helping you get started.

Change-Id: Ib48a8ce46af7b6cc37a27508c81df03bfd2093e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295040
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-04-14 21:33:50 +00:00
Konstantin Shcheglov 36caf084b9 Issue 51953. Quick fix for ParserErrorCode.DEFAULT_IN_SWITCH_EXPRESSION
Bug: https://github.com/dart-lang/sdk/issues/51953
Change-Id: I21d7abdda8b7197cffb87a359c97f12e54cf427a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295390
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-14 21:15:18 +00:00
pq cae0bfa66f assist to destructure local record variable assignments
First, basic cut.

See: https://github.com/dart-lang/sdk/issues/52025

Change-Id: I3388f5ec96a45211669e3ac8a5975ff39feea4bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295381
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-04-14 21:04:20 +00:00
Keerti Parthasarathy 90c434254f Add support for patterns for Add type quick fix
Bug: 51866
Change-Id: Id38d0c8405931cad057ec3db1e0c0e3d297d7b4c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294880
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2023-04-14 20:09:52 +00:00
Konstantin Shcheglov 0d6067232b Issue 51980. Reduce relevance of 'break' inside 'switch'.
Bug: https://github.com/dart-lang/sdk/issues/51980
Change-Id: Ic3a365c85a36a18739b20482c8c7c136210b12b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295387
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-14 19:37:38 +00:00
Konstantin Shcheglov 1925041a31 Issue 52019. Late instance field is not a static context.
Bug: https://github.com/dart-lang/sdk/issues/52019
Change-Id: I6416a2e65c93b08ad145c2e64129873ae414ccfb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295383
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-14 17:58:24 +00:00
Janice Collins 1abf129bf8 Enable crash reporting via the unified_analytics consent mechanism.
This pulls in the `okToSend` method from https://github.com/dart-lang/tools/pull/79 in the tools repository.

Bug: https://github.com/dart-lang/sdk/issues/28633
Change-Id: I512d041750050338699d3635ba426cc0acdd5a20
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295380
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Janice Collins <jcollins@google.com>
Auto-Submit: Janice Collins <jcollins@google.com>
2023-04-14 17:29:28 +00:00
Konstantin Shcheglov 9a6b637444 Issue 51989. Add 'Convert to switch statement' assist.
Bug: https://github.com/dart-lang/sdk/issues/51989
Change-Id: I297cbc077604d0c750dc0d78d8480b33852f3a64
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295201
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-14 17:19:25 +00:00
Simon Binder a42a163f3b [analysis_server] Handle missing null in missing enum case fix
When switching over a nullable expression, the `null` value should also
be handled for exhaustiveness.
The analyzer reports a lint for missing nulls, but the correction
producer was unable to fix the problem as it only adds missing enum
constants.
This change makes the fix producer add missing null cases.

Change-Id: I92065b36b6a370d5165e302d84391568894c5dc5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294981
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-13 21:55:57 +00:00
Konstantin Shcheglov 63fd5aa364 Issue 52014. Make an implicit name of a named PatternField explicit when the pattern variable is renamed.
Bug: https://github.com/dart-lang/sdk/issues/52014
Change-Id: Ifcc8ba255cb536cba11360ef4326525c1e037b44
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295101
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-13 21:02:37 +00:00
Sam Rawlins 2f30f88916 Mark deprecated Hints with Warning aliases as deprecated
This will help with any references to deprecated Hints in other
codebases, like nnbd_migraion or linter...

Change-Id: Iccd43d8e3113e6e3e0e458bf959c7f4d48185f35
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294182
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-04-13 20:07:36 +00:00
Konstantin Shcheglov f70238a83b Issue 52015. Extract local variable into SwitchCase / SwitchPatternCase.
Bug: https://github.com/dart-lang/sdk/issues/52015
Change-Id: I069ecfbd2be5375bdba9977872bc9e0c88431f62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295100
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-13 19:18:38 +00:00
Kallen Tu 2954986a7e [parser] Add errors for using class modifiers on enums.
Otherwise, in its current state, there's no clear error for any modifiers when used before an enum declaration.
This follows the same format to FINAL_MIXIN_CLASS and those groups of errors.

Bug: https://github.com/dart-lang/sdk/issues/51935
Change-Id: I8174b6894c95fef5c0f4704927b161942c19d3ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294122
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2023-04-13 14:59:57 +00:00
pq a45fc0f3c2 TokenType extension
See also: https://github.com/dart-lang/linter/pull/4272

Change-Id: Ie12b5d6a214bd085e12acf3b0c3745278aa7a8f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294881
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-12 22:50:27 +00:00
pq 05965ef720 + fix dangling library comments
Change-Id: Ia857fec46ddf83d307cd19450cea88aab8c86a38
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294430
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-04-11 20:17:38 +00:00
pq 68ef7530d7 switch expression conversions (and unnecessary breaks removed)
All auto-converted. A bunch more will be convertible when we address: https://github.com/dart-lang/sdk/issues/52005

EDIT: updated w/ 64 fewer breaks

Change-Id: I9b6009e316341e7c9b9c2f2c651b6eada385960d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294423
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-04-11 19:56:05 +00:00
Jens Johansen 99395b2b0c [parser] Recover differently from mixin with clause
Fixes #50838 (https://github.com/dart-lang/sdk/issues/50838)

Change-Id: Ib0f0c01a07ab6232732a2be6c3aec34cb4bfdd29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292360
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-11 16:29:53 +00:00
pq f37e85049e Support bulk fixing dangling library doc comments
We generally only test bulk fixes when we're worried about overlapping fixes. Since this can only be applied once per file I didn't feel it necessary to add any tests.  Happy to if you feel otherwise!

Change-Id: Id74f8b2f9b1acd70bef789ad83406a71d5ddf391
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294422
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-04-11 00:37:30 +00:00
Konstantin Shcheglov 9a6335fe14 Add "Unwrap 'if' body" assist.
Sometimes I realize that the `if` statement is not necessary, and
want to replace it with its `then` statement. With this Quick Assist
we can make the change without temporarily unbalancing `{` and `}`.

Change-Id: Icab454ad21e4babaada3cf58a4a3cccdb84c2ebe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294283
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-04-10 23:51:55 +00:00
Devon Carew b603d4c4ac [deps] rev tools, web_socket_channel, webdev
Revisions updated by `dart tools/rev_sdk_deps.dart`.

tools (cd799be..58d9147):
  58d9147  2023-04-07  Christopher Fujino  [unified_analytics] Add NoOpAnalytics (#77)

web_socket_channel (40eb236..b28bae6):
  b28bae6  2023-04-07  Rexios  Allow passing through custom http client in IO socket connect (#259)
  1064b47  2023-04-07  Nate Bosch  Fix deprecated_new_in_comment_reference (#262)

webdev (22b34e3..7546291):
  75462913  2023-04-07  Elliott Brooks  Run mono_repo generate (#2081)
  9964ebab  2023-04-07  dependabot[bot]  Bump actions/labeler from 4.0.2 to 4.0.3 (#2067)
  3dee56b5  2023-04-07  Anna Gringauze  Remove eval error message on async frames (#2073)
  d6b3e9ce  2023-04-07  Elliott Brooks  Dart Code Metrics follow-up (#2072)
  48e3211a  2023-04-07  Elliott Brooks  Update the release script to take into account `pubspec_overrides.yaml` (#2080)
  fd75f511  2023-04-06  Elliott Brooks  Reset Webdev to 3.0.5-dev (#2077)

Change-Id: Iac863f7c4822fe6b9585e80e95d69467e8d60b6d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294364
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
Auto-Submit: Devon Carew <devoncarew@google.com>
2023-04-10 17:44:36 +00:00
Danny Tuppeny cf8aaebc4a [analysis_server] Prevent colon from automatically triggering completion in switch statements
See https://github.com/dart-lang/sdk/issues/51980.

Change-Id: I66d52018f22442241a3203c08e3a58d5f1c2fbff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294300
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-04-08 16:17:20 +00:00
Brian Wilkerson 9b1798e081 Finish evaluating the status of fixes
Change-Id: Ie9a6709eb50f16771a340109bbd3e37918b8743e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294260
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-04-07 23:50:37 +00:00
Konstantin Shcheglov b1c0f16a51 Issue 51961. Suggest getter names inside pattern of named PatternField without name, inside RecordPattern.
Bug: https://github.com/dart-lang/sdk/issues/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>
2023-04-06 19:55:08 +00:00
Danny Tuppeny da1898e0c7 [analysis_server] Prevent "dart fix" prompts if do-not-show preferences cannot be persisted
See https://github.com/dart-lang/sdk/issues/51968.

Change-Id: I67e0a85f171b9ff5c508063458fc92491c8e5c70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294000
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-04-06 15:59:07 +00:00
Konstantin Shcheglov ef79407d04 Enable language 3.0 for analysis_server/.
Change-Id: I6237a9ecfa95438ad1a5959183722cf95fe1cbba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293740
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-06 00:27:09 +00:00
Konstantin Shcheglov 7ba94c9202 Issue 51961. Suggest getter names inside pattern of named PatternField without name, inside ObjectPattern.
Bug: https://github.com/dart-lang/sdk/issues/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>
2023-04-05 22:47:19 +00:00
Janice Collins b6cf3f9c22 Fix npe in UserPromptPreferences
Bug: https://github.com/dart-lang/sdk/issues/51968
Change-Id: I7bcaee7266b6c39ca21e11d3cc5e4eed94981294
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293920
Reviewed-by: Jacob Richman <jacobr@google.com>
Commit-Queue: Janice Collins <jcollins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-05 22:31:06 +00:00
Konstantin Shcheglov 2427527612 Suggest type names during completion in CaseClause and SwitchExpression body.
Change-Id: Iea7c2c3d0879191265c368b5e79fbf2cfaab0dd0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293821
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-05 20:48:24 +00:00
Konstantin Shcheglov 006c60690e Increase timeout for SelectionCoverageTest.
Change-Id: Ic1e88478b500f87744dec64f3990f2681351a178
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293742
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-05 18:34:08 +00:00
Janice Collins 17dd6d27cc Enable analytics support for VSCode.
Change-Id: Iea17bf917deccadb26a78470fabfb6fe5f4ada71
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292900
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Janice Collins <jcollins@google.com>
2023-04-05 18:19:21 +00:00
Keerti Parthasarathy a02f252ef1 Revert "Add support for patterns for Add type quick fix"
This reverts commit f4773e49c0.

Reason for revert: Breaks server tests
Original change's description:
> Add support for patterns for Add type quick fix
>
> Bug:51866
> Change-Id: I42d4443c38fc7708a2b174a80b689adfc0a37aaa
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293460
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>

Bug: 51866
Change-Id: I5d1f933fa7b88495f941b30001873c33206975f0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293820
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-05 18:13:37 +00:00
Keerti Parthasarathy f4773e49c0 Add support for patterns for Add type quick fix
Bug:51866
Change-Id: I42d4443c38fc7708a2b174a80b689adfc0a37aaa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293460
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-04-05 17:53:59 +00:00
Brian Wilkerson 7bcc913ef1 Evaluate the remaining compilation errors
Change-Id: I9506c550598410533523e96d4ebd634589720725
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293387
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-04-05 16:21:41 +00:00
Kallen Tu b565a2f4c7 [analysis_server] Fix code completion for mixin declarations and class
declarations with class modifiers.

Fixes what modifiers are suggested considering you can only use 'base'
on mixins and mixin classes.

Also fixes some existing bugs with classes suggesting 'sealed' after
'abstract'.

Change-Id: I3fcd1470dc015cb0c9c1c358041ca226aa298dc8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293340
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-04-05 16:05:35 +00:00
Sam Rawlins 7d6ab9bdfd Allow dead code in completion_metrics script.
Change-Id: I16751bcbb25f09c3a897de82c06ab424abcfcf1b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293005
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-04-04 23:15:31 +00:00
Sam Rawlins 23b73d7ca4 ignore unreachable constructors in reflective tests
These were flagged as unused by `unreachable_from_main` but they are
used by `dart:mirrors`.

Change-Id: I3637b4b234f0bf7fe795977cb7ec6a1ca5449810
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293006
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-04-04 21:37:18 +00:00
Konstantin Shcheglov d47cd99310 Report NOT_NAMED_FIELD_IN_OBJECT_PATTERN
Change-Id: Iea58d3cef38c07f5fbac0dcbc8984ea727ffd93e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293441
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-04 21:36:38 +00:00
Konstantin Shcheglov 784998da98 Fix for EXPECTED_TOKEN, replace ':' with '=>' in SwitchExpressionCase.
Change-Id: I38080d8ec445bb6466c26c0233ac6dc719ba6f40
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293084
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-04 19:14:25 +00:00
Paul Berry a3f5cfdc7f Patterns parsing: recover when switch statement syntax used for switch expressions.
This change ensure that if the user makes an erroneous switch
expression by imitating the syntax of case statements (i.e. using
`case`, `default`, `:` instead of `=>`, or `;` instead of `,`), error
recovery will understand the user's intent, avoiding follow-on errors.

Fixes #51886.

Bug: https://github.com/dart-lang/sdk/issues/51886, https://github.com/dart-lang/sdk/issues/51943
Change-Id: Icd405d4fd4ddfb1aadcf0867e5a51ba898d4cdbc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293200
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-04-04 18:52:59 +00:00
Konstantin Shcheglov c399536c3f Remove print() from getProcessUsage() test.
Change-Id: I0209e96e933713fa04e87f7c41e4be19b81c4001
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293163
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-04 16:15:39 +00:00
Danny Tuppeny b7fbf1e4b2 [analysis_server] Fix completion snippet context for inside enum declarations
Previously we'd fail to match anything here and end up using "top level", showing snippets for creating classes. This adds enums to "inClass" showing things like "function" snippets.

I didn't split class/enums because right now we don't have any snippets that would differ, though we might want to do this if that changes.

Fixes https://github.com/Dart-Code/Dart-Code/issues/4473.

Change-Id: I67c8e2a67698fb15136cba68b63549acf29ee596
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292884
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-04-04 15:08:41 +00:00
Paul Berry 8aa48712be Patterns parsing: recover from patternVariableDeclaration non-statement.
Previously, if a pattern variable declaration appeared outside of a
function or method, the parser would get very confused.  Now it
recognizes the situation, issues a comprehensible error message, and
replaces the pattern with a synthetic identifier token so that the
analyzer AST is somewhat sensible.

Fixes #51322.

Bug: https://github.com/dart-lang/sdk/issues/51322
Change-Id: Ica5f060cb483a39c4e50942d639939b1fab40bea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293087
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-04-04 14:55:00 +00:00
Johnni Winther 5518abf1c7 [_fe_analyzer_shared] Update non-exhaustive message
This updates the message report for non-exhaustive switch statements
and expressions to include the witness in the problem message and
a reduced witness, which doesn't include properties that fully cover the
static type. The message is also split into two messages; one for
switch statements and one for switch expressions, allowing for a
better wording regarding the default/wildcard pattern case.

Change-Id: I17db657ef12ade5d47fa96bf69b8807e33ed5b8c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293040
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-04-04 09:44:59 +00:00
Keerti Parthasarathy 5c5f4ef65e Add a timer to send analytics data periodically.
Change-Id: Iaf58e3b7f45868579892ded8c005843d2f45b443
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289402
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2023-04-04 03:27:27 +00:00
Konstantin Shcheglov 525376cc88 Fix ConvertToSwitchExpression when SwitchStatement is empty.
Change-Id: Id7ab8319ff5a9e41b353ed1363ce0d5159fe4ff2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292984
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-03 23:44:48 +00:00
Konstantin Shcheglov 4cb8bd0c37 Issue 51931. Fix for LATE_PATTERN_VARIABLE_DECLARATION.
Bug: https://github.com/dart-lang/sdk/issues/51931
Change-Id: I2b3c42389a5184086e66a1fc35c045d2581a2d8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293004
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-03 22:35:58 +00:00
Brian Wilkerson 40973edbb5 Handle type arguments when replacing an empty map pattern
Change-Id: I4c917d60d93a316459f2478cc21a7845af46781b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292920
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-04-03 21:02:18 +00:00
Brian Wilkerson aa1f415e4f Add a fix for invalid_inside_unary_pattern
Closes 51915

Change-Id: I378f66d70c083dd5852a9c8a04e3ddf59aff66d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292981
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-04-03 20:56:10 +00:00
Konstantin Shcheglov db0dfec609 Issue 51893. Report PATTERN_NEVER_MATCHES_VALUE_TYPE in some cases.
Bug: https://github.com/dart-lang/sdk/issues/51893
Change-Id: Ia7582df3942a077e81f0343e83359c303d152b1b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292420
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-03 20:31:45 +00:00
Konstantin Shcheglov bb85a2d183 Fix for UNNECESSARY_WILDCARD_PATTERN
Change-Id: I0afbfdf60d03019b781b6634623565b6b2477dda
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292980
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-03 20:18:25 +00:00
Konstantin Shcheglov 7f9ec2513a Fix for LintNames.type_literal_in_constant_pattern
Change-Id: I44bc36da4176f6e7cca74b7d0273807734b31a59
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292921
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-03 19:51:52 +00:00
Konstantin Shcheglov fabe2af5e3 Issue 51762. Update CompletionResponsePrinter sorting.
Bug: https://github.com/dart-lang/sdk/issues/51762
Change-Id: I46019bea72ac1656c97acb9da88da7dc577d8ef5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292640
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-03 19:07:34 +00:00
Danny Tuppeny f1007d4aa2 [analysis_server] Prevent switch-expression snippets showing up in patterns
+ don't assume a semicolon on the end of a switch expression.

Change-Id: Ie141996bc79e3764c70dea66f570ca17046eecdf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292880
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-04-03 17:34:41 +00:00
Paul Berry 8d16c1dc87 Patterns parsing: improve error recovery for late in patternVariableDeclaration.
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: Id706ff0afab3f14d817fbf99112f772d1f1f7817
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292800
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-04-03 15:04:07 +00:00
Paul Berry d2df7ce24a Update comments and readmes to specify dart run --no-pub when necessary.
Now that https://dart-review.googlesource.com/c/sdk/+/291500 has
landed, `dart run` now tries to invoke `dart pub` before execution.
This doesn't work when running scripts inside the SDK, because the SDK
doesn't use pub to get its dependencies.  So scripts in the SDK now
need to be run with `--no-pub`.

Change-Id: Ic320b717b2d45278cd26d373ae0823c2935ce102
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292720
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-04-03 12:11:49 +00:00
Brian Wilkerson 49263509a9 Update the quick fix status file
Change-Id: I6f4040ff9b05c1edda658673dd190789b965a543
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292700
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-04-03 04:13:40 +00:00
Konstantin Shcheglov 30a8b2ee4b Use raw strings for assertResponse() that don't do any interpolation.
We use this pattern to find expectations to update.

Change-Id: Ibae370cfdf85dd83122b5571f3a05d86355c647f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290344
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-02 00:33:28 +00:00
Brian Wilkerson 40fd297793 Extend MakeFinal to support pattern variable declarations
Fixes 51872

Change-Id: I517eddd8c716ae14a023d483d03c29e99d2d8ebb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292400
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-03-31 23:37:52 +00:00
Janice Collins 27d6918ab9 Update for vscode only and latest version of unified_analytics for
analysis server.

Change-Id: I6a5e8a4424ccdf8a40c08a3cd2d697c2108422e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292201
Commit-Queue: Janice Collins <jcollins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2023-03-31 22:17:14 +00:00
Paul Berry d2184a9d03 Patterns parsing: disallow unaryPattern or relationalPattern in unaryPattern.
The precedence-based pattern parser can understand a unary pattern
inside another unary pattern (e.g. `_ as int as num`) or a relational
pattern inside a unary pattern (e.g. `> 1?`), but the specification
prohibits these constructions because they're difficult to read and
not very useful.

This change updates the implementation to match the spec, by producing
the appropriate error.  The offset and length of the error cover the
inner pattern, so it should be easy to construct an analysis server
quick fix that inserts the necessary parentheses.

Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: I33e74d6d1f863e7162851d26fefbacd4fd17277c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292120
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-03-31 16:43:01 +00:00
Brian Wilkerson 39c9220927 Add a fix to replace an empty map pattern
Change-Id: If4544e6f33d96ad9e5a8790de1211a15befc64b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292284
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-03-31 16:30:22 +00:00
Sam Rawlins 44b8ccdde6 Report when a @reopen annotation is invalid
A `@reopen` annotation is invalid when it annotates a declaration which
does not reopen anything.

Fixes https://github.com/dart-lang/sdk/issues/51592

Also cleaned up some code around reporting other invalid annotations.

Change-Id: I5add39cf2ef553a3441d39dfc47bcd1ffdbeb8ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292140
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-03-31 16:11:27 +00:00
Keerti Parthasarathy 386db23227 Add support for patterns to replace null assert with cast fix
Bug: 51880
Change-Id: I3b4bebefdb1122531ec9070ed70a15933d06dd70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292100
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2023-03-31 14:48:50 +00:00
Paul Berry 2828256821 If verify_error_fix_status_test fails, output the status file path.
This will save me a lot of time because I keep forgetting where the
status file is.

Change-Id: I3ab6ad59f66c4e84515bad3a6b7689b6b47ecddf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292283
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-03-31 14:40:47 +00:00
Keerti Parthasarathy 5fda05d041 Add support for patterns to RemoveQuestionMark fix.
Bug: 51885
Change-Id: I11cbba03c73ef380ea2bba2db4d6c9267dbb803c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292123
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-03-30 22:06:04 +00:00
Danny Tuppeny 2ff94f8882 [analysis_server] Allow action in response to showMessageRequest to be null
This allows for users to dismiss a notification without taking any action (something that VS Code / LSP allows for but this API did not).

Change-Id: Icf384008cfcfde6f150c63d3f2889e81e79d1dc1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292080
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-03-30 19:48:18 +00:00
Konstantin Shcheglov 1ec1e7358a Changes for map pattern: report an error for rest elements, empty map pattern.
Bug: https://github.com/dart-lang/language/issues/2861
Change-Id: I00ccb3ea03aa476f96c2ecf3e3a9e13bd4926193
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291940
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Marya Belanger <mbelanger@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-03-30 17:54:06 +00:00
Paul Berry 104ac30cf4 Parser: clean up handling of variable patterns.
The listener API for variable patterns is split into three separate
functions, to handle the three separate behaviors:

- `handleAssignedVariablePattern` for variable names appearing in an
  assignment context (these assign to an existing variable upon a
  successful match).

- `handleDeclaredVariablePattern` for variable declarations appearing
  in a declaration or matching context (these cause a new variable
  name to come into scope).

- `handleWildcardPattern` for wildcards in any context (these don't
  capture the matched value).

Also, responsibility is shifted to the parser for reporting the
following error conditions:

- VariablePatternKeywordInDeclarationContext (e.g.
  `var (var x) = ...;`)

- PatternAssignmentDeclaresVariable (e.g. `[x, var y] = ...;`)

Previously these errors were detected by the implementations, and
weren't fully covering all possible error scenarios.

In the case of VariablePatternKeywordInDeclarationContext, the
listener method `handleDeclaredVariablePattern` is called instead of
`handleAssignedVariablePattern`.  This ensures that no tokens are
dropped from the analyzer AST.  The CFE uses the `inAssignmentPattern`
argument of `handleDeclaredVariablePattern` to distinguish this error
recovery case from a legitimate declared variable pattern.

Fixes #51868.

Bug: https://github.com/dart-lang/sdk/issues/51868
Change-Id: I28ec679b73d64033166721c6460be35f15e23171
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291583
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-03-30 14:12:03 +00:00
Kallen Tu f7bc72fce6 [analyzer/cfe] Remove interface mixin, final mixin and sealed mixin.
Added error messages for when users try to use invalid mixins + a language test that tests that (and tests in each of the front ends).

Removed the tokens from the parser listeners.

Removed all behaviours and error reporting related to these invalid mixins.

Change-Id: I558595826dae7e2c176bd1929e97caa2335c167c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290614
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-03-30 11:56:08 +00:00
pq cb4761f6e8 support "effectively exhaustive" switch statement conversions
Fixes: https://github.com/dart-lang/sdk/issues/51884

Change-Id: Ia3f63e9c469035be4047647c75b956332f7b7909
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291880
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-03-29 21:55:07 +00:00
Danny Tuppeny 76761576a2 [analysis_server] Move "dart fix" prompt into base server for use by both protocols
Change-Id: I5abc6172b1cdb83c855064eb5a7b81a5d4930c07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291823
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-03-29 20:50:37 +00:00