Commit Graph

14 Commits

Author SHA1 Message Date
Konstantin Shcheglov 3009984866 CQ. Replace many parseStringWithErrors() with parseTestCodeWithDiagnostics().
Change-Id: Id992c63a83bbb8eb2f2539f8735b72ee1c3a2e39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504121
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-20 09:34:54 -07:00
Konstantin Shcheglov 6cd3938741 Breaking changes for analyzer 13.0.0
https://github.com/dart-lang/sdk/issues/62799
https://github.com/dart-lang/sdk/issues/62944
https://github.com/dart-lang/sdk/issues/63002
https://github.com/dart-lang/sdk/issues/62970

Looks mostly green in google3: https://fusion2.corp.google.com/presubmit/901021300/OCL:901021300:BASE:901308428:1776439417713:37cd1695

Change-Id: I44754a48f66a0b58851d7c20fcfa61f7fb1b555a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488624
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-04-17 23:06:25 -07:00
Konstantin Shcheglov c421bc9df2 CQ. Migrate ComplexParserTest to parseStringWithErrors and assertParsedNodeText.
Rewrite ComplexParserTest to parse full snippets with
parseStringWithErrors and verify AST shape with assertParsedNodeText.

This moves the suite from fragment-oriented parsing and ad hoc property
checks to the parser diagnostics harness, so each case now asserts the
parsed structure and the recovered diagnostics together. That makes the
tests more explicit about precedence, recovery, and how complex
constructs are embedded in real code.

Update the migrated cases to select nodes from wrapped function or class
bodies, and add FindNode.firstBinaryExpression to make that navigation
easier.

Adjust expectations where full-snippet parsing recovers differently from
expression-only parsing, including written-out operator cases that now
validate the parser's actual recovered AST.

Change-Id: I06ff024afac03a2814943aa3228de99e767cdc84
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485584
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-03-05 10:23:02 -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
FMorschel 240eda5647 [analyzer] Migrates to contexMessages from analyzer_testing package
This also includes some small refactorings for parameter names to start using the diagnostic wording instead of error. As well as a small change to `contextMessage` and related to use a list of `Pattern`s instead of a single `String` for better matching.

In future CLs, the TODOs added in this one will be addressed so we can fully migrate this. Added them because of the size of the CL.

Bug: https://github.com/dart-lang/sdk/issues/61557
Change-Id: I5557668a1baed98faff977255c9f22e0d9d96008
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452180
Commit-Queue: Paul Berry <paulberry@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-10-20 13:37:00 -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 24fbe71dd6 analyzer: Use DiagnosticCode instead of ErrorCode in tests
Change-Id: I6b70bda2e678777efdfde7c0cb9dca4ec85b27e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425686
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-01 09:18:03 -07:00
Konstantin Shcheglov becd91df17 Format analyzer/ with tall mode.
Change-Id: I410cd1cf63fbf00b868bbb3e060433cad3ac9e6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423520
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-04-21 12:15:58 -07:00
Sam Rawlins 50c1d9e1a3 analyzer: Fix remaining comment reference issues
Change-Id: I345c8d25e9f27dedffc596a2040cd89e059eb46e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/408880
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-02-11 07:12:20 -08:00
Konstantin Shcheglov b41ae230a2 Replace many casts to TypeName with NamedType.
Change-Id: I485b7a3e268c59c435f02e3357dc5dcf256e627e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214067
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-09-21 20:32:38 +00:00
Sam Rawlins 51d5c58d6a Remove redundant imports from analyzer
Many of these are a redundancy between
    'package:analyzer/src/generated/source.dart' and
    'package:analyzer/src/generated/source_io.dart'

I chose to remove the latter, for no particular reason.

Bug: https://github.com/dart-lang/sdk/issues/44569
Change-Id: Ic69b09fd502c978cef9e4d3b8a0ef9acd92d5184
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213849
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-09-20 15:22:51 +00:00
Konstantin Shcheglov 9f986d2501 Migrate package:analyzer to null safety.
Change-Id: Iffe4370431587e46a141ddc72a86ceec29c163b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176486
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-02-01 18:56:04 +00:00
Jens Johansen 16a66c8902 [parser] Don't crash, try to recover from written out logical operators and and or
Fixes #44785

Change-Id: I4c7198ea1c223900a58039c032ee303d7da2c14f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181580
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-02-01 09:30:48 +00:00
Sam Rawlins cad324cf79 Analyzer: Extract all parser tests to individual files
Change-Id: Ia3f85355186e25d4cc38fcb15ed3770a1db5805c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176360
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-12-15 22:57:21 +00:00