Commit Graph

32 Commits

Author SHA1 Message Date
Konstantin Shcheglov b1ee5a3ec3 CQ. Replace MockSource with FileSource in analyzer_plugin/.
Change-Id: Id45b00c588a7557e3cf6258b26afe25ea3848372
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499741
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-04-30 22:30:34 -07:00
Sam Rawlins b40781459a Bump analyzer_plugin to use Dart SDK 3.9.0
Change-Id: Ice7b7e978ccc666c18cbea9cb9e79673893066ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/448221
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-09-02 14:07:49 -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 126def2b08 analyzer_plugin: Use Diagnostic instead of deprecated AnalysisError
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: Icf62987d6de7cafb6f6e92076a5fcc2bd48772c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426522
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-05 11:34:00 -07:00
Sam Rawlins 895093e9f9 Initial PluginServer implementation
This is the core implementation of the "plugin server" that will support the API described at https://docs.google.com/document/d/1T8P323DJxsc3YPzveNIaSKWFkrJp9ydTR4jp_XFb7XQ/edit?resourcekey=0-f8Ue29KMUizqXNGhATp1tg#heading=h.23fjh5hfm2is

This is heavily curbed from the ServerPlugin class at
`package:analyzer_plugin/plugin/plugin.dart`, but does not depend on it.
It depends on two concepts from the analyzer_plugin package: (1) the
protocol used for de/serializing requests, responses, etc. And (2) the
`PluginCommunicationChannel` class. This is also just a utility for
communicating between the analysis server and the plugin server.

This plugin server is capable of "registering" individual "plugins",
which allows plugins to register individual (maybe multiple) lint rules,
and individual (maybe multiple) quick fixes.

The plugin server for now only responds essentially to three requests:

* `ANALYSIS_REQUEST_SET_CONTEXT_ROOTS`
* `EDIT_REQUEST_GET_FIXES`
* `PLUGIN_REQUEST_VERSION_CHECK`

All files are analyzed during `handleAnalysisSetContextRoots`, and
quick fixes are calculated during `handleEditGetFixes`.

There are many TODOs, but the included test shows that this plugin
server can notify the analysis server of lint diagnostics to be
reported, and can respond to a query for quick fixes.

Change-Id: Ibc93332319220a2caf49d20ab480940041a15049
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382480
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-08-29 16:03:42 +00:00
Sam Rawlins 73ab31b98a analyzer: Move the Source class to be public API.
Deprecate accessing LineInfo, Source, or SourceRange via the
old library (pkg/analyzer/lib/src/generated/source.dart).
Migrate all SDK code to the new library.

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

Change-Id: Ic7c98a5820415c92a457f9fa2756351b05520cd1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335382
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-11-14 17:10:37 +00:00
Konstantin Shcheglov 46b73c6785 Use AnalysisContextCollection for DartServerPlugin.
Not for landing, has debug logging.

There is also an example (also not for landing) of a concrete plugin.

Change-Id: Id79336205b7b6d4cd462e7cfa0fdc7bea41c2987
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243161
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-06-21 18:48:44 +00:00
Konstantin Shcheglov 139385c615 Breaking changes for analyzer version 4.0.0
Change-Id: I26961f29f9171e94db2f5c95f1f8af5fd01bb9b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233681
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-04-07 06:52:27 +00:00
Konstantin Shcheglov 3b89039454 Deprecate Source.isInSystemLibrary
Change-Id: Ifb76cc37e5b0aa86713675cf27086f6ce7625fbd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220822
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-11-19 20:30:37 +00:00
Konstantin Shcheglov d6d45d96f8 Deprecate Source.modificationStamp
Change-Id: Id7f361beff1c4e3f9edc743c58cce7888d330c1f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220860
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-11-19 19:33:07 +00:00
Konstantin Shcheglov fb05622b3b Deprecate Source.uriKind
We almost can remove it.
Unfortunately surveyor/lib/src/analysis.dart uses it, so we need to
update it first.

Change-Id: I239d24506f99183147bf45744a6f8d66d3eb4f94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220826
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2021-11-19 18:29:07 +00:00
Konstantin Shcheglov 7e6b3d83b8 Mark all Source.encoding implementations deprecated.
Change-Id: If12b9af54def3754a701477241d8364c283921ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220823
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-11-19 16:03:27 +00:00
Konstantin Shcheglov bb732826fb Stop implementing AnalysisTarget by Source, remove source and librarySource getters.
Change-Id: I3a1d81ea33641156dccc67b1ed486e449741a5e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220824
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-11-19 16:02:47 +00:00
Konstantin Shcheglov 114d7b980a Migrate analyzer_plugin package to null safety
Bug: https://github.com/dart-lang/sdk/issues/45236
Change-Id: I01175a2b2b1eb3ce6cdf30ade794d8186c6e8ead
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191622
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-03-30 00:29:37 +00:00
Konstantin Shcheglov a45d66c6e9 Make MockAnalysisDriver implement AnalysisDriver, not extend.
The way we used to configure it does not work with changed I want to
make, specifically we were given SourceFactory with no resolves,
so no DartUriResolver, so no SDK.

R=brianwilkerson@google.com

Change-Id: Ibf798aae1792366cfbe240f9781038568936146d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149384
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-05-28 21:56:45 +00:00
Brian Wilkerson 6f15530536 Enable omit_local_variable_types in analyzer_plugin
Change-Id: I908e15b4820eab0e8375994ce3cebfac332306f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/141581
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2020-03-30 04:06:49 +00:00
Konstantin Shcheglov abf7d1fc08 Issue 40572. Pass Packages to AnalysisDriver.
Just as SourceFactory is given to AnalysisDriver, so should be Packages.
Understanding --packages and discovery in out of scope.

Bug: https://github.com/dart-lang/sdk/issues/40572
Change-Id: Id120fba0f23a4423797fa9976c4cda5ed54dad53
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135188
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-02-11 00:57:45 +00:00
Brian Wilkerson 7494f58032 Enable always_declare_return_types in analyzer_plugin
Change-Id: I972f0e2569de64397828d887b1fb37fcf57e006f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133408
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2020-01-26 23:13:34 +00:00
Brian Wilkerson 491201aae6 Enable use_function_type_syntax_for_parameters in analyzer_plugin
Change-Id: I78e70d652a1f4c8539767d65beb9a08882f78e55
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132455
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2020-01-18 20:12:33 +00:00
Brian Wilkerson f34a25099b Enable slash_for_doc_comments in analyzer_plugin
Change-Id: I9cafff7fcbf6c8930e3ac8ddba05061601aa8223
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132452
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2020-01-18 18:17:31 +00:00
Brian Wilkerson 03c33360b7 Remove unnecessary uses of new in analyzer_plugin
Other than
- the change to enable the lint (in analysis_options.yaml) and
- updates to the generator (in tool) to stop generating 'new',
all of the changes were generated by dartfix.

Change-Id: I9d14b99ab748ef5b80f8800a802e20100eee04a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128577
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2019-12-17 20:12:05 +00:00
Konstantin Shcheglov e3c8774543 Add AnalysisSession.analysisContext, stop using AnalysisDriver's AnalysisResult outside the driver.
Change-Id: I63138e002d9e777f51d2d843f7ef2b1f32fed3e0
Reviewed-on: https://dart-review.googlesource.com/c/82529
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-11-02 14:16:31 +00:00
Brian Wilkerson 180b3dd301 Remove extra spaces in copyright notices in analyzer_plugin
Change-Id: Icf01fbdd84747fc92908fe5ca818124c5df992af
Reviewed-on: https://dart-review.googlesource.com/c/79640
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-10-13 18:05:23 +00:00
Devon Carew 17b53a2835 Test out no_implicit_casts on the analyzer source base.
Change-Id: I4eb2414d7d9bbe21883c9e5e8eca10f2eaafb465
Reviewed-on: https://dart-review.googlesource.com/62725
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2018-06-28 02:20:43 +00:00
Konstantin Shcheglov 8c20f26234 Use mock of AnalysisResult in analyzer_plugin.
R=brianwilkerson@google.com, paulberry@google.com

Change-Id: Ia185d6f24d3cd250dc0b42aecb64aea482e0a46a
Reviewed-on: https://dart-review.googlesource.com/58841
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-06-06 19:09:54 +00:00
Konstantin Shcheglov 9976cddcd7 Shared cache of FileState contents.
This makes Flutter repo analysis about 12% faster.

R=brianwilkerson@google.com, devoncarew@google.com

Base: 76.2 74.9 75.9
After: 65.6 66.0 66.6 67.1
Change-Id: I5afffdae15eacf2c09c4ede40d7312c8827bae0c
Reviewed-on: https://dart-review.googlesource.com/51061
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-04-13 16:43:36 +00:00
Brian Wilkerson c6b206a2d9 Clean up after some recent code changes
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/3009513002 .
2017-08-24 10:01:11 -07:00
Brian Wilkerson e8010e4a44 Enhance NavigationMixin to handle notifications
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/3008443002 .
2017-08-24 07:44:51 -07:00
Brian Wilkerson 0a50effce5 Add minimal support for sending notifications
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/3003573002 .
2017-08-23 13:26:59 -07:00
Paul Berry e2f77056a5 Eliminate dependencies on pkg/front_end.
The API for pkg/front_end is still in flux so we want to avoid having
any packages depend directly on it (other than analyzer and
back-ends).

This CL re-exports some of the critical pieces of front_end needed by
analyzer clients so that those clients can access them via analyzer,
without having to directly depend on front_end.  It also updates
pkg/analyzer_plugin to make use of those re-exports.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2993123002 .
2017-08-07 09:46:30 -07:00
Brian Wilkerson 4a10003924 Update the plugin API
R=maxkim@google.com, mfairhurst@google.com

Review-Url: https://codereview.chromium.org/2953093002 .
2017-06-23 12:31:00 -07:00
Brian Wilkerson 624f4d8b3d Add tests for recently added mixins and improve plugin tests
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2932553004 .
2017-06-09 07:27:16 -07:00