Skip to content

Commit 2e55343

Browse files
scheglovCommit Queue
authored andcommitted
Fine. Extract LibraryRequirements to group per-library data
The `RequirementsManifest` class previously managed several distinct maps keyed by library URI to track top-level elements, instances, interfaces, and extensions. This change introduces a new `LibraryRequirements` class to encapsulate all requirements for a single library. This refactoring simplifies the structure of `RequirementsManifest` by replacing four separate maps with a single map from a library's URI to its `LibraryRequirements` object. This improves data locality and makes the code easier to follow. As part of this change, several fields were also renamed for clarity: - `requestedFields` is now `requestedDeclaredFields` (and similar for getters, setters, and methods). - `allDeclaredConstructors` is now `allConstructors`. Some printed requirements are now empty because we usually exclude SDK libraries. Change-Id: I3a64a9e890fa6155d16b08b255d80b8d0a937c8e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/445346 Reviewed-by: Paul Berry <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 722f7fa commit 2e55343

File tree

4 files changed

+234
-295
lines changed

4 files changed

+234
-295
lines changed

pkg/analyzer/lib/src/dart/analysis/driver.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ testFineAfterLibraryAnalyzerHook;
109109
// TODO(scheglov): Clean up the list of implicitly analyzed files.
110110
class AnalysisDriver {
111111
/// The version of data format, should be incremented on every format change.
112-
static const int DATA_VERSION = 520;
112+
static const int DATA_VERSION = 521;
113113

114114
/// The number of exception contexts allowed to write. Once this field is
115115
/// zero, we stop writing any new exception contexts in this process.

pkg/analyzer/lib/src/fine/library_manifest.dart

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ class LibraryManifest {
110110
]);
111111
}
112112

113-
/// Returns the ID of a top-level element either declared or re-exported,
114-
/// or `null` if there is no such element.
115-
ManifestItemId? getExportedId(LookupName name) {
113+
/// Returns the ID of a declared top-level element, or `null` if there is no
114+
/// such element.
115+
ManifestItemId? getDeclaredId(LookupName name) {
116116
return declaredClasses[name]?.id ??
117117
declaredEnums[name]?.id ??
118118
declaredExtensions[name]?.id ??
@@ -121,8 +121,13 @@ class LibraryManifest {
121121
declaredTypeAliases[name]?.id ??
122122
declaredGetters[name]?.id ??
123123
declaredSetters[name]?.id ??
124-
declaredFunctions[name]?.id ??
125-
reExportMap[name];
124+
declaredFunctions[name]?.id;
125+
}
126+
127+
/// Returns the ID of a top-level element either declared or re-exported,
128+
/// or `null` if there is no such element.
129+
ManifestItemId? getExportedId(LookupName name) {
130+
return getDeclaredId(name) ?? reExportMap[name];
126131
}
127132

128133
void write(BufferedSink sink) {

0 commit comments

Comments
 (0)