Commit Graph

10280 Commits

Author SHA1 Message Date
Danny Tuppeny fb22849379 [analysis_server] Extract expected offsets in Extract Local test
Follow-up from https://dart-review.googlesource.com/c/sdk/+/441840.

Change-Id: I085099fde59fce052b01fd06a8cc41a83f55ac24
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441941
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Danny Tuppeny <danny@tuppeny.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-07-29 11:45:03 -07:00
Kallen Tu ad7f7860d9 [analysis_server] Dot shorthands: Update CreateGetter and CreateField.
`CreateGetter` and `CreateField` are now two available fixes for dot shorthand property accesses.
Updated each fix to handle dot shorthands using the computed context type element and added tests.

Bug: https://github.com/dart-lang/sdk/issues/60994
Change-Id: I6b21c8034521503eae6c490597a1b3894acb489c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442247
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-07-29 11:09:26 -07:00
Danny Tuppeny 86d3c739b6 [analysis_server] Remove useLineEndingsForPlatform=false from some fix tests
See https://github.com/dart-lang/sdk/issues/60234

Change-Id: I851779a43260a468d772dbb997a1f7e1e2395656
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441960
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-07-29 10:46:33 -07:00
Chris Sauer 590d6f292b Fix typo: checkVisibilty -> checkVisibility
Closes https://github.com/dart-lang/sdk/pull/61207

GitOrigin-RevId: b5ad0f59552e7d8b5347844c42e0547855521eff
Change-Id: Ic17a75877949d06fffff5f5c38c893944e3b2fee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442564
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-07-29 07:43:10 -07:00
Fedor Shcheglov 0bc13a8e00 Change rename class member refactoring to allow renaming chained super formal parameters, and renaming field formal parameters to private.
Bug: https://github.com/dart-lang/sdk/issues/60803

Change-Id: I6eab2eaa6d724f7f2c544c6f2bf74e9e73ad31f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442249
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-07-28 10:25:19 -07:00
Fedor Shcheglov a35946cdc6 Rename parameters and _parameters in element.dart to formalParameters
Change-Id: I62ec961129ca0191f7cb228ef94915d2627c3209
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442172
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-07-28 10:20:49 -07:00
Sam Rawlins 38b60624d4 DAS plugins: Test how an unsupported request is handled.
Change-Id: If214c32f396867a5af0a3bfcc40946121c895aef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442285
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-07-28 09:44:52 -07:00
Konstantin Shcheglov a278738f3c Elements. Make PropertyAccessorElement.variable non-nullable.
The null assert in `PropertyAccessorElementImpl.variable` is safe
because `ElementBuilder` always creates synthetic
`TopLevelVariableFragmentImpl` or `FieldElementImpl` for a getter or
setter. And the other way around, non-synthetic
`TopLevelVariableFragmentImpl` or `FieldElementImpl` when created
associate itself with synthetic getter / setter.

Change-Id: I40e4ce866edffab6c8bcdf6e408bd1bbfbba6581
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442246
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-07-25 15:45:02 -07:00
Paul Berry 6610e5cbfe [analyzer] Break dependency between analyzer message codegen and analyzer.
This fixes a bootstrapping problem: previously we could get into a
situation where the generated files for analyzer diagnostic messages
were out of date, but the code generator for those messages couldn't
be run, because it imported the analyzer itself, which contained
compiled errors due to the generated files being out of date.

There were two problematic dependencies:

- The `GeneratedContent.check` and `GeneratedContent.checkAll` methods
  relied on invoking the Dart formatter as a library (rather than
  invoking `dart format` as a subprocess); the Dart formatter library
  imports the analyzer. Fortunately, this functionality is not needed
  by the code generators themselves. It's only needed by the _tests_
  that verify that code generation has run. So I was able to break the
  dependency by moving this functionality into a new file,
  `package:analyzer_utilities/generated_content_check.dart`, which is
  imported only by the code generation tests. The new API is slightly
  different: `GeneratedContent.checkAll` has been replaced by an
  extension method `check` on `Iterable<GeneratedContent>`.

- The diagnostic message code generator used to have a post-processing
  step that made use of the scanner to find error messages used by the
  parser that needed to be translated, and issued a warning if it
  found any. This check was useful a long time ago, when we were
  unifying the analyzer and CFE parsers, and is no longer useful, so
  I've removed it.

Change-Id: I509b741faca3b9ae21c23936001105ded731b490
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442241
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-07-25 13:18:00 -07:00
Kallen Tu c42bdd1be2 [analysis_server] Dot shorthands: Update ChangeTo fix.
Updates the `ChangeTo` fix to handle miswritten dot shorthands.
We use the calculated context type to determine the closest element that
the user might be attempting to write.

Bug: https://github.com/dart-lang/sdk/issues/60994
Change-Id: If69b6b30fa70a9cd047a3f2946ae1e0883f322e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442168
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-07-25 12:40:51 -07:00
Danny Tuppeny 684a39190b [analysis_server] Fix completion error when a typedef points to a mixin
This fixes an exception that prevents completion from working if a typedef points at a mixin, which is something Flutter has:

```dart
typedef RenderConstrainedLayoutBuilder<LayoutInfoType, ChildType extends RenderObject> =
    RenderAbstractLayoutBuilderMixin<LayoutInfoType, ChildType>;

mixin RenderAbstractLayoutBuilderMixin<LayoutInfoType, ChildType extends RenderObject>
    on RenderObjectWithChildMixin<ChildType>, RenderObjectWithLayoutCallbackMixin
```

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

Change-Id: Ibf31612d34893f2183a7da513359bdbff6a5c066
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441962
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-07-25 09:31:40 -07:00
Fedor Shcheglov 4bb2269a06 Fix renaming super formal parameters in long subclass chains.
Bug: https://github.com/dart-lang/sdk/issues/61194

Change-Id: Icb3b8e5044e13e046122490e1dfceb5dc944eafe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442170
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-07-24 21:54:16 -07:00
asiva ab44b20ab8 Reapply "[VM/dartdev] Switch dartdev to use an AOT runtime." and
Add the fixes that were done after original CL landed.

This reverts commit 97bc401163.

TEST=ci

Change-Id: I26373aecc325e4c0c379c92e779aa301e3a58c5a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441700
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2025-07-24 14:48:03 -07:00
Elliott Brooks a1699ecfb0 [Property Editor] Use dot-shorthand syntax in enum edits when possible
Bug: https://github.com/dart-lang/sdk/issues/60727
Change-Id: I41388422b0c317e7500166d29ba4f9e7b656a24f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441862
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Elliott Brooks <elliottbrooks@google.com>
2025-07-24 13:40:35 -07:00
Kallen Tu 289278b584 [analysis_server] Dot shorthands: Update ReplaceFinalWithConst fix.
Adds an extra dot shorthand constructor invocation case to the
`ReplaceFinalWithConst` fix. Added relevant tests.

Bug: https://github.com/dart-lang/sdk/issues/60994
Change-Id: I23d9882ae5b8633a29f6d50a40de35d80edb2a2f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442161
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-07-24 13:35:09 -07:00
Brian Wilkerson 3303e1d140 Convert the summary request to use the elememnt model
Converting the summary request to use elements allows us to include API
from parts as well as API exported from other libraries in a uniform way.

Change-Id: Iad4982efc76c41331e0507bd6fc95e8ee0e4c9c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441833
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
2025-07-24 13:00:29 -07:00
Danny Tuppeny 33824188a0 [analysis_server] Disallow inlining SDK code
Fixes https://github.com/dart-lang/sdk/issues/60308

Change-Id: Ic813b309f57464f16e3285e594ec4ec18f14f4e1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442120
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-07-24 13:00:15 -07:00
Danny Tuppeny 02ea7d0b14 [analysis_server] [lsp] Support return/yield/break/continue in Document Highlights
This adds support for keywords like `return`, `yield`, `break`, `continue` to Document Highlights. For break/continue, the matching loop keyword (`do`/`while`/`for`) is also highlighted (and this works in both directions). This behaviour matches what I see for TypeScript in VS Code.

This is only supported for LSP because the legacy protocol groups these by "Elements" which we don't have for loops (though since IntelliJ uses its own data for occurrences, it's not clear to me if anyone is using Occurrences over the legacy protocol).

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

Change-Id: I5563ec0a91a6fe33d10a6317d33e9256b3c50209
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442061
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-07-24 10:47:40 -07:00
FMorschel 13e29e24ff [DAS] Starts refactoring tests migration to TestCode markers
Continuing the work to normalize all our tests to use the TestCode markers.

Bug: https://github.com/dart-lang/sdk/issues/60234
Change-Id: I687bc35409b1e37938c60206d07155fcc7ac2ac9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433800
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-07-24 10:03:59 -07:00
Konstantin Shcheglov 945346292f Move check for setter formal parameters to AstBuilder.
Now every setter after parsing has exactly one required positional
formal parameter. This will cause setter elements have exactly one
formal parameter, and let us avoid checking for it in multiple places.

Remove CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER

Add ParserErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER

Change-Id: I80a6f3f6e51ac2ed2f6ddb49d059c2d78ff64b2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441830
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-07-24 07:21:26 -07:00
Fedor Shcheglov f47cc4487b Remove Xyz2 suffix getters from /analysis
Change-Id: I10221b86f63ee8a2d74938ef0438945b43e11f6b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441990
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-07-24 05:54:30 -07:00
Kallen Tu b1af1bdd0a [analysis_server] Dot shorthands: Update RemoveConst fix.
Updates `RemoveConst` fix to handle dot shorthands. Will remove `const` where it can't be constant and then push the `const` into a dot shorthand's arguments if possible.

Bug: https://github.com/dart-lang/sdk/issues/60994
Change-Id: Idb7ef4e5006c6561ce621a48e8351fd65b27c5b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441863
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-07-24 00:14:59 -07:00
Sam Rawlins e4e36a396b DAS plugins: Make a constraint on the analysis_server_plugin package instead of the others
Fixes https://github.com/dart-lang/sdk/issues/61182

Change-Id: I46cff3e599ae63fb718a1e05778afa05be50ab79
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441835
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-07-23 17:02:02 -07:00
Danny Tuppeny 741504807d [analysis_server] Update closing label to not require useLineEndingsForPlatform=false
See https://github.com/dart-lang/sdk/issues/60234

Change-Id: I449c32c17430fd01d28d6d8f40d02c6e1f2bb65b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441801
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Danny Tuppeny <danny@tuppeny.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-07-23 09:38:48 -07:00
Danny Tuppeny dfad9f3caf [analysis_server] Update element visitor tests not require useLineEndingsForPlatform=false
See https://github.com/dart-lang/sdk/issues/60234

Change-Id: Idaf96d95f0e694366cfff30dbc62f86eaca0bc72
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441802
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Danny Tuppeny <danny@tuppeny.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-07-23 09:33:46 -07:00
Danny Tuppeny e885432d5f [analysis_server] [lsp] Support navigation from return/break/continue/yield to loop/function
This adds navigation support via Go-to-Definition for LSP for these keywords, matching similar behaviour in other languages (like TypeScript) in VS Code.

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

Change-Id: I30601b54c8ed7235b7789582032b9565618f2148
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441520
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-07-23 09:26:29 -07:00
Danny Tuppeny c235fadc99 Fix some EOL bugs + remove useLineEndingsForPlatform=false from refactor tests
Some additional work towards https://github.com/dart-lang/sdk/issues/60234, along with a couple of small fixes for issues uncovered while getting the tests running with \r\n.

Change-Id: Iff3700fad017825f65d64195d844b1694163456a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441840
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-07-23 09:12:53 -07:00
Konstantin Shcheglov fd33d9eae8 Elements. Use 'value' as the name of the formal parameter for a synthetic setter.
```
According to Gemini:
There is a very strong and widely followed recommendation.
The formal parameter for a setter in Dart should be named value.
```

So, it makes synthetic setters consistent with manually written setters.
These names sometimes are show in UI, e.g. in hover.

Change-Id: I4b53314aae63dce267906856d98a16ec22d38097
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441827
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-07-23 08:55:49 -07:00
Danny Tuppeny a207698ec5 [analysis_server] [lsp] Add docs for inlay hints config to readme
See https://github.com/dart-lang/sdk/issues/60326

Change-Id: I8d7faf4a48e3e3738cd97fba3f695e404318cab5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441141
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Danny Tuppeny <danny@tuppeny.com>
2025-07-23 08:49:40 -07:00
Kallen Tu e776c1ff48 [analysis_server] Dot shorthands: Update AddConst fix to add const to dot shorthand constructor invocations.
The `AddConst` fix is triggered by the `PreferConstConstructors` lint and this CL updates the fix to add `const` to dot shorthand constructor invocations that can be made constant.

Fixes: https://github.com/dart-lang/sdk/issues/61163
Bug: https://github.com/dart-lang/sdk/issues/60994
Change-Id: I4520c1edf807c041f38f5477f48ab1b1327732b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441720
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-07-22 10:10:30 -07:00
Kallen Tu 35b09df976 [analysis_server] Dot shorthands: Update ReplaceWithVar fix and assist.
When the initializer of a variable declaration is exactly a dot shorthand, we can insert the declared type in front of the dot shorthand to ensure that we're retaining the necessary context type.
`E e = .a;` -> `var e = E.a;`
In other cases such as typed literals and constructor invocations, the correction already does what we need it to.

When we're looking at a for-each and the iterable is a typed literal, if there's a dependent dot shorthand, we add explicit type arguments to the literal to retain the context type.

Added tests for the fix and the assist which has the same code path.

Bug: https://github.com/dart-lang/sdk/issues/60957, https://github.com/dart-lang/sdk/issues/60994
Change-Id: I31a05f10a7cdaae731c6f6c59deae12c2543a4a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441320
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-07-21 17:02:03 -07:00
Brian Wilkerson 82a01bb69c Add a custom LSP request to produce a summary of a file
The exact format of the summary is yet to be decided, but at the moment
it's producing an abbreviated form of Dart that doesn't include function
bodies or documentation comments.

No attempt is made to remove in-line comments, but we might want to
consider doing that.

Change-Id: Iec6e27c54e3099a596d50d5c461356006694690b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/440682
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
2025-07-21 15:45:39 -07:00
Danny Tuppeny 6477e0ebae [analysis_server] Add basic configuration for controlling which inlay hints appear
Fixes https://github.com/dart-lang/sdk/issues/60326

Change-Id: Ic3247420ddc23cda6c4e459a6992721ab814f8dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/440940
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>
2025-07-21 13:30:46 -07:00
Kallen Tu 676a40ec54 [parser] Dot shorthands: Recover as a DotShorthandPropertyAccess rather than a PrefixedIdentifier.
This change mainly has side effects for code completion, making sure we're suggesting the right members. When the user writes something like `E e = .^` where `^` is the cursor, they're most likely intending to write a dot shorthand.

So this parser recovery change ensures that we recover as a dot shorthand node and not as a prefixed identifier (missing it's target) in the analyzer. We don't need special casing in the code completion pass to handle dot shorthands in the prefixed identifier visitor now.

The CFE should have no notable changes, but I added a few tests since it uncovered some crashing behavior. The duplicate errors have always been the case even prior to this change.

Bug: https://github.com/dart-lang/sdk/issues/59836
Change-Id: I6c4a9f2c8cc376e4dedd715af76967da471aa681
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439140
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-07-21 11:45:32 -07:00
Danny Tuppeny 8124814de5 [analysis_server] Update search engine tests to not require useLineEndingsForPlatform=false
Change-Id: I73a56ee2529df9af2a1df19622c988f2eb493a0e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441580
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2025-07-21 11:23:53 -07:00
Danny Tuppeny 267488a405 [analysis_server] Remove useLineEndingsForPlatform from statement completion tests
+ fix related bugs in the implementation.

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

Change-Id: I2a2b1aef1380b77016e672e0d3b53d3049249105
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441542
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-07-21 11:14:12 -07:00
Fedor Shcheglov c957029739 Add tests for most displayString() methods.
Significantly improve test coverage of `display_string_builder.dart`.

Fix an error involving a missing space when reading the enclosing
fragment of a local variable declaration.

Change the formatting of `ConstructorElement` to print only the type and
not the name to avoid duplication, as they were the same.

Change the formatting of `TypeAliasElement` to just print the name of
the aliased type, rather than the whole aliased element - as this rarely
provided useful information.

Change-Id: Ie1e4a3649063c2b3662ef7bd21327c17a5b1456b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441082
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-07-21 11:02:14 -07:00
Danny Tuppeny 9890e6a6e2 [analysis_server] Update call hierarchy tests to not require useLineEndingsForPlatform=false
See https://github.com/dart-lang/sdk/issues/60234

Change-Id: I1f45b587d5257750f8afed149524a8061363b536
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441543
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-07-21 10:39:57 -07:00
Samuel Rawlins 50bb4721d3 Revert "Revert two recent changes to no_literal_bool_comparisons:"
This reverts commit cb3017cb9c.

Reason for revert: Re-landing two commits together.

Original change's description:
> Revert two recent changes to `no_literal_bool_comparisons`:
>
> * "[DAS] Broadens the scope of `no_literal_bool_comparisons`"
>   commit 0541ad3828.
> * "[DAS] Fixes broken cases for "Convert to boolean expression" fix"
>   commit 04448385dd.
>
> The first commit may have lead to broken customer tests. See
> https://github.com/flutter/flutter/pull/172087.
>
> Change-Id: Iba2c936a32ecf678318fa3aea929787dca046e09
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/440261
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Commit-Queue: Samuel Rawlins <srawlins@google.com>

Change-Id: I82594e3a77404dc0a4e22f44dd9f850f05f94ca5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/440500
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-07-21 09:20:51 -07:00
Konstantin Shcheglov 3c60075478 Elements. Switch away from TypeAliasElement.aliasedElement
Change-Id: I2ddc4c1a850871d63c0b12f0a14293fff888d523
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441440
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-07-21 09:15:04 -07:00
Konstantin Shcheglov c4f4dcbe6a Elements. Inline FragmentedXyz mixins into ElementImpl classes.
This significantly simplifies hierarchies at cost of a few duplications.

Change-Id: I72bfe4d2af1fab1cabf6226b102d2bd32b146272
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441244
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-07-18 15:49:48 -07:00
Kallen Tu 53991691f8 [analysis_server] Dot shorthands: Extract expression tests.
Adding logic to add a type when extracting locals or methods, otherwise we're refactoring shorthands into a statement with no context.

Tests for mixins, extension types, enums and classes.

Bug: https://github.com/dart-lang/sdk/issues/59836
Change-Id: I8ee1407ba82118831e3bbb092e11a44b6ea5384c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431950
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-07-18 12:54:09 -07:00
Konstantin Shcheglov 6f0909d8e2 DAS. For foo.name and foo.name() include ElementMatcher(s) for supertypes too.
Change-Id: I46c88a185af73951d46815053c997984735b853a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/440961
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-07-17 12:56:19 -07:00
Paul Berry ad503267f1 [analyzer] Remove format method; change callers to use formatList.
This method wasn't exposed through the analyzer public API, and wasn't
strictly necessary; all it did was wrap up all its arguments (except
the first) in a list and call `formatList`.

In the long term I intend to replace `formatList` with a richer and
more type-safe API that allows clients to supply message parameters
through named parameters. Removing the `format` method now will make
it easier to evolve towards that richer API.

Note that this change is not strictly a no-op; one of the call sites
(in
pkg/analysis_server/lib/src/services/refactoring/legacy/inline_local.dart)
was incorrectly wrapping its argument in a list and then calling
`format`, causing the argument to be wrapped in a second list. That
was clearly a mistake, so I went ahead and fixed it as part of this
CL.

Change-Id: I0796804ab949e66a129bfeec6dfe688dfa113eb2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/440548
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-07-16 10:12:11 -07:00
Fedor Shcheglov 6a5c577465 Rename / deprecate more getters and methods.
* Deprecate `DirectiveUriWithLibrary.library2`, use `library` instead.
* Deprecate `ElementAnnotation.element2`, use `element` instead.
* Deprecate `LibraryImport.prefix2`, use `prefix` instead.
* Deprecate `MultiplyDefinedElement.conflictingElements2`, use `conflictingElements` instead.
* Deprecate `ScopeLookupResult.getter2`, use `getter` instead.
* Deprecate `ScopeLookupResult.setter2`, use `setter` instead.

Change-Id: I523eb21d194b661eed5bcbbfc923e9a7de87c962
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/440361
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-07-15 15:10:55 -07:00
Sam Rawlins cb3017cb9c Revert two recent changes to no_literal_bool_comparisons:
* "[DAS] Broadens the scope of `no_literal_bool_comparisons`"
  commit 0541ad3828.
* "[DAS] Fixes broken cases for "Convert to boolean expression" fix"
  commit 04448385dd.

The first commit may have lead to broken customer tests. See
https://github.com/flutter/flutter/pull/172087.

Change-Id: Iba2c936a32ecf678318fa3aea929787dca046e09
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/440261
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-07-14 12:57:34 -07:00
Fedor Shcheglov 5e057f9895 Change display_string_test to reflect new element model.
Delete `getDisplayString()`

Remove most `displayString()` overrides from `ElementImpl's` subclasses.

Add more precise `appendTo()` for most `ElementImpl` subclasses.

Change-Id: Ic955721f0698d2472a6bf56e7955490e8ccf4eaf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439544
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-07-14 12:49:29 -07:00
FMorschel 04448385dd [DAS] Fixes broken cases for "Convert to boolean expression" fix
Fixes: https://github.com/dart-lang/sdk/issues/60614
Change-Id: Ib083c4150cacc4e0e8cf3a2a37916fd5894d116b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/440203
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-07-14 10:30:54 -07:00
Danny Tuppeny f8d6ad7e4b [analysis_server] Don't generate inline values inside function types
We shouldn't treat parameter names inside function types as if they are references to other parameters/variables of that name.

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

Change-Id: Iadc97723a87af1ddbbde618d1c9c8e5b51499a6f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/440160
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-07-14 08:16:00 -07:00
Fedor Shcheglov 8cfa901c6e Rename nameOffset2 to nameOffset
Change-Id: I3c8051840122b6046bc89ed48ec329c825607fe5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/440180
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-07-13 20:44:49 -07:00