Commit Graph

1264 Commits

Author SHA1 Message Date
Danny Tuppeny c1ebd226ea [analysis_server] Mark the dart.lineInfo setting as deprecated in LSP docs
This should be set in `analysis_options.yaml` now (since it applies to all IDEs and CLI invocations of tools). I've also marked this as a legacy setting in Dart-Code.

See https://github.com/Dart-Code/Dart-Code/issues/5943.

Change-Id: Ief585c08f1986afc2ddc40bc66b921bc368139a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489942
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-03-23 14:35:20 -07:00
Ben Konyi 2a83a78213 [ DAS ] Add initial support for widget preview detection service
The Flutter Widget Preview feature is currently implemented within
Flutter Tools, which is responsible for detecting widget preview
annotations in the user's project. When previews are detected, the
Flutter Tool injects code generated based on the detected previews into an artificial widget_preview_scaffold project and performs a hot reload to render updates to the preview set in the scaffold application.

`package:analyzer` is currently being used to detect previews, but this comes with a significant amount of memory overhead. Since widget
previews are mostly being used from within IDEs which already have an
active analysis server, moving widget preview detection into the DAS
will remove the need for creating an additional analysis context in the Flutter Tool itself.

This change includes the initial work to move widget preview detection
into the DAS. It utilizes a pull-based mechanism, where the Flutter Tool listens for file system events and then queries the DAS using the `dart/textDocument/getFlutterWidgetPreviews` and `dart/workspace/getFlutterWidgetPreviews` LSP methods.

Each reported preview contains some generated code based on the annotation used to define the preview. This code has all constants from the original annotation evaluated to either primitive values or constant expressions with namespaces applied to each symbol, allowing for the Flutter Tool to inject this code directly when updating the generated code in the scaffold project.

Towards https://github.com/flutter/flutter/issues/179584

Change-Id: I043cb3235a66b25dda3f852ca7f147bff0e1e537
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478100
Auto-Submit: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-03-22 19:19:03 -07:00
Lasse R.H. Nielsen 56505e0575 Stop using Match.group.
The `Match.operator[]` does the same thing and is
generally recommended (and shorter).
(I want to deprecate `group` and `groups`)

Tested: Refactoring.
CoreLibraryReviewExempt: Calling equivalent function.
Change-Id: I4c758968ae622fe16b7322be1b29b05b91e7fcd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489021
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2026-03-20 09:09:46 -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
Sam Rawlins 7d0a17196c DAS plugins: Add print-debugging support in Insights pages.
Work towards https://github.com/dart-lang/sdk/issues/61868

This adds a new notification type, 'PluginPrint'. There are several
fields and variables then named 'pluginPrint' or 'print', and I am
definitely open to changing these names, but this is the best one that
I thought of.

PluginPrint has three fields: The name of the plugin that printed, the
message that was printed, and the timestamp.

We wrap each plugin's AnalysisRule invocations with a zone, so that
the `print` handler can know the name of the plugin. The prints are
caught and sent to the server isolate as Notifications. The
PluginIsolate then stores the collected prints. The Plugins Insights
page can then retrieve them and display them.

Manual testing, with 1000 libraries that get new lint reported once per
file, I did not observe a negative performance impact.

Change-Id: Id800ae41781c15ce89d06b563878c2b0edae43d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486827
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-03-16 14:56:59 -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
Paul Berry 07b214eef5 Bump analysis server to language version 3.12.
Also start using the "private named parameters" feature.

Change-Id: I1c6da5f8ae2985e12313d405a2eb419c6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487521
Auto-Submit: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-03-12 14:18:11 -07:00
Sam Rawlins fe0afebf55 DAS session logger: Normalize paths as log entries are written.
This copies much of the logic from the normalize.dart standalone script.
It normalizes "workspace folders," context roots, and the Dart SDK path.

I tweaked the SessionLogger constructor to instantiate its own
`SessionLoggerInMemorySink` rather than the caller needing to call it.

And then the `SessionLoggerInMemorySink` instantiates the
`SessionLoggerFileSink` so that the caller doesn't need to worry about that. This lets the sink and the nextLogger each be final, and removes
details about what I consider "SessionLogger implementation details"
from the caller's concern.

When a SessionLogger is instantiated, it creates a LogNormalizer which
the SessionLoggerSinks use to normalize log entries.

I almost used
`WorkspacePackage.packagesAvailableTo(String libraryPath)`, but it
seemed unnecessary to require a file path (there is a TODO about
considering files in/out of the 'lib' folder, but not necessary for this
work). So I made `Workspace.packages`, as most of the subclasses
already implemented this concept.

Bug: https://github.com/dart-lang/sdk/issues/62697
Change-Id: Ic57fec490414cef7028c290614363623e88f5c15
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485260
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-03-10 11:29:06 -07:00
Brian Wilkerson 2ddceeaa3f Update the relevance table generator
This is the first CL in what will probably turn out to be a fairly large
number of CLs. The goal is to get the relevance table generator up to
date so that we could then use it to generate new tables, thereby,
hopefully, improving the ranking of completion suggestions.

It includes two sets of changes, and if it would be easier to review I
can split it into two CLs.

The first set of changes is to add visit methods for all of the AST
node classes. While the use of a recursive visitor doesn't allow the
compiler to let us know about missing visit methods, I temporarily
changed the superclass in order to ensure that all of them are
overridden. I want to do that so that we can know when a lack of data
collection is intentional vs. just an oversight.

Which is where the second set of changes comes in. This adds a
mechanism to report if the generator ever sees a keyword or identifier
for which data should have been collected but wasn't. It does this by
recording all such tokens before visiting the AST, and then removing
tokens for which data is collected and tokens that we've explicitly
decided we didn't need data for.

In future CLs I want to get it to a place where we can validate that
the generator and the code completion passes are using the same set of
keys for the generated tables. I also want to add reporting if we have
failed to record data for an expected key because that would indicate
that the corpus used to build the tables is incomplete in its coverate.

Change-Id: I9cb4b729f558884e7321abd741e7b8dc85c997ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486260
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-03-06 12:09:50 -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 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
Keerti Parthasarathy c284947183 Look at root when running pub in project generator.
Not doing this was giving analysis errors at startup.

Also included a log for the test case on flutter/packages/pigeon. Had to trim it a lot, the actual session log was 13 MB.

Change-Id: I69c0e6111ea01fc21e4acd7751d91db78b513896
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482062
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Keerti Parthasarathy <keertip@google.com>
2026-02-20 07:04:19 -08:00
Keerti Parthasarathy 89859e5fa7 Keep track of all congiguration messages
Change-Id: I4c546fc13d10adf969a3903b42ea863f0e0cf875
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/481181
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-02-17 13:48:42 -08:00
FMorschel a750287f44 [analysis_server_plugin] Fixes non-LintCode fixes showing up for users
Fixes: https://github.com/dart-lang/sdk/issues/62658
Change-Id: I180934a9ead47ae25cf5ef9ea633f43a994ca3be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480080
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-02-13 13:58:19 -08:00
Keerti Parthasarathy ead50eae61 Add a scenario/log with multiple contexts
Change-Id: I515cd736461e099a9af2e6c89354204d508700d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/479340
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2026-02-10 14:20:09 -08:00
Jake Macdonald dea5b5c3aa Support initializing projects with multiple package configs, as well as
flutter projects more broadly.

Also added some TODOs for future work that needs to happen.

Change-Id: Iffad6f30f2df6a8e76a1aa179c2711105207470a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476880
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2026-01-30 12:43:38 -08:00
Cory R e76c7d64cd Fixing path issue on windows, adding new scenario for testing (also fixing formatting issue).
Change-Id: I2557542b76aaf1a7a50ec7ae1e7ecc59771cb910
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475125
Commit-Queue: Jake Macdonald <jakemac@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
2026-01-22 12:05:41 -08:00
Danny Tuppeny 2b88f4fea8 [analysis_server] Support String IDs in log replay + run some LSP integration tests with string IDs
My previous CL made some LSP tests run with String IDs instead of ints, but those tests don't appear to go through the session logger so did not fail with the casts here.

This change adds a base integration test that also uses string IDs, which did fail on the cast, so I've updated the session logger to use `Either2<int, String>` for IDs instead.

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

Change-Id: Iee582e9ce2b8b5a1127120c987670a679d2ca76c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/473260
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-01-21 12:24:27 -08:00
Brian Wilkerson f92ea3d58d Update the relevance table generator to support newer language features
I don't have a lot of confidence that the data being collected is what
needs to be collected in each of these cases, but I believe that I've
correctly identified the visit methods that need to be collecting data.

I think we need to have a test that ensures that the keys being used in
this table generator are the same as the keys being used by the
relevance feature computer (as computed by the in-scope pass). I don't
know exactly what that test would look like, but that would ensure that
(a) the keys are the same and (b) the table generator isn't missing
keys being used by the completion engine or collecting data that isn't
being used.

I also fixed a bug that prevented this generator from running and tested
to ensure that it could run over several example packages.

Change-Id: I0c0cff148d288942e39ee876e89cdf9d1468f59d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/473780
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-01-16 10:04:00 -08:00
Jake Macdonald 5b501e97a3 add readme for recording and creating scenarios
Change-Id: Id37f157896dfec9c7741e0a0079878c5287d9349
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/473560
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2026-01-15 16:03:28 -08:00
Jake Macdonald f904d1ebb2 Add custom message equality class to support ignoring certain map keys, skipping id checks, and supporting future customization.
Change-Id: I8da7c1ec4e6150ca699e5916b1d4ed9308c00bbb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472720
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2026-01-15 09:20:12 -08:00
Brian Wilkerson dddda28fb6 Capture workspace and file status in the log
This still isn't complete. It only removes file changes when a file is
closed and it ought to remove them when a file is saved, but I think
this is a minor enough hole that we can land this now and work on it
later.

It also still doesn't handle the legacy protocol.

Change-Id: If07d20fe61cc3d03167f9a930b67ddd59b8e97e1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471860
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-01-14 17:16:10 -08:00
Danny Tuppeny b5b452230c [analysis_server] Update toJson() methods to handle unions
Previously, the result of calling `toJson()` could still include some classes (like `List` and `EitherX<>` unions). This didn't cause issues because `jsonEncode()` would handle those types anyway (calling `toJson()` recursively), however changes to support the log replay are looking inside the returned Map and should see consistent types.

Change-Id: Ie52a7251ee10579de8ce605584feb82abc15eb8d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472900
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-01-14 11:26:20 -08:00
Jake Macdonald ba183805c9 Small improvements/fixes for analysis server scenario replay
- Return messages that fail to parse with the error response.
- Add support for open subdirs to projects, speeds up SDK replays.
- Fix up normalize script when package deps are subdirs of the project.
- Re-record the sdk scenario with only pkgs/analysis_server open.
- Fix some bad hard coded responses that were failing to parse.
- Add extra context (extra messages recieved) when scenarios fail.

Change-Id: Idfdcde70776967c2d419e76a21a6c6d1c59902f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472700
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
2026-01-13 13:51:26 -08:00
Jake Macdonald 4066e5b64c Get a working public github repo scenario.
- Adds support for normalizing package dependency roots using the
  package config
- Updates the project generator so it can handle multiple project roots
  and analysis contexts, as well as package configs.
- Handle sending watcher messages to the analyzer.

Removes the basic "initialization" scenario that didn't have any real
value other than being an example github project scenario.

Change-Id: I5b49effe524d325360a754296f4cc3578ad49527
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471360
Commit-Queue: Jake Macdonald <jakemac@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-01-07 15:26:12 -08:00
Jake Macdonald 1a0371034b Additional fixes for scenario replays
- Skip notifications from analyzer
- Hard code responses to certain startup logs if they are unexpected
- Use cli_util to show loading spinner and get sdk location
- Update normalize to substitute the sdk location
- Make id field optional on message (notifications don't have ids)

Change-Id: Ia5276eef554a3afefeae227fa7351f902d21131e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471060
Auto-Submit: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-01-06 13:34:56 -08:00
Jake Macdonald c2dc8f62a3 Add current directory project generator
This makes iterating on things faster, with the downside of requiring a clean git tree
to avoid bashing over pending changes.

Change-Id: I5725c288f6f4f4665e9cd8cc8d91cb77d214df2c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470340
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
2026-01-05 09:08:53 -08:00
Jake Macdonald fb40ed857a fix the normalize tool to only replace the path of the workspace uri with the placeholder (the path appears as a bare path in many parts of the file also).
Change-Id: Idccdd218b2c25db444c01efb3ce077117eb354f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470320
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-01-05 09:03:59 -08:00
Aman Gupta ebc9f84f50 chore: Fix typos in analysis_server error messages
Closes https://github.com/dart-lang/sdk/pull/62336

GitOrigin-RevId: 9871d040bbf7c85208e61962583b209a8418ffa5
Change-Id: I7b934e1df6a667c2f43ac4ff10552a3d5fae292b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470280
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-01-05 09:00:50 -08:00
Jake Macdonald e88d67e34a add a way to manually replay server logs one at a time or send custom messages (without requiring LSP headers)
Change-Id: Id662f52df392aab65228a2b69a830ad6058ebd55
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470760
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
2026-01-05 08:42:00 -08:00
Jake Macdonald db06bb7f13 Initialize SDK and regular projects on creation
Runs either `dart pub get` or `gclient sync`, based on project type.

For the SDK, copies the .gclient and .gclient_entries files as well
into the parent dir.

Also adds a `--timeout` argument, controls how long to wait for analyzer messages.

Change-Id: Id2c28e6d0251e94914bb0650be104c1f90a66651
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468620
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
2025-12-16 12:30:25 -08:00
Jake Macdonald 42e7de8f6c add the ability to run a single scenario, fix results getter
Change-Id: I74e0e0ddb20a2182d4dc4f5e37ffb6c1925ee4f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468360
Auto-Submit: Jake Macdonald <jakemac@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-12-15 13:51:30 -08:00
Paul Berry 8600df906e [messages] Add SyntacticEntity.sourceRange getter.
This will allow diagnostic reporting code in the analyzer to be more
easily converted to the new literate diagnostic reporting API, because
it will make it possible to use `SourceRange` as the common
denominator for situations where the location where a diagnostic needs
to be reported might come from either a `SyntacticEntity` or a
`SourceRange`.

Change-Id: I6a6a6964f3ec2ea33e8900d93b5abe714c9e1dcc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467682
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-12-15 09:02:26 -08:00
Jake Macdonald dadbd93260 change the log file format to be newline separated objects
Change-Id: I2257b2af5e28ac50b47b9a6cfe688abb7c9e8ac1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466401
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2025-12-09 14:51:16 -08:00
Paul Berry ca7780c402 [messages] Use lower case diagnostic names in analysis_server.
Changes the logic in `pkg/analysis_server` to use
`DiagnosticCode.lowerCaseName` instead of `DiagnosticCode.name`, and
`DiagnosticCode.lowerCaseUniqueName` instead of
`DiagnosticCode.uniqueName`. This ensures that diagnostic codes are
matched in a case-insensitive fashion.

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

Change-Id: I6a6a69643ef19385ab43d7a04809e58305ca4f0a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466185
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:25:01 -08:00
Jake Macdonald 307948681c match up actual analysis server request ids
Change-Id: I20b67c18c6d531cd378c27cc3b73a1bbf3e6908a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466260
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2025-12-08 10:48:45 -08:00
Jake Macdonald c5bc65395b match analysis server logs when replaying scenarios
Change-Id: I68fa02bbcbfa667d65fe07abe69a9f04a47daa13
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466240
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2025-12-04 11:43:49 -08:00
Paul Berry 527dd5a99f [messages] Change diagnostic codes to lower case in error_fix_status.yaml.
This paves the way for a follow-up CL that will standardize all
diagnostic names to `lower_snake_case` conventions.

For now, the case differences between the entries in
`error_fix_status.yaml` and the actual diagnostic code names are
accounted for by adding some calls to `.toLowerCase()` to
`verify_error_fix_status.dart`.

Change-Id: I6a6a6964b0eacf50b11f302ab511fba149b1ac07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465981
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-12-03 13:10:24 -08:00
Jake Macdonald d58a6ee53c Start on a log normalization tool
For now this just takes the workspace root and replaces all occurrences of it with {{workspaceRoot}}.

Change-Id: I14af057ddd4e20f002499670effb6f9e7101fce6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465500
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
2025-12-02 13:47:26 -08:00
Paul Berry 9c9ee03755 [messages] Stop including class name in uniqueName.
Modifies the code generation logic that populates the
`DiagnosticCode.uniqueName` field so that it doesn't include the
diagnostic's class name.

This paves the way for removing the last remenants of the diagnostic
classes from the analyzer.

Change-Id: I6a6a696453fe1f2bd8bd3cea00a9a496392fbf98
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464240
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-12-01 15:23:55 -08:00
Brian Wilkerson b262f60227 Code cleanup in log player and server driver
Setting the command-line arguments separately from the protocol used to
be necessary, but it no long is, so it's cleaner to just set the command
line arguments when creating the server and moving the handling of the
protocol option into the server. This resulted in a cleaner API and
implementation.

Change-Id: I9456e2a43310bb855b54c010af64ce0328a08ff7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464785
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2025-11-27 07:29:41 -08:00
Brian Wilkerson 11230466e7 Fix the handling of LSP headers
The invalid handling of LSP headers caused the analysis server, in LSP
mode, to not recognize any of the messages being sent to it.

Change-Id: I03b3c8e22216f3451401823dd62a49a984edc550
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464626
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2025-11-26 11:31:58 -08:00
Brian Wilkerson 7bbf6f9a7a Add the ability to generate export directives
This was used to test the timing of export cycles.

Change-Id: Ib7ddb6b46639f196e8db30039d25e64e8dc5f662
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464462
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2025-11-26 07:29:09 -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 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
Paul Berry 9bef3225fb [messages] Better validation for error_fix_status.
Adds logic to `verify_error_fix_status.dart` to validate that every
entry is a YAML map and contains a valid status code.

The error reporting logic is rewritten to make use of the
`LocatedError` class so that if validation fails, it's not necessary
to describe where to find the erroneous entry; instead, the offending
path, line number, and column is printed as part of the exception
message.

Change-Id: I6a6a6964c8cc3094f81ad2b28dd444bfcb6c15c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463084
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-11-19 15:17:50 -08:00
Paul Berry f72f7d2b16 [messages] Remove diagnostic class names from error_fix_status.yaml.
This is part of a larger effort to remove the diagnostic classes
entirely.

Change-Id: I6a6a69646c8d604d29d8e62da886628c3c9613ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462501
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-18 11:56:21 -08:00
Sam Rawlins e9bf7d423a DAS: Simplify == code to use one expression
The code used to generate:

```
bool operator ==(Object other) {
  if (Other is X) {
    return a && b && c;
  }
  return false;
}
```

which is just simplified to the one expression:

```
bool operator ==(Object other) =>
  other is X && a && b && c;
```

Change-Id: I0d1a80b57598bd8e840c0cd99304ace64f4cd786
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462740
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-18 10:40:09 -08:00
Jake Macdonald 4c7f0c1f41 Add some real scenario logs and get them running successfully.
- Move analysis server startup into log_player.dart, parse the protocol
  from the arguments.
- Add {{workspaceRoot}} and {{dartSdk}} root placeholder support to log
  files.
- Create logs of a real sdk scenario (rename the analysis server class),
  anonymize the logs using the placeholders.

Future work:

- We should add support for mutating a log to put in these placeholders.
- Figure out how we want to support package dependencies in a similar way.
- Implement the matching for server responses so the scenarios don't just complete early.

Change-Id: Ic0f6ac9c26da9d0a4473d08709aa05e9ff1e8536
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462620
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2025-11-18 10:11:36 -08:00
Jake Macdonald 5436fcde7d add analysis server scenarios, project generators, and a simple runner script
Currently supports a "git worktree" mode for running on local directories, as well as a "git clone" mode for cloning remote directories.

You can execute the script, but it will fail when it gets to replaying the logs due to the empty Json file, but this is a good start.

I think the next step here is to have some way of normalizing the logs so they are portable across machines/directories.

Change-Id: I8de5defe81c76f18c3bf3220e2a517a4247d4641
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462260
Commit-Queue: Jake Macdonald <jakemac@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-17 09:01:58 -08:00