Commit Graph

5886 Commits

Author SHA1 Message Date
Keerti Parthasarathy 95e049c7e2 Add a test case for #52233
Bug:
Change-Id: I1d98420ce20ec6d52baef5683ae1ab83b21066e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342103
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2023-12-18 18:30:01 +00:00
Parker Lougheed 691ae80cd5 [analysis_server] Allow rethrow partial completion in catch clause
Fixes https://github.com/dart-lang/sdk/issues/54384

Bug: https://github.com/dart-lang/sdk/issues/54384
Change-Id: Id86f0e1b71d27921054e11f2fcbb8bb952f8161e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342220
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-12-18 17:20:27 +00:00
Brian Wilkerson ae15831811 [code completion] Move completion generation for initializing and super parameters
Change-Id: Ie9d09b323c7072c4fe375b6de12347a16065ac5e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341823
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-12-15 17:41:32 +00:00
Sam Rawlins aad9e57674 Revert "Revert "[analyzer] new warning for nullable '==' parameter type""
This reverts commit 885457e1d3.

[analyzer] new warning for nullable '==' parameter type

This rule checks that a parameter to an `operator ==` implementation has
a non-nullable type.

I intentionally did not enforce, in this rule, that the parameter is
exactly `Object`. It is legal to narrow the parameter type to a
different non-nullable type, like `int`. I can't imagine doing it, but
it seems to be unrelated to whether the type should be nullable or not.

Fixes https://github.com/dart-lang/linter/issues/3441

Replaces https://github.com/dart-lang/linter/pull/3923

Change-Id: Ic0be2bfebaf59b0336e9a3a58e5b7f5359eb8646
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291042
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-12-14 23:58:12 +00:00
Keerti Parthasarathy 6c09ade242 Add a test for flutter use case: renaming enum value
https://github.com/dart-lang/sdk/issues/54188

Change-Id: I3c436a4055f0d99c9c7a00e852e16a798f14aeba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341389
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-12-13 18:32:28 +00:00
Brian Wilkerson 7a3df2c801 Move the last of the local reference contributor to the first pass
Change-Id: Ib345a5facef37e2d9d9fc8494b8df116d36c23f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341332
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-12-13 18:01:03 +00:00
Brian Wilkerson d45080d365 Remove support for the older legacy completion protocol
This does not remove the computation of available declarations. This CL
seemed big enough without that, so I (or someone else) can get that in
the next CL.

Change-Id: I67ab49b75c8a415ccfaef16c4e49a00026a6091f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341160
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-12-12 00:54:48 +00:00
Danny Tuppeny 367b8fdc16 [analysis_server] Add inlay hints for for-in and for elements
Fixes https://github.com/Dart-Code/Dart-Code/issues/4891

Change-Id: I788008bca06f98b4308c897d41b2dc034579c6a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340880
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2023-12-11 22:48:27 +00:00
Konstantin Shcheglov 4d7938dfc2 Fix CONVERT_TO_SWITCH_STATEMENT for 'is NotInterfaceType'.
Change-Id: Ic5308541f279e5f23d8e90bee095bf8aa8aec3e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341083
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-12-11 21:46:13 +00:00
Ahmed Ashour d9962e5053 [analyzer] UNNECESSARY_SET_LITERAL to handle multiple expressions
Bug: https://github.com/dart-lang/sdk/issues/50900
Change-Id: Id09e102c2cc12c9043d3f6c22b3af3babf18920e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284021
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Oleh Prypin <oprypin@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Oleh Prypin <oprypin@google.com>
2023-12-11 21:24:59 +00:00
Brian Wilkerson 14a836f6f6 Move the generation of imported elements to the in-scope completion pass
Sorry for the long CL; once again I couldn't find a reasonable way to
split it up into smaller pieces.

This CL causes all of the elements from imports to be generated by the
new approach.

It does contain a new flag that is used to preserve the current
semantics when computing completions for Cider. I hope to be able to
make the new approach efficient enough that we can remove this flag,
but I can't realistically do that until more of the approach is
implemented.

I'm also not fond of the way it fails to handle conflicts in the import
scope. There's a TODO marking the places that would need to be changed,
but the current behavior is that if the same name N is imported from
two or more imports and they refer to different elements, the first one
found will be suggested and others won't. I don't think we want to
suggest any of them unless we also fix the imports so that the name
won't be conflicting. I'm not sure how we want to do that, but it needs
to work with whatever optimization approach we choose.

I think the changes to the tests are all positive, but please double
check that I haven't missed a good reason for the previous behavior.

Change-Id: I70d4514a67988f654984ac20f33b2d7a3cfc78e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340282
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2023-12-08 22:17:38 +00:00
Oleh Prypin 3f299c9174 Handle more cases in convert_to_null_aware fixer
This is done mainly by copying significant parts of the code from the prefer_null_aware_operators lint itself

Change-Id: I13fb7f52ee003924fd5e2f336cfde2bac6b6011a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340080
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Oleh Prypin <oprypin@google.com>
2023-12-07 21:56:54 +00:00
Sam Rawlins eeb3ecb599 analyzer: Convert Flutter (utilities) into a static class.
This was a utility class with absolutely zero state. It almost protected
against unnecessary instantiation by providing a static `instance`
member, but the constructor was still public. Also, the instance was
passed around various objects as an instance field, even allowing for
the static instance to be nullable in a few cases. All of this can be
prevented by making the class `abstract final`, with all of its members
static.

(An argument can be made that all of the code in here could be made
top-level functions, but I'll leave that for a later refactoring, if it
is desired. Also the functions could be made into extension methods, but
many of them rely on promotion of a parameter, so until we get `this`
promotion in extensions, I won't advocate for that change.)

The main reason I was looking at this was to get Flutter out of `_AbstractCorrectionProducer`, so that we don't have to drag the flutter utils into analyzer_plugin (we still can if we want to, but we won't _have_ to).

I also modernized the code, following Effective Dart:

* https://dart.dev/effective-dart/documentation#do-start-doc-comments-with-a-single-sentence-summary
* https://dart.dev/effective-dart/documentation#do-separate-the-first-sentence-of-a-doc-comment-into-its-own-paragraph
* https://dart.dev/effective-dart/documentation#prefer-starting-function-or-method-comments-with-third-person-verbs
* https://dart.dev/effective-dart/documentation#prefer-starting-a-boolean-variable-or-property-comment-with-whether-followed-by-a-noun-or-gerund-phrase

Change-Id: I0d1896ae2d45a31e00f8a824e92d173469cc7eea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340301
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-12-07 02:03:26 +00:00
Danny Tuppeny 315d0b7fa7 [analysis_server] Prevent LSP formatting from adding \r to files formatted with \n if a previous file was formatted with \r\n
Caching the formatter (something we recently discussed removing) was causing issues if you formatted multiple files with different line endings.

It might be a VS Code bug that "\r\n" is being rendered with a blank line in between when the document was in LF mode, but I'll investigate that separately and file an issue there if required.

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

Change-Id: Ib5ec5355f078bc8dd2b30440fd253663727a2b66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340220
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2023-12-07 00:21:31 +00:00
Keerti Parthasarathy 30c5a535fb Add tests for dart:io migration
Change-Id: I901c8289e033d1bf83102b9fabaf7298cf34ff29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340304
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2023-12-06 23:51:31 +00:00
Sam Rawlins 6d909e51f5 analyzer: Remove the (unused) notion of data_driven transform overrides
Change-Id: If265b50226815fa835a85fc1cb64b4931b764b1a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340280
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-12-06 23:42:21 +00:00
pq a354347178 Add PubWorkspacePackage.sdkVersionConstraint.
See: https://github.com/dart-lang/sdk/issues/54043.

In a follow-up, we'll:

* deprecate `AnalysisOptions.sdkVersionConstraint` and
* update all callers to use `PubWorkspacePackage`

Change-Id: Ie24861d50168de79e6a6db511887aea5148987f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340021
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-12-06 20:41:13 +00:00
Danny Tuppeny 23e1437f6a [analysis_server] Update generated code to match latest spec
This should have been a small change to keep us in-sync with small changes so when there are bigger changes (LSP 3.18.0) the change is less noisy.

However, it turns out the meta model is built from the latest version always, so it includes 3.18.0 proposed features.

So this change not only regenerates the code with the latest spec, it also adds some handling to exclude any types (and methods) marked as proposed.

It also includes a few minor fixes to things like re-wrapping of comments where there are references.

So, it should still essentially be a non-functional change, but the CL isn't as small as planned because of the cleanup.

- The lsp_meta_model.json file is downloaded and not changes I've made
- The protocol_generated.dart file is the output of the code-gen
- All other files are changes I made manually

Change-Id: I6380f86848d2799cf94d58a419ace0bf0d5a35ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340040
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-12-05 19:58:47 +00:00
Danny Tuppeny b1620d1ba0 [analyzer] Drop return type from element display for setters
Change-Id: Id580f2c5796b3024b127464ffffdb420511a5632
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339540
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-12-04 06:16:26 +00:00
Konstantin Shcheglov 0bc9815ad0 Migrate all 'fileSystem_' tests of analysis domain to assertNotificationsText.
Change-Id: If6dd1553e2a0bbc9fbe8f42740c1c0f0fef13c1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339232
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-12-03 17:42:05 +00:00
Danny Tuppeny 51d46fd27b Update watcher and remove related failingTest() annotation
This updates the watcher package to include a fix for the `ready` Future not completing for non-existent folders on Windows:

https://github.com/dart-lang/watcher/pull/157

This fixes a bug where the analyzer would wait indefinitely during initialisation if the workspace contained a folder that did not existing on disk (such as if you have a .code-workspace containing folders and one was subsequently deleted).

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

Change-Id: If283403681080477e497fe7e17f2faa217a5a643
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339401
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-12-02 16:42:01 +00:00
Konstantin Shcheglov 60e8519402 Rewrite test_fileSystem_changeFile_buildFile_legacy
Change-Id: Idb764aa7b2aa36a9191e10d68cb6a2351f986d46
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339343
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-12-01 23:27:30 +00:00
Keerti Parthasarathy 48fd851fad Remove unnecessary ignore comment
Change-Id: I34f2ef4244f3d665c361d15c7466201a413af6de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339226
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-12-01 19:51:20 +00:00
Keerti Parthasarathy 9cf01a3bee Reland changes to PubWorkspace support for multiple packages
- reworked logic for `findPackageFor` to be more cognizant of generated paths and indices.
- added more test cases for `findPackageFor`.

Change-Id: Ic8b123c8156921574873737b57415465dbf8f53b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339042
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2023-12-01 15:43:29 +00:00
Brian Wilkerson 3ef27cc0fd Remove a missed piece of the test support for older legacy code completion support
Change-Id: I49a547ccfea531866a57da83691b21bcd7118b80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339203
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-11-30 18:40:38 +00:00
Brian Wilkerson 0915f6e053 Remove the tests related to the deprecated completion protocol
I left the mixin structure because Danny and I plan to use the same
structure to start adding LSP-specific test coverage.

Change-Id: I2eefc05c01eadb67f2c95fcaed3e5a963df7d69b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339100
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-11-30 05:27:39 +00:00
Konstantin Shcheglov b22025d5c3 Macro. Fix for 'add constructor', 'augment constructor' sequence.
Change-Id: If9a5a07cefc7dcd782db636ada2dfa02d7b26e4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339044
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-11-30 01:56:14 +00:00
Danny Tuppeny 7f9099e75a [analysis_server] Fix static type on hovers for non-synthetic getters/setters
Fixes https://github.com/Dart-Code/Dart-Code/issues/4863

Change-Id: Ie4272b77e81fcee282e22002a8cc3f58611af969
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338821
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-11-29 23:18:09 +00:00
Keerti Parthasarathy a7e402df46 Add more test cases to test pubspec fixes for missing dependencies.
- Use YamlNode to access spans and offsets instead of casting.
- Add logic to merge conflicting edits when removing multiple entries
from dev_dependencies.

Change-Id: I1f20b5a4691c37e9f56293acbaf870a489380b9e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338592
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2023-11-29 19:34:49 +00:00
Daco Harkes 019efc9c65 [analyzer] Add dart:typed_data to mock sdk
Split off https://dart-review.googlesource.com/c/sdk/+/338620 which
starts testing FFI analyzer logic that uses Typed Data objects.

Change-Id: I65f98a0f0074b9eaedf7dd6fb0dee57532d41d71
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338960
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-11-29 18:03:52 +00:00
Brian Wilkerson 3641fc33d6 Suggest local declarations in new framework
Sorry for the length of the CL. I couldn't really think of a good way
to split it up further.

The first pass was previously suggesting everything declared in scopes
below the class level. This CL expands that to include everything
declared in the current library. It does not include imported
declarations. It also doesn't yet handle members suggested after a
period. Those are both being handled by constributors.

Please look over the tests carefully. There are more changes than I
would have liked, although I think they're mostly for the better (as
in, the suggestions are more accurate), but I could easily have
missed an invalid change.

Change-Id: I98b3cfc8440ee5da09a8e6828c946d65d8d77759
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338482
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2023-11-28 21:48:28 +00:00
Danny Tuppeny 07d40a0210 [analysis_server] Fix Rename+References for forElements outside of blocks
Fixes https://github.com/Dart-Code/Dart-Code/issues/4849

Change-Id: Iceeeab549235622d4fe8c5c129c754cea53012b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337741
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-11-28 21:23:39 +00:00
Danny Tuppeny 4f0dc3bfd9 [analysis_server] Ensure textDocument/didClose removes overlays synchronously to avoid races when files are closed/opened quickly
Plugin re-registration could cause VS Code to send us a close/open request very close together and this `await` before removing the overlay could result in them being processed in the wrong order. This resulted in subsequent file updates failing with "Unable to edit document because the file was not previously opened"

Fixes https://github.com/Dart-Code/Dart-Code/issues/4862
See also https://github.com/Dart-Code/Dart-Code/issues/4740

Change-Id: If6beeebdd79914e1b26553b81f4fb38f000cbaf7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338660
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-11-28 17:52:57 +00:00
William Hesse cc7095a6c2 Revert "Support multiple packages in a PubWorkspace."
This reverts commit d032598d26.

Reason for revert: SDK build is broken if the checkout path includes "build" as a path segment.

Original change's description:
> Support multiple packages in a PubWorkspace.
>
> A PubWorkspace is now
> - rooted at package config, or the outermost pubspec if there is no package config
> - packages are identified by pubspec
> - all packages are considered to be package build packages
>
> Change-Id: Id1552ab584ccedf60a482b93b375d1c4c7da6796
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337607
> Commit-Queue: Keerti Parthasarathy <keertip@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Samuel Rawlins <srawlins@google.com>

Change-Id: I2ecda907b8bb6164c7cc5446aceff1f168810341
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338560
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Auto-Submit: William Hesse <whesse@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-11-28 12:34:27 +00:00
Keerti Parthasarathy d032598d26 Support multiple packages in a PubWorkspace.
A PubWorkspace is now
- rooted at package config, or the outermost pubspec if there is no package config
- packages are identified by pubspec
- all packages are considered to be package build packages

Change-Id: Id1552ab584ccedf60a482b93b375d1c4c7da6796
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337607
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-11-27 23:23:26 +00:00
Sam Rawlins 28ca02d3a0 Remove WithoutNullSafety tests in DAS and analyzer_plugin tests
Change-Id: I3ea9e767ff49b16a8dcdec5540a6b2d68f414930
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337844
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-11-27 21:40:11 +00:00
Danny Tuppeny 7d9daade2a [analysis_server] Add a failing test for Dart-Code#4857
See https://github.com/Dart-Code/Dart-Code/issues/4857#issuecomment-1826760554

Change-Id: I10aee8f2174da7902a2834f40bdc22eefd5e5ae0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338180
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2023-11-27 19:29:08 +00:00
Danny Tuppeny 7d3020f14f [analysis_server] Handle snippet completions correctly in return statements
Fixes https://github.com/Dart-Code/Dart-Code/issues/4843

Change-Id: I59c41c2ef6439583465a729785fe379c03583cce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338401
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2023-11-27 19:28:09 +00:00
Sam Rawlins cf44f0c780 Analyzer: unregister test rules in tearDown
Change-Id: I8aae2ce4d75af0e47b900a149ff73dcb6064a26e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337613
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-11-22 01:24:11 +00:00
Danny Tuppeny 2aa6fa772b [analysis_server] Don't send redundant empty LSP diagnostics
We never need to send empty diagnostics to the client unless we have previously sent a non-empty set. These empty diagnostics account for a large amount of traffic during initial analysis and also could be quite large when modifying files with dependencies.

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

Change-Id: I3d0e2ea2633469da905c8ca328dcc89e38a64edc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337582
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-11-21 20:05:04 +00:00
Danny Tuppeny 4438cdc6b9 [analysis_server] Add a failing integration test for non-existent workspace roots
See https://github.com/dart-lang/sdk/issues/54116

Change-Id: Ic5d448f0b461fcc8d85384cf16ddd947da1ab02f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337542
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-11-21 19:41:13 +00:00
Danny Tuppeny cfcd74e72c [analysis_server] Remove some boilerplate from LSP tests
No functional changes, just some refactoring extracted from another change to simplify reviewing.

This just:

- adds an `initialAnalysis` getter for tests since it's very common to wait for
- adds a `diagnostics` map that tracks the current state of diagnostics in a test (to avoid tests setting up their own tracking)
- removes some duplicating code for sending diagnostics by having NotificationManager call LspAnalysisServer to send them
- removes unnecessary experiment flags from LSP tests

Change-Id: I1811f393a6d3446550f9007ede926f9ca4556563
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337580
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-11-21 19:02:16 +00:00
Sam Rawlins dd6c961bf0 Remove all pre-NNBD support in the linter code
In this CL we "remove" 3 linter rules, and any subsequently unused quick fixes:

* `always_require_non_null_named_parameters`
* `avoid_returning_null`
* `avoid_returning_null_for_future`

We also delete any code that branched on pre-NNBD libraries; these are
no longer supported.

Change-Id: I3bad7a44de3563e5737919c878170213ad506b82
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336244
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-11-21 18:55:01 +00:00
Parker Lougheed 9e328d4af3 [analysis_server] Do not suggest Type instance methods on extension static member access
Fixes https://github.com/dart-lang/sdk/issues/52962

Bug: https://github.com/dart-lang/sdk/issues/52962
Change-Id: I516050aa3592a33a7710dc13d79cd6e4b0208b8c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337420
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-11-21 00:24:16 +00:00
Sam Rawlins 20f05ad0bd Remove Hints that only fire on pre-NNBD code
These Hints and any subsequently unused quick fixes are deleted:

* HintCode.CAN_BE_NULL_AFTER_NULL_AWARE
* HintCode.IMPORT_OF_LEGACY_LIBRARY_INTO_NULL_SAFE
* HintCode.NULL_AWARE_BEFORE_OPERATOR
* HintCode.NULL_AWARE_IN_CONDITION
* HintCode.NULL_AWARE_IN_LOGICAL_OPERATOR

Work towards https://github.com/dart-lang/sdk/issues/50796

Change-Id: I1b9326ae3c83fcc6be7a7ba4a5f493fc08cc75be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336321
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-11-20 21:20:07 +00:00
Keerti Parthasarathy a0d83fd482 Add a couple more tests for package platform migration
Change-Id: I26073544349cd0646ac277656d44be5c80242c39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337262
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2023-11-20 21:01:57 +00:00
Paul Berry 1c7fe7196d Delete the migration tool
Change-Id: I40db4f08e5e440c336d512fa010ac2a2991575e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336181
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-11-20 18:53:00 +00:00
Parker Lougheed a35921065b [analysis_server] Preserve field doc comments in CONVERT_CLASS_TO_ENUM assist
Fixes https://github.com/dart-lang/sdk/issues/53202

Bug: https://github.com/dart-lang/sdk/issues/53202
Change-Id: Icbc1627da55eb7c680cba802fdb931a843317b3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336860
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-11-20 18:29:28 +00:00
Parker Lougheed 4b09c6d205 [analysis_server] Account for different assignment operators in convert_to_switch_expression
Before this fix, mixes of assignment operators were allowed and converted to a default assignment, changing the semantics of the code.

Change-Id: Ie88ffc5eacaec7cb722f2e2c56980c7f21905260
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336983
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-11-20 18:21:25 +00:00
Parker Lougheed 984e4b214f [analysis_server] Resolve TODO in convert_to_switch_expression quick assist
I'm looking to make some additions to this assist, but to make review easier and assist my understanding, I combined the logic for determining if a switch statement is supported, and if so, what kind it is.

Change-Id: Ic5c48df82c305c31898dd884178ce78ce7da28f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336782
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-11-17 22:53:26 +00:00