Commit Graph

16 Commits

Author SHA1 Message Date
Sam Rawlins ce3b7c2b9c DAS plugins: support overlay changes
This adds and tests support for adding file overlays, changing them, and
removing them.

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

Change-Id: I7939f8199639f7e336cd97515c2f7d48b1d777a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384305
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-09-09 22:12:19 +00:00
Sam Rawlins 42a6ac4315 DAS plugins: Run plugin code zoned
In this CL, I run plugin code that responds to a request in an error
zone. The bulk of this change though is the tests that verify how we
handle asynchronous and synchronous thrown errors.

I separate some shared code from plugin_server_test into a shared lint
rules file and a base class. Then a second test is introduced with a
few error cases.

Change-Id: I4e252ae0d3bec0cf6625c0044681677fba3132bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384140
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-09-09 14:46:18 +00:00
Konstantin Shcheglov d90bb7321a Parts. Remove support for library augmentations.
Change-Id: I04f076ea6917bd4597b79c75db16207ccf387c9b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383702
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-09-05 22:21:33 +00: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 ed622c5300 DAS: Move FixInFileProcessor to analysis_server_plugin
Also move the top-level `computeFixes` convenience function.

The `computeFixes` function is the main entrypoint that various code
uses to, well, compute all fixes with a FixProcessor and a
FixInFileProcessor. In order for plugin code to call `computeFixes`,
we need that function and FixInFileProcessor in the
analysis_server_plugin package.

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

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: Id5f02864762eeefb92055a3534e91b60b76dfeb2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378220
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-07-31 19:16:27 +00:00
Sam Rawlins 34ad8e075e Move FixProcessors and registeredFixGenerators to analysis_server_plugin
These two are needed in the shared package so that plugins can run
CorrectionProducers. They go in 'src' because plugin developers do not
need to see this code.

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

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: Iee5b5dd063d5b0a9b00c58b91a3e50328c8b5fc2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377860
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-07-30 21:17:13 +00:00
Sam Rawlins 4e6d8115cd DAS: Move DartFixKindPriority, and rename values as lowerCamelCase.
FixProcessor has to be part of the analysis_server_plugin package, so
it cannot have any dependencies on the analysis_server package. This moves one.

The word 'default' is reserved, so I changed to 'standard'.

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: I1ee21c800203fac758f10a6fde0ea7d07eee5e7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/374742
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-07-18 21:23:14 +00:00
Konstantin Shcheglov d2ff2d1925 Parts. Visit 'configurations' child, update visitors.
Change-Id: Ifaa33b9d0c92f6677e1f100d45d5edbce11e765f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/375744
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-07-15 21:53:50 +00:00
Sam Rawlins 1e84b64a0e DAS: Move DartChangeWorkspace to the analysis_server_plugin package
Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: I79f43d06b48149b1d9dec30c5f5a77fdfd57ce4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373143
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Sam Rawlins <srawlins@google.com>
2024-06-26 02:17:59 +00:00
Sam Rawlins 8c918ffda3 analyzer: Fix resolution of private extension members
Fixes https://github.com/dart-lang/sdk/issues/45240

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: Idc054d968c5884dcf6bc876d996c741e8300cab0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371760
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Sam Rawlins <srawlins@google.com>
2024-06-17 18:28:21 +00:00
Sam Rawlins e5f3a50a7a DAS: Support Parse-only correction producers
This brings the soft static enforcement that we had before: a producer
that extends ParsedCorrectionProducer cannot access the
ResolvedUnitResult of a ParsedUnitResult.

Also we add some runtime enforcement that the producers used for parse-
only lint rules are ParsedCorrectionProducer.

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: If77fa66ae6fc070de1c7e931eb992a4adc14b68a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369561
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-06-03 23:13:18 +00:00
Konstantin Shcheglov 2628bfe733 QuickFix. Issue 55805. Create extension method.
Bug: https://github.com/dart-lang/sdk/issues/55805
Change-Id: Ifbe1420413ebe20e6e5e28c49da6c1cde6f801ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368900
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-05-31 20:07:31 +00:00
Sam Rawlins ebd8c46b85 DAS: Make _AbstractCorrectionProducer._context non-late, final.
We do this by passing a CorrectionProducerContext up each of the
constructors. We can then remove all `configure` methods. This
requires a few changes and allows a few changes:

* Remove ParsedCorrectionProducer. It does not seem to have served a
  purpose.
* CorrectionProducerContext no longer needs to be generic.
* Add a public getter for `MultiCorrectionProducer._context`, so that
  a multi correction producer can pass along its context to child
  correction producers.
* Introduce a `CorrectionProducerContext.instance` dummy variable,
  used when we need to check if a correction producer can be applied
  in bulk.
* Make `CorrectionProducerContext._node` public, so that it can be
  used in factory constructors.
* `BulkFixProcesor.correctionContext()` return type is non-nullable.
* Add a factory constructor for AddMissingParameter, and move the
  `configure` logic there.
* Add a factory constructor for ConvertAddAllToSpread, and move the
  `configure` logic there. Then make `_isInlineInvocation` and
  `_invocation` final.
* Add a factory constructor for ReplaceFinalWithVar, and move the
  `configure` logic there. Then make `_removeFinal` and
  `_finalKeyword` final.
* Add a factory constructor for ReplaceWithIsEmpty, and move the
  `configure` logic there. Then make `fixKind`, `multiFixKind`,
  `_binary`, and `_replacement` final.
* Rename `_AddMissingParameter.context` to `_executableParameters`,
  and make it final.


Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: If0e9bc1cbf5c8e656938bc6cd4eb32a9d4f06b38
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368760
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-05-30 22:49:39 +00:00
Sam Rawlins cf4550718f DAS: Move CorrectionProducer and Selection classes
Work towards https://github.com/dart-lang/sdk/issues/53402

None of the classes which were moved are changed in any way.

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: If81098971de044e2f69c1039ec23eff07b108af6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368066
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-05-28 04:54:08 +00:00
Sam Rawlins 1b400ed68d DAS plugins: Move CorrectionUtils to analysis_server_plugin
* Move the only 3 files from server_plugin to analysis_server_plugin.
* Copy some test infra into analysis_server_plugin. This is temporary,
  as we need some shared test infra location.

Change-Id: If2b41d436c9d3051e590f60ae2eb7ab31e529321
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364161
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-04-24 14:12:24 +00:00
Sam Rawlins cfc705ce09 Introduce analysis_server_plugin package; replacement for server_plugin
We have chosen a new name for this package. So before we write more
code inside, we need to move everything from 'server_plugin' to
'analysis_server_plugin'. There are some steps do doing so, to not
break various infra:

1. Land this change, introducing the new package in the SDK, but no
   dependencies on it.
2. Land this change independently in google3 (the package is not
   yet "unbundled.")
3. Mark the package as "unbundled" in google3.
4. Move all code from server_plugin to analysis_server_plugin; update
   imports; and delete server_plugin.
5. Remove server_plugin as an "unbundled" package; and remove
   server_plugin from google3.

Bug: https://github.com/dart-lang/sdk/issues/53402
Change-Id: I70197fdf61dd5862c2220d8ed5dd0880a1593ead
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363600
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-04-19 01:38:29 +00:00