74ef6d1740
Work towards https://github.com/dart-lang/sdk/issues/61490 When a plugin re-resolves a library [1] via `AnalysisSessionImpl.getResolvedLibrary`, which calls `AnalysisDriver.getResolvedLibrary`, eventually we get down to `LibraryAnalyzer.analyze`. This method contains the singular piece of code that checks `AnalysisOptions.lint` and `AnalysisOptions.warning` [2]. A plugin re-resolves a library in order to parse the code, and ultimately resolve the library into a LibraryElement. It does _not_ use any lint computed by `LibraryAnalyzer.analyze()`, nor any warnings, nor even any compile-time errors. So we should do our best to do the minimal amount of work that still gets us our LibraryElement. Setting `AnalysisOptions.lint` and `AnalysisOptions.warning` reduces the amount of work that `LibraryAnalyzer.analyze()` does. [1]: https://github.com/dart-lang/sdk/blob/c11f9118692461f61570e1ee07b6f5fc43288bb0/pkg/analysis_server_plugin/lib/src/plugin_server.dart#L351 [2]: https://github.com/dart-lang/sdk/blob/c11f9118692461f61570e1ee07b6f5fc43288bb0/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart#L342-L359 Change-Id: I73413a6646b14ff3a01246470b00e0a3676c4b3a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/450365 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Samuel Rawlins <srawlins@google.com>
analysis_server_plugin package
This package offers support for writing Dart analysis server plugins.
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: