Move PackageConfigFileBuilder into the analyzer_testing public API and
deprecate the copy exposed from package:analyzer. The builder is only
used by test infrastructure, so keeping it in analyzer_testing makes the
ownership clearer and avoids exposing test-only utilities from analyzer.
Update the builder API to accept a rootFolder instead of a rootPath.
This lets callers pass the resource-provider folder directly, so the
generated rootUri is derived from the same file-system abstraction that
created the test files. This avoids accidentally passing POSIX paths
where resource provider paths are required, such as on Windows.
Update existing test utilities and callers to import the new library and
pass Folder objects. Remove the production analysis server dependency on
the builder by emitting the temporary plugin package config JSON
directly.
Change-Id: I46b14710626e0d6d5884afcdc5a05b23077acfc9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499081
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This data is collected on shutdown, the same as the legacy analytics data.
This is implementation for some of the analytics we want to collect,
specified at go/dart-analyzer-plugin-analytics.
* How many plugins are enabled for each context?
* How many lint rules are registered for each plugin?
* How many warning rules are registered for each plugin?
* How many fixes are registered for each plugin?
* How many assists are registered for each plugin?
Change-Id: I36c176737c194550e1947985576ed461fd8a1bf3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452482
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Fixes https://github.com/dart-lang/sdk/issues/61684
This caching is based largely on the `--depfile` feature offered by
`dart compile`, which is based on a Ninja depfile concept
(https://ninja-build.org/manual.html#_depfile), which spits out a file
(`depfile.txt` here) which lists all of the input files which were
required to build an AOT snapshot.
The process is essentially:
1. If an AOT snapshot is found, maybe use it as a cached snapshot!
a. If the `pubspec.yaml` modification timestamp is newer, re-compile!
b. If the `.dart_tool/package_config.json` modification timestamp is
newer, re-compile!
c. If the `bin/plugin.dart` modification timestamp is newer,
re-compile!
d. If the `bin/depfile.txt` file is missing or malformed, re-compile!
e. If any files mentioned in `bin/depfile.txt` have a newer
modification timestamp, or don't exist, or are an otherwise bad
path, re-compile!
f. Otherwise, save a dozen seconds and use the cached snapshot.
Change-Id: Icc747198f8af76d256ac915685473d6f529a3cef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464602
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Work towards https://github.com/dart-lang/sdk/issues/61684
PluginManager needs to be more testable before implementing the caching feature. This CL lays the groundwork.
We add ProcessManager.runSync, and a handler for that in MockProcessHandler. Then we can add tests which call `PluginManager.filesFor` with `isLegacy: false`, and `dart pub upgrade` will not be run on the real filesystem.
Change-Id: I7b8877d985296741e51543c10a7cb87c8a43c116
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465662
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
This includes the `excludedGlobs`, `optionsFile`, and `packagesFile`
fields. In each case of setting the field's value after instantiation,
the code happens _right_ after instantiation, so they can just be
set in the constructor and be final.
Change-Id: If39e8ebd8a52f4bfc81a016bff2f40d00db16a3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455862
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
* Rename `PluginSession.interestingFiles` to `.interestingFileGlobs`.
This confused me for a bit, though the doc comment is accurate.
* `PluginManager.broadcastWatchEvent` was needlessly async and
needlessly returned a Future. It can just return the List of Futures.
* In addition, the implementation of this method is made simpler; the
previous very long if-condition is broken into a series of
`if (foo) continue` statements, which allows for nice promotion and
allows the large comment to sit next to the condition to which it is
referring.
Change-Id: I77e8f7476b38d21f4c1a991045333d1e19a54143
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452200
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This renames the old screen, "Legacy plugins" and adds a new screen,
"Plugins". On the new plugins screen, we ask the plugins isolate(s) for
their plugins details, and print the following, for eadh plugin:
* the plugin's name
* the names of the registered lint rules
* the names of the registered warning rules
* the IDs and "messages" of the registered assists
* the IDs and "messages" and associated diagnostic codes of the
registered quick fixes
More to come in follow ups:
* The resolved versions of plugin packages (coming from package_config.json)
Change-Id: Ic3dc4c5bffa64fd4da4097c042a847cc064e41ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/447763
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Work towards https://github.com/dart-lang/sdk/issues/61386
A few distinct changes:
* Rename PluginInfo to PluginIsolate
* Move PluginInfo and PluginSession to a new library,
plugin_isolate.dart. PluginSession is _essentially_ a private class
to PluginIsolate, so it's good to co-locate them.
* Move PluginInfo tests and PluginSession tests to a new library.
* Extract out shared parent class for PluginManager tests,
PluginIsolate tests, and PluginSession tests.
Change-Id: Ib0c638b8797f51c57c07e277acdaea6d8202f957
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446960
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
I don't know the history here, but there was a BuiltInPluginInfo
subclass, which has no instances (dead code), and a
DiscoveredPluginInfo class. So I deleted the former, and merged the
latter into the superclass, PluginInfo.
I also made a few members private, in PluginInfo, PluginManager, and
PluginSession. I modernized comments along the way.
This all paves the way for adding information to PluginInfo about
_new_ plugins, for use in the diagnostics pages.
Change-Id: Ib7c5deebd43e5636141ed36ddb3d5da7cf325883
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/445405
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Work towards https://github.com/dart-lang/sdk/issues/55660
The comment for `MemoryResourceProvider.convertPath` includes:
> This is a utility method for testing; paths passed in to other
> methods in this class are never converted automatically.
and indeed, the actual impl of this method is found in an extension,
in analyzer's test_utilities/ directory. It seems to me better to
leave a testing utility as a testing utility, and not expose it in
the public API of MemoryResourceProvider.
Additionally, the extension method is used by `ResourceProviderMixin`,
which is moving to the public analyzer_testing package. It is illegal
to have a circular non-dev dependency between the analyzer package
and the analyzer_testing package.
The migration for the ~half dozen test files that use this method is
to call the extension method directly. Sometimes with an extension
override, and sometimes without.
Change-Id: I9c2e18600461134bfd91c082b3af0d5079600f0c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426984
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This change means that during `dart analyze`, an exception caught in a plugin isolate will be printed to the terminal, and the process will
exit (similar to the support for when the isolate has static errors).
Change-Id: I31b1ebe7a71a331274d4f1dc1ea1b94f33e2329b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415981
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This change allows the LegacyAnalysisServer to understand when the
plugin isolate (if there is one) is analyzing or not. There are a few
primary concepts:
* The plugin isolate (PluginServer) notifies the analysis server, when
analyzing all files in a context collection, and analyzing changed
files, that it is analyzing, and later that it isn't.
* The NotificationManager tracks whether the plugin isolate is analyzing
or not, based on the last status.
* The PluginManager tracks whether new plugins are initialized or not.
This is determined by the work done by the PluginWatcher. If no
plugins are configured, then plugins are declared to be "initialized".
Otherwise, the AnalysisServer sets their status to be "initialized"
after receiving the first status notification from the plugin isolate.
* The LegacyAnalysisServer now uses the additional "are plugins
analyzing" signal, held in NotificationManager, and the "are plugins
initializing" signal, held in PluginManager, to determine whether to
notify the client that analysis is complete.
Change-Id: Ie2b6a6048f074d7a26d7d5d07622a17c30fcab96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405444
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This change is the final piece in enabling plugins in the new style to
be launched from a specification in analysis options.
Work towards https://github.com/dart-lang/sdk/issues/53402
* We support both one legacy analyzer plugin (the current max), and
a set of new analyzer plugins, which are combined and launched in one
shared plugin isolate.
* Make PluginLocator.pluginMap private.
* Add a parameter to PluginManager.addPluginToContextRoot:
isLegacyPlugin. This method is used for both legacy and new plugins,
but has slightly different behavior, finding where the plugin files
are.
Change-Id: I6644aecd4283eea22586ffd051a01b0ec8987fc5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395360
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
* Update comments to be modern and reference "package config files"
rather than "packages files"
* Remove commented out code that we aren't going to uncomment.
* Rename PluginFiles.packages.
* Simplify `PluginManager._computeFiles` to use less nesting, and use
early `throw` statements, rather than storing data in local
and choosing late whether an exception should be thrown with the
stored data.
Change-Id: I7d5da0e299962d8887f2222137478a2fd96671b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392960
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
In many cases, AnalysisOptions is sufficient.
* ResolvedCorrectionProducer will be public API for someone writing an
analyzer plugin; it should not expose an AnalysisOptionsImpl. Luckily
the only need for the Impl, today, is in the "ignore diagnostic" fixes
so we can cast in there. (We could also expose the `file` and the
`unignorableNames` fields.)
* Some other spots only cast in order to access one of the 'strict'
fields, but all of those have been made public.
* AnalysisOptionsImpl.enabledLegacyPluginNames can be made final.
* Many other users don't need AnalysisOptionsImpl, or only need it to
pass it to other code that _does_ need it. In many of those cases it
makes sense to look at an object as an AnalysisOptions, and let the
code that needs a field from Impl to do a cast.
Change-Id: I3640934fb9d93c9b95f15a22457af604e420c7a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392240
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
+ make the implementation of ResourceProviderMixin methods not depend on MemoryResourceProvider.
This is a step towards being able to share more code between tests that use different kinds of ResourceProviders. Although ResourceProviderMixin currently still has a MemoryResourceProvider, all of the methods themselves can work against any ResourceProvider.
convertPath was moved to an extension in test_utilities (rather than to the base ResourceProvider) because it seems quite test-specific (it assumes any absolute paths are relative to drive C - something we'll need to update to use for non-memory tests.
Change-Id: Ibb3cfb31ebbdac6410868f0395bd19f9ce7b0e18
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350380
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Maybe related to https://github.com/dart-lang/sdk/issues/38629. These tests have been skipped for so long, enabling them took some work, to migrate them from '.packages' files to package config files.
Some other tidying in the test file:
* inline `byteStorePath`, only used once.
* simplify `_packagesFileContent` and `_getPackagesFileContent`
into a static getter.
* simplify `_defaultPluginContent` into a const String, so it can
be used as a function parameter default value
The diff is way bigger than the functional changes, because we sort
elements.
This reverts commit aa6b6470e3.
Change-Id: I9dc533710255534ec27454712a1a64facf5dd12d
Cq-Include-Trybots: luci.dart.try:analyzer-win-release-try,flutter-analyze-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345367
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
This reverts commit 7784cf3f94.
Reason for revert: broke windows bot
Original change's description:
> analyzer: Do not overwrite an original exception when a plugin crashes
>
> Maybe related to https://github.com/dart-lang/sdk/issues/38629. These tests have been skipped for so long, enabling them took some work, to migrate them from '.packages' files to package config files.
>
> Some other tidying in the test file:
>
> * inline `byteStorePath`, only used once.
> * simplify `_packagesFileContent` and `_getPackagesFileContent`
> into a static getter.
> * simplify `_defaultPluginContent` into a const String, so it can
> be used as a function parameter default value
>
> The diff is way bigger than the functional changes, because we sort
> elements.
>
> Change-Id: I193316316750e80268b684fdc1abe558a77994fe
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344601
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Commit-Queue: Samuel Rawlins <srawlins@google.com>
Change-Id: Ibeb761afebad4fb4166cec756743dbb35d323e7d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345143
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Maybe related to https://github.com/dart-lang/sdk/issues/38629. These tests have been skipped for so long, enabling them took some work, to migrate them from '.packages' files to package config files.
Some other tidying in the test file:
* inline `byteStorePath`, only used once.
* simplify `_packagesFileContent` and `_getPackagesFileContent`
into a static getter.
* simplify `_defaultPluginContent` into a const String, so it can
be used as a function parameter default value
The diff is way bigger than the functional changes, because we sort
elements.
Change-Id: I193316316750e80268b684fdc1abe558a77994fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344601
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>