Commit Graph

764 Commits

Author SHA1 Message Date
Paul Berry 8b66930364 [presubmits] Print stdout,stderr if CheckSorted result can't be parsed.
Previously, in the `CheckSorted` presubmit check, if
`verify_sorted_test.dart` returned a nonzero exit code but none of its
output lines contained the string `Unsorted file`, then a presubmit
failure would be generated containing an empty string, resulting in
confusing output like this:

    Running presubmit upload checks ...
      18.4s to run CheckChangeOnUpload from /home/paulberry/dart1/sdk/pkg/_fe_analyzer_shared/PRESUBMIT.py.
    ** Presubmit ERRORS: 1 **


    Presubmit checks took 21.4s to calculate.
    There were presubmit errors.

This might happen, for example, if `verify_sorted_test.dart` contained
a compile-time error or threw an unhandled exception.

With this change, the message is `CheckSorted: could not parse output
of verify_sorted_test.dart`, followed by the full stdout and stderr
from the attempt.

This should make this sort of failure a lot easier to debug.

Note: I've made this same fix before to
`pkg/_fe_analyzer_shared/PRESUBMIT.py` (see
https://dart-review.googlesource.com/c/sdk/+/485601). I didn't realize
at the time that the code was duplicated.

Note: This should make it easier to debug
https://github.com/dart-lang/sdk/issues/63464.
Change-Id: I4892dcff7ad6969ca40564c1fd7e62e36a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506605
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-05-27 14:34:26 -07:00
Paul Berry 9bd89a769d Work around issue with -r in presubmit scripts.
For some reason, when a `CheckSorted` presubmit invokes
`verify_sorted_test.dart`, the `-r` flag is preventing the compiler
from picking up the proper language version from
`.dart_tool/package_config.json`. This is interfering with my ability
to run presubmits for
https://dart-review.googlesource.com/c/sdk/+/505046.

See https://github.com/dart-lang/sdk/issues/63464 for additional
details.

As a temporary workaround, this CL removes the `-r` flag. It should be
reverted once https://github.com/dart-lang/sdk/issues/63464 has been
fixed (and the pre-built SDK has been updated to include the fix).

Change-Id: Ibc48eec4ef382d6afe17d73454f07dcd6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506700
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-05-27 13:49:54 -07:00
Konstantin Shcheglov 9f1438813f Fix JsonErrorFormatter to use right LineInfo for context messages.
Change-Id: Icd9e254308a54e47ea3be63220ada5fd028712e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500660
Reviewed-by: Paul Berry <paulberry@google.com>
2026-05-06 11:28:54 -07:00
Konstantin Shcheglov 921ec7f507 CQ. Simplify Scanner constructors.
Replace the positional Scanner constructors with a single constructor
that takes the input text and error reporting callback as named required
arguments.

Remove the unused fasta forwarding constructor, reader offset handling,
and stored first token. The scanner now keeps only the input text and
returns the token stream directly from tokenize.

Update analyzer, analysis server, plugin, CLI, scrape, and scanner test
call sites to use the named constructor arguments.

Change-Id: Ieabb7b28570d4a963563fb2d1c5ef5ac0c89032a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500340
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-05-05 14:04:00 -07:00
Konstantin Shcheglov 245f876407 CQ. Abstract Scanner away from DiagnosticReporter, so that we don't need Source to scan.
Change-Id: I377a49a7997f416acdfde3a05616715abaa84ad8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499780
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2026-05-01 09:17:00 -07:00
Konstantin Shcheglov 3409224923 CQ. Use actual diagnostics in analyzer_cli OptionsTest.
Change-Id: I94c2f1b77ad948a6ac612626c7264b6d1cfa901c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499664
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-05-01 08:18:53 -07:00
Konstantin Shcheglov 70577807bd CQ. Use actual, not mock results in analyzer_cli reporter tests.
Change-Id: I050289421791b3b2be56f82fc5ebab6bb048a500
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499423
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-04-30 08:23:17 -07:00
Sam Rawlins e06cdb847e analyzer: Make SourceFactory.resolveUri take non-nullable parameters
The function mostly returned null/nonsense if given a null argument,
and the few call sites with nullable arguments (in tests and tools)
are easily tweaked.

Change-Id: I7f9993696c4bd822b648a5a89114e6af25eac552
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490020
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-03-23 20:43:22 -07:00
Paul Berry d6db1483e0 Bump model packages to language version 3.12.
This CL is part of an effort to bump the SDK requirement to `3.12.0-0`
for all the packages in `pkg` that are not published to `pub`, so that
we can get better testing of the "private named parameters" feature.

(Packages that *are* published to `pub` can't be safely bumped yet,
because SDK 3.12 hasn't been released, and I don't want to block those
packages' ability to publish useful updates to customers.)

This change covers the following packages, which are owned by
OWNERS_MODEL:
- pkg/analyzer_cli
- pkg/frontend_server
- pkg/testing

Changes to `pubspec.yaml` files were made manually.

Changes to `.dart` files were made automatically, using `dart fix` to
fix failures in the unnecessary_underscores lint.

Change-Id: Ie444a97b2aed3f9eabfde4963c19cfb26a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487883
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Paul Berry <paulberry@google.com>
2026-03-13 15:48:42 -07:00
Paul Berry d9f191575a [analzyer] Refactor analyzeAnalysisOptions into a class.
Replaces the top level function `analyzeAnalysisOptions`, which
contained 3 nested local functions, with a class
`AnalyzeAnalysisOptions`, where the nested local functions have been
changed into private methods.

All the variables in the top level function that were implicitly
write- or read-captured by the nested local functions have been
changed into class fields or explicit method parameters. This should
make the code a lot easier to follow.

In this CL, I've tried hard to preserve the existing functionality
exactly; besides converting local variables to fields and parameters,
I haven't really made any changes to the core logic beyond code
motion. In follow-up CLs, I plan to make some simplifications that are
less obviously semantics preserving (but should be easier to review
since they won't involve so much code motion). Once that is done I
hope to be able to migrate the error reporting in this class to use
the literate diagnostic API.

Change-Id: I6a6a696414ecae80535c8d6633eaa567d37dcccc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/479080
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2026-02-09 14:00:42 -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
Jake Macdonald 39eba46d91 add presubmit checks for sorting, support only checking changed files
BUG: https://github.com/dart-lang/sdk/issues/52064
Change-Id: Ie45f22cbfb9f97018ba2bf6256f1470abc95a220
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476980
Commit-Queue: Jake Macdonald <jakemac@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-02-02 08:18:20 -08:00
Sam Rawlins d337f4b84b analyzer: rename "packages" files to "package config" files
I found one instance of a variable called "packagesFile" and well, I
pulled that thread :/

There is a nice functional simplification here: The `_findPackagesFile`
function returned a `_PackagesFile` object, which contained both a
`Folder parent` and a `File file`. The latter was never referenced, so
simplification 1. Also, the reason to have an object that stores both
is that this object handled both `.packages` files, whose immediate
parent is `parent`, and `package_config.json` files, whose _grandparent_
is `parent`. But with the distinction gone, we don't need this
`_PackagesFile` class, and `_findPackagesFile` can instead return the
folder, and be renamed `_findFolderWithPackageConfigFile`.

Change-Id: Id7cfad02bad16baeebfd8a719a3a92187fec730f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475930
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-01-28 10:29:02 -08:00
Sam Rawlins d3ecc0f8a7 anlyzer: Simplify AnalysisOptionsProvider exception-logic, non-nullable _sourceFactory
Change-Id: I8eb2484340a939107abfad88bbf7a919c1461a75
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475785
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-01-27 08:59:11 -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
FMorschel ac0be94edd [analyzer] Adds lineNumberDifference and onSameLine methods to LineInfo
Bug: https://github.com/dart-lang/sdk/issues/61186
Change-Id: Ib0584203b000103f8137901c258a86ec571ff74c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471061
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-01-07 10:15:29 -08:00
Slava Egorov b3857af0e5 Bump core to 58b0a108b4d1310465e8482d6629357891df1cb1
Changes:
```
> git log --format="%C(auto) %h %s" 5c3e2c3..58b0a10
 https://dart.googlesource.com/core.git/+/58b0a108 Make it possible to add default subcommand (925)
 https://dart.googlesource.com/core.git/+/e43ff949 feat(collection): Replace quickSort with pdqsort for performance and robustness (922)
 https://dart.googlesource.com/core.git/+/f2efaaf3 Bump actions/checkout from 5.0.0 to 6.0.0 in the github-actions group (924)
 https://dart.googlesource.com/core.git/+/33b52327 Add `separated`, `separatedList` and `separate` to iterables and lists. (919)
 https://dart.googlesource.com/core.git/+/20ed9668 Add use_null_aware_elements to recommended (923)
 https://dart.googlesource.com/core.git/+/e6c3810c [crypto] remove the -wip to release new version (921)
 https://dart.googlesource.com/core.git/+/f7a786ac Bump actions/stale from 10.0.0 to 10.1.0 in the github-actions group (920)
 https://dart.googlesource.com/core.git/+/018e1dc7 fix(crypto): update conditional import for js interop library (915)
 https://dart.googlesource.com/core.git/+/9fefb52b Make Int64 default constructor non-const in native mode (916)
 https://dart.googlesource.com/core.git/+/f00841de Bump the github-actions group with 2 updates (914)
 https://dart.googlesource.com/core.git/+/7fee9c06 Fix `Int64.operator ==` (911)
 https://dart.googlesource.com/core.git/+/a4dc8738 Implement `Int64` as a wrapper for `int` when targeting native and Wasm (905)
 https://dart.googlesource.com/core.git/+/1aa58ef5 [fixnum] update the min. required dart sdk (907)
 https://dart.googlesource.com/core.git/+/60f2b5d3 Run fixnum tests with dart2wasm (906)

```
Diff: https://dart.googlesource.com/core.git/+/5c3e2c38df268be2347f3aad30ced0147dd012bb..58b0a108b4d1310465e8482d6629357891df1cb1/

Change-Id: Ibde49f27d1d26b8fc1aad3fd7df3efd924796b33
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467361
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2025-12-12 00:42:31 -08:00
Paul Berry 479a081852 [messages] Use lower case diagnostic names in analyzer_cli.
Changes the logic in `pkg/analyzer_cli` to use
`DiagnosticCode.lowerCaseName` instead of `DiagnosticCode.name`, and
`DiagnosticCode.lowerCaseUniqueName` instead of
`DiagnosticCode.uniqueName`. This ensures that diagnostic codes are
matched in a case-insensitive fashion.

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

Change-Id: I6a6a6964f1254f248d2b772f69e33adf0b682bb9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466186
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-12-09 06:32:27 -08:00
Paul Berry 46f62c8f69 [messages] Add lowerCaseName and lowerCaseUniqueName to DiagnosticCode.
Adds the getters `lowerCaseName` and `lowerCaseUniqueName` to the
`DiagnosticCode` class. These getters behave the same as the `name`
and `uniqueName` getters, except that they convert the string to lower
case before returning. These getters should help make it easier for
the analyzer and related packages (as well as analyzer clients) to
treat diagnostic codes in a case-insensitive fashion.

In follow-up CLs, I plan to switch the analyzer and related packages
over to using the new getters, and then I'll deprecate and eventually
remove `name` and `uniqueName` from the analyzer public API.

Change-Id: I6a6a6964e8891fc6f74a9777eae375f1a553c2f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466182
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-12-08 09:57:56 -08:00
Paul Berry ce0c219753 [analyzer_cli] Remove unused CommandLineOptions.
Removes the field `AnalyzerImpl.options`, the `options` parameter of
the method `Driver._runAnalyzer`, and the `commandLineOptions`
parameters of the functions `computeSeverity` and
`determineProcessedSeverity`. None of these were used.

Change-Id: I6a6a6964617cecb81f0d1c6570be1d78fb599af4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463085
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-11-19 15:17:59 -08:00
Paul Berry 9f6d1c1029 [messages] Start using toplevel diagnostic constants.
Changes the analyzer and related packages so that when they refer to
diagnostic constants, they do so via the import prefix `diag`, which
refers to the appropriate `diagnostic.dart` file containing the top
level diagnostic constant declarations, rather than the static
declarations inside `DiagnosticCode`-derived classes (which will soon
be removed).

This CL was created by the following steps:

- Run the script
  `pkg/analyzer_utilities/tool/messages/switch_to_toplevel_diagnostics.dart`.

- Execute `dart fix --apply --code=unused_import,unnecessary_import`
  on the following directories (this removes imports that are no
  longer necessary due to the change):
  - `pkg/analysis_server`
  - `pkg/analyzer`
  - `pkg/linter`
  - `pkg/analysis_server_plugin`
  - `pkg/analyzer_plugin`
  - `pkg/analyzer_testing`
  - `pkg/front_end`
  - `pkg/analyzer_cli`

- Execute `dart format` on the following files and directories:
  - `pkg/analysis_server`
  - `pkg/analyzer`
  - `pkg/linter`
  - `pkg/analysis_server_plugin`
  - `pkg/analyzer_plugin`
  - `pkg/analyzer_testing`
  - `pkg/front_end/test/scanner_test.dart`

  (Note that `pkg/front_end` and `pkg/analyzer_cli` are not
  re-formatted as whole directories because they contain `.dart` files
  that are test cases rather than source code, and reformatting those
  files might change test expectations.)

- Manually add `diag` to
  pkg/front_end/test/spell_checking_list_tests.txt.

- Manually fix the ignore comment in
  `pkg/analyzer_testing/lib/src/analysis_rule/pub_package_resolution.dart`. (The
  script `switch_to_toplevel_diagnostics.dart` automatically adds it
  after `import 'package:analyzer/src/diagnostic/diagnostic.dart' as
  diag;`, but then executing `dart format` bumps the ignore comment to
  the following line, where it has no effect.)

Change-Id: I6a6a69643022aab2b5a6224fb4124eead243260d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461521
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-12 16:53:42 -08:00
Paul Berry ea768b29a4 [messages] rename diagnostic.dart.
Renames `pkg/analyzer/lib/src/diagnostic/diagnostic.dart` to
`pkg/analyzer/lib/src/diagnostic/diagnostic_message.dart`. The new
name aligns better with the library's purpose (which is solely to
export the class `DiagnosticMessageImpl` from
`package:_fe_analyzer_shared`).

This frees up the filename
`pkg/analyzer/lib/src/diagnostic/diagnostic.dart` to be used as the
repository for all generated analyzer messages.

Change-Id: I6a6a6964be0904a383334974f1e64a03c0df551b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/458381
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-10-29 15:08:40 -07:00
Konstantin Shcheglov 6c5631ed88 Fine. Enable in analyzer_cli/.
Not for performance, because it is one shot, but all language/ and co19/
code will go through manifests builder, and give us better coverage.

Change-Id: Iae83ec685084847358d960deff81d18fb9904f4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456404
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-10-21 14:38:58 -07:00
Konstantin Shcheglov 05bcfd2571 Breaking changes for analyzer version 9.0.0
Change-Id: I4d1b611edcf5340543b5cabf93b88a103408920b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/444924
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-10-19 13:29:07 -07:00
Jens Johansen 2c0648dd7d [analyzer cli] Don't ask for errors on the same file several times
```
$ out/ReleaseX64/dart pkg/front_end/tool/benchmarker.dart --silent --iterations=10 --gcs=5 --snapshot=pkg/analyzer_cli/bin/analyzer.aot.1 --snapshot=pkg/analyzer_cli/bin/analyzer.aot.2 --arguments="/tmp/extracted_compile_dart_compile/"
Will now run 10 iterations with 2 snapshots.
..............................

Comparing snapshot #1 (analyzer.aot.1) with snapshot #2 (analyzer.aot.2)
msec task-clock:u: -7.7915% +/- 1.2399% (-851.98 +/- 135.58) (10934.74 -> 10082.76)

page-faults:u: -1.7454% +/- 1.1131% (-2457.20 +/- 1566.98) (140777.80 -> 138320.60)
cycles:u: -5.6010% +/- 1.2559% (-2318118149.50 +/- 519783195.96) (41387425609.80 -> 39069307460.30)
instructions:u: -7.0130% +/- 0.5970% (-3636754009.20 +/- 309595118.25) (51857207312.90 -> 48220453303.70)
branch-misses:u: -6.2869% +/- 4.5941% (-9795625.90 +/- 7158088.69) (155810738.90 -> 146015113.00)
seconds time elapsed: -7.7884% +/- 1.2389% (-0.85 +/- 0.14) (10.94 -> 10.09)
seconds user: -6.0176% +/- 1.4855% (-0.59 +/- 0.14) (9.75 -> 9.16)
seconds sys: -22.3326% +/- 4.4197% (-0.27 +/- 0.05) (1.19 -> 0.92)
Comparing GC:
No change in combined time.
```
Change-Id: Ibb34829a42770c22567bc1399bcf7eaf26201e99
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/449121
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-09-11 05:45:20 -07:00
Sam Rawlins 958ae6ab1e analyzer: Simplify AnalysisContextCollectionImpl with new updateAnalysisOptions4 parameter
The new updateAnalysisOptions4 parameter is a callback function,
similar to updateAnalysisOptions3, but with one removed parameter
itself, the `DartSdk sdk` parameter.

The one place where this parameter was used in the callback passed by
the caller, was in DAS's ContextManager, and it was just used in order
to compute a FeatureSet from (a) the computed DartSdk and (b) the
command-line `--enable-experiment` options. We can instead provide a
`enabledExperiments` parameter on AnalysisContextCollectionImpl,
leading to a simpler API and still a simple implementation in
ContextBuilder.

The reason for the incremental migration is that dartdoc, and possibly
some internal clients, use updateAnalysisOptions3.

Change-Id: Ie990ab8f7b850aed1ce3ef39ab71c01835c080da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/447400
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-08-27 11:05:29 -07:00
Sam Rawlins 0513a22206 analyzer_cli: Bump language version to 3.9
Change-Id: I4d696cb827c993e95c1f0c946b8cbce636a390fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/447140
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-08-27 08:45:06 -07:00
FMorschel 83ecfc3ef0 [DAS] Adds some warnings for the analysis_options file
Adds `incompatible_lint` for included rules (and some variants of it) and `unsupported_value` error for linter rules values.

Original change: https://dart-review.googlesource.com/c/sdk/+/419982
Original change reverted at: https://dart-review.googlesource.com/c/sdk/+/429381

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

Change-Id: I0bc9a1a3c101c6455b8731cc0a40a39b6dfb5aac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429240
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-08-26 12:17:43 -07:00
Paul Berry f2123a8f7c [analyzer] Rename error constants to camelCase.
This change was generated by the following process:

- The script `pkg/analyzer/tool/messages/rename_error_constants.dart`
  was run. This generated the vast majority of the diffs.

- Then all modified files were reformatted using
  `tools/sdk/dart-sdk/bin/dart/format`.

- Finally, the script `pkg/analyzer/tool/messages/generate.dart` was
  run, to rebuild generated code.

Change-Id: I6a6a69644ed8740ad6269d98cb169076151824ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/444921
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-08-13 22:02:42 -07:00
Sam Rawlins 0ffd2849e4 analyzer: Move analysis options-validating code out of "task"
* OptionsValidator was defined in the `src/plugin/` directory (the only
  file in there), which I found confusing. Moved it to
  `src/analysis_options/`.
* OptionsFileValidator, and a few related classes, were defined in the
  `src/task/` (the last file in there!), so I moved it to the same
  place.

There is more to tidy in here, but this is a simple file-move.

Change-Id: I8f4c5cc0ae4e76eb6c17249457c50ab69c82590d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/443147
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-07-31 15:05:31 -07:00
Paul Berry 96efc10c68 Ignore TODOs in analyzer_cli package.
Some time ago, the analyzer team decided to adopt the convention of
using `TODO` comments to document long term issues that should persist
in the codebase, and `FIXME` comments to document short term issues
that need immediate attention.

Accordingly, it makes sense to suppress `TODO` comments from being
surfaced to the IDE "problems" view (since there can be a lot of them,
and they're not immediately actionable).  This makes VSCode's
"problems" view much more usable in "tree" mode.

Previous CLs that have made this change in other packages:
- https://dart-review.googlesource.com/c/sdk/+/295662
- https://dart-review.googlesource.com/c/sdk/+/325121
- https://dart-review.googlesource.com/c/sdk/+/358980
- https://dart-review.googlesource.com/c/sdk/+/410060
- https://dart-review.googlesource.com/c/sdk/+/440546

Change-Id: I2df5fc3ad1da3d2654622e5e276ed3e3a841eb7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442167
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-07-24 16:02:28 -07:00
Fedor Shcheglov 238cd4c20a Deprecate constants2, lookUpInheritedMethod2, lookUpInheritedMethod2, classes2, classes2, extensionTypes2, extensions2, functions2, libraryExports2, libraryImports2, libraryImports2, mixins2, topLevelVariables2, typeAliases2, join2, isNonSubtypableClass2, and typeParameters2.
Change-Id: Ia4b5504d91548b561e2e2434e711c40b2dc5e495
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/440100
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-07-12 16:23:12 -07:00
Fedor Shcheglov 7218145cd2 Deprecate appendToWithoutDelimiters2, correspondingSetter2, unnamedConstructor2, getNamedConstructor2, entryPoint2, exportedLibraries2, getClass2, getEnum2, getMixin2, exportedLibrary2, accessibleExtensions2, importedLibraries2, importedLibrary2, isImplementableIn2, join2, variable3, getter2, setter2, correspondingGetter2, superConstructorParameter2, aliasedElement2, typeParameters2, constantInitializer2, and isNonSubtypableClass2
Change-Id: I091804b9f200f525baf3979773dd489e3be17697
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439640
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-07-09 20:34:14 -07:00
Sam Rawlins ee69f45a1f analyzer: rework AnalysisErrorListener deprecation
Work towards #60635

In this change, we rework the AnalysisErrorListener deprecation to
better support users who have their own class that implements
AnalysisErrorListener. This change introduces a sealed supertype,
DiagnosticOrErrorListener, with the old implementation,
AnalysisErrorListener, and the new implementation, DiagnosticListener,
as its sole direct subclasses. Users who have implemented
AnalysisErrorListener should be able to instead implement
DiagnosticListener, and their class is an acceptable instance of
DiagnosticOrErrorListener, wherever that is needed.

In a breaking change we can drop AnalysisErrorListener and deprecate
DiagnosticOrErrorListener, and in the next breaking change, we can drop
DiagnosticOrErrorListener.

For reference, see the first API difference when deprecating AnalysisErrorListener and introducing DiagnosticListener: https://github.com/dart-lang/sdk/commit/903d77cc8229972a424941dcb7b7b79741e833eb#diff-dec15868961d7eadcd009f49d129bebcdb747aaa8dbfde5f5a08884e0cf11e32

Change-Id: I3ccf11d54b41fbca98d020d89978d250c16b4c04
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436480
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-25 06:54:20 -07:00
Sam Rawlins 69cd0ee5f6 analyzer: Deprecate "errorCode" parameters in Diagnostic constructors
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: Ifc173ec6e5924057fee3c420c8916f0abb257428
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434141
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-11 14:19:09 -07:00
Sam Rawlins 7b42aae99f analyzer: Deprecate AnalysisResultWithErrors.errors in favor of .diagnostics
Also rename UnitAnalysisResult.errors (package-private API) to .diagnostics

Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: I0bdd7c9c19cff3bff9ee61fe4689564a7b5b727b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433581
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-09 15:51:01 -07:00
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
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
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
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
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
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
Sam Rawlins c4c9854b9b analyzer_testing: Move ResourceProviderMixin to analyzer_testing
Work towards https://github.com/dart-lang/sdk/issues/55660

Change-Id: I31932409e495369793dd16c017385c98b86cf44c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427480
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-09 16:56:29 -07:00
Sam Rawlins 8a17ad9f05 analyzer: Deprecate AnalysisError in favor of Diagnostic
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: If9bbc96beed95129b099588c5bd9728afda8e392
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426902
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-05-08 14:02:16 -07:00
Sam Rawlins 739ca671af Deprecate MemoryResourceProvider.convertPath in favor of extension
Work towards https://github.com/dart-lang/sdk/issues/55660

The comment for `MemoryResourceProvider.convertPath` includes:

> This is a utility method for testing; paths passed in to other
> methods in this class are never converted automatically.

and indeed, the actual impl of this method is found in an extension,
in analyzer's test_utilities/ directory. It seems to me better to
leave a testing utility as a testing utility, and not expose it in
the public API of MemoryResourceProvider.

Additionally, the extension method is used by `ResourceProviderMixin`,
which is moving to the public analyzer_testing package. It is illegal
to have a circular non-dev dependency between the analyzer package
and the analyzer_testing package.

The migration for the ~half dozen test files that use this method is
to call the extension method directly. Sometimes with an extension
override, and sometimes without.

Change-Id: I9c2e18600461134bfd91c082b3af0d5079600f0c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426984
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-07 13:10:03 -07:00
Sam Rawlins 49562fd152 analyzer: Deprecate ErrorCode in favor of replacement: DiagnosticCode
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: I0cfc0bff4e5d10b7cb373f77de55fffc13b8cf76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426641
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-06 14:43:10 -07:00
Sam Rawlins e98a2af452 analyzer: Use DiagnosticSeverity in _fe_analyzer_shared and analyzer_cli
Work towards https://github.com/dart-lang/sdk/issues/60635

DiagnosticSeverity is the new name for ErrorSeverity.

Change-Id: I23a0e3d487934cea2f44a673215bc22faf34ee52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426000
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-05 11:11:20 -07:00
Sam Rawlins 35e8b9ba0b analyzer: Deprecate ErrorType in favor of new name, DiagnosticType
Change-Id: I552e816de6d526e3476cac9dd3ee2919fc7ec499
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425720
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
2025-04-30 19:07:42 -07:00
Sam Rawlins 992cfb13bc analyzer: Deprecate AnalysisError.correction; simplify other final fields
Work towards https://github.com/dart-lang/sdk/issues/60635

* `AnalysisError._contextMessages` unnecessarily backed the public
  `contextMessages` getter; the field is final so it can be public
  itself.
* `AnalysisError._correctionMessage` unnecessarily backed the public
  `correctionMessage` getter; the field is final so it can be public
  itself.

Change-Id: If269d4ed590ef7df81d9b9e3be03766601526d7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425620
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-04-30 16:06:19 -07:00
Kevin Moore 67a24ea983 [pkg] drop lints already covered by the included lint file
Change-Id: I84fdee27e3e28576187896502e5ffed487ee232f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425408
Reviewed-by: Moritz Sümmermann <mosum@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Kevin Moore <kevmoo@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Kenzie Davisson <kenzieschmoll@google.com>
2025-04-30 11:58:24 -07:00