Commit Graph

269 Commits

Author SHA1 Message Date
Konstantin Shcheglov 23e558876a Start analyzer 12.1.0-dev, analyzer_plugin 0.14.8-dev, analyzer_testing 0.2.5-dev, analysis_server_plugin 0.3.14-dev
Change-Id: Ib0971736635e507fbd1cc4a214ccba8beea83639
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490346
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-03-24 17:03:40 -07:00
Konstantin Shcheglov ea94b269d1 Prepare to publish analyzer 12.0.0, _fe_analyzer_shared 98.0.0, analysis_server_plugin 0.3.13, analyzer_plugin 0.14.7, analyzer_testing 0.2.4
Change-Id: Ia46a1ba04db30a15d8848e8e1586795921a33ed1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488241
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-03-16 19:32: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
Jens Johansen 2849d34c7c [analyzer] Replace regex in ignore_info with normal code
The RegEx engine in the VM was updated in
e443b89f23 which caused the analyzer
analyzing the CFE to use ~150 mio instructions more.

Part of this was an increased cost in ignore comment processing which
relied on regex. Using regex before the updated engine made
`processPrecedingComments` have a cost of ~240 mio instructions,
updating the regex engine took that to ~264 mio instructions.

This CL gets rid of the regex and takes the cost of
`processPrecedingComments` to ~74.4 mio instructions a saving of about
189 mio instructions (all then analyzing the CFE and looking at output
from `valgrind --tool=callgrind`).

Benchmarking with `perf stat` with normal GC gives:

```
task-clock:u: -2.1760% +/- 1.6063% (-265608341.80 +/- 196062087.98) (12206056036.20 -> 11940447694.40)
page-faults:u: 0.2301% +/- 0.0313% (448.20 +/- 60.88) (194764.60 -> 195212.80)
cycles:u: -2.2906% +/- 1.6090% (-1180119481.60 +/- 828994273.75) (51521138476.00 -> 50341018994.40)
instructions:u: -0.3325% +/- 0.0032% (-196547942.60 +/- 1874215.18) (59120651337.60 -> 58924103395.00)
seconds time elapsed: -2.1715% +/- 1.6011% (-0.27 +/- 0.20) (12.21 -> 11.95)
seconds user: -2.2487% +/- 1.7816% (-0.27 +/- 0.21) (11.87 -> 11.60)

Comparing GC data:
'No' GC change.
```

Note that it must push the GC - the savings isn't really 2% in time.

And with GC disabled:

```
instructions:u: -0.4562% +/- 0.0029% (-185499444.00 +/- 1189012.77) (40663084597.80 -> 40477585153.80)
```

So here a saving of ~185 mio which fits okay with the data from
valgrind.

Change-Id: Ib203baeac6a93f5e37c737080fed342dbd0740a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487021
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-03-13 02:43:23 -07:00
Konstantin Shcheglov 2e6153cdb6 Start analyzer 11.1.0-dev, analyzer_plugin 0.14.6-dev, analyzer_testing 0.2.3-dev, analysis_server_plugin 0.3.12-dev
Change-Id: Iddeffba7499ea1b1bcd607bf72ad9766a997ae74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/484501
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-03-02 10:53:00 -08:00
Konstantin Shcheglov e819fffbd1 Prepare to publish analyzer 11.0.0, _fe_analyzer_shared 97.0.0, analysis_server_plugin 0.3.11, analyzer_plugin 0.14.5, analyzer_testing 0.2.2
Change-Id: Ibfa9fa0db341a9335bf5983375e15212717b6b5a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/484220
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-02-27 10:52:00 -08:00
Konstantin Shcheglov 19895724dd Breaking changes for analyzer version 11.0.0
Change-Id: I75c4dca69a99c0129cc8ae6934d5925382228a00
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/481542
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-02-24 14:36:29 -08:00
Sam Rawlins 7143390ba0 DAS plugins: add changelog note regarding excluded files
Fixed in https://dart-review.googlesource.com/c/sdk/+/482460

Change-Id: I57667f948cf9af40b88dc98f8983bff881487933
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482960
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-02-23 11:02:35 -08:00
FMorschel e8df76286e [analysis_server_plugin] Skips files that are analyzer excluded.
Fixes: https://github.com/dart-lang/sdk/issues/62729
Change-Id: I4b60ad02b10009decfa091d8dce84a0e765a7b6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482460
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-02-23 08:27:38 -08:00
Konstantin Shcheglov 5cbe70416f Start analyzer 10.3.0-dev, analyzer_plugin 0.14.5-dev, analyzer_testing 0.2.2-dev, analysis_server_plugin 0.3.11-dev
Change-Id: I5fecb1813aebf0be764f41f270ae26a0de4dcc17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482600
Reviewed-by: Paul Berry <paulberry@google.com>
2026-02-21 10:52:57 -08:00
Konstantin Shcheglov 777b6efcd9 Prepare to publish analyzer 10.2.0, _fe_analyzer_shared 96.0.0, analysis_server_plugin 0.3.10, analyzer_plugin 0.14.4, analyzer_testing 0.2.1
Change-Id: Id5f874b59e441c81910d979d9f50e4415674179d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482363
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-02-20 12:59:46 -08:00
Paul Berry c6a9c9536e [api_summary] Add class modifier support.
Adds the modifiers `abstract`, `base`, `final`, and `interface` to the
API summary output.

This information is an important part of the public API of a package,
because it determines whether a client can:

- Construct an instance of the class,
- Extend the class, or
- Implement the class.

Change-Id: I6a6a6964ba07db1714bc2fcb549cc15230e87058
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482362
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2026-02-20 10:49:45 -08:00
Paul Berry 02ced6c1a5 [api_summary] Fix member sort order.
Fixes two minor bugs with the sorting of members in the API summary
tool:

- The technique for placing getters next to their corresponding
  setters was to sort them lexicographically based on
  `Element.apiName`, which in the case of setters appends `=`. This
  mostly worked, but due to the fact that `=` is between `9` and `A`
  in ASCII, it was wrong in a few corner cases. For example, it would
  sort `x`, `x=`, `x1`, and `x1=` in the order `x`, `x1`, `x1=`,
  `x=`. Fixing this didn't affect any `api.txt` files in practice.

- The technique for sorting constructors also used `Element.apiName`,
  which in the case of an unnamed constructor is `new`. This meant
  that if a class had both named and unnamed constructors, the unnamed
  constructor would not always be sorted before the other
  constructors.

The fix for both bugs is to sort by `Element.name` (which does not add
`=` for setters and is the empty string for unnamed constructors), and
then to break ties by explicitly checking whether the element is a
setter.

Change-Id: I6a6a69648fb5915266a9111c5d884531bba4405d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482361
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2026-02-20 10:43:16 -08:00
Konstantin Shcheglov d3d0ec9f66 Start analyzer 10.2.0-dev, analyzer_plugin 0.14.4-dev, analyzer_testing 0.2.1-dev, analysis_server_plugin 0.3.10-dev
Change-Id: I99ed03bc272bf6c243438b41b69c78dbf5511427
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/481240
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-02-17 10:53:10 -08:00
Konstantin Shcheglov fc41bfcf92 Prepare to publish analyzer 10.1.0, _fe_analyzer_shared 95.0.0, analysis_server_plugin 0.3.9, analyzer_plugin 0.14.3, analyzer_testing 0.2.0
Change-Id: Ibe306aceaf6967a978fbf7e8bad07c3475e8ca10
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/481060
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-02-17 09:20: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
Jonas Finnemann Jensen b62a14bf9a Remove unnecessary catch for YamlException.
`YamlEditor.update` should never throw `YamlException`, it should also
never throw `AssertionError`, but we know that it has bugs, and in those
cases it does throw `AssertionError`.

Change-Id: I941d88063effc8c46ba270da8531978a72e7a806
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472562
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Jonas Jensen <jonasfj@google.com>
Commit-Queue: Jonas Jensen <jonasfj@google.com>
2026-02-10 03:02:14 -08:00
FMorschel e19b298536 [analysis_server_plugin] Fixes suggested ignore fixes
Fixes: https://github.com/dart-lang/sdk/issues/61715
Change-Id: Iafc3e2aa22d975addce67829ad18e2798299903c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/477900
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
2026-02-03 10:34:33 -08:00
Albert Moravec 7226a4ce87 [analysis_server] Allow analyzer plugins from hosted pub server
Added support for the `hosted` field in plugin definition,
so that analyzer plugins can be sourced from pub servers other
than pub.dev.

TEST=pkg/analysis_server/test/src/plugin2/generator_test.dart
TEST=pkg/analyzer/test/src/options/analysis_options_test.dart

Change-Id: Ie99693ab39c77b3d814843963613798f72e27f62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475580
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Albert Moravec <albert.moravec@gmail.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-02-02 14:32:37 -08:00
Konstantin Shcheglov 98c4f54c0f Start analyzer 10.1.0-dev, analyzer_plugin 0.14.3-dev, analyzer_testing 0.1.11-dev, analysis_server_plugin 0.3.9-dev
Change-Id: I2ec7613ce0abcfa6e55f8c7837860319d9503adf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/477641
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-02-02 11:54:49 -08:00
Konstantin Shcheglov 5273f91b95 CQ. Scan from strings and drop scanner reader shim.
Remove the analyzer-only `scanner/reader.dart` re-export and refactor
`Scanner` to accept source text directly.

* Delete `pkg/analyzer/src/dart/scanner/reader.dart`, which only re-exported
  `_fe_analyzer_shared` reader types.
* Replace the `Scanner(CharacterReader, ...)` factory with
  `Scanner(String contents, ...)`, aligning the API with the underlying
  `scanString` implementation.
* Update analyzer, analysis_server, analyzer_cli, analyzer_plugin, and scrape
  call sites to pass the source string directly instead of constructing
  `CharSequenceReader`.

This removes an unnecessary abstraction layer, reduces
imports/indirection, and makes scanner usage simpler and more uniform
across the repo.

Change-Id: I380b365676c8a62971a3700deadb695d1519d653
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/477600
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-02-02 11:20:31 -08:00
Sam Rawlins 4eabd1d870 DAS plugins: Use a proper glob string and canonicalize globs
Work towards https://github.com/dart-lang/sdk/issues/62341

Change-Id: I72d882607bfd4db0ad3b179d2b20549744bda0cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472662
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-01-31 14:55:50 -08:00
Sam Rawlins 94a701bb0a Bump analyzer to 10.0.2, analyzer_plugin to 0.14.2, analyzer_testing to 0.1.10, and analysis_server_plugin to 0.3.8
This release is so we can publish a version of analysis_server_plugin,
and then start depending on that published version in DAS.

In addition, we get a highly requested fix out to analyzer_testing
users.

Change-Id: I694f47aeee59367c1fc066bc8f7a865406b09917
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476620
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-01-30 09:24:57 -08:00
FMorschel 03980b59ac [analysis_server_plugin] Fixes warning ignores by namespacing rules by plugins
Bug: https://github.com/dart-lang/sdk/issues/62173
Change-Id: I09b26b99fa928822f76246d8c6380a7c9a2b0a1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475080
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
2026-01-28 12:22:28 -08:00
Paul Berry cf1d8b96db [messages] Make Scanner and Parser take a DiagnosticReporter.
Changes the signature of the following constructors:
- Scanner
- Scanner.fasta
- Parser

So that they accept a `DiagnosticReporter` object rather than a
`DiagnosticListener` object. This brings the scanner and the parser
into alignment with the majority of the rest of the analyzer (which
reports errors using `DiagnosticReporter` rather than by talking to
`DiagnosticListener` directly).

It also makes the `source` parameter of these constructors
unnecessary, because the `source` can be obtained from the
`DiagnosticReporter`.

Change-Id: I6a6a6964607ffb52a8332a6e618dc0c9a1e48c5c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/473442
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2026-01-16 13:34:50 -08:00
Sam Rawlins ca475a991d Release meta 1.18.0
analyzer package now depends on new TargetKind values in meta, so we
must bump the dependency to prevent crashes.

Change-Id: Ia639b0cd67c0dc70ae03613b6b1bfd4ad552788c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/473421
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-01-15 11:41:02 -08:00
Jonas Finnemann Jensen bd2770e9eb Ignore internal errors in YamlEditor
When we landed null-safety we accidentally disabled internal self-testing in YamlEditor.
We fixed this in: https://github.com/dart-lang/tools/pull/2284

But this was reverted because this test broke. With this we should able to land:
https://github.com/dart-lang/tools/pull/2299

TL;DR: `YamlEditor.update` may throw `AssertionError` if it has an internal error.

Internal errors in `YamlEditor` should not happen, but we have bugs.
There is open PRs to fix some of those bugs, but in practice it's not unlikely
that there will always be bugs. We're modifying YAML source using `SourceSpan`s
from the YAML parser. Changes in the parser, surprising corner cases, complex modifications
or combinations of these can probably cause internal errors.

These internal errors happens when:
 * The result YAML output is invalid YAML.
 * The resulting YAML doesn't match the same semantic modification on the original YAML structure, when compared with deep equals.

Change-Id: I159b37e9a9f039f92c82881ccac2c4826332f816
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471460
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Jonas Jensen <jonasfj@google.com>
2026-01-12 04:15:02 -08:00
Sam Rawlins 9e13669268 DAS plugins: Bump to 0.3.6 with fix
Publishing in order to ship this fix:
https://dart-review.googlesource.com/c/sdk/+/471840

Change-Id: I7eea712fea9be3b2d26635170ca541fca4e59b6b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471890
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-01-09 12:45:39 -08:00
FMorschel 463217e282 [DAS Plugins] Fixes diagnostic messages not showing for plugins
Fixes: https://github.com/dart-lang/sdk/issues/62357
Change-Id: I21c33c4af5f0e41fc5015c61f0bf7e2a7229a8f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471840
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-01-09 11:21:03 -08:00
Konstantin Shcheglov ef20543995 Prepare to publish analyzer 10.0.0, _fe_analyzer_shared 93.0.0, analysis_server_plugin 0.3.5, analyzer_plugin 0.14.0, analyzer_testing 0.1.8
Change-Id: I22aaf17a81027ac44d5f23b114ece789d66eed93
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471120
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-01-07 11:25:23 -08:00
Paul Berry 5d199d6afe [messages] Move SourceRange class to _fe_analyzer_shared.
This will allow `SourceRange` to be referred to by classes in
`pkg/_fe_analyzer_shared` such as `LocatableDiagnostic` and
`SyntacticEntity`.

Change-Id: I6a6a69641f9daa351fbea3a0cc61f760f7a966d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467683
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-12-11 14:51:41 -08:00
Sam Rawlins 4aa853ad72 analyzer: Add a CHANGELOG entry for Dart 3.11 and analysis_server_plugin
Change-Id: Id3505a7ff5070969ad4480f6698991c0814dc655
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467383
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-12-10 11:15:32 -08:00
FMorschel 0e35d4ecf7 [DAS] Fixes create member inference for switch expressions
Fixes: https://github.com/dart-lang/sdk/issues/62108
Change-Id: Iefed0af48180deb75f185417ea88361290a85ebe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466122
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-12-10 11:06:58 -08:00
FMorschel 2cbcc7f37c [DAS] Fixes Create (extension) method for unresolved closure return type
Fixes: https://github.com/dart-lang/sdk/issues/61898
Change-Id: I0b1e7ad208a54a04f0ff4147f27403845f9a379d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/459521
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-12-10 10:40:00 -08:00
Sam Rawlins 49dc34715e analyzer plugins: Document how to add a stub package in tests
Fixes https://github.com/dart-lang/sdk/issues/61915

I add documentation to a few APIs, and primarily document `newPackage`
and `PackageBuilder.addFile`, which already have sufficient doc
comments.

Change-Id: Ice088c2d76604ccb991d895a1e4bb408c492b963
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467240
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-12-09 14:53:52 -08:00
Sam Rawlins 21e5638140 analyzer plugins: Support AnalysisRuleVisitor.afterLibrary
Fixes https://github.com/dart-lang/sdk/issues/62010

Change-Id: If0652125d1aefc819c996191869e0b0d8635c774
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467140
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-12-09 13:21:29 -08:00
FMorschel b93d9130f4 [DAS plugin]: Fixes so that part files also get fixes and assists
Fixes: https://github.com/dart-lang/sdk/issues/62075
Change-Id: I6fddc81a7a2200de39e083319eddd76f2de29f50
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464300
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
2025-12-09 10:09:02 -08:00
Paul Berry 3a91bf9b22 [messages] Make PluginConfiguration.diagnosticConfigs case insensitive.
Changes the initialization logic for `PluginConfiguration` so that it
always populates the `diagnosticConfigs` field with a map that ignores
case when matching keys. This insures that diagnostic codes in a
plug-in configuration are matched in a case-insensitive fashion.

Also changes the logic in `pkg/analysis_server_plugin` so that when it
looks up names in this map, it uses `DiagnosticCode.lowerCaseName`
rather than `DiagnosticCode.name`. This in itself has no effect (since
the map ignores case), but it paves the way for deprecating (and
eventually removing) the `DiagnosticCode.name` getter.

Change-Id: I6a6a6964f8ba149f883d1e9b2c9168a0929f7803
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466184
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-12-09 06:24:23 -08:00
Paul Berry f46b657711 [messages] Use lower case diagnostic names in analysis_server_plugin.
Changes the logic in `pkg/analysis_server_plugin` to use
`DiagnosticCode.lowerCaseName` instead of `DiagnosticCode.name`. This
ensures that diagnostic codes are matched in a case-insensitive
fashion.

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

Change-Id: I6a6a6964f4733c550f9c1060377e198808190acc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466129
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-12-09 06:16:19 -08:00
FMorschel 9f4c7e5d8b [DAS] Fixes Create setters, getters and fields for using type parameters
Bug: https://github.com/dart-lang/sdk/issues/61186
Change-Id: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442240
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-12-05 10:32:55 -08:00
Paul Berry 7ac6ad6d42 [messages] Make lint name matching case insensitive.
Adjusts the logic in the lint `Registry` class so that lint names are
matched in case-insensitive fashion. For the most part this is
accomplished by adding calls to `.toLowerCase()` inside the `Registry`
class, preserving its API.

For the `enabled` method, preserving the API would have been a pain (I
would have had to translate the keys in the `ruleConfigs` parameter to
lower case). So instead I added an assertion to verify that the keys
were lower case, and pushed the responsibility to the callers to
create lower case keys.

This paves the way for a follow-up CL that will translate diagnostic
codes to `lower_snake_case` conventions.

It also solves a longstanding problem with the mixed case lint rules
`no_runtimeType_toString`, `prefer_for_elements_to_map_fromIterable`,
`prefer_iterable_whereType`. Previously, the user had to carefully
imitate the capitalization of the lint rules when specifying them in
the `analysis_options.yaml` file, even though `// ignore:` comments
for the lints matched in case insensitive fashion. With this CL, the
lint rule names in `analysis_options.yaml` are matched in case
insensitive fashion as well.

Change-Id: I6a6a6964d83241e49878bbf96ef9b94cbb12098b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465964
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-12-03 13:14:49 -08:00
Loïc Sharma 836465deaf Improve the docs of Dart analyzer plugins
Closes https://github.com/dart-lang/sdk/pull/62071

GitOrigin-RevId: ebbb22dde160ff788ad1f2cf6a24f4c86fa636f2
Change-Id: I5b30f18d8f553e8b03dd6dd8ad1e631505224091
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464000
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-12-01 18:35:01 -08:00
FMorschel eb1a814681 [DAS] Fixes create fixes type resolving in for-in loops.
This makes the create fixes correctly suggest `Iterable`, `Future<Iterable>`, or `Future<Stream>` when the awaited expression is used in a for-in loop. It also takes into account the type of the loop variable for the type argument of `Iterable` or `Stream`.

Fixes: https://github.com/dart-lang/sdk/issues/62092
Change-Id: I055af13ee12ceb141f5d75c340c607ae803d0b07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464782
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-30 15:19:55 -08:00
Paul Berry 26c90ed46b [messages] Clean up unignorable error handling.
Prior to this CL, the analyzer's set of unignorable diagnostic code
names (`AnalysisOptionsImpl.unignorableDiagnosticCodeNames`) was
constructed in the following way:

- For each entry in the `cannot-ignore` section of the
  `analysis_options.yaml` file that matches the name of a severity
  code, the names of all diagnostic codes with matching severities
  were added (1).

- All other entries in the `cannot-ignore` section were converted to
  upper case and then added (2).

However, diagnostic codes associated with lints are named using
`lower_snake_case`, while analyzer diagnonstic codes are named using
`UPPER_SNAKE_CASE`.

Some of the logic that consumed
`AnalysisOptionsImpl.unignorableDiagnosticCodeNames` didn't account
for this, resulting in some subtle bugs:

- When the resolved correction producer base class
  `_BaseIgnoreDiagnostic` attempted to figure out if a diagnostic was
  unignorable, it compared elements of
  `unignorableDiagnosticCodeNames` to `DiagnosticCode.name`, which
  meant that it would successfully recognize non-lint codes as
  unignorable, but it would only recognize that a lint code was
  unignorable if it was included in `unignorableDiagnosticCodeNames`
  by putting the name of a severity in the `cannot-ignore` section of
  the `analysis_options.yaml` file.

- When `LibraryAnalyzer._filterIgnoredDiagnostics` attempted to block
  unignorable diagnostics from being ignored, it compared elements of
  `unignorableDiagnosticCodeNames` to `DiagnosticCode.name`,
  `DiagnosticCode.uniqueName`, and
  `DiagnosticCode.name.toUpperCase()`. This worked, however the
  comparison to `DiagnosticCode.uniqueName` had no effect. Note that
  values of `DiagnosticCode.uniqueName` always take the form
  `ClassName.snake_case_diagnostic_code` or
  `ClassName.SNAKE_CASE_DIAGNOSTIC_CODE`. It's impossible for any of
  the values added to
  `AnalysisOptionsImpl.unignorableDiagnosticCodeNames` to ever match
  this, because (1) always adds values of `DiagnosticCode.name` (which
  never contains a `.`), and (2) always adds strings that have been
  converted to upper case.

- When `IgnoreValidator.reportErrors` attempted to report unignorable
  and duplicate entries, it compared elements of
  `unignorableDiagnosticCodeNames` to `IgnoredDiagnosticName.name`,
  which is always lower case. That meant that it would only recognize
  that a diagnostic code was unignorable if the diagnostic code was
  associated with a lint and was included in
  `unignorableDiagnosticCodeNames` by putting the name of a severity
  in the `cannot-ignore` section of the `analysis_options.yaml`
  file. (Note, however, that this bug was unobservable because the
  reporting of the `unignorable_ignore` diagnostic is currently
  disabled; I will address this in a follow-up CL.)

- Additionally, the logic to populate
  `AnalysisOptionsImpl.unignorableDiagnosticCodeNames` based on a
  severity code had a bug in its handling of error processors: if one
  or more error processors were used to change the severity of a
  diagnostic, then entries would be added to
  `AnalysisOptionsImpl.unignorableDiagnosticCodeNames` corresponding
  to both the original and the new severity.

These buggy behaviors have been fixed by:

- Streamlining and simplifying the logic that builds
  `AnalysisOptionsImpl.unignorableDiagnosticCodeNames`, and ensuring
  that all strings added to it are all lower case.

- Changing all logic that checks whether a string is contained in
  `AnalysisOptionsImpl.unignorableDiagnosticCodeNames` so that it
  first converts that string to lower case.

- Removing the ineffective logic in
  `LibraryAnalyzer._filterIgnoredDiagnostics` that attempted to
  compare elements of `unignorableDiagnosticCodeNames` to
  `DiagnosticCode.uniqueName`.

Change-Id: I6a6a6964d89c139492dbb11d8ba3b2d33c0e2ee8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462864
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-11-19 13:46:10 -08:00
Paul Berry e4868ca176 [messages] Clean up ErrorProcessor behavior.
Currently, diagnostic codes associated with lints are named using
`lower_snake_case`, while analyzer diagnonstic codes are named using
`UPPER_SNAKE_CASE`.

However, when the analyzer builds instances of the `ErrorProcessor`
class, it always uses `UPPER_SNAKE_CASE` names.

Some pieces of logic that matched up `ErrorProcessor`s to diagnostic
codes accounted for this difference; others didn't.

This led to a some buggy behaviors:

- If an instance of `ErrorProcessor` got constructed outside of the
  analyzer (by an analyzer client using the analyzer public API), and
  it supplied a `lower_snake_case` name, then
  `ErrorProcessor.appliesTo` would only successfully match if the name
  referred to a lint.

- The resolved correction producer base class `_BaseIgnoreDiagnostic`
  (which forms the basis for the quick fixes "Ignore '...' in
  `analysis_options.yaml`", "Ignore '...' for this line", and "Ignore
  '...' for the whole file") would only notice that a diagnostic was
  unignorable if the case matched exactly. In practice, this meant
  that when operating on instances of `ErrorProcessor` created by the
  analyzer, it wouldn't properly handle lints.

These buggy behaviors have been fixed by:

- Changing the `ErrorProcessor` constructor to always convert the
  `code` to lower case.

- Changing all references to `ErrorProcessor.code` to assume lower
  case.

Change-Id: I6a6a69645284f646e0c070fc2b55c4a90203d74a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462863
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-11-19 11:31:21 -08:00
Sam Rawlins 2fb8ef8417 bump deps to analyzer 10
Change-Id: I181a914a4086d868a3dbed7d817f8bc04a72e2b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462560
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-11-17 12:39:49 -08:00
Konstantin Shcheglov 0349520b98 DeCo. Migrate everything to new AST.
No more flag, always parse into the new AST, always visit new AST nodes,
always return them as child entities, parent-child structure reflects
the new AST.

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

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

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

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

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

Bug: https://github.com/dart-lang/sdk/issues/61701
Change-Id: Ic48104da8b029c9b454bbd2336574b7823025565
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461841
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-11-17 08:57:36 -08:00
Konstantin Shcheglov ba1e7e8c45 Fine. Use 'withFineDependencies: true' in analysis_server_plugin/ and analyzer_plugin/.
Change-Id: If27c37c311afd5647fc1e4e741816ced5c9b576f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462221
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-11-14 15:22:43 -08:00
FMorschel a16f481ecb [DAS] Fixes ignore_for_file fix when documentation comments in first line
Fixes: https://github.com/dart-lang/sdk/issues/61892
Change-Id: Ia4b21162f6c231c5fc456457de32a30612c1cfe9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/459320
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-11-13 15:12:49 -08:00