Skip to content

Commit a2718d9

Browse files
stereotype441Commit Queue
authored andcommitted
Add a machine-generated summary of the analyzer public API.
The summary is checked into source control in `pkg/analyzer/api.txt`. It contains an entry for each type declaration, extension, function, method, getter, or setter that is part of the analyzer API, as well as the types of all functions, methods, getters, and setters, and all type declarations referenced by those types. The tool `pkg/analyzer/tool/api/generate.dart` regenerates `api.txt`. The test `pkg/analyzer/tool/api/generate_test.dart` checks that generation of `api.txt` is up to date. The intention is that `api.txt` will serve as an audit trail to (a) detect unintentional changes to the analyzer public API, and (b) help ensure that the developer experience team reviews intentional changes to the analyzer public API. Once an appropriate OWNERS file has been set up for the developer experience team, I intend to add an ownership rule to require developer experience team review for this file. The structure of the file is hierarchical, with top level nodes representing libraries URIs, children of those nodes representing top level elements declared or exported by those libraries, and grandchildren of those nodes representing members of type declarations. If a type is considered part of the API, but it isn't exported by an analyzer public API library (e.g., the type `Namespace`, which is declared in `package:analyzer/src/dart/resolver/scope.dart`, but part of the analyzer API due being exposed by `LibraryElement.exportNamespace`, `LibraryElement.publicNamespace`, `LibraryImportElement.namespace`, and so on), then it is listed under the URI of the library that declares it. If a type is not considered part of the API, but it is declared inside `package:analyzer` and it is referenced by something in the API (e.g., `Workspace`, which is a private analyzer class but is the type of `ContextRoot.workspace`), then instead of listing the members of the type declaration, `api.txt` simply says `(non-public)` after the entry for the type. If a type is not considered part of the API, and it is not declared inside `package:analyzer`, but it is referenced by something in the API (e.g., `WatchEvent`, which comes from `package:watcher` but is used in the type of `ResourceWatcher.changes`), then instead of listing the members of the type declaration, `api.txt` simply says `(referenced)` after the entry for the type. If there are two distinct declarations in `api.txt` with the same name (e.g., the two declarations of `AnalysisContext` from `package:analyzer/dart/analysis/analysis_context.dart` and `package:analyzer/src/generated/engine.dart`), then they are disambiguated by appending an `@` symbol followed by an integer. Change-Id: Ia2c856e79feebabb74aeb26f57c0a1eea7c63f68 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409862 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Paul Berry <[email protected]>
1 parent 197bbbd commit a2718d9

File tree

3 files changed

+6017
-0
lines changed

3 files changed

+6017
-0
lines changed

0 commit comments

Comments
 (0)