Commit Graph

591 Commits

Author SHA1 Message Date
Konstantin Shcheglov 6cd3938741 Breaking changes for analyzer 13.0.0
https://github.com/dart-lang/sdk/issues/62799
https://github.com/dart-lang/sdk/issues/62944
https://github.com/dart-lang/sdk/issues/63002
https://github.com/dart-lang/sdk/issues/62970

Looks mostly green in google3: https://fusion2.corp.google.com/presubmit/901021300/OCL:901021300:BASE:901308428:1776439417713:37cd1695

Change-Id: I44754a48f66a0b58851d7c20fcfa61f7fb1b555a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488624
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-04-17 23:06:25 -07:00
Danny Tuppeny 0b9b70a81b [analysis_server] Fix some minor bugs in hovers
Two fixes here:

1. The code that tried to compute a relative path from the "package root" was using the "context root" which in a Pub Workspace is not the same. Now we instead first try to get the package via `workspace.packages.packageForPath()`.

2. We used underscores for italics in the package name, and in GH Markdown, underscores at what it considers word boundaries can mess things up, so `_package:_foo_` would be rendered incorrectly. Now, we use single asterisks for italics instead.

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

Change-Id: I72dc736aef32c85a9e4fce8a0aad552a5a4e3c14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/491840
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2026-03-31 11:05:45 -07:00
Danny Tuppeny 2bf4d20cd3 [analysis_server] Improve handling of inheritance in LSP Document Highlights
With this change, we collect elements for all supertypes for the element at the supplied position. Then when walking the AST, we check whether each items elements or any of its own supertype elements match against that set.

This should result in all of the items the user would consider "reachable" from the starting location. This does mean some results are not symmetric (see the `fromLeaf` and `fromRoot` tests), but I think they are the most logical. While VS Code currently has a bug related to asymmetric highlights, I believe this will be fixed (because TypeScript also behaves this way).

This does add a little more work, but when walking the AST, we do check the name first as a quick check before we look at any supertypes.

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

Change-Id: Id2bcdff04c6c7826f8a164ecf99752951f641b8a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490960
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-03-26 14:30:41 -07:00
Danny Tuppeny f300269d0c [analysis_server] Exclude NameWithTypeParameters from selection ranges
This makes things more consistent between class/mixin (that have different ASTs) but also avoids jumping to the name+type args which probably isn't what you'd expect.

Change-Id: Ibd5e2a9b332c4c214ccc753080a61b1222445485
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490260
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-03-24 10:20:30 -07:00
Danny Tuppeny 811849dd1e [analysis_server] Fix LineInfo used in Type Hierarchy
This fixes the LineInfo used for type hierarchy, no longer assuming that the Element is in the same file where Type Hierarchy was invoked.

It also removes some of the fetching of LineInfos for files and caching them, since we can now access the LineInfo from a LibraryFragment much more easily.

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

Change-Id: I3dd3527cf4afb9ae3171b90def02452d04ffa9c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488481
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-03-17 08:49:50 -07:00
Konstantin Shcheglov e655e9fd6c DeCo. Add ClassBody.members, EnumBody.constants, EnumBody.members
Add `ClassBody.members` and `EnumBody.constants`/`members` so callers
can access class and enum contents through the common body interfaces
instead of pattern matching on `BlockClassBody` and `BlockEnumBody`.

Implement empty node lists for empty class and enum bodies, update the
public API, and migrate analyzer, analysis_server, analyzer_plugin, and
linter code to use the new accessors directly. This removes the ad hoc
`members2` helper extensions and a large amount of repeated `tryCast`
and `switch` logic, making body traversal more uniform.

Change-Id: I51d75f2253c7e6f75efecae84bf0443ff5eb6788
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488263
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-03-16 19:29:20 -07:00
Konstantin Shcheglov e9d8109258 DeCo. Support empty bodies in membered declarations
Allow enums, extensions, and mixins to use `;` as their body and
represent that form explicitly in the AST. The parser now produces
`EmptyEnumBody` or `EmptyClassBody` for the empty form.

Also replace `LibraryIdentifier` with token-based `DottedName` and store
the full token sequence for dotted names. This preserves periods and
source offsets directly in the AST, which keeps printing, selection, and
directive name handling working with the new shape. See
https://github.com/dart-lang/sdk/issues/62819

See https://github.com/dart-lang/language/issues/4645

Google3 presubmit looks green:
https://fusion2.corp.google.com/presubmit/884063020/OCL:884063020:BASE:884079610:1773618867493:b2110d76

Change-Id: I2d023cd03b6423da634c3e14742e02a61dc3b403
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486080
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-03-16 08:56:11 -07:00
Danny Tuppeny c3cc1d53a3 [analysis_server] Add test for hover with factory()
This was recently updated for `new()` but didn't handle `factory()`.

Change-Id: I8a75dcbfa7d5454e0758f0ff8f2ca1bb7bd5ddfa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/484740
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-03-02 08:44:08 -08:00
Brian Wilkerson 6225aade99 Add tests for hover and primary constructors
The previous set of tests missed two cases:
- a primary constructor with a private named parameter
- constructors introduced by `new`

The latter had some bugs, which are fixed in this CL.

Change-Id: I872a3948dd1b0f791dbea1354c8377e83048e618
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/484227
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-02-27 21:18:20 -08:00
Danny Tuppeny 8d983debe0 [analysis_server] Update call hierarchy for factory keyword
+ fix some typos

Change-Id: Ic4f05cc57130657445f3c2f5312998d018f56a8e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483540
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-02-25 08:59:41 -08:00
Danny Tuppeny 329c861be8 [analysis_server] Fix document highlights for factory + tests for references
Change-Id: I63551ea9ac9faf114d5b07e6ed86b673651ef92a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483520
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-02-25 07:47:42 -08:00
Danny Tuppeny 2a375317f4 [analysis_server] Deprecate HighlightRegionType.BUILT_IN and always use KEYWORD
Change-Id: I86ff7edc2b4de5910b19f6bdb0d4422b7546897a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482820
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-02-23 07:44:32 -08:00
Danny Tuppeny 7b0732f272 [analysis_server] Handle new constructors and include primary constructor bodies in Outlines/Document Symbols
Fixes `new` constructors showing up as `<unnamed>` and also adds a `this` entry in the outline for primary constructor bodies.

Change-Id: I46efa9b65824d726b8544e5fabc31ee9f7ca43ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/481960
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-02-19 13:14:09 -08:00
Danny Tuppeny f06562cbda [analysis_server] Tweak handling of factory keyword without type names in constructors
Change-Id: I4d162ef66300caa07fd64f7de338c6ed1df04fc1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/481963
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-02-19 13:13:10 -08:00
Danny Tuppeny c9ded6a356 [analysis_server] Support constructor "new" keyword in semantic tokens / highlights
Change-Id: Idceb8a2e34262336d90b968a16222b0584dd3f76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/481961
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-02-19 11:33:53 -08:00
Danny Tuppeny 74588039e9 [analysis_server] Expand tests for Document Highlights + References for "new()" constructors
Change-Id: I7fdec7b2e3bfcd139d0ba4d0e78cecce8931c8a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/481780
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-02-19 07:48:33 -08:00
Danny Tuppeny c91f8128c9 [analysis_server] Expand tests for Call Hierarchy for new() constructors
Change-Id: Ia668ec18f1418384c20043464913791abe230ee5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/481800
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-02-19 07:43:18 -08:00
Danny Tuppeny 2c9cfbd1e1 [analysis_server] Change LSP document highlights computer to not build all groups for the whole file
As a copy of Occurrences, this computer would previously build all of the groups for all elements (/loop nodes) in the document and then filter at the end.

With this change, we determine the target element(s) or node first, and then only collect the related tokens as we walk the AST.

This should reduce the amount of memory used and reduce the cost of doing something like https://github.com/Dart-Code/Dart-Code/issues/4670 which may add some additional computation for resolving members to their super-most element.

Change-Id: Id516dbdf26b0b6ac3b1bedc7bc092f1f79f94a95
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/479622
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-02-11 08:41:39 -08:00
Danny Tuppeny 4fe1e12283 [analysis_server] Split LSP document highlights away from legacy occurrences
This moves the LSP handler off the legacy servers occurrences onto its own copy in `computer_document_highlights`, and then removes the LSP-specific parts from the original occurrences class.

The implementation of `DartDocumentHighlightsComputerVisitor` is an exact copy of the original `DartUnitOccurrencesComputerVisitor` with no changes yet (to simplify reviewing, and have a better git history for changes that are made in future CLs).

Change-Id: Iea884522f6cbd760b8443d8e4525558de699f87b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/479560
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-02-11 08:11:06 -08:00
Konstantin Shcheglov c410e613b1 CQ. Use isDeclaring to outline primary constructor fields.
DartUnitOutlineComputer adds field outlines for primary constructor
parameters that declare implicit fields. Previously this relied on a
syntactic heuristic (`final`/`var` keyword checks) via
FormalParameterExtension.isDeclaringParameter, which duplicated analyzer
logic and could misclassify parameters.

Switch to the resolved element model instead:

- Read the declared fragment element for each primary constructor
  parameter.
- Add a declared-field outline only when the element is a
  FieldFormalParameterElement with isDeclaring set.

Remove the now-unused AST extension and its import.

Change-Id: Ic0780a0cb9af1519d9a1f39a116e935eda52ab8f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478244
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-02-04 13:39:12 -08:00
Sam Rawlins 2ba33b6448 DAS: Use semicolons to breakup related independent clauses
Change-Id: I8fd2852b0ae481975077d325e54b21a4921d9572
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478023
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
2026-02-03 09:49:44 -08:00
Danny Tuppeny 5a9603b18e [analysis_server] Support primary constructors in Call Hierarchy
For consistency with other things, we're generally just using the declaration for all ranges/positions, but we do support invoking call hierarchy on the `this` keyword of the body for convenience too.

Change-Id: I52e7a02a33f36f69775fb1231cc06095d47ecda9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/477740
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-02-03 08:20:19 -08:00
Danny Tuppeny e1928bc20f [analysis_server] Support primary constructors in Go to Super
Change-Id: I4038b5ef499215a45633da2ab96760b8b05feb8a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476220
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-02-02 12:48:16 -08:00
Keerti Parthasarathy 930e5fdaa7 Add hover support for primary constructors
Change-Id: I3ec1f577dc8d469d8c4c415927f0ff5ee4c5f5f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475780
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2026-01-28 14:52:20 -08:00
Danny Tuppeny 1864ef2053 [analysis_server] Add "extends" to syntax highlight primary constructor tests
This was left out of the tests originally due to a crash at https://github.com/dart-lang/sdk/issues/62396 which is now fixed.

Change-Id: Ie1d95dba9a24a04decad269c41f6b4247191875c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/473320
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-01-23 10:15:17 -08:00
Danny Tuppeny 6eb9a1fc1e [analysis_server] Update syntax highlighting + semantic tokens for primary constructors
Change-Id: Ia47a868cf82dac8be197db9aa272d159790d6641
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472563
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2026-01-15 09:42:19 -08:00
Danny Tuppeny 3d8d622bf9 [analysis_server] Handle DefaultFormalParameter when building outlines for primary constructors
Fixes https://github.com/dart-lang/sdk/issues/62390

Change-Id: I07fb558c1ccbd8b3dc7680c4423032509a85ef47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472400
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2026-01-14 09:21:23 -08:00
Konstantin Shcheglov d9b88bd48c DeCo. Add PrimaryConstructorDeclaration.body and PrimaryConstructorBody.declaration to API.
Change-Id: I1164941486002ab79df70d1baf0121b3593b12b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472441
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-01-12 16:14:23 -08:00
Danny Tuppeny d54b0c5772 [analysis_server] Handle classes with primary constructors and no body in outline
I noticed if you use `;` instead of `{}` the class wouldn't show up at all.

Change-Id: I2c4dd6491e728c18e4ddc19125e35a5110347ae0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472224
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-01-12 11:20:14 -08:00
Danny Tuppeny bab16ed884 [analysis_server] Handle folding for primary constructors + some constructor fixes
Change-Id: I11174e465573c68b454d5bcd3757e1e0141c4f66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472221
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-01-12 09:08:08 -08:00
Brian Wilkerson 1cadcbd88b Add legacy outline support for primary constructors
This might address the other outline related features, but I decided to
add tests for those separately.

Change-Id: I67b1e5a8b24a3aa8129201be58fcd321e5137859
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471344
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-01-08 14:46:30 -08:00
Brian Wilkerson 7ed0d8d7b2 Fix a crash in the outline computer
This isn't the right implementation, but it no longer crashes when
experimenting with the primary_constructor feature.

While I don't expect this to impact users, it makes it easier for us to
play with the feature while developing the tooling for it.

Change-Id: I317eb03bfd4057adb39dd4352e43e41fdd28bd7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469101
Auto-Submit: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-12-18 13:01:59 -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
Danny Tuppeny eaba16ce3b [analysis_server] Fix selection of Type Hierarchy node for comment references
Fixes https://github.com/dart-lang/sdk/issues/62119

Change-Id: I929ab73010686d6f454a478e4420c886754ef3af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465682
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-12-02 14:01:41 -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
Danny Tuppeny 75fd0906fa [analysis_server] Support dot shorthands in colour picker
Adds support for detecting colours in dot shorthands so they get colour pickers, and also changes the colour presentations when using the colour picker to use dot shorthands in the replacements (though the label will still contain the color class name).

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

Change-Id: I6a7a16f6f613ed6b9a093e22c5665ccc009b320d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463340
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
2025-11-25 10:02:51 -08:00
Konstantin Shcheglov e61aa1107d DeCo. Add ConstructorDeclaration.typeName, switch analysis_server/ to it.
Not actual migration, uses null asserts.
Should be made safe as part of implementation in the server.

Bug: https://github.com/dart-lang/sdk/issues/61701
Change-Id: I792ca9d05f25d3819d83a6119586ef937f00d31f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463464
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-11-20 13:52:56 -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
Sam Rawlins 6910a34b0a DAS: Correct calculations of whether an element is deprecated
I missed examining these use cases when I introduced the other
Deprecated constructors. But this leads to some UI bugs (like hover and
suggestions showing strikethrough) and relevance bugs in DAS.

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

Change-Id: Ief71c4d70d57f989aaf5c2d7159f418d706d6a03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462742
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-18 13:22:11 -08:00
Konstantin Shcheglov 68058cf0b3 DeCo. Deprecate NamedCompilationUnitMember.
Bug: https://github.com/dart-lang/sdk/issues/61701
Change-Id: I6de6874d27423d466d8bb5a5a75a8c26518fa557
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462562
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-18 10:22:13 -08:00
Danny Tuppeny ef9a322196 [analysis_server] Fix hover ranges on operators
Fixes https://github.com/dart-lang/sdk/issues/62000

Change-Id: I35277f538903d54a9a0a74ee632d5cdc43c11080
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462445
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-11-17 10:01:22 -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
Danny Tuppeny 7a16a44aee [analysis_server] Add support for type inlay hints for dot shorthands
Fixes https://github.com/dart-lang/sdk/issues/61841

Change-Id: I0697c9a05639e723aec32e84b1680f72a2241d5c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/458300
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
2025-10-29 12:12:23 -07:00
FMorschel b668fc8d3f [DAS] Fixes hover for try/catch error/stack
Fixes: https://github.com/dart-lang/sdk/issues/55907
Change-Id: I385483eaf5cba4fbac10b402cdb87ace51e9b020
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456400
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-10-24 21:55:08 -07:00
Danny Tuppeny a0eb8c5783 [analysis_server] Fix Call Hierarchy target selection for tear-offs
This fixes `_findTargetNode` on function tear-offs. Previously it would take the parent node of many `SimpleIdentifiers` which in the case of a tear-off could be some random expression.

Now we only return something other than the `node` in some very specific cases where we're trying to handle constructors (so that the type name is not considered a call for named constructors, but is considered the constructor for unnamed constructors).

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

Change-Id: I815d4dc8e1f1eaadd5ee033abf9731666944e45e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/457061
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-10-23 14:10:32 -07:00
FMorschel b243e6aae5 [DAS] Fixes semantic token for FunctionType.call
Bug: https://github.com/dart-lang/sdk/issues/61319
Change-Id: I4b42c410ff8e901da546d71658e37a5da6a410aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/451620
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-10-17 09:47:27 -07:00
Danny Tuppeny 25f86fe0ff [analysis_server] Fix syntax highlighting for a function's "call" method
+ some additional Hover tweaks

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

Change-Id: Ia1ab56ed4f186a820ce1b36402e1c7042ed23068
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/449802
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-10-07 11:09:38 -07:00
Sam Rawlins 33f664940a Bump DAS to use Dart SDK 3.9.0
Change-Id: I04bc285d822a657adb5573c6de3eb38655ab0fcd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/448232
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-09-03 12:56:29 -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