Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 538e47a

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Inline addLocalDeclarations
R=brianwilkerson@google.com Change-Id: I74bb5b6c1d74ba0a61d117e56e2081dcf6119909 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201140 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
1 parent 991dc32 commit 538e47a

File tree

2 files changed

+6
-34
lines changed

2 files changed

+6
-34
lines changed

pkg/analyzer/lib/src/summary2/library_builder.dart

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -82,39 +82,6 @@ class LibraryBuilder {
8282
}
8383
}
8484

85-
/// Add top-level declaration of the library units to the local scope.
86-
void addLocalDeclarations() {
87-
for (var linkingUnit in context.units) {
88-
for (var node in linkingUnit.unit.declarations) {
89-
if (node is ast.ClassDeclaration) {
90-
// Handled in ElementBuilder.
91-
} else if (node is ast.ClassTypeAlias) {
92-
// Handled in ElementBuilder.
93-
} else if (node is ast.EnumDeclarationImpl) {
94-
// Handled in ElementBuilder.
95-
} else if (node is ast.ExtensionDeclarationImpl) {
96-
// Handled in ElementBuilder.
97-
} else if (node is ast.FunctionDeclarationImpl) {
98-
// Handled in ElementBuilder.
99-
} else if (node is ast.FunctionTypeAlias) {
100-
// Handled in ElementBuilder.
101-
} else if (node is ast.GenericTypeAlias) {
102-
// Handled in ElementBuilder.
103-
} else if (node is ast.MixinDeclarationImpl) {
104-
// Handled in ElementBuilder.
105-
} else if (node is ast.TopLevelVariableDeclaration) {
106-
// Handled in ElementBuilder.
107-
} else {
108-
throw UnimplementedError('${node.runtimeType}');
109-
}
110-
}
111-
}
112-
if ('$uri' == 'dart:core') {
113-
localScope.declare('dynamic', reference.getChild('dynamic'));
114-
localScope.declare('Never', reference.getChild('Never'));
115-
}
116-
}
117-
11885
/// Return `true` if the export scope was modified.
11986
bool addToExportScope(String name, Reference reference) {
12087
if (name.startsWith('_')) return false;
@@ -135,6 +102,8 @@ class LibraryBuilder {
135102
as LibraryElementImpl;
136103
}
137104

105+
/// Build elements for declarations in the library units, add top-level
106+
/// declarations to the local scope, for combining into export scopes.
138107
void buildElements() {
139108
for (var unitContext in context.units) {
140109
var elementBuilder = ElementBuilder(
@@ -147,6 +116,10 @@ class LibraryBuilder {
147116
}
148117
elementBuilder.buildDeclarationElements(unitContext.unit);
149118
}
119+
if ('$uri' == 'dart:core') {
120+
localScope.declare('dynamic', reference.getChild('dynamic'));
121+
localScope.declare('Never', reference.getChild('Never'));
122+
}
150123
}
151124

152125
void buildEnumChildren() {

pkg/analyzer/lib/src/summary2/link.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ class Linker {
119119
}
120120

121121
for (var library in builders.values) {
122-
library.addLocalDeclarations();
123122
library.buildElements();
124123
}
125124

0 commit comments

Comments
 (0)