The new lint, called `analyzer_public_api`, verifies that the analyzer
public API satisfies the following properties:
- No method, function, getter, setter, or supertype in the public API
refers to a non-public type.
- No `export` declaration in the public API shows a non-public name.
- No declaration in the public API has a name ending in `Impl`.
- No file in the public API has a `part` declaration that points to a
file that's not in the public API. (If it did, then the other checks
could be circumvented.)
A new annotation is added, `@AnalyzerPublicApi()`, allowing
declarations in `package:analyzer/src` or
`package:_fe_analyzer_shared/src` to be marked as part of the analyzer
public API. This is necessary because some parts of the analyzer
public API need to be declared elsewhere and then exported by the
analyzer.
A few lint violations have been ignored using `ignore:` comments. I
will try to clean these up in follow-up CLs.
Fixes https://github.com/dart-lang/sdk/issues/60058.
Bug: https://github.com/dart-lang/sdk/issues/60058
Change-Id: I0047a73dec8a29e2ffe03dd3a90f7e41ca2e27b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409763
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Now that we have `defaultValue` against each argument, there was some redundancy here.
`isDefault` is redundant because if `hasArgument=false` it's always default, and if `hasArgument=true`, then `value` and `defaultValue` can be compared
When `hasArgument=false`, there's no value in duplicating `defaultValue` into `value`
Change-Id: I5cba055e56175565842efef815e08dd46e9ed36a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406621
Reviewed-by: Elliott Brooks <elliottbrooks@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
There were two issues here:
1. Analyzer's `prefixesUsedInLibrary` search did not handle when an element was not found in the library (for example when looking for a top level variable that doesn't match because it's referenced through a getter)
2. The refactor not looking for prefixes for getters/setters when updating other files
Fixes https://github.com/dart-lang/sdk/issues/59968
Change-Id: Ic560e06c45091937611b247e7fee26b9854873fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406844
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
While fixing the doc comments for DartSnippetProducer.addImports, I
saw that it references two methods only found in the subclass,
FlutterSnippetProducer ("Adds public imports for any elements fetched
by [getClass] and [getMixin]").
It turns out that the `addImports` method and the `requiredElementImports` are only needed in the subclass,
FlutterSnippetProducer, so I just moved them over. Now the doc
comment references resolve correctly.
Change-Id: Id90e8257b4096308b8cd3ce19b14708ca1b5e365
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/407960
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@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 moves the existing `debugPrintCommunication` flag out of `test/lsp` into `test/` and passes it to the `MockServerChannel` to simplify printing protocol messages for LSP-over-Legacy tests (similar to what MockLspServerChannel already does).
Change-Id: Ic5fa6309e8de01ce0c624584ad6eb653ced90698
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406021
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
This class had a few methods which only pertain to the resource provider
and can just be extensions on ResourceProvider. They also have the
exact same impl! So one can redirect to the other.
Change-Id: I3a0433304adba1b71f69d0a4afc8a44515a23d10
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405600
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
The types of the following members of `CollectionLiteralContext` are
all changed to use `TypeImpl` rather than `DartType`:
- `elementType`
- `iterableType`
- `keyType`
- `valueType`
To reduce the number of casts that need to be added, some field types,
getter types, method return types, and method parameter types are
changed to `Impl` types in the following classes, mixins, and
extensions:
- `BodyInferenceContext`
- `ElementsTypesMixin`
- `ErrorDetectionHelpers`
- `ExecutableMember`
- `ExtensionMemberResolver`
- `ExtensionsExtensions`
- `ExtensionsExtensions2`
- `FormalParameterElementMixin`
- `FragmentedFunctionTypedElementMixin`
- `FunctionTypeImpl`
- `GenericFunctionInferenceTest`
- `InstantiatedExtensionWithMember`
- `InterfaceTypeImpl`
- `InvocationInferrer`
- `LeastUpperBoundHelper`
- `LowerBoundTest`
- `MethodMember`
- `NotInstantiatedExtensionsExtensions`
- `NotInstantiatedExtensionsExtensions2`
- `ParameterElementExtension`
- `ParameterElementMixin`
- `ResolverVisitor`
- `StringTypes`
- `TypedLiteralResolver`
- `TypeSystemImpl`
- `TypeSystemOperations`
- `_BoundsTestBase`
- `_InferredCollectionElementTypeInformation`
- `_NotInstantiatedExtension`
- `_ParamInfo`
There is no change to the analyzer public API.
This is part of a larger arc of work to change the analyzer's use of
the shared code so that the type parameters it supplies are not part
of the analyzer public API. See
https://github.com/dart-lang/sdk/issues/59763.
Change-Id: I7a5f7c411e81b829be205f1919c933f8f874e5ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405404
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>