Replaces the top level function `analyzeAnalysisOptions`, which
contained 3 nested local functions, with a class
`AnalyzeAnalysisOptions`, where the nested local functions have been
changed into private methods.
All the variables in the top level function that were implicitly
write- or read-captured by the nested local functions have been
changed into class fields or explicit method parameters. This should
make the code a lot easier to follow.
In this CL, I've tried hard to preserve the existing functionality
exactly; besides converting local variables to fields and parameters,
I haven't really made any changes to the core logic beyond code
motion. In follow-up CLs, I plan to make some simplifications that are
less obviously semantics preserving (but should be easier to review
since they won't involve so much code motion). Once that is done I
hope to be able to migrate the error reporting in this class to use
the literate diagnostic API.
Change-Id: I6a6a696414ecae80535c8d6633eaa567d37dcccc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/479080
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
I found one instance of a variable called "packagesFile" and well, I
pulled that thread :/
There is a nice functional simplification here: The `_findPackagesFile`
function returned a `_PackagesFile` object, which contained both a
`Folder parent` and a `File file`. The latter was never referenced, so
simplification 1. Also, the reason to have an object that stores both
is that this object handled both `.packages` files, whose immediate
parent is `parent`, and `package_config.json` files, whose _grandparent_
is `parent`. But with the distinction gone, we don't need this
`_PackagesFile` class, and `_findPackagesFile` can instead return the
folder, and be renamed `_findFolderWithPackageConfigFile`.
Change-Id: Id7cfad02bad16baeebfd8a719a3a92187fec730f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475930
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Changes the logic in `pkg/analyzer_cli` to use
`DiagnosticCode.lowerCaseName` instead of `DiagnosticCode.name`, and
`DiagnosticCode.lowerCaseUniqueName` instead of
`DiagnosticCode.uniqueName`. This ensures that diagnostic codes are
matched in a case-insensitive fashion.
This paves the way for deprecating (and eventually removing) the
`DiagnosticCode.name` and `DiagnosticCode.uniqueName` getters.
Change-Id: I6a6a6964f1254f248d2b772f69e33adf0b682bb9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466186
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Removes the field `AnalyzerImpl.options`, the `options` parameter of
the method `Driver._runAnalyzer`, and the `commandLineOptions`
parameters of the functions `computeSeverity` and
`determineProcessedSeverity`. None of these were used.
Change-Id: I6a6a6964617cecb81f0d1c6570be1d78fb599af4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463085
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Not for performance, because it is one shot, but all language/ and co19/
code will go through manifests builder, and give us better coverage.
Change-Id: Iae83ec685084847358d960deff81d18fb9904f4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456404
Reviewed-by: Samuel Rawlins <srawlins@google.com>
The new updateAnalysisOptions4 parameter is a callback function,
similar to updateAnalysisOptions3, but with one removed parameter
itself, the `DartSdk sdk` parameter.
The one place where this parameter was used in the callback passed by
the caller, was in DAS's ContextManager, and it was just used in order
to compute a FeatureSet from (a) the computed DartSdk and (b) the
command-line `--enable-experiment` options. We can instead provide a
`enabledExperiments` parameter on AnalysisContextCollectionImpl,
leading to a simpler API and still a simple implementation in
ContextBuilder.
The reason for the incremental migration is that dartdoc, and possibly
some internal clients, use updateAnalysisOptions3.
Change-Id: Ie990ab8f7b850aed1ce3ef39ab71c01835c080da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/447400
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
* OptionsValidator was defined in the `src/plugin/` directory (the only
file in there), which I found confusing. Moved it to
`src/analysis_options/`.
* OptionsFileValidator, and a few related classes, were defined in the
`src/task/` (the last file in there!), so I moved it to the same
place.
There is more to tidy in here, but this is a simple file-move.
Change-Id: I8f4c5cc0ae4e76eb6c17249457c50ab69c82590d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/443147
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Work towards https://github.com/dart-lang/sdk/issues/60635
* `AnalysisError._contextMessages` unnecessarily backed the public
`contextMessages` getter; the field is final so it can be public
itself.
* `AnalysisError._correctionMessage` unnecessarily backed the public
`correctionMessage` getter; the field is final so it can be public
itself.
Change-Id: If269d4ed590ef7df81d9b9e3be03766601526d7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425620
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Currently, the `AnalysisContextCollectionImpl` constructor has a
callback parameter, `updateAnalysisOptions2`, which has 3 required
parameters. The caller can then pass in a closure which accepts those
parameters, and updates analysis options.
I find this to be a bit of an awkward API, and a little bit complex, so
it would be good if we can simplify it. It is all private impl, but it
is used in a few codebases, I believe. Dartdoc is one.
So, it looked to me like none of the callers _use_ the `ContextRoot`
parameter, so it would be good to simplify here, and remove it from
the callback signature.
This is _not_ the final API I'm looking for. Just an incremental step,
and since it is private API, it doesn't need to be in a major release
of analyzer.
Change-Id: Iad9da9f36e817add0bd8c49975ecd14311588661
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392204
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Previously, the fields in an AnalysisOptionsImpl were primarily
arranged by an extension method, declared externally, called
`applyOptions`. It seemed very odd that this wasn't just a method on
AnalysisOptionsImpl; the "Impl" class is already private.
But it turns out that an AnalysisOptionsImpl is _mostly_ not mutated
in practice; the class wants to be immutable, with final fields.
In this change, I make AnalysisOptionsImpl mostly immutable, and
convert the `applyOptions` extension method, and all of its helper
code, into a builder class, AnalysisOptionsBuilder. While we don't
use a lot of builders in analyzer packages, this is a much more common
and idiomatic pattern for setting up complicated data, multiple values,
and then finalizing it all into an object that will not be changed
again during it's lifetime.
One big benefit of this refactoring is that most fields in AnalysisOptionsImpl are now final:
* sourceLanguageConstraint
* errorProcessors
* excludePatterns
* file
* strictCasts
* strictInference
* strictRawTypes
* chromeOsManifestChecks
* codeStyleOptions
* formatterOptions
* unignorableNames
Whereas before, they _all_ had to be mutable, as `applyOptions`, the
primary mechanism for setting up an AnalysisOptionsImpl, had to able
to write any field.
Other changes:
* Flip the instantiation of AnalysisOptionsImpl and CodeStyleOptions;
now CodeStyleOptions is instatiated first, and AnalysisOptionsImpl
sets itself as `codeStyleOptions.options`.
* Remove the private, deprecated, `applyToAnalysisOptions` function.
Change-Id: I6595d88aa5721e4f9a8b2b987482f9f43d27efd1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390660
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
They are used mostly as dependency tracking, because without combinators we don't know specific elements exported/imported. But for such dependency purpose CompilationUnitElement level "dependencies" are useless, so we should keep them at LibraryElement, but not add to CompilationUnitElement.
Change-Id: I14aaf14debaf167f29740e86d82ff2c02e241569
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389142
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This reverts commit 43fb59f4dc.
Reason for revert: Breaking Dart SDK -> Flutter Engine roller. See https://github.com/flutter/flutter/issues/142253
Original change's description:
> Refactor PubWorkspace into PackageConfigWorkspace
>
> - use package_config.json as marker file for workspace.
> - workspace can have multiple packages, they can be either PubPackages (marker pubspec.yaml) or BasicWorkspace.
> - add package info (pubspec) to resolution salt.
> - removed duplication of finding package_config.json from ContextLocator, as this is now done while creating workspace.
> - some test/s setup/expectations were changed since we now use package config as marker for workspace instead of pubspec.
>
> Change-Id: I091a4a686c6b1d8c14858aefd9843a8d9c8efa25
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345346
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Commit-Queue: Keerti Parthasarathy <keertip@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Change-Id: I59adf5b26d25e360bcf962323db688156774c767
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348364
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Jackson Gardner <jacksongardner@google.com>
- use package_config.json as marker file for workspace.
- workspace can have multiple packages, they can be either PubPackages (marker pubspec.yaml) or BasicWorkspace.
- add package info (pubspec) to resolution salt.
- removed duplication of finding package_config.json from ContextLocator, as this is now done while creating workspace.
- some test/s setup/expectations were changed since we now use package config as marker for workspace instead of pubspec.
Change-Id: I091a4a686c6b1d8c14858aefd9843a8d9c8efa25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345346
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Before this change, the analyzer supported analyzing legacy code if
the (somewhat confusingly named) global variable `noSoundNullSafety`
was set to `false`. This was used to support legacy code while google3
was still migrating to null safety.
Now that the internal migration process is complete, the analyzer no
longer needs to support legacy code. As a first step in removing that
support, this change removes the `noSoundNullSafety` flag and all the
unit tests that made use of it.
From this point forward it will not be possible to use the analyzer to
analyze code that has a Dart language version less than 2.12.
Change-Id: Idce4b271d1cfc43d25251b7a899259d62b421caf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345365
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Noteworthy:
* deprecates the `sdkVersionConstraint` getter and updates uses
* migrates tests for sdk contstraints in the absence of a pubspec from context_builder_test to analysis_context_collection_test
* makes `pubPackages` getter broadly visible
Next step: remove the code that sets the `sdkVersionConstraint` in the analysis options object and remove the getter.
Change-Id: I443cdd15ec8d28ac6fa6786e06c1e4b027eee747
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341084
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>