Commit Graph

841 Commits

Author SHA1 Message Date
FMorschel ac0be94edd [analyzer] Adds lineNumberDifference and onSameLine methods to LineInfo
Bug: https://github.com/dart-lang/sdk/issues/61186
Change-Id: Ib0584203b000103f8137901c258a86ec571ff74c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471061
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-01-07 10:15:29 -08:00
FMorschel 20d8f8f166 [analyzer_plugin] Fixes writing recursive type parameter
Fixes: https://github.com/dart-lang/sdk/issues/62272
Change-Id: I2370adbf51b709e8860fcc12b6678cde504f1329
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469201
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-01-02 11:26:48 -08:00
Fedor Shcheglov bf5cfaedd9 Renamed variables, formal parameters, and declared identifiers that were incorrectly named elements, when they had a fragment type.
Change-Id: Id201a1f319ee2ae1e328c1d551a98df97bdc2b5a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469640
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-12-29 18:04:29 -08:00
FMorschel 2cbcc7f37c [DAS] Fixes Create (extension) method for unresolved closure return type
Fixes: https://github.com/dart-lang/sdk/issues/61898
Change-Id: I0b1e7ad208a54a04f0ff4147f27403845f9a379d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/459521
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-12-10 10:40:00 -08:00
Paul Berry 5adc86d0ce [messages] Use lower case diagnostic names in analyzer_plugin.
Changes the logic in `pkg/analyzer_plugin` to use
`DiagnosticCode.lowerCaseName` instead of `DiagnosticCode.name`. This
ensures that diagnostic codes are matched in a case-insensitive
fashion.

This paves the way for deprecating (and eventually removing) the
`DiagnosticCode.name` getter.

Change-Id: I6a6a6964db7910a1226693ab60305b25aa02dce5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466130
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-12-09 06:40:32 -08:00
FMorschel 9f4c7e5d8b [DAS] Fixes Create setters, getters and fields for using type parameters
Bug: https://github.com/dart-lang/sdk/issues/61186
Change-Id: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442240
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-12-05 10:32:55 -08:00
Konstantin Shcheglov a135929050 DeCo. Stop using isSynthetic in analysis_server/, analyzer_plugin/, linter/.
Change-Id: I0764ad0bde41d97a98d9eb5b088b50b4eb69155f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465982
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-12-03 14:42:54 -08:00
Konstantin Shcheglov 342a0a7422 DeCo. Add PropertyAccessorElement.isOriginDeclaration, isOriginInterface, isOriginVariable. Same element text writer.
Change-Id: I4a80530e7fe8e971bb5ee3f1138d4e2756b3ff19
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465742
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-12-02 20:59:00 -08:00
Konstantin Shcheglov fb0d56b81b DeCo. Use origin flags for constructors.
Introduce explicit origin flags on ConstructorElement and its fragment
(isOriginDeclaration, isOriginImplicitDefault, isOriginMixinApplication)
and deprecate isSynthetic in favor of these. Define isSynthetic as the
inverse of isOriginDeclaration to preserve the legacy meaning while
encouraging clients to use the more precise origin predicates.

Eventually `Element.isSynthetic` also will be deprecated and removed.
This CL is a step toward this goal, migrating what is possible with new
flags.

Update analyzer internals to rely on the new origin flags when checking
for non-factory generative constructors, building synthetic constructors
for mixin applications, and walking constructor chains in index/search
logic. Only constructors with an origin declaration are now treated as
declarations, and nonSynthetic is defined in terms of origin
declarations rather than synthetic-ness. Add corresponding origin
descriptors to the manifest enum and bump AnalysisDriver.DATA_VERSION.

Adjust analysis server refactorings and fixes to distinguish implicit
default constructors from other synthetic constructors. Code paths that
previously checked isSynthetic for default constructors now check
isOriginImplicitDefault, and mixin-application traversal uses
isOriginMixinApplication.

Overall, this change removes the overloaded semantics of isSynthetic,
makes constructor provenance explicit, and prepares the element model
for future DeCo and primary-constructor scenarios without relying on
brittle synthetic heuristics.

Change-Id: I8568bdfe478867af313a4d13afe1f2859394831b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465201
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-12-02 09:20:12 -08:00
Danny Tuppeny c8ab18f13e [analysis_server] Improve the display of unnamed extensions in LSP Outline, Document Symbols
We previously just showed "<unnamed extension>" for extensions without names, but in some files I noticed we have a lot of these, and the outline/symbols list looks awful (just "<unnamed extension>" repeated many times).

This changes it to instead show "extension on FooClass" instead (if there is a valid type name). I added a new field to the protocol to support this because the LSP classes convert from those classes (something we've discussed changing, but might be easier later).

Screenshots of before/after are in https://github.com/Dart-Code/Dart-Code/issues/5818

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

Change-Id: I3885a722443291bfa2419514841469c862b74450
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464560
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-25 13:49:55 -08:00
Konstantin Shcheglov abc6f1e378 DeCo. Switch linter/ and analyzer_plugin/ to ConstructorDeclaration.typeName
Not actual migration, uses null asserts.
Should be made safe as part of implementation in linter.

Bug: https://github.com/dart-lang/sdk/issues/61701
Bug: https://github.com/dart-lang/sdk/issues/62055
Change-Id: I08f709b9f9c74dbab1b41c4e12ed498135450531
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463465
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-11-20 14:26:46 -08:00
Konstantin Shcheglov ea84bc9df1 DeCo. Deprecate RepresentationDeclaration and RepresentationConstructorName.
Bug: https://github.com/dart-lang/sdk/issues/61701
Change-Id: I3ed4ccabdd466654585e14f674bb404cde466c1f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462861
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-11-19 10:08:13 -08:00
Konstantin Shcheglov 0349520b98 DeCo. Migrate everything to new AST.
No more flag, always parse into the new AST, always visit new AST nodes,
always return them as child entities, parent-child structure reflects
the new AST.

So, use `namePart` and `body` where possible. Deprecate previous
properties.

This is still de jure a breaking change, because `parent` of deprecated
properties changes. De facto this required very few changes in google3.

Once this CL lands, I will publish `analyzer 10.0.0`, migrate everything
to new properties, delete deprecated properties, and publish `analyzer
11.0.0`.

Maybe deprecate `NamedCompilationUnitMember.name` and migrate to
subclass specific `name` or `namePart` properties before publishing
`analyzer 10.0.0`. This part is not breaking per se.

* Deprecations in `ClassDeclaration`:
  * Properties `leftBracket`, `members`, `rightBracket` are deprecated, use `body` instead.
  * Properties `name`, `typeParameters` are deprecated, use `namePart` instead.
* Deprecations in `EnumDeclaration`:
  * Properties `leftBracket`, `constants`, `members`, `rightBracket` are deprecated, use `body` instead.
  * Properties `name`, `typeParameters` are deprecated, use `namePart` instead.
* Deprecations in `ExtensionDeclaration`:
  * Properties `leftBracket`, `members`, `rightBracket` are deprecated, use `body` instead.
* Deprecations in `ExtensionTypeDeclaration`:
  * Properties `leftBracket`, `constants`, `members`, `rightBracket` are deprecated, use `body` instead.
  * Properties `constKeyword`, `name`, `representation`, `typeParameters` are deprecated,
    use `primaryConstructor` instead.
* **Breaking Change:** While the deprecated members mentioned  above still exist in the AST,
  their parent nodes have changed. This means that code  relying on specific parent-child
  relationships for these nodes might break.

Bug: https://github.com/dart-lang/sdk/issues/61701
Change-Id: Ic48104da8b029c9b454bbd2336574b7823025565
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461841
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-11-17 08:57:36 -08:00
Konstantin Shcheglov ba1e7e8c45 Fine. Use 'withFineDependencies: true' in analysis_server_plugin/ and analyzer_plugin/.
Change-Id: If27c37c311afd5647fc1e4e741816ced5c9b576f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462221
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-11-14 15:22:43 -08:00
FMorschel c9f3e9a78e [DAS] Fixes Add missing parameter fix for super parameters
Fixes: https://github.com/dart-lang/sdk/issues/48359
Change-Id: Id7a286ad5757387a78a952c9367fc4cd071f7bba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/459540
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-14 13:32:01 -08:00
FMorschel e4cec87683 [DAS] Fixes argument completion for dot shorthands invocations
Bug: https://github.com/dart-lang/sdk/issues/61969
Change-Id: Ie109e6bdf657ccbc02510da912087d2babf3806e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462081
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-11-14 07:42:38 -08:00
Sam Rawlins 151cc0ce8f analyzer_plugin: Remove remaining deprecated elements
Change-Id: Ia984b4462eba7d565ffe59ee07129118d8c399d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461524
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-11-13 07:36:52 -08:00
Sam Rawlins 8eb7c58b38 analyzer_plugin: Remove deprecated "methodBeingCopied" parameters
Change-Id: I7973e6badfbf9f9585707ea713c4ad27fe193584
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461583
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-11-12 14:14:19 -08:00
TejasSojitra12 b203ab1571 [analyzer_plugin] FooMixin classes are not mixins #61768
Change-Id: Icbccc25df1f2127212adb656955b74bdbafdd323
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/460720
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-11-10 12:02:27 -08:00
Moritz 131760f204 Fix placing of field for bind_to_field fix
Now respect the `sort_constructors_first` lint when inserting fields.

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

Change-Id: I3d79ee0ea25d34af16a90a155406c08b5b5a8547
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/459300
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Moritz Sümmermann <mosum@google.com>
2025-11-10 08:26:01 -08:00
FMorschel 822450ba78 [DAS] Fixes DartEditBuilder.writeType to handle private typedefs correctly
Fixes: https://github.com/dart-lang/sdk/issues/61838
Change-Id: Ic5e73241bfdb3210d5d2d43ea6136a8d948f2e13
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/457883
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-10-28 11:26:29 -07:00
Fedor Shcheglov 33fcfbf3ab Implement DotShorthandConstructorInvocationImpl support for argument list context.
Bug: https://github.com/dart-lang/sdk/issues/61843
Change-Id: I54118ea6599c30e36918dd3255f6c79b2f02280e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/457801
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-10-27 20:46:32 -07:00
FMorschel 56ccc3f887 [DAS] Fixes Go to Definition for try/catch error/stack
Fixes: https://github.com/dart-lang/sdk/issues/61771
Change-Id: If815663ab6689a8f1b70812489f4e1abc7fa86e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456420
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-10-24 11:35:07 -07:00
Danny Tuppeny 0941ee70a0 [analysis_server] Add navigation regions for declarations of enums, extensions, typedefs, mixins
This allows Ctrl+Click on the declarations to fall back to Find References in VS Code, which is consistent with other declarations names.

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

Change-Id: Ic6b9de6597fa52dcb79e8f8ea946943e9101ca44
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/454081
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-10-10 10:38:49 -07:00
Sam Rawlins 793aeaee01 DAS protocol: Update comments to use markdown codeblocks
One can see that we have bare HTML in these signature-in-comments,
like:

  "contextMessages": optional List<DiagnosticMessage>

These are flagged by the unintended_html_in_doc_comment lint rule.

This CL solves this by indenting these signatures 4 spaces, making
them Markdown indented code blocks. Alternatively we could use
backticks. Backticks would make the comments taller; indenting makes
them wider. I would prioritize whichever style is less intrusive when
reading them in plain text, which I think would be to use
indentation.

Change-Id: I019d9073e994a505325194ceeac3c6e0635d947e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/453642
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-10-08 09:16:20 -07:00
FMorschel f58012e81b [DAS] Fixes writeType importing shadowed type by local declaration
Fixes: https://github.com/dart-lang/sdk/issues/59701
Change-Id: Ief2816ee8b05296adfdbb4f2c1f01a8892711136
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/451404
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-10-06 14:49:53 -07:00
FMorschel 3e7ba3e234 [DAS] Fixes "Create missing overrides" for unary operators
Fixes: https://github.com/dart-lang/sdk/issues/61127
Change-Id: I8f50bc0cec05734ddb182256345ccb1462c35636
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442800
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-09-26 11:18:56 -07:00
Danny Tuppeny 68f0d0e3a9 [analysis_server] Fix handling of edits that require sequential processing
This moves the check for whether we need to apply edits sequentially to above some of the validation checks (because they are only applicable if not applying sequentially) and tweaks the logic slightly.

It also removes a third copy of this function in analysis_server that was only used in one test, so we're down to two copies now (analyzer_plugin and analysis_server_client).

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

Change-Id: I89ac94e8fd65e904c4eddcd8f1ebba3bf1293487
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/450380
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-09-18 09:43:06 -07:00
Sam Rawlins b1944f9529 Improve mismatch exception, wrapping field names in quotes
When hitting a protocol error, I saw some errors that were confusing
for a moment because of the lack of quotes, for example:

> Invalid parameter 'params'. Expected to be files; found \"...

This CL doesn't actually improve the situation _much_, but it at least
puts quotes around `files`, to indicate it is a property or something
similar.

Change-Id: Ic12d063b427661025cd4418951c58abf3394df3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/449220
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-09-15 11:47:54 -07:00
Sam Rawlins b40781459a Bump analyzer_plugin to use Dart SDK 3.9.0
Change-Id: Ice7b7e978ccc666c18cbea9cb9e79673893066ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/448221
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-09-02 14:07:49 -07:00
Sam Rawlins 26102c5d52 DAS plugins: Wire up initial screen for new plugins.
This renames the old screen, "Legacy plugins" and adds a new screen,
"Plugins". On the new plugins screen, we ask the plugins isolate(s) for
their plugins details, and print the following, for eadh plugin:

* the plugin's name
* the names of the registered lint rules
* the names of the registered warning rules
* the IDs and "messages" of the registered assists
* the IDs and "messages" and associated diagnostic codes of the
  registered quick fixes

More to come in follow ups:

* The resolved versions of plugin packages (coming from package_config.json)

Change-Id: Ic3dc4c5bffa64fd4da4097c042a847cc064e41ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/447763
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-09-02 08:38:32 -07:00
Kallen Tu 9342bac2d9 [parser/analysis_server] Dot shorthands: Code completion for 'const .'
Parser and analysis server changes for adding code completion for `const .^` where `^` is the cursor location.

I modified the parser to handle recovering when we were parsing a dot shorthand constructor invocation that was incomplete.

Added analyzer tests, code completion tests, and frontend parser tests.

Fixes: https://github.com/dart-lang/sdk/issues/59836
Change-Id: Ia200ebd9149658d7563c4942afd749c262c52dc5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446987
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-09-02 08:37:48 -07:00
FMorschel 7c754d325d [DAS] Adds typeParametersInScope for DartEditBuilder.writeType and related methods
This change adds a new parameter `typeParametersInScope` to `DartEditBuilder.writeType`, and related methods to deprecate the previous `methodBeingCopied` parameter, which limited our ability to pass in some type parameters that are in scope.

Also fixes a TODO about testing if the `Record` feature is enabled or not.

And as a bonus, we now always write down type parameters by looking for the closest public type or falling back to `Object?` or `dynamic`.

Bug: https://github.com/dart-lang/sdk/issues/61186

Change-Id: I7a7b1c62adb81aecfdf61ebbaa0d95f1d33bced8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442282
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-08-29 10:32:10 -07:00
Sam Rawlins 1b212e6cee DAS: improve error-throwing code to include JSON
Most calls to `jsonDecoder.mismatch` include the 3rd argument. I add
more here, so that the error can say, "I expected this field in some
JSON, but instead the JSON looks like this: ..."

Change-Id: I7d1944624e1fe758d9732d71db6571a579dc4690
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/447360
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-08-27 11:31:39 -07:00
Konstantin Shcheglov 32124f25a0 API. Deprecate 'VariableDeclaration.declaredElement', use 'VariableDeclaration.declaredFragment'.
This makes API consistent.

Bug: https://github.com/dart-lang/sdk/issues/61231
Change-Id: I841dc10cd2ef4b28286d374af26c079dcf69179e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/444863
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-08-12 14:30:49 -07:00
Kallen Tu b2f2dc01a3 [analysis_server] Dot shorthands: Update AddEnumConstant fix.
Update `AddEnumConstant` fix to handle dot shorthands. Added some relevant unit tests.

This revealed a bug in `change_builder_dart` where we'd crash with an enum with no constants. Added some tests for that in `create_field_test`.

Bug: https://github.com/dart-lang/sdk/issues/60994
Change-Id: Id75b79b8717305ddca3092fc35cadec7677177df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/443363
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-08-06 14:44:20 -07:00
Kallen Tu c5eba84538 [analysis_server] Dot shorthands: Code completion for methods and constructors.
Update code completion to handle completing static methods and (non-const) constructors.

Additionally, I noticed that we weren't suggesting any completion for extension types? I added the case for it and a few tests.

Bug: https://github.com/dart-lang/sdk/issues/59836
Change-Id: Ib677cd99e51b8a641aa1bfbad5ffc8a8cbdc38c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441681
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-08-05 15:36:57 -07:00
Danny Tuppeny 784fdb4a1f [analysis_server] Move EOL from ChangeBuilder to FileEditBuilder
Because ChangeBuilder can be used to modify multiple files, the EOL should come from an individual files edit builder and not from the overall ChangeBuilder.

This change renames `eol` on ChangeBuilder to `defaultEol` (since it's still useful to supply a custom default, for example when moving a class from an existing file to a new file, we want to default to the same EOL as the source file), and adds an EOL to file edit builders which is computed from the file content (and falls back to the default from ChangeBuilder if there are none).

My intention here is to not introduce any breaking changes (yet) so the ChangeBuilder constructor interface still has the "eol" named parameter (marked as deprecated) as well as the new `defaultEol` parameter.

I added a new `StringExtension` for `endOfLine` to both analyzer_plugin and analysis_server_plugin as we need this in both places (but I expect one of those projects will ultimately be dropped). This slightly differs from `CorrectionUtils.endOfLine` because it can return `null` which is a signal to fall back to the ChangeBuilder default instead of forcing its own default. (CorrectionUtils.endOfLine now uses that extension, although because of the null/default, it's likely that some - if not all - uses of this should migrate to the new extension and fall back to a default from a ChangeBuilder).

Change-Id: Ie2e6eaba78c96a1cbd79eba881e12bbeef724aa8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/443122
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-08-04 14:56:40 -07:00
Konstantin Shcheglov 6311478193 Elements. Add documentationComment and metadata to Element and Fragment.
Bug: https://github.com/dart-lang/sdk/issues/61216
Change-Id: I46ee0dfe2a720d61b3b4576634cf623b8817d0ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/443149
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-08-01 09:04:47 -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
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
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
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
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
Fedor Shcheglov 238cd4c20a Deprecate constants2, lookUpInheritedMethod2, lookUpInheritedMethod2, classes2, classes2, extensionTypes2, extensions2, functions2, libraryExports2, libraryImports2, libraryImports2, mixins2, topLevelVariables2, typeAliases2, join2, isNonSubtypableClass2, and typeParameters2.
Change-Id: Ia4b5504d91548b561e2e2434e711c40b2dc5e495
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/440100
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-07-12 16:23:12 -07:00
Fedor Shcheglov 7218145cd2 Deprecate appendToWithoutDelimiters2, correspondingSetter2, unnamedConstructor2, getNamedConstructor2, entryPoint2, exportedLibraries2, getClass2, getEnum2, getMixin2, exportedLibrary2, accessibleExtensions2, importedLibraries2, importedLibrary2, isImplementableIn2, join2, variable3, getter2, setter2, correspondingGetter2, superConstructorParameter2, aliasedElement2, typeParameters2, constantInitializer2, and isNonSubtypableClass2
Change-Id: I091804b9f200f525baf3979773dd489e3be17697
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439640
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-07-09 20:34:14 -07:00
Danny Tuppeny 077f16021f [analysis_server] Include DocumentLinks to Pub for dependency_overrides
+ a small refactor to stop using a Map to verify links because we can have multiple instances of the same package name in the file now, so mark up the ranges in the file and verify against them.

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

Change-Id: I83d452be37c7eeb8579adc488b0a59a366c9fe5f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439500
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2025-07-09 11:20:49 -07:00
Fedor Shcheglov 933f3da0f7 Deprecate appendToWithoutDelimiters, correspondingSetter2, unnamedConstructor2, getNamedConstructor2, and typeParameters2
Change-Id: I42dcff17c5bb0c9d6c3ae55dcdd4df85d83cd076
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439560
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-07-09 11:13:07 -07:00
Fedor Shcheglov 1a88edceb7 Deprecate redirectedConstructor2, superConstructor2, children2, displayString2, getExtendedDisplayName2, isAccessibleIn2, thisOrAncestorMatching2, thisOrAncestorOfType2, constants2, field2, typeParameters2, children3, asInstanceOf2, instantiateInterfaceToBounds2, and instantiateTypeAliasToBounds2.
Change-Id: I82004d5d1c758aae51ec8c97645aa53ed8cc52bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439383
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-07-09 07:13:51 -07:00
Fedor Shcheglov 247ae2364f Deprecate Element.name3, use name instead.
Change-Id: I24a5e4a519b9f3bf755912f21a5c192edd1dd4ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439381
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-07-08 14:13:49 -07:00