Commit Graph

10135 Commits

Author SHA1 Message Date
Sam Rawlins c219974ecf analyzer: Deprecate Diagnostic.errorCode in favor of diagnosticCode
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: I2c7d64a81bc214e64fbc3ac95cf1fe2363a6ebd0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433242
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-06-09 09:22:22 -07:00
Brian Wilkerson b0adb4185e Convert upper snake case fields to lower camel case
There are no semantic changes in this CL, just renames.

The one unfortunate rename was from `DEFAULT` to `default_`. It can't be
`default` because that's a built-in identifier. If you have a better
convention to follow here I'm happy to change it.

Change-Id: Idf70621ad577dbea6c1c161aac17e9e200aac2d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433440
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-06-09 07:35:37 -07:00
Sam Rawlins bddcddfe6b analysis_server: use new Diagnostic name over AnalysisError
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: I5cc0cc66afd3531271eb8dc337556505cb21c074
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425962
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-06 16:00:25 -07:00
Kallen Tu 5a17591682 [analysis_server] Dot shorthands: Hover work and tests.
Added some extra logic for handling dot shorthands in hovers. They should show the same information in the hover as if we had added the type in front of `.`.

Added a new line "Declared in:" to show the containing class information.

Bug: https://github.com/dart-lang/sdk/issues/59836, https://github.com/dart-lang/sdk/issues/60864
Change-Id: If159d53b7c4443d8a8311125ceef66c441d39d4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431944
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-06-06 13:35:19 -07:00
FMorschel bd2a0e6a5e [DAS] Fixes keyword/type in auto-completion for pattern matching
Fixes: https://github.com/dart-lang/sdk/issues/59854

Change-Id: Ic7a0dee51eb45792520ae49d935510e8669f94ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417222
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-06-06 13:31:50 -07:00
Keerti Parthasarathy 426227b3ac [Completion] Fix for adding duplicate suggestions for Keywords 'covariant' and 'this'.
Change-Id: I736ad405791638bf8be0eb898e72ccb7983abfb2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433400
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2025-06-06 12:58:23 -07:00
Kallen Tu 5ccfa844da [analysis_server] Update bullets on language feature checklist.
The bullets on this doc were bugging me because they were confusing which tasks were subtasks of one another. I made them all into checklist bullets (since that's what's most useful for me anyways) and it looks much better.

Change-Id: I593ceb7db5ae39ffda52a2a2e481b1c53a5a7784
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433360
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-06-06 11:57:10 -07:00
FMorschel fae7752e9e [DAS] Adds tests for fix priorities and new priority for Create class
The related issue asked for a new priority for the `Create class` fix
that would be lower if the undefined name was lowercase, giving the
`Create method` and `Create function` fixes a higher relative priority.

This change also adds a new abstract class to test the relative priority
between fix kinds. It is also used to test agains the merge combinators
fixes.

Fixes: https://github.com/dart-lang/sdk/issues/60523
Change-Id: I938f52a577ecf1b6bb8dd66c94fd45395a011ffa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422321
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>
2025-06-05 16:58:40 -07:00
FMorschel f0ad03cabf [DAS] Adds fixes for implicit_this_reference_in_initializer
Fixes: https://github.com/dart-lang/sdk/issues/60729
Change-Id: Ie2ee6ff84062b749a9a8385a3140f9bc35760df2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429081
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-06-05 16:17:39 -07:00
Brian Wilkerson 4fbb4dc6ee Fix the field formal parameter to normal parameter assist
This disables the assist if the field formal parameter happens to also
be an older style function typed parameter. As written the assist
produces invalid code, and the older style is strongly discouraged so
not supporting it shouldn't impact very many users.

Change-Id: I44a3942b4656265bb1cbbba29e68fff61962b689
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433260
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-06-05 14:30:09 -07:00
Sam Rawlins 903d77cc82 analyzer: Rename ErrorListener classes to DiagnosticListener
Work towards https://github.com/dart-lang/sdk/issues/60635

I tried to keep this minimal but still sensible:

* Rename AnalysisErrorListener and all subtypes to use 'Diagnostic'.
* Rename all instantiations of such classes if they previously
  contained the word 'error'.
* Rename `RecordingDiagnosticListener.errors` to `.diagnostics`.
* Rename some _testing_ instance members that had the word 'error'
  to instead use 'diagnostic'.

Change-Id: I3948e27ba28ac2494092e04f4e1d201a20cc1135
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433004
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-06-05 14:05:40 -07:00
Brian Wilkerson edce10b761 Add an assist to convert from a field formal parameter to a normal parameter
Fixes https://github.com/dart-lang/sdk/issues/60852

Change-Id: Iffc674e61b4df16e80ca71cfd18e12c548770b54
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433220
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-06-05 12:33:34 -07:00
FMorschel 9d6c5d40d0 [DAS] Fixes "Go to declaration" for undefined new constructor
Fixes: https://github.com/dart-lang/sdk/issues/60773
Change-Id: I7ee7cec371fbf0d0f9de1a4fe2b946929ba80d61
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432741
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
2025-06-05 12:08:44 -07:00
Danny Tuppeny 9df000075a [analysis_server] Exclude blocks/switch cases from Inline Values unless execution is within them
This prevents inline values showing up alongside code that didn't execute in conditional blocks. It does also mean they don't know up in conditional blocks that _did_ execute one execution has fallen out of them, but I believe this is the best we can do with the current LSP APIs (unless we try to track execution across requests, but that would probably be complete and not entirely reliable).

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

Change-Id: Ia1cf2437b76844ff0a6aeeb958d769c9523dc5dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433200
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-05 10:53:12 -07:00
Danny Tuppeny b8daa53fef [analysis_server] Don't rebuild contexts on deletion of an analysis root
This is a partial revert of ca9523058e (it removes the behaviour change and the test that verifies this, but leaves two additional tests that were added relating to roots that are created later).

If we rebuild contexts when a root is deleted, we may get stuck in a loop because we will again try to recreate the same (deleted) root, and then the watcher will close in a way that looks like a deleted folder, and we will repeat.

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

Change-Id: I10289160b341d273e8e409184a1c013c7fb9439d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433140
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-05 09:24:41 -07:00
Sam Rawlins b2beba242d analyzer: Convert callers of InheritanceManager3 to use InterfaceElement API
This includes all callers in analysis_server and analyzer_plugin. And
callers of `getOverridden4`.

Change-Id: Ia744f6c7260b445c6b1e02d3cf5515aaa9c7feeb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432962
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-04 16:30:22 -07:00
Brian Wilkerson 0404c6cd08 Add some message scheduler data to the collected report
Change-Id: I086b741a90955a2753efbabdf1c3cb321de98ee0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432903
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-06-04 15:08:20 -07:00
Danny Tuppeny 8d36178a43 [analysis_server] Move support for locking requests to the scheduler
This removes the original `lockRequestsWhile` functionality of the LSP server which worked by pausing reading from stdin to instead pause the processing of messages in the scheduler.

Change-Id: I737e977adee11fe6fc70f44185cfaa22c22805da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432342
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-06-04 15:06:12 -07:00
Sam Rawlins 47f7c4fb87 analyzer: expose canBeConst and computeConstantValue as public API
Work towards https://github.com/dart-lang/sdk/issues/50986

These utilities are used by a handful of lint rules, and the analysis
server, which makes me think they could be offered as public API.

Change-Id: I12415c2b86ca6fb96b03def4a304da73c6fb4cae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430300
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-04 11:02:17 -07:00
Sam Rawlins 508c35b6f0 linter: unawaited_futures: narrow the reported range, matching discarded_futures
Change-Id: Id8a361a352e409df0a8c9cc9fa73a9f7b5e52c3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431365
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-04 09:26:31 -07:00
Danny Tuppeny b1751e6871 [analysis_server] Update some tests to not required useLineEndingsForPlatform=false
Change-Id: I5eafe194465e20942ebea6989a75679d1a9bb866
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432980
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-04 08:45:59 -07:00
Keerti Parthasarathy 25b99786d1 [Completion] Fix for adding duplicate keywords like 'dynamic' when in a declaration.
Change-Id: If8e35edd5ee136b0d272f1ea43a705cf04540bbc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432821
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-04 08:31:37 -07:00
Danny Tuppeny 0f161e3ebe [analysis_server] Allow documentation preferences to be different between completion/hovers
For https://github.com/Dart-Code/Dart-Code/issues/4729 we added a configuration setting to let you control how much documentation was included in responses. The motivation here was to reduce the completion payload sizes when running in remote workspaces (Dart-Code would adjust the default setting if not explicitly set by the user based on the workspace kind).

However in hindsight, forcing no docs on Hovers just because we didn't want them in Completion requests was a bad choice, because these are individual requests where the payload size is less important and seeing the docs is useful.

So this alters the setting to accept a `Map` to allow you to have different preferences for each request that returns docs. Dart-Code will be updated to adjust the defaults accordingly (after this lands) so that Hover/SignatureHelp can default to `"full"` even in remote workspaces.

Work towards https://github.com/Dart-Code/Dart-Code/issues/5499

Change-Id: Ib64f762a0559c7afc7653fad9749fc208beee8b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431280
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-04 07:51:45 -07:00
pq d150bcb97c [das] legacy server support for analytics checking
Fixes: https://github.com/dart-lang/sdk/issues/60853

Change-Id: I3a14c209482b47dc8228c678793e23cf91295fd6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432780
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-03 12:56:12 -07:00
Sam Rawlins 31f8f4b522 analyzer: Make various AnalysisRule classes and their dependencies public
This is a big CL; no code is really "changed." We basically move 3
components into the public API, which can all be reviewed concisely
in the `api.txt` file.

* The AnalysisRule classes: `AbstractAnalysisRule` (which is good to
  make public as a lot of the public API is specified and documented
  here), `AnalysisRule`, `MultiAnalysisRule`.
* The Pubspec classes, available for linting pubspec files:
  `PubspecDependency`, `PubspecDependencyList`, `PubspecEntry`,
  `PubspecEnvironment`, `PubspecGitRepo`, `PubspecHost`, `PubspecNode`,
  `PubspecNodeList`, `PubspecVisitor`.
* The `RuleVisitorRegistry` class. This class is needed by analysis
  rule authors, and is part of the public API of AnalysisRule.

Change-Id: Ib1803180de9469f4ff39cf1778f96787f5f74b14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432363
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-03 11:09:32 -07:00
Danny Tuppeny ca9523058e [analysis_server] Rebuild context roots if an analysis root folder is deleted
Change-Id: I79ada9184686f6f413ed7d732feea22cf39865bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238640
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-03 09:27:10 -07:00
Konstantin Shcheglov a10ce29c08 Elements. Add reference to ConstructorElementImpl2, write it.
Change-Id: I40ff802e9c78b2d74c19769da8339a947d23d7f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432540
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-03 08:57:59 -07:00
Jens Johansen 47bc250896 [analyzer] Add benchmark that calls getFixes on an actual error
This CL adds a benchmark for getFixes calls on an actual error case.
The time it takes is nowhere near the times we're seeing in
http://b/407797012 but it's better than nothing.

The benchmark does 5 requests for `getFixes`.
The first one is always much slower because it has to "discover files".

Comparing old dart releases and CLs
https://dart-review.googlesource.com/c/sdk/+/420323 and
https://dart-review.googlesource.com/c/sdk/+/421220:

3.7.2 was quite a bit slower than 3.6.2.
Both CL 420323 and CL 421220 improve things - both separately and combined.
With both we're faster than 3.6.2 for all but the first getFixes call
(which has to "discover files").

Details:

```
Comparing 3.5.4 with 3.6.2
no change.

Comparing 3.6.2 with 3.7.2
Fixes (1): 16.4789% +/- 8.3240% (0.23 +/- 0.12) (1.39 -> 1.62)
Fixes (2): 300.2940% +/- 21.5781% (0.06 +/- 0.00) (0.02 -> 0.08)
Fixes (3): 220.0321% +/- 23.8171% (0.05 +/- 0.01) (0.02 -> 0.07)
Fixes (4): 89.0472% +/- 86.0948% (0.03 +/- 0.03) (0.04 -> 0.07)
Fixes (5): 202.9467% +/- 22.5906% (0.04 +/- 0.00) (0.02 -> 0.07)

Comparing 3.7.2 with HEAD-ish without the two CLs
Fixes (1): 9.2103% +/- 6.7559% (0.15 +/- 0.11) (1.62 -> 1.77)
Fixes (2): -32.2017% +/- 7.2433% (-0.03 +/- 0.01) (0.08 -> 0.06)
Fixes (3): -39.1903% +/- 7.4656% (-0.03 +/- 0.01) (0.07 -> 0.04)
Fixes (4): -41.5019% +/- 8.2911% (-0.03 +/- 0.01) (0.07 -> 0.04)
Fixes (5): -38.7623% +/- 4.4327% (-0.03 +/- 0.00) (0.07 -> 0.04)

Comparing HEAD-ish without the two CLs with CL 420323 (cache) only
Fixes (1): -5.9976% +/- 4.4944% (-0.11 +/- 0.08) (1.77 -> 1.66)
Fixes (4): -39.3839% +/- 13.3201% (-0.02 +/- 0.01) (0.04 -> 0.02)
Fixes (5): -49.0495% +/- 4.2557% (-0.02 +/- 0.00) (0.04 -> 0.02)

Comparing CL 420323 (cache) only with CL 421220 (element2) only
Fixes (2): -63.4332% +/- 42.9828% (-0.02 +/- 0.02) (0.04 -> 0.01)
Fixes (3): -79.6318% +/- 17.5009% (-0.04 +/- 0.01) (0.05 -> 0.01)
Fixes (4): -68.4995% +/- 11.7414% (-0.02 +/- 0.00) (0.02 -> 0.01)
Fixes (5): -54.6697% +/- 11.1116% (-0.01 +/- 0.00) (0.02 -> 0.01)

Comparing CL 421220 (element2) only with both
Fixes (2): -21.3437% +/- 7.8302% (-0.00 +/- 0.00) (0.01 -> 0.01)
Fixes (3): -17.7975% +/- 10.4789% (-0.00 +/- 0.00) (0.01 -> 0.01)
Fixes (5): -30.5353% +/- 20.5827% (-0.00 +/- 0.00) (0.01 -> 0.01)
```

Change-Id: I477c7a73c669099e2d7bc9d64000cfb78ced2ea4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421601
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-06-03 07:24:41 -07:00
Brian Wilkerson e12e916041 Fix a bug on the diagnostic pages
This was introduced when I changed the ids of some of the pages.

Change-Id: Ia0dc4a49fcabb02782a0e037779a29a55f5deb7c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432560
Auto-Submit: 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>
2025-06-02 15:54:18 -07:00
Kallen Tu 5f9c5da238 [analysis_server] Dot shorthands: Find element references tests.
Tests for Find References (Element) for dot shorthands.

Bug: https://github.com/dart-lang/sdk/issues/59836
Change-Id: I7eee219022b974a8ab8a804e60a30964493a0a8f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432124
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-06-02 13:48:51 -07:00
Sam Rawlins a5520d07cb analyzer: Expand BlazeWorkspacePackage.isInTestDirectory to include 'testing'
This changed definition is required for google3, in order to support
using `WorkspacePackage.isInTestDirectory` over the `inTestDir`
extension getter.

Then remove linter's export of the `inTestDir` extension method, and
instead rely on WorkspacePackage in lint rules.

Change-Id: I81fc6a27ca8f19f71a8b915edb3968d5d43262ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431943
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-06-02 11:17:53 -07:00
Konstantin Shcheglov 73a85ec195 Elements. Deprecate FragmentImpl.name
Next I will remove it completely.
And instead require `name2` as the constructor formal parameter.

Change-Id: Ib4afac3266fe36a7299d60a8b6d87c99349dd64c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432125
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-02 10:23:24 -07:00
Brian Wilkerson 5df7479633 Reorganize the status/diagnostic pages
I moved several classes out of `diagnostics.dart` into their own
libraries under `pages`. I also moved one of the singling files into
`pages`. Several other sibling pages were moved to `utilities`. In the
process I needed to make a couple of methods public rather than private.

There are no functional changes.

I was going to split out the rest of the classes from `diagnostics.dart`
and `pages.dart` but I haven't yet decided whether they should all go
into a single directory or whether they should be in two directories.
The classes in `pages.dart` appear to be classes appropriate for any
web site generating code while those in `diagnostics.dart` are specific
to this web site, but it isn't clear to me that the abstraction is
helpful given that we only have one web site to build.

Change-Id: Iff968bc3bfb654db24e896cb1ae0ced9bc6333fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432360
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-06-02 08:06:50 -07:00
Sam Rawlins 28fc6346eb analyzer: Move RuleContext and RuleContextUnit to public API
Change-Id: I9cca5ee27e623bfa5b878bb0277f5e12e84a745b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431982
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-30 15:42:10 -07:00
Brian Wilkerson 2c0fad24ff Normalize the diagnostic pages
This normalizes the names of the classes to match the label displayed to
the user (to make it easier to find the class that needs to be updated).

It also normalizes capitalization in titles and the formation of the
page ids.

This is a precursor to splitting the page classes out into separate files.

Change-Id: I571bfaf23057f2366274e4b853412c8756151f65
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432121
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-05-30 15:23:01 -07:00
Konstantin Shcheglov 63aa736da2 Elements. Add reference to MethodElementImpl, write it.
Change-Id: Iedfa3cb01749e527012e24a72539d591a3a0afbf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431940
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-05-30 14:42:03 -07:00
Brian Wilkerson 2b59598def Display message scheduler information on the diagnostic pages
This adds a new page to the diagnostic pages that displays the current
state of the message scheduler (or rather the messages passing through
the scheduler) as well as the most recent history.

The next steps after this are to
- include this information (and library cycle information) in the
  generated report
- add this (and cycle) information to the analytics we're gathering

I put the new page in its own file, and would like to move existing
pages to separate files as well. Doing so might trigger moving some
files around in the directory structure in order to better organize
the code.

Change-Id: Ic4f0e72ffbadc1e39702f1f8f13850f5bd5814a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431947
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-05-30 11:52:59 -07:00
Kallen Tu 74f74d7157 [analysis_server] Dot shorthands: Document highlights tests.
Tests for documenting highlighting for dot shorthands. Tested with enums, classes, and extension types.

Bug: https://github.com/dart-lang/sdk/issues/59836
Change-Id: I9b13dd8594ff8113ec9dbe97089688d893d2853d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431983
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-30 11:21:11 -07:00
Konstantin Shcheglov e724547892 Elements. Deprecate Annotatable.metadata2, use 'metadata' instead.
Change-Id: Ic4a7d8f19cb1793031951aadeb340e5dadf4744c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430261
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-05-30 11:09:40 -07:00
Kallen Tu 8f9cab4440 [analysis_server] Dot shorthands: Go to type definition tests.
Tests for `Go to Type Definition` for dot shorthands. Passing.
Part of the analysis server work.

Bug: https://github.com/dart-lang/sdk/issues/59836
Change-Id: I265891c21ed1e3f0a01d1e75aa51df0265054392
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432000
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-30 10:39:49 -07:00
FMorschel f18bd99230 [DAS] Fixes comment references for enum constants
Fixes: https://github.com/dart-lang/sdk/issues/60760
Change-Id: I1a6dc74f1265ac4195f772a3e0374856008cbc6f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430000
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-05-30 10:04:32 -07:00
Kallen Tu 009a6194b3 [analysis_server] Dot shorthands: Call hierarchy changes and tests.
Added work and tests needed for the call hierarchy to handle dot shorthands.

The element locator needed to be updated for the call hierarchy to work, so I updated that too.

Unit tests passing.

Bug: https://github.com/dart-lang/sdk/issues/59836
Change-Id: Id61e6071c5ff008300f7bd25f762a14f22e47595
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431701
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-29 13:35:13 -07:00
Sam Rawlins 41ac971d8a analyzer: rename Lint*Context classes
For the analyzer plugin APIs, these classes should not have the word
'Lint' in them, as they are used for all analysis rules, whether they
report lints or warnings.

* LinterContext                    -> RuleContext
* LinterContextWithParsedResults   -> RuleContextWithParsedResults
* LinterContextWithResolvedResults -> RuleContextWithResolvedResults
* LintRuleUnitContext              -> RuleUnitContext

I'm open to better names for these. Some of these suffer from a
chain-of-nouns name (a "RuleUnitContext" is a Context for a Unit for
a Rule). So we could go with "UnitContextForRule" and "ContextForRule"
or other ideas like that.

Only RuleContext and RuleUnitContext will be public API.

Change-Id: I5550736beaba7e39b36e7b5584ca6d023aa4d02b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431703
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-29 11:49:29 -07:00
Kallen Tu 560bb8e0aa [analysis_server] Dot shorthands: Go to definition tests.
Tests with dot shorthand invocations, constructor invocations and property accesses for the go to definition feature.

Bug: https://github.com/dart-lang/sdk/issues/59836
Change-Id: If8f7d85d273299d7a5c6c7cddaffc59cd41eb2fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431780
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-05-28 14:05:09 -07:00
Sam Rawlins eba91c5045 analyzer: Move RuleState into the public API
Work towards https://github.com/dart-lang/sdk/issues/50986

Change-Id: I32e1d9b6dbb0a6ef91569ae65100365f775ec0f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430544
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-28 13:28:26 -07:00
Brian Wilkerson b5e12ecaff Replace use of NodeLocator2 in CorrectionProducer
This is the last use of NodeLocator2 outside of the analyzer package
itself that I'm aware of (at least in our code base).

Change-Id: I57ba74571d60e820c60e2ca3d8d17e9374597073
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431440
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-05-27 21:03:43 -07:00
Keerti Parthasarathy 797b076edb Check for visisbility only once when adding completions for element members.
Change-Id: Icc482b005407262afe746d066971bb071a5e4508
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431380
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2025-05-27 18:05:41 -07:00
Brian Wilkerson 785b38ed5b Convert remove-dead-code to use nodeCovering
Change-Id: Ie91e56708dce7a5cce352a06f239ca3b29a4eb12
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431340
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-05-27 11:00:09 -07:00
Danny Tuppeny d2c0f0ae16 [analysis_server] Support folding try/catch/finally blocks
Fixes https://github.com/Dart-Code/Dart-Code/issues/5201

Change-Id: I1790d3aa624d80ad0233216ca650d497f31c632b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431281
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-27 10:45:12 -07:00
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