Commit graph

8585 commits

Author SHA1 Message Date
Konstantin Shcheglov 473ba0254c Legacy. Use non-nullable TypeProvider, don't create legacy TypeProvider/TypeSystem.
Change-Id: I01ec3849ed0ad1f2a777cd14a51720b88c489a37
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350003
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-02-03 01:22:50 +00:00
Konstantin Shcheglov 14a9782895 Legacy. Remove 2.5 language tests, two error codes.
Change-Id: If29c291d17fbbd74141c08afe55d0c174b303f0a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349627
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-02-01 23:02:38 +00:00
Danny Tuppeny c3d80286fe [analysis_server] Add a supportsUris client capability for legacy server to switch into URI mode
This adds support for the legacy server to switch to URIs using a client capability. In this mode, all "FilePaths" will be URI strings over the protocol (in both directions).

It also allows the server to send LSP notifications (wrapped inside an "lsp.notification" notification, matching how requests/responses work). Notifications are automatically enabled if the client uses any LSP methods or sends the new "supportsUris" capability.

Change-Id: I5d2b76e396862129c61de70d57397603c958a02d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349120
Reviewed-by: Jaime Wren <jwren@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-02-01 22:19:00 +00:00
Danny Tuppeny 581686b8fb [analysis_server] Consolidate some more writePackageConfig() methods
+ tidy up some redundant package versions that are inherited from the ConfigurationFiles mixin.

Change-Id: I93329cbf65af3a68ed27284903e7becac01cf5ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349380
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-02-01 19:11:27 +00:00
Danny Tuppeny 19677cb591 [analysis_server] Remove "previewSurveys" flag
Dart-Code has defaulted this flag to true for a while now and this flag was intended to be temporary to allow for our own testing.

Change-Id: Iad679303480151627fa2dead26b4a3a9f625c773
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349742
Reviewed-by: Jaime Wren <jwren@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Elias Yishak <eliasyishak@google.com>
2024-02-01 19:10:12 +00:00
Brian Wilkerson 394538ebf1 Enhance semantic highlighting for macros
Change-Id: I1d2e26e25f69971ea9a7979290d26c8f63208923
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349363
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-02-01 17:10:36 +00:00
Brian Wilkerson bdb3996a5d Suggest if when after if at the beginning of a statement
I know there was an issue opened for this, but I can't find it.

Change-Id: I6bdbbdb6d001dea519405e67ead65874c9a234e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349464
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-02-01 16:05:59 +00:00
Konstantin Shcheglov 3ea570739d Legacy. Deprecate 'isNonNullableByDefault' in ErrorReporter constructor.
Change-Id: Ia05e113115fb29b47ba12fc9bf46c1d4c04721b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349463
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-02-01 01:51:48 +00:00
Brian Wilkerson 81f26c8f64 Add server test support for macros
It also adds one example of the use of the support method for code
completion of a macro generated method.

Change-Id: I86adbf42fb0905509ab74cafbd0034cb9b4732bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349462
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-01-31 23:02:29 +00:00
Daco Harkes 70e4ff3e1a Revert "[vm/ffi] Unwrap typed data in FFI calls"
This reverts: https://dart-review.googlesource.com/c/sdk/+/338620

We'd like to support this use case with a different API. See the
discussion in https://github.com/dart-lang/sdk/issues/54739.

TEST=tests/ffi

Bug: https://github.com/dart-lang/sdk/issues/44589
Bug: https://github.com/dart-lang/sdk/issues/54771
Change-Id: Ic22fbcab14d374bb9c81bba1f1bf6ae2dfc9e674
Cq-Include-Trybots: luci.dart.try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64c-try,vm-aot-win-release-x64-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-eager-optimization-linux-release-ia32-try,vm-eager-optimization-linux-release-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-x64-try,vm-kernel-linux-debug-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try,vm-win-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349340
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-01-31 09:22:45 +00:00
Danny Tuppeny 8d936d38fc [analysis_server]/[analyzer_plugin] Make all toJson/fromJson methods go through a central converstion for Path<->URI Strings
This change shouldn't change any current behaviour, but means all "FilePath" types in the legacy protocol spec will go through a (currently no-op) conversion. The server will be able to replace this conversion based on client capabilities in a future CL.

Because a lot of the generated classes are in analyzer_plugin, this also moves the ClientUriConverter class there.

`pkg\analysis_server\test\src\utilities\json_test.dart` contains tests that the toJson/fromJson methods go through the converter recursively (inc. map keys/values/etc.).

Change-Id: If5aec884070128eea594540fd25a9017ada86079
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349060
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-01-30 16:58:25 +00:00
Danny Tuppeny 6872a0bb77 [analysis_server] Combine writePackageConfig helpers from LSP and legacy server tests
Both LSP and legacy server tests had their own implementation of writing package_config files. This combines them by moving the LSP `ConfigurationFilesMixin` mixin to its own file and updating the legacy test classes to use it.

This removes a little duplication and avoids adding more for the temporary packages required for Macros that's currently only in the LSP version (but required for some upcoming LSP-over-Legacy tests).

Change-Id: Iaa4055c544df4cdd5a0f140b0c6171ff1a406946
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347081
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-01-29 21:57:13 +00:00
Brian Wilkerson 4cd6c05544 Remove tests for the non-nullable feature from server
Change-Id: I79608f35ca03ff27714dcc15ae372a19066af724
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349140
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-01-29 21:15:47 +00:00
pq 23aff1c23e make RECORD_LITERAL_ONE_POSITIONAL_NO_TRAILING_COMMA an error
Fixes: https://github.com/dart-lang/sdk/issues/54760

My thinking is this doesn't qualify as a breaking change in practical terms but would love Sam's feedback.


Change-Id: I073c478b21377113b3bdbdb3f940ef4dd2bea1d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349080
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-01-29 21:04:28 +00:00
Danny Tuppeny f0e2f96a5c [analysis_server] Fix racy refactor test
This test relied on the file modification being processed during an `await` inside the refactor which could be flaky. Now we artificially pause the handler and resume it only after the test has sent (and awaited) the file update.

Change-Id: Ib99bed8c73cbfb64405908d08193733539669360
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349100
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-01-29 20:25:13 +00:00
Parker Lougheed 4ff3f604e0 [analysis_server] Suggest enum keyword at top-level
Fixes https://github.com/dart-lang/sdk/issues/54744

Change-Id: Ic43c761776b92529cb243e2338768ab6ab5f6f43
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348543
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-01-29 17:25:17 +00:00
Brian Wilkerson 2404a0cb4c Add a flag to disable debouncing of status notifications
I tried to find tests related to the server's command-line options, but
we don't appear to test them.

Change-Id: I0c840deca19402acc59fd5c126be46e4bb2de81d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348765
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-01-27 16:08:10 +00:00
Konstantin Shcheglov b6647fd9ab Stop listening AnalysisDriverScheduler stream during server shutdown.
So, that we don't send analyzing/idle during drivers dispose.

Change-Id: I589cc368b2877baa0878d405f7ab3ca7daf31f3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348763
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-01-27 02:23:48 +00:00
Brian Wilkerson 8f48cbcccb Record the completion location in more places
This is the first of many such CLs. We need to record the completion
everywhere that `OpType` is computing it in order to eventually be able
to stop using `OpType`. I have temporary code that compares the two
computations in order to ensure that they're the same, but I can't
commit it into prod, nor will it be useful beyond this transition.

In addition to recording the completion location in more places, this
also better handles the case when the offset is immediately before the
first character of a top-level declaration. I believe that we need to
do something similar when immedately after the last character, when
before and after class members, and when before an after statements.

Change-Id: I046675c56243981762cd06db4cd35c17989ccf27
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348762
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2024-01-26 21:17:19 +00:00
Konstantin Shcheglov 6757f8d109 AnalysisDriver. Rename to AnalysisStatusWorking.
This name better describes when the status is produced.

Inspired by https://github.com/dart-lang/sdk/issues/54712

Change-Id: I23a8f2f3f6ee500d21c8d93dd81f4f78f2b1840e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348181
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-01-26 20:12:57 +00:00
Konstantin Shcheglov 5ec8fa0b40 AnalysisDriver. Use Set<FileState> for 'knownFiles'.
Change-Id: I7187c12aae8b64a0f7db4f816066bf1df1226ec9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348760
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-01-26 19:21:22 +00:00
Konstantin Shcheglov 3d4a39e9c2 Revert "Revert two CLs that remove WithoutNullSafetyMixin usages."
This reverts commit 1719ef36c4.

See https://github.com/flutter/flutter/issues/141576 for why it was
reverted.

Change-Id: I3a0a6ddf1b23cda008ae1d3a052c6daa05c10729
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348185
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-01-26 15:37:18 +00:00
Keerti Parthasarathy 20a27fee11 Fix for data driven rename when class is used in as expression
Change-Id: I7726b025b417278007f55af55bd2eaead0f55c94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348340
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2024-01-26 14:45:37 +00:00
Parker Lougheed 30b7a2f364 [analysis_server] Don't suggest adding a second late as a fix to assignment_to_final
Change-Id: I83b729e76a39759e0264a9b78947a318a782a26a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348540
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
2024-01-25 23:19:26 +00:00
Jackson Gardner e9590179fe Revert "Refactor PubWorkspace into PackageConfigWorkspace"
This reverts commit 43fb59f4dc.

Reason for revert: Breaking Dart SDK -> Flutter Engine roller. See https://github.com/flutter/flutter/issues/142253

Original change's description:
> Refactor PubWorkspace into PackageConfigWorkspace
>
>  - use package_config.json as marker file for workspace.
>  - workspace can have multiple packages, they can be either PubPackages (marker pubspec.yaml) or BasicWorkspace.
>  - add package info (pubspec) to resolution salt.
>  - removed duplication of finding package_config.json from ContextLocator, as this is now done while creating workspace.
>  - some test/s setup/expectations were changed since we now use package config as marker for workspace instead of pubspec.
>
> Change-Id: I091a4a686c6b1d8c14858aefd9843a8d9c8efa25
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345346
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Commit-Queue: Keerti Parthasarathy <keertip@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>

Change-Id: I59adf5b26d25e360bcf962323db688156774c767
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348364
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Jackson Gardner <jacksongardner@google.com>
2024-01-25 21:00:47 +00:00
Konstantin Shcheglov 8c7ccfafd2 QuickAssist. Support for relational operators in ConvertIfStatementToSwitchStatement.
Change-Id: Ia156566914c45688b164669a18fed5ef4237cd03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348420
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2024-01-25 18:03:09 +00:00
Keerti Parthasarathy 43fb59f4dc Refactor PubWorkspace into PackageConfigWorkspace
- use package_config.json as marker file for workspace.
 - workspace can have multiple packages, they can be either PubPackages (marker pubspec.yaml) or BasicWorkspace.
 - add package info (pubspec) to resolution salt.
 - removed duplication of finding package_config.json from ContextLocator, as this is now done while creating workspace.
 - some test/s setup/expectations were changed since we now use package config as marker for workspace instead of pubspec.

Change-Id: I091a4a686c6b1d8c14858aefd9843a8d9c8efa25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345346
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-01-25 13:08:44 +00:00
Oleh Prypin 0da8f7a7b4 Remove unnecessary imports of 'package:collection' IterableExtension
* Replace `.whereNotNull()` with `.nonNulls` which is now in Dart core.
* `.firstOrNull`, `.lastOrNull`, `.singleOrNull` and `.elementAtOrNull(i)` are also in Dart core and even under the same name, so simply drop the import of 'package:collection' whenever possible.

Bug: b/322159291
Change-Id: I81eb93426680dc78a608bbcc714eb26c0eca5c62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348260
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Oleh Prypin <oprypin@google.com>
2024-01-25 11:07:28 +00:00
Konstantin Shcheglov 079e433e15 Don't suggest from dart:html if not yet imported.
Bug: https://github.com/dart-lang/sdk/issues/54610
Change-Id: Ibf01a25ac6e67fb99370ed4d6119c9f8e92d1f5a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348081
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-01-24 05:02:41 +00:00
Sam Rawlins 27ba055f1f analyzer: Remove unused CancelCorrectionException
The comment makes it sound like a worthy exception type, but it is never
thrown or even instantiated.

Change-Id: Icc946250ed730a3eb61cdc39eed3dc68206e9663
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348083
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-01-24 00:29:28 +00:00
Brian Wilkerson 0dcef64e67 Only suggest non-void members in string interpolations
Bug: https://github.com/dart-lang/sdk/issues/54682
Change-Id: I03a7fc0dc6f914b65775c84124b963929a9813bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347980
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-01-23 18:59:59 +00:00
Brian Wilkerson 3a92c525a6 Suggest the representation field in an extension type
Bug: https://github.com/dart-lang/sdk/issues/54681
Change-Id: I98a8d1843205d8c127a1d053db530903349db391
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347651
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-01-23 17:52:59 +00:00
Sam Rawlins 1f603eb35b analyzer: Tidy up our extensions on AstNode
* No need to give an extension a private name, without an explicit extension override. Just go unnamed.
* Co-locate the two extensions on `AstNode` and on AstNode?` in analyzer package.
* Combine two linter extensions on the same type, `AstNode?`.

Change-Id: I88fef7d5b85bb04bf7263af3810a1c8c3b35f541
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347652
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-01-23 16:48:59 +00:00
Sam Rawlins b19141a202 analyzer: Rename some extensions
And add a bit to our style doc about naming of extensions.

Change-Id: I22dd05dfe08b46ae38cc200456eb008e02eb002f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347782
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
2024-01-23 16:26:39 +00:00
Konstantin Shcheglov 307c6d1dd2 Use notDefault extension method.
Change-Id: Iaa58435a5e7bbd6565758f6c862cddbec5de82a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347649
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-01-23 01:07:23 +00:00
Sam Rawlins 39b7249915 Analyzer: Combine CorrectionUtils_InsertDesc into InsertLocation
Change-Id: I4b847f20e53ba57012a412e0099a6310fdc9c6d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347780
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-01-22 23:15:08 +00:00
Parker Lougheed 60fbf2a4c3 [analysis_server] Expand unnecessary_final fix to typed locals
Bug: https://discord.com/channels/608014603317936148/1171510601655275612/1195499827174309988
Change-Id: I691f7dd2f1e00087c5daa80fbfba8a2fac54b148
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346120
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-01-22 22:54:31 +00:00
Sam Rawlins 4361834047 analyzer: Inline CorrectionUtils.patternOfBoolCondition into ConvertToSwitchStatement
This method takes advantage of a class, PatternCaseExpression, which
was only introduced for the method. The class should not be made
private, as it is returned by the method, to code outside the library. However, since patternOfBoolCondition is only used by one correction producer, I think it is more pragmatic to just inline it into that producer.

We can remove the need for the PatternCaseExpression class, as it can easily be replaced by a record. I think this change nicely simplifies both ConvertToSwitchStatement, and the correction/util.dart library.

Change-Id: If630994ce74451047c5ce5cccd2641475121a94b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347781
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-01-22 22:28:45 +00:00
Sam Rawlins 19b2224e61 analyzer: Remove unused TransformOverride class
Change-Id: Ie713b2b262de21fe88d017867c08b48a31c18327
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347641
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-01-22 21:16:48 +00:00
Konstantin Shcheglov 7965219df2 Extension type. Report CONST_EVAL_EXTENSION_TYPE_METHOD if the operator is declared by extension type.
Change-Id: I26a04332939d2a09b898835dc82cdc75cf23fb33
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347388
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-01-22 21:11:47 +00:00
Konstantin Shcheglov a8b48d3e2c AnalysisDriver. Remove transitionToAnalyzingToIdleIfNoFilesToAnalyze()
It caused race condition via async nature of DAS and AnalysisDriver.

My understanding of the scenario:
1. We started fulling AD with files.
2. We set `priorityFiles`, this notifies the scheduler.
3. We add Dart files to AD.
4. We do something async, this allows the scheduler to ask AD
   to takes the next file, and start analyzing it.
5. We run transitionToAnalyzingToIdleIfNoFilesToAnalyze(), it sees
   there there are no files _to_ analyze (the only file is _being_
   analyzed). So, it turns analysis on/off.
6. DAS sends "analysis: done", `dart analyze` says, I'm done, no errors.
7. AD ends analysis of the file, report errors. Too late.

I believe we don't need this (hackish) method anymore.
1. We switch to analysis status with `priorityFiles`, for good or bad.
2. We are more aggressive now to switch status on/off.

Bug: https://github.com/flutter/flutter/issues/141873
Change-Id: If4e8b74ebdce33b173a686a7b87d14368dfc175d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347421
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-01-22 17:59:51 +00:00
Sam Rawlins 74a4d59bba analyzer: Simplify finding-extensions for DartContextFixImpl
I'm not sure the history of this Extensions class, but in its
current form, it is unnecessary complexity. It is a class with a
single, final field, and a single method. The whole thing can be
inlined into the _single_ caller.


Change-Id: I3ae92383241d6f79be2d96eb52de5a7ecf661fd4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347063
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-01-19 17:59:35 +00:00
pq 7b7dfa6bb5 add analysisOptions to FileResults
See: https://github.com/dart-lang/sdk/issues/54667

Change-Id: I5d756e9f8ba2282c7c022a8dc6c11fe4da254a3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347126
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-01-18 22:05:18 +00:00
Brian Wilkerson af07a3f798 Suggest static members in the first pass of code completion
Change-Id: I308449dd69a623cdb437fadfa9715564d596699d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347064
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2024-01-18 21:02:50 +00:00
Danny Tuppeny 97ac9ace13 [analysis_server] Use FileResult.content for LSP TextDocumentContentProvider
Change-Id: I09546804419bb5d78c3add4e1fa3d80a11526160
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347022
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-01-18 20:16:43 +00:00
Danny Tuppeny 2b713a9e4e [analysis_server] Add experimental TextDocumentContentProvider support for virtual documents
This adds support for serving the contents of virtual files to the client over a custom LSP protocol (based on the VS Code API of the same name). This is currently a custom Dart protocol but hopefully very close to something that could become standard LSP in future.

If the client advertises support for this feature (currently with an experimental flag "supportsDartTextDocumentContentProviderEXP1") we will return the set of URI schemes we can provide content for (currently "dart-macro-file"). Additionally, we will map internal analyzer macro paths (like `/foo/bar.macro.dart`) onto that scheme (`dart-macro-file://foo/bar.dart`) instead of standard `file://` URIs.

Overlays are not created for these kinds of files (because they would override the server-generated content).

Some language functionality "just works" because we can get resolved ASTs for the macro files (and many LSP features operate on these), but more testing (and tests) are required.

Included are tests for the virtual file methods (and events) and Go-to-Definition. Tests for other features are outstanding.

Change-Id: I2056699652873a12b730f565b823f187f883a1ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345420
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-01-18 17:34:43 +00:00
Sam Rawlins 0c3503dde7 Analyzer: Stop relying on a static lint rule map in AssistProcessor
This also simplifies the logic of determining whether a possible producer is
already being proposed as a quick fix for an enable lint rule.

Fixes testing analysis_server with: `dart --enable-asserts pkg/analysis_server/test/test_all.dart`.

Otherwise a functional no-op.

Change-Id: I623101b1c4c732f631a0b74c488cc8853afd282e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346622
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-01-18 17:33:29 +00:00
Konstantin Shcheglov 1719ef36c4 Revert two CLs that remove WithoutNullSafetyMixin usages.
There is code in Flutter that verifies the analyzer with language
verison `2.7`, and breaks if we remove legacy support.

I opened https://github.com/flutter/flutter/issues/141743

Bug: https://github.com/flutter/flutter/issues/141576
Change-Id: I9ec47c2126149ead49cdead82f49fd9eb80a75ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346948
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2024-01-18 03:22:17 +00:00
Konstantin Shcheglov b6d2662a82 Fix producing errors from bytes to update the latest signature.
This should fix analyzer-mac-release bot.

Change-Id: Ia61f5c33a21d703f20fb7a275bbffa4511a122c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346941
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-01-18 02:04:14 +00:00
pq 4a7dd72bcf stop accessing driver.analysisOptions
Change-Id: Ieb9d2581691b82f59b2a5540aaae2c3e453c078c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346944
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2024-01-18 00:40:29 +00:00