Commit Graph

10086 Commits

Author SHA1 Message Date
Keerti Parthasarathy eb9cc6f5c9 Remove duplicate logic in KeywordHelper
Change-Id: I32e7643f785228b99961e50bc2380bdcdffca1d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430881
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-23 13:32:00 -07:00
Sam Rawlins b0b74b2810 Rename some loose ends w.r.t. "errorSeverity"
Change-Id: Id68fcd8bbbe45a95a294fd557ee4556c2af5c4c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430548
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-23 10:36:28 -07:00
Brian Wilkerson 2545c3eb31 Remove three more uses of NodeLocator2
Change-Id: I3e8fba0516bb0988ca0794991e980157dacb7231
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430860
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-05-23 10:22:17 -07:00
Brian Wilkerson 816b974c15 Report the number and sizes of library cycles
Reported in the report created by the diagnostic pages.

Change-Id: I44de39b8388101d8ef5c5d0ecd5d50c1a1f559cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430600
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-05-22 17:27:20 -07:00
Sam Rawlins 2dc94ee84a analyzer: Rename DiagnosticCode.errorSeverity to DiagnosticCode.severity
Change-Id: I244a96a940f82902a20e817fd13fe32026607ce3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430581
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-22 17:25:01 -07:00
Brian Wilkerson b55b2bb092 Refactor the performance reporting support
This CL contains no functional differences; it just reorganizes the code.

I expect to be adding data to the collected report, and I decided that
it would be better to break the massive method up before doing so in
order to improve overall readability.

I also wondered whether we might want to structure the data in a similar
way. For example, the top-level map could have entries corresponding to
each of these methods, each of which has a value that is a map
containing the data collected by that method. I don't know whether this
would make the output easier to read or whether the current form is
depended on anywhere, but it's something to consider for the future.

Change-Id: Id0ef3c2f64b00ea58069c496e7c485c7b3f163c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430560
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-05-22 14:06:00 -07:00
Kenzie Davisson 10dd59c039 Add a DTD method to get all registered services.
This CL contains breaking changes for package:dtd and prepares both package:dart_service_protocol_shared and package:dtd for publish.

This CL also fixes https://github.com/dart-lang/sdk/issues/60757 so that DTD-registered services are sent over the `Service` stream upon initial subscription like what is done for client-registered services.

Change-Id: I619af816e64af01864c7ed9b98743c6691bf7e0b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429161
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Kenzie Davisson <kenzieschmoll@google.com>
2025-05-22 13:52:54 -07:00
Sam Rawlins f2d416b866 analyzer: simplify PackageConfigFileBuilder.toContent
This API did not exist (was not public) in analyzer 7.4.x, so is safe
to change in 8.0.0.

Change-Id: Ib4a06008b1cdf1be4f33dcb9036ea87b6d258067
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430041
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-22 10:58:49 -07:00
Sam Rawlins 87f5185577 analyzer: Rename NodeLintRegistry to RuleVisitorRegistry, provide alias
Work towards https://github.com/dart-lang/sdk/issues/50986

Change-Id: Id0053b4721ca0517e315d5118ae48839dfaa3027
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429465
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-22 10:03:19 -07:00
Sam Rawlins e4810025ad Remove RuleState type hierarchy with an enum and condensed constructors
Change-Id: I07ee606b00467b8113f1722dba21b8c16cfe85b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429900
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-22 09:53:18 -07:00
Sam Rawlins 7a4c651eb3 analyzer: Rename 'errorCode' parameters in ErrorReporter
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: I4a3d320585967a4d2e8cbed430d2a67aa3f905fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430040
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-21 16:12:59 -07:00
Sam Rawlins f16cd980ce DAS: Deprecate CorrectionProducer.inheritanceManager
Change-Id: Id1772d47617a98ffc15d700a9bd7de58a04d745e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430020
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-21 14:42:21 -07:00
FMorschel f2776dfab1 [DAS] Fixes no parenthesis when inlining variables in literal expression
Fixes: https://github.com/dart-lang/sdk/issues/60761
Change-Id: Ide0f446712e5cda235e82bf69030bdc24c1441fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430001
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-21 10:13:31 -07:00
Danny Tuppeny 0f48263ac2 [analysis_server] Improve the performance of applying LSP edits in tests
This slightly improves the performance of applying edits in LSP tests. The previous code would sort the edits in reverse and then sequentially replace each edit into a string. With a large number of edits, both the string replacement and the subsequent rebuilding of LineInfo after each change could be quite slow.

With this change, we instead work through the edits forwards, appending the original text + new text into a StringBuffer to be combined once at the end.

Since most tests don't make large numbers of edits this only shaved a few seconds off the whole server test run, however when running a small benchmark of 20000 edits that Brian sent me recently, the time taken comes down from 42s (which hit the default test timeout) to 17s (which is not fast, but is faster).

Change-Id: Ia91937f4912b35ee1fe29f31157db3ef0e4bd79e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429960
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-05-21 09:01:05 -07:00
Sam Rawlins fb03a18f63 DAS: switch ConfigurationFilesMixin to use package getters
Change-Id: I4931f2b7598ea96313fb00963e5e154101d51c24
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429829
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-21 08:41:38 -07:00
Sam Rawlins 61c3582420 DAS: Migrate from InheritanceManager3 in corrections
Change-Id: I2adf06ba0a1b19c233bd54f5116e6f63c62b1fd3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429720
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2025-05-21 07:15:30 -07:00
Sam Rawlins e68d688abd DAS: Migrate from InheritanceManager3 in completion code
Change-Id: I097889fb2baaf71e99d765bcc076f1091383fbb0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429580
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-21 07:13:22 -07:00
Sam Rawlins 4ef189a513 linter: Rename State to RuleState, and sub-classes
Change-Id: Id74c1a34e0a3154e1720d323bf4002aceb092dd4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429160
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-20 15:52:54 -07:00
Konstantin Shcheglov 5d175fa43c Elements. Deprecate InterfaceElement.constructors2, use constructors.
Change-Id: I78faea1fdbc55e46cdb7fc0b187d12561736cec2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429822
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-20 15:11:42 -07:00
FMorschel 37edff79b1 [DAS] Adds new Remove async assist
Fixes: https://github.com/dart-lang/sdk/issues/59814
Fixes: https://github.com/dart-lang/sdk/issues/23962

Change-Id: I8121da0106f4f81b93bfcdc0908b0977210fa3c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425602
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
2025-05-20 12:56:40 -07:00
Danny Tuppeny d6cc4c3901 [analysis_server] Don't return the Fix All code action for legacy server
Currently the commands for Fix All are only supported for a real LSP server, so we shouldn't return a Source CodeAction that would try to run the command when running in the legacy server.

Change-Id: I3256ef5e19c3a45e7fc3f3ec726a59da30d3a30c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429642
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-20 09:30:09 -07:00
Danny Tuppeny 2a694349ef [analysis_server] Fix filtering of code actions to exclude mismatched kinds instead of throwing
No current tests hit this, but if you call verifyCodeActionLiteralEdits without a "title", you could trigger a failed expectation here that you should not - the mismatched actions should just be filtered out.

Change-Id: I6962c9f99a7a3051afcf3f76ad90945cd1381e0e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429621
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-20 09:26:49 -07:00
Sam Rawlins 9c6c7c5a25 DAS: Migrate away from InheritanceManager3 in feature_computer.dart
Change-Id: Ibee348643560a4ee079d53dfb2f65880de3c8354
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429464
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-20 08:30:30 -07:00
Sam Rawlins 540efbbb5d analyzer: Extract some public API from WorkspacePackage
Fixes https://github.com/dart-lang/sdk/issues/60725

Change-Id: I63e79075d6538810ddc518e96b5bb7430e55496b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428564
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-19 16:24:19 -07:00
Sam Rawlins 823908a435 Simplify ConfigurationFilesMixin
Work towards https://github.com/dart-lang/sdk/issues/55660

This mixin has some members that can be made private, and some that
can be removed.

Removing a `macro` parameter also simplifies things.

Change-Id: Id3b5d33ff66dde0c763499ff183943d72901d395
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429440
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-19 12:44:59 -07:00
Alexander Aprelev 1159405ad4 Revert "[DAS] Trigger incompatible lint for included rules"
This reverts commit 261f8199af 

Reason for revert: it breaks flutter customer testing on hh and on the roller.


Original change's description:
> [DAS] Trigger incompatible lint for included rules
>
> Fixes: https://github.com/dart-lang/sdk/issues/60125
> Change-Id: Icc0b8efda0e7e915d7315a1c2e70c1a7a5093057
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419982
> Auto-Submit: Felipe Morschel <git@fmorschel.dev>
> Reviewed-by: Samuel Rawlins <srawlins@google.com>
> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>

Change-Id: I0db90864092760efde1cb02cc792c1de14eabf2d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429381
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2025-05-19 10:08:35 -07:00
Danny Tuppeny ee0a316495 [analysis_server] Suppress snippet support for Command CodeActions
We support a non-standard mechanism (https://github.com/rust-lang/rust-analyzer/blob/b35559a2460e7f0b2b79a7029db0c5d4e0acdb44/docs/dev/lsp-extensions.md#snippet-textedit) for having snippets on edits for Code Actions. This is only specified for edits returned from `codeAction` requests (and only implemented in Dart-Code for the same), so we should not return snippets when applying edits via `workspace/applyEdit` (eg. when code actions are returned as commands).

This prevents snippet markup being inserted literally into the editor if codeActions are executed over DTD (eg. from property editor).

Change-Id: I7882bffb8038671459e7487dc2e944020395f128
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429340
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-05-19 09:32:06 -07:00
Brian Wilkerson 0dd4a95b3c Display correct line and column offsets for context messages
The line and column offsets for the context messages were being computed
based on line information for the file in which the diagnostic was being
reported, which can be different than the file pointed to by the context
message. This ensures that we use the right line info.

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

Change-Id: I6dbc95bde5aeb1abc70d90767dc59082982a5a96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429380
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-05-19 09:23:59 -07:00
FMorschel 652a419fdb [DAS] Fixes completion for collection ifs and fors
Fixes: https://github.com/dart-lang/sdk/issues/60604
Change-Id: I55a8426ae54a92fb26fd5a04e3dc11c267c26acf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428940
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-19 09:19:49 -07:00
Sam Rawlins e35e665259 analyzer_testing: convert all modifyFile users to modifyFile2
This also involves tidying up blaze_watcher_test, in order to
easily get back a File object from a helper method.

Change-Id: If9dc812dc3a97a205dee600b89c3e8490e9efcba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429201
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-19 07:11:23 -07:00
Sam Rawlins 750ecda6b3 Remove two underused methods from ResourceProviderMixin
Change-Id: I41f288f216e7db5a744d10a38074e104321e49f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429220
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-17 10:39:12 -07:00
FMorschel 261f8199af [DAS] Trigger incompatible lint for included rules
Fixes: https://github.com/dart-lang/sdk/issues/60125
Change-Id: Icc0b8efda0e7e915d7315a1c2e70c1a7a5093057
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419982
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-16 17:31:21 -07:00
FMorschel 83eb816e51 [linter] Adds new switch_on_type lint
Fixes: https://github.com/dart-lang/sdk/issues/59546
Change-Id: Ib78714e03c1487376c961214910d10c24ec9f8ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/413600
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
2025-05-16 16:00:54 -07:00
FMorschel 46348af8ab [DAS] Fixes Removes unused local variable with awaited expressions
Fixes: https://github.com/dart-lang/sdk/issues/60663

Change-Id: I290f29c3a07e2f20cfd6e78e87b5543fa8131a9c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426380
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-16 15:54:59 -07:00
FMorschel 3c6af25d4a [DAS] Fixes auto-complete import combinator update for enum constants
Fixes: https://github.com/dart-lang/sdk/issues/60565

Change-Id: I9bd4740b48569afe86c4a7f02412f5e50e654bfd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423621
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-16 15:52:51 -07:00
Sam Rawlins dfaf1514ea linter: discarded_futures: do not report on await-in-synchronous function
When a synchronous function body has an `await` expression, we report
an error. We don't need to _also_ report a lint.

The noted error, `CompileTimeErrorCode.AWAIT_IN_WRONG_CONTEXT`, already
is associated with the "add async" fix. Reporting a lint when an error
is also definitely reported is just double reporting.

Change-Id: If6d260a01cc654c87897480996d3f6f4b61373dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429063
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-16 15:34:20 -07:00
FMorschel 5b4dc61717 [DAS] Fixes coloring for record fields access in extension
Fixes: https://github.com/dart-lang/sdk/issues/60625

Change-Id: Idce84fbdc9b58b2e91c2e40a058bf466e8d5fb65
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426342
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-16 14:57:15 -07:00
FMorschel 52dc876ebf [DAS] Fixes extension instance member occurrences
Fixes: https://github.com/dart-lang/sdk/issues/60626
Change-Id: Ia1050fe54f9c2ff208092b00ecccce678b7e616a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424688
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-16 13:58:19 -07:00
FMorschel ade4bf824a [DAS] Fixes record extension field completion
Bug: https://github.com/dart-lang/sdk/issues/60625
Change-Id: I23e4a5a85dc15059c9b1e658fb2fc3f868fa91a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424684
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
2025-05-16 13:43:09 -07:00
Sam Rawlins b40b806bee DAS: enforce unnecessary_async lint rule
Change-Id: I05c6fbcc5ea7dea37bb7a01a3492e5cd842d11ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428923
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-16 13:37:53 -07:00
Konstantin Shcheglov 78bc6da66c Elements. Deprecate InstanceElement.xyz2, use 'xyz' instead.
Change-Id: Ie12b7596b70c77fd2f08520a423eeaf3b6978326
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428880
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-05-16 10:24:25 -07:00
Konstantin Shcheglov 2db49488c1 CodeGen. Generate members of most leaf AstNodeImpl classes.
Every declaration annotated with `@generated` was generated. In the
current version there are `2180` such declarations. For comparison,
there are `2167` instances of `@override` in total, and `@generated +
@override` has `1576` instances, so we generate `72%` of all overrides.

The generator automatically formats and sorts `ast.dart` after applying
changes, so the result is nice and clean. We run a separate DAS instance
from the script to do this.

Things to improve in the future:

1. Generate for non-leaf classes.

2. Support for `DoNotGenerate`.

Change-Id: I05e6356c9aac68449d5117ad8fd533735f130c73
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427481
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-05-15 18:05:42 -07:00
Sam Rawlins bd700772ff analyzer: move testing utilities to analyzer_testing package
Work towards https://github.com/dart-lang/sdk/issues/55660

Change-Id: Iae062d95e5cf3b94b540496242b3627268ac2612
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428844
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-05-15 16:28:50 -07:00
Sam Rawlins 22453ba77f linter: deprecate AnalysisRule.lintCode
Work towards https://github.com/dart-lang/sdk/issues/50986

Change-Id: Iedf1127b9f04aec910647c7f35597f38c6bfe1d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428846
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-15 16:20:11 -07:00
Konstantin Shcheglov 05da3e1f22 Elements. Deprecate Element.enclosingElement2, use enclosingElement.
Change-Id: I055b1f9dd1c00605d813effcbbadb9cea874129a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428860
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-05-15 13:47:32 -07:00
Konstantin Shcheglov c6722fc566 Elements. Rename / deprecate ClassElement.isXyzIn
Change-Id: I5ebc171cd8de04526cdde35f4140635f6bea7edd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428845
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-15 12:36:00 -07:00
Sam Rawlins 701c6113c2 analyzer: Simplify interface of WorkspacePackage, use File for root
Work towards https://github.com/dart-lang/sdk/issues/50986

Change-Id: I56c14bc941e1204b9d9cc13086f5ed92a1228585
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428623
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-15 11:35:42 -07:00
Danny Tuppeny fadf8a0959 [analysis_server] Support LSP executeCommand over DTD to support code actions
There are a few things in this CL that were difficult to separate testing of (because they're all part of the same feature):

1. sets `requiresTrustedCaller=false` on the `executeCommand` handler so that commands can be called over DTD. It adds the same flag to the command handlers themselves, so a command can control whether it can be called over DTD or not (right now we allow everything except `logAction` and `sendWorkspaceEdit` which are both commands used internally and not appropriate for DTD clients to call).

2. Removes the allow-list on DTD methods, allowing all LSP shared methods to be available over DTD

3. Extends the integration test classes to support reverse-requests so we can verify the edits being sent back to the editor when calling the code actions commands over DTD

4. It also fixes a few bugs where we read the callers capabilities instead of the editors capabilities (which until now would always be the same in those places, but with this change are not).

Change-Id: I6d271ddad6dc1b00a98b10b735763a368c91af7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428784
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-05-15 11:08:41 -07:00
Sam Rawlins a3b1b4f172 analyzer: Deprecate AbstractAnalysisRule.lintCodes
Work towards https://github.com/dart-lang/sdk/issues/50986

Change-Id: I4c86dbf806964c98f4a1c5854eb53c6c8cfe002b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428624
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-15 11:04:43 -07:00
Danny Tuppeny 49e7d4ac83 [analysis_server] Support "Fix" CodeActions via commands if client doesn't support CodeActionLiterals
This updates fixes to return either CodeActionLiterals or Commands based on the capabilities of the client (similar to was done previously for assists).

Change-Id: I688cb80aef415d329d65092edba247e5ec7a5a13
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428783
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-05-15 10:54:48 -07:00