Commit Graph

7022 Commits

Author SHA1 Message Date
FMorschel dbf87d8644 Improving string conversion
Closes https://github.com/dart-lang/sdk/pull/56723

GitOrigin-RevId: 802fda7efeace66f33a82fa939a3efac11064390
Change-Id: I6d4d3931e62b89265eb1d324856bed5b9febfe8e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384962
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-09-25 21:11:17 +00:00
FMorschel a0374dd70c Fix create method/function inside conditional operator
Closes https://github.com/dart-lang/sdk/pull/56722

GitOrigin-RevId: 9a861d4078b326754b8855e833c52ede03f0e28d
Change-Id: Ia7535ff48c16836b0e7d3a32005051c7defc3766
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384941
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-09-25 20:51:54 +00:00
Danny Tuppeny c8adf3da3f [analysis_server] Update color handling for recent Flutter Color class changes
In https://github.com/flutter/engine/pull/54714 the "int value" that was used for storing the color values for a Flutter color was removed and replaced with `double red, double green` etc.

The color computer used the `value` field so this stopped it from computing any colors for previews in LSP clients. No tests broke because the tests here use a mock version of the Color class that still had `value`.

This change updates the mock Color class to match the new Flutter implementation, and updates the computer to use the red/green/blue doubles instead of parsing from an int.

It also adds support for the new `Color.from()` constructor that was also recently added.

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

Change-Id: I3ff20bda0cc848e028822cfcb5a14e6a8f6934d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386802
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-09-25 16:27:51 +00:00
Brian Wilkerson 037f313959 Migrate add_missing_enum_case_clauses
Change-Id: Idef9c7cb952ed11d39082f160713daf9c75c67e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386341
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-09-24 19:25:22 +00:00
Fedor Shcheglov 9f4bb0d654 Issue 56559. Remove @override from private field, add to getter/setter.
Bug: https://github.com/dart-lang/sdk/issues/56559
Change-Id: I57e9c5e286af520499ddddeee5818f1c22a94ee8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384921
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-09-23 18:13:45 +00:00
pq 2c73635d00 [wildcards] fix ConvertToWildcardVariable to convert variable references
Change-Id: Ie9b9d03adf11bf2e18d5a3da6e28be8abf4eb53d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384943
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2024-09-23 16:53:11 +00:00
FMorschel 26a035d692 Fix remove-unnecesary-parentheses quick-fix false negative
Closes https://github.com/dart-lang/sdk/pull/56746

GitOrigin-RevId: 3e296b4b88b91d671e4e061ae8613f9b09d7f2f5
Change-Id: Ib174df2b3d825129c22eab71f2c7f38d88a66781
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385382
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-09-23 15:04:44 +00:00
FMorschel 00a1608bd8 Add fix for use_colored_box
Closes https://github.com/dart-lang/sdk/pull/56702

GitOrigin-RevId: 1e043e03da0b43f7f7ab3365f16fe557689a712c
Change-Id: I7fff9c1d0f7c479890625b16b3beed449d504436
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384662
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2024-09-17 18:37:54 +00:00
Parker Lougheed 4819bd09aa [analyzer/linter] Deprecate LintRule.details to avoid new usages
Change-Id: I3d03d5f06901e0a548020522387e8984507a7f4c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384940
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-09-13 18:13:26 +00:00
Sam Rawlins b1416116b7 analyzer: rename most API references to 'plugins' to 'legacy plugins'
Change-Id: I56217045ff9d4da8a5a556cd709e0f63a507884f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384964
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-09-12 21:25:56 +00:00
Konstantin Shcheglov 35bbfb2314 Parts. Move changes to prepare for removing deprecated 'enclosingElement'.
Change-Id: I79804b8907627e54d993a905c62ffc36e6d348b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384963
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-09-12 20:33:20 +00:00
Keerti Parthasarathy fcd1e66663 [Code completion] Some more refactoring in SuggestionBuilder.
Change-Id: I86a1a1211385589ce1e288db5487cc8073b01746
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384821
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2024-09-12 16:48:59 +00:00
Erik Ernst 46cff10fc7 Add lint avoid_futureor_void
This CL adds support for a new lint, `avoid_futureor_void`, that reports on every occurrence of the type `FutureOr<void>` in a covariant or invariant position. More details can be found at https://github.com/dart-lang/linter/issues/4622.

Change-Id: I1b86e04921d1fb0b3661be091ea1f4ad72089e8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382403
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-09-12 10:49:48 +00:00
Danny Tuppeny e7442b7066 [analysis_server] Add a semantic token modifier to wildcards
Also fixes top-level variable declarations to be treated as variables and not properties (see https://github.com/dart-lang/sdk/issues/55956).

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

Change-Id: I899ce4fc5950369acae70517d76a2830fe082731
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384746
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-09-11 18:59:55 +00:00
Sam Rawlins 5ee4eb52e6 DAS plugins: Add plugin package generator
This generator will be used create shared plugin package entrypoints from
plugin configurations.

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

Change-Id: If5c6aeb7bc7845311975928fba1cb9c8d273423c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384681
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-09-11 16:54:29 +00:00
Paul Berry cda2815bb1 Add UNREACHABLE_SWITCH_DEFAULT warning to the analyzer.
This warning is similar to the existing `UNREACHABLE_SWITCH_CASE`
warning, except that it warns if the `default` clause of a switch
statement is unreachable due to all the `case` clasuses fully
exhausting the switched type.

To make the implementation easier, I changed the API for the
`reportExhaustiveness` method in `_fe_analyzer_shared` (which is the
primary entry point to the shared exhaustiveness checker). Previously,
this method returned a list of `ExhaustivenessError`, where each list
element was either an `UnreachableCaseError` (indicating that a
certain case was unreachable) or a `NonExhaustiveError` (indicating
that the entire switch statement was not exhaustive). If the caller
passed in `false` for `computeUnreachable`, `UnreachableCaseError`s
would not be returned, so the returned list would either be empty or
contain a single `NonExhaustiveError`.

The new API renames the types for clarity:

- `NonExhaustiveError` becomes `NonExhaustiveness`, to highlight the
  fact that it's not necessarily an error for the switch's cases to be
  non-exhaustive; it's only an error if the scrutinee's static type is
  an "always exhaustive" type and there is no `default` clause.

- `UnreachableCaseError` becomes `CaseUnreachability`, to highlight
  the fact that it's not an error for a case to be unreachable; it's a
  warning.

Also, the new API adds instances of `CaseUnreachability` to an
optional user-provided list instead of returning a newly created list;
this allows callers to communicate that they don't need to see
`CaseUnreachability` information by passing `null`. This frees up the
return type to simply be an instance of `NonExhaustiveness` (if the
cases are not exhaustive) or `null` (if they are exhaustive). This
makes it easier for the analyzer to decide whether to issue the new
warning, because it doesn't have to dig around the list looking for an
instance of `NonExhaustiveness`.

The new warning has an associated quick fix (remove the unreachable
`default` clause). This quick fix uses the same `RemoveDeadCode` logic
in the analysis server that the existing `UNREACHABLE_SWITCH_CASE`
warning uses.

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

Bug: https://github.com/dart-lang/sdk/issues/54575
Change-Id: I18b6b7c5249d77d28ead7488b4aae4ea65c4b664
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378960
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2024-09-10 19:13:12 +00:00
Danny Tuppeny df010e598f Support DTD requests in the message scheduler
Most DTD tests are currently skipped because we're not currently exposing the LSP handlers, however I temporarily added them and verified with this change that those tests pass (both success and error requests).

Change-Id: I001b7b07c99be18a3711a434bdd081a631e4b4c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383842
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2024-09-10 16:42:47 +00:00
Danny Tuppeny ffeadc947a [analysis_server] Fix sorting of different kinds of imports in DartFileEditBuilder.importLibrary
Previously any pending imports added by DartFileEditBuilder would just be sorted by their text ignoring the kind of import. If there were existing imports for dart, package, relative then they might be inserted in the right places, but if there were not (or not the right kind) of existing imports, they would be just be added in alphabetical order (rather than dart, then package, then relative).

This change extracts some of the rules for sorting directives from analysis_server's ImportOrganizer into analyzer_plugin/src so that they can be reused by the DartFileEditBuilder that lives there.

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

Change-Id: I6dc5476add2b7b1804080ffdc8270d0bb80597db
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384284
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-09-10 14:43:58 +00:00
Keerti Parthasarathy 857243efe0 [Code completion] Move logic from SuggestionBuilder to NamedArgumentSuggestion.
Change-Id: I1e6d1a75ecb37c8dd7ee65414d880431347053a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384302
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2024-09-10 03:03:48 +00:00
Fedor Shcheglov 4a7f9c87e2 Issue 56682. Add break for empty cases when converting if chain into switch.
Bug: https://github.com/dart-lang/sdk/issues/56682
Change-Id: Iafc1154801ec207152104b9b064f2b587a13ac4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384306
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-09-09 22:49:51 +00:00
Konstantin Shcheglov 4dba633c0c Parts. Deprecate LibraryElement.accessibleExtensions
Change-Id: I59227d602d69949e49ed523285b5f77493f70299
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384401
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-09-09 22:18:52 +00:00
Fedor Shcheglov bbc642e6c1 Issue 56371. Quick assist from switch to if statements chain without unnecessary break statements.
Bug: https://github.com/dart-lang/sdk/issues/56371
Change-Id: I826f6f8fa1e9b5123ff8aa1d637d5da1ff63a09a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383931
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-09-09 15:58:39 +00:00
Danny Tuppeny 80057b98d2 [analysis_server] Take prefixes into account when determining the visibility of completions
A prefixed identifier like `a.Foo` should not hide a prefixed identifier like `b.Foo` not an unprefixed identifier (and vice-versa).

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

Change-Id: I8be8b3260f2a9f4333d38bba7ffe309cd3817932
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383641
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-09-09 14:42:29 +00:00
Konstantin Shcheglov 8dd8fd7bc3 Parts. Remove diagnostics related to augmentation imports.
Change-Id: I70a8765d6e9514064a450c3b25b7b66869c12bc8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384044
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-09-06 21:32:12 +00:00
Konstantin Shcheglov 0de8f19be3 Parts. Remove isAugmentation, rename isMacroAugmentation to isMacroPart.
Change-Id: Ibf60f8d20f304a15ff9b2049788a3775fc09686d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383922
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-09-06 21:16:29 +00:00
Fedor Shcheglov 4aaca0b4c0 Issue 56413. Consider prefer_int_literals in 'Wrap with Padding'.
Bug: https://github.com/dart-lang/sdk/issues/56413
Change-Id: I0e4aa2a53a2387caa4ad451e7033767c1b180436
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384100
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-09-06 20:24:48 +00:00
Danny Tuppeny 40b9153fab [analysis_server] Fix semantic tokens/highlights skipping annotations on super parameters
+ treat super parameters that reference field formals as field references, the same as field formals themselves.

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

Change-Id: I5ea841a32445a141a3cf46d8662154f2e9950ebe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383580
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-09-06 14:34:59 +00:00
Konstantin Shcheglov d90bb7321a Parts. Remove support for library augmentations.
Change-Id: I04f076ea6917bd4597b79c75db16207ccf387c9b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383702
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-09-05 22:21:33 +00:00
Honza Bittner 18466983ac feat: make remove widget work for slivers
Closes https://github.com/dart-lang/sdk/pull/56638

GitOrigin-RevId: 835dd143a7b56a9249d4d48da5de4253c57bee21
Change-Id: If0fd507b51a224770cf724568925fa895bfa3e20
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383201
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-09-05 22:13:30 +00:00
Keerti Parthasarathy caa36cfe83 Add a MessageScheduler queue that all incoming messages to the analysis server go through.
Change-Id: I3770b5a1a8faa391fb35a5a1e3d2678dbc4fb3f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383703
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-09-05 20:45:59 +00:00
Keerti Parthasarathy e7d367b1bc Delete dupicate code in DeclarationHelper.
Change-Id: Id3db7c34a7770b784d581ec0f65a4600e54f9963
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383700
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-09-05 16:05:04 +00:00
Keerti Parthasarathy 1236a6a128 Delete unused methods in SuggestionBuilder.
Change-Id: I9849e6c5534c73233381f93e2bca0cfed2535669
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383701
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2024-09-05 01:44:40 +00:00
Danny Tuppeny 803537682f [analysis_server] Provide LSP ClientCapabilities to LSP handlers reflecting the calling client instead of always the server
Prior to this change, all LSP handlers would ask the server for the client capabilities when they would affect their output. For callers over DTD, this could result in the same requests getting different results depending on the capabilities of the editor.

This change adds LspClientCapabilities to the MessageInfo that goes along with each message (usually a request) and then passes in the servers clientCapabilities for requests originating from the editor client, and a fixed set of capabilities for requests that come from DTD.

Most handlers will now use the callers capabilities, however there are a few handlers that build edits to send to the editor (instead of _returning_ the edits), which will use the editors capabilities.

This is essentially a no-op for now, because we're just providing the same capabilities via a different route - but when we come to supporting LSP handlers over DTD (that are affected by client capabilities), they will get consisted results based on our fixed set of capabilities (which as of yet is probably incomplete and may be updated a little as that progresses).

Change-Id: I5bcef8c3ebb7b94c83d85e56a303333d302abdee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382881
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2024-09-04 17:04:46 +00:00
Konstantin Shcheglov 2aa54ab42c Parts. Fix unnecessary_import before landing the reporting CL.
https://dart-review.googlesource.com/c/sdk/+/382901 will start
reporting it in more cases.

Change-Id: I3ae1d407f37a317f33cb98977b0e6eb08de75065
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383221
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2024-09-03 03:51:29 +00:00
Konstantin Shcheglov 8de1422a0e Parts. Deprecate Element.enclosingElement, use enclosingElement3.
Change-Id: Iadc4ed02d4bda3b882e65dc6f4d263a6a938e0fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382920
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-09-01 18:50:29 +00:00
Danny Tuppeny a0411ae244 [analysis_server] Prevent duplicate completions for extensions for libraries that import them
Fixes https://github.com/dart-lang/sdk/issues/56320

Change-Id: I4645165857c082cb26ac09eb12df3106769fb25a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382821
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-08-29 17:11:33 +00:00
Danny Tuppeny d8376f191e [analysis_server] Include color hex codes in LSP completions to get color previews
VS Code will show color previews in code completion if there's a hex value at the start or end of the documentation (or a few other fields, but documentation seems lease intrusive here).

This change will compute and include the hex color if the client indicates it supports the Color completion kind.

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

Change-Id: I94a81993ce5ad95d8cdce2fd61dc7b139710a659
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382604
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2024-08-29 14:36:42 +00:00
Brian Wilkerson dd47ff74cc Remove MultiplyInheritedExecutableElement2
Also removes the only reference to the old model equivalent.

Change-Id: I9dd30f4d7864eca6190df7ae5ebb419ea61e1f9d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382683
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-08-29 14:06:51 +00:00
Keerti Parthasarathy c78b8a5cc2 [Code completion] Move suggesting field from SuggestionBuilder to DeclarationHelper.
Also deleted unused class MemberSuggestionBuilder.

Change-Id: Ibe64963e342e4b0be822fbd25826159276a3d41e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382442
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2024-08-28 21:11:16 +00:00
Danny Tuppeny 8ca61608d8 [analysis_server] Add an allow-list for LSP methods exposed over DTD
Before exposing existing LSP methods we need to provide a way for DTD clients to always get the same format responses regardless of the client capabilities provided by the original server. Until then, add an allow-list for LSP methods that we can use to selectively enable specific methods that are not affected by client capabilities.

Change-Id: Ia1c994a50c9b94a91f4085c09f9d9d94c0fad79e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382401
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2024-08-27 16:50:15 +00:00
Fedor Shcheglov a5cfca1b48 Issue 56572. Fix suggesting extension methods on record types.
Bug: https://github.com/dart-lang/sdk/issues/56572
Change-Id: I47e4b07270843ffb53ab90963e04f01b3b105043
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382261
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-08-26 21:18:56 +00:00
Danny Tuppeny da414c2957 [analysis_server] Allow passing a DTD URI to the analysis server so it can provide LSP functionality to DTD clients
This adds a new request `dart/connectToDtd` that lets a client pass a DTD URI to the server. The server will connect to DTD and provide a subset of LSP methods (those that are currently available over LSP-Over-Legacy, minus the `connectToDtd` method itself) to DTD clients.

This works for both LSP and Legacy servers, and the shared tests run against both (where for legacy, the `dart/connectToDtd` request uses the LSP-over-Legacy support).

This is not currently behind a flag, however it won't do much on its own because no clients will make this request. Once we're happy the functioanlity is good we can either agree an SDK version number for IDEs to gate calling this method on, or we can expose a flag in server capabilities (and some equiv for legacy) so the client knows the functionality is available.

Change-Id: I911d37745a1b2685249dd88e4b152c3196ba627c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/379303
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2024-08-22 20:43:41 +00:00
Keerti Parthasarathy ffd9004314 [Code completion] Move checks to when suggestions are created for static fields.
Change-Id: Iaf11cd7cad225859d7731acd4eb0d3a94076eb4c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381700
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-08-21 17:19:29 +00:00
Keerti Parthasarathy f1a0c38af5 [Code completion]Compute completion string for ConstructorSuggestion.
Change-Id: Ic061c0bc04a777c10447df03c70403442f4b9841
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381310
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2024-08-21 15:58:32 +00:00
Danny Tuppeny a76ff6b2cf [analysis_server] Add failing tests for analyzer plugin issue
This adds failing tests for https://github.com/dart-lang/sdk/issues/56475.

If this CL is applied to the 3.5 release and the `singleOptionContexts` flag set back to `true` (matching 3.4 behaviour), the tests will pass. Each package in both tests will get its own context root (because they have analysis_options to enable the plugins) and each one will read the correct plugins that are enabled.

However if `singleOptionContexts` is `false` (as shipped in 3.5) or this code is applied to bleeding-edge (where the flag is gone, but behaves the same as `false`) both tests fail as follows:

`test_sentToPlugins_inNestedPackages_withPackageConfigs` fails because we read the child analysis_options for the root and try to incorrectly load plugins from the root (and include duplicates and allow more than one plugin):

```
  Expected: {
              'package1': ['plugin1'],
              'package2': ['plugin2'],
              'package3': ['plugin1']
            }
    Actual: {
              'home': ['plugin1', 'plugin2', 'plugin1'],
              'package1': ['plugin1', 'plugin2', 'plugin1'],
              'package2': ['plugin1', 'plugin2', 'plugin1'],
              'package3': ['plugin1']
            }
```

`test_sentToPlugins_inNestedPackages_withoutPackageConfigs` fails because we now only have a context root for the root which enables all plugins from the children:

```

  Expected: {
              'package1': ['plugin1'],
              'package2': ['plugin2'],
              'package3': ['plugin1']
            }
    Actual: {
              'home': ['plugin1', 'plugin2', 'plugin1']
            }
```
Change-Id: I12f45eeb5c1848352af26ac3fdb690e51833c22a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381460
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2024-08-20 20:13:57 +00:00
pq 6413386f29 [wildcards] improve _ type param handling
See: https://github.com/dart-lang/sdk/issues/56361

Change-Id: Ic3be09014afc095490d9332bd124843b5a65e1cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381385
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2024-08-20 17:07:33 +00:00
Sam Rawlins 5ce0cc571c analyzer: correct wording of "always null" and "never null" warning
Fixes https://github.com/dart-lang/sdk/issues/53670

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: I5e890e990d128754b8d9a89e8e940c756779a602
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381100
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-08-19 16:14:28 +00:00
Paul Berry 7f5a698514 UNREACHABLE_SWITCH_CASE: Remove HintCode in favor of WarningCode.
Previously, `HintCode.UNREACHABLE_SWITCH_CASE` was marked as
deprecated, and `WarningCode.UNREACHABLE_SWITCH_CASE` was an alias to
it. This created a slightly confusing situation, because it meant that
all code referring to the diagnostic had to refer to it as
`WarningCode.UNREACHABLE_SWITCH_CASE` (to avoid a deprecation lint),
but the diagnostic still _behaved_ like it was a hint, and therefore
test runner expectations still had to treat it as a hint.

It turns out that it's not really necessary to go through the
deprecation dance when changing the kind of a diagnostic, since (a)
members of `HintCode` and `WarningCode` aren't exposed through the
analyzer public API, and (b) ignore comments don't have to specify
whether something is a hint or a warning.

So the easiest way to clear up the confusion is to just remove
`HintCode.UNREACHABLE_SWITCH_CASE` entirely, and move its implemention
into `WarningCode.UNREACHABLE_SWITCH_CASE` (so that the latter is no
longer an alias).

Change-Id: I9ff7901ad38a2c168c5e54cbe0c1c52bf7c50186
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381103
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2024-08-19 16:09:14 +00:00
Keerti Parthasarathy 738e65bb98 [Code completion] Add a SetStateMethodSuggestion for completions of the setState method.
Change-Id: I86a0955d45a7d62b3063c9683c883c47fe5a88dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380964
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2024-08-16 18:43:04 +00:00
Keerti Parthasarathy 334a131c0a [dart fix] Catch exception when parsing pubspecs.
Fixes https://github.com/dart-lang/sdk/issues/56473.

Change-Id: I4b69a74c4d0f129ff25a074104b80c6b75e96e9b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380076
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2024-08-16 18:17:10 +00:00