Files
sdk/pkg/analysis_server_plugin
Paul Berry e3bdaae457 [messages] Clean up references to DiagnosticCode-derived classes.
Replaces "is" tests that refer to classes derived from
`DiagnosticCode` with tests on `DiagnosticCode.type`:

- `x is ScannerErrorCode || x is ParserErrorCode` is replaced with
  `x.type == DiagnosticType.SYNTACTIC_ERROR`. This is exactly
  equivalent, because `ScannerErrorCode` and `ParserErrorCode` are the
  only two `DiagnosticCode`-derived classes whose `type` method returns
  `SYNTACTIC_ERROR`.

- `x is TodoCode` is replaced with `x.type ==
  DiagnosticType.TODO`. This is exactly equivalent, because `TodoCode`
  is the only `DiagnosticCode`-derived class whose `type` method
  returns `TODO`.

- In `statement_completion.dart`, `x is! HintCode && x is!
  WarningCode` is replaced with `x.type ==
  DiagnosticType.SYNTACTIC_ERROR`. The new test is less accepting: for
  example, it previously accepted diagnostics of type
  `StaticWarningCode`. This test is used to short-cut the generation
  of statement completions such as completing an incomplete `do`
  statement. These completions are only necessary to generate if there
  is a syntax error, so there should be no user-visible behavior
  change.

- In `fix_processor.dart`, `x is LintCode || x is HintCode || x is
  WarningCode` is replaced with `x.type == DiagnosticType.LINT ||
  x.type == DiagnosticType.STATIC_WARNING`. The new test is more
  accepting: it now accepts any diagnostic code whose type is
  `STATIC_WARNING`, when previously it only accepted warnings of type
  `WarningCode` (and rejected warnings of types like
  `StaticWarningCode`). This test determines when quick fixes like
  "ignore diagnostic on this line" are offered, so the behavior change
  is appropriate.

- Also replaces a documentation reference to `TodoCode` (in
  `todo_codes.dart`) with a reference to `DiagnosticType.TODO`.

These changes pave the way for a follow-up CL in which I plan to
eliminate these derived classes entirely.

Change-Id: I6a6a69647ff62dfe06b0219d8b292da53427cf0d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461140
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-11-11 11:49:27 -08:00
..
2025-11-03 11:49:49 -08:00
2025-11-04 06:58:25 -08:00
2025-11-03 11:49:49 -08:00

analysis_server_plugin package

This package offers support for writing Dart analysis server plugins, for Dart 3.10 (Flutter 3.38) and later.

Analysis server plugins empower developers to contribute their own Dart static analysis in IDEs and at the command line via dart analyze and flutter analyze. Analysis server plugins can offer the following static analyses:

  • analysis rules, which report diagnostics in the IDE, and at the command line
  • IDE quick fixes, which are local refactorings offered to users to correct a given diagnostic
  • IDE quick assists, which are local refactorings that are offered at specific syntax nodes in code, but do not necessarily correct a static code issue

Review the following documents for how to write and how to use analysis server plugins: