Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Unified Diff: pkg/analyzer/lib/src/summary/link.dart

Issue 1839663003: More fixes to summary linking. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Test corner cases involving undefined names Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/summarize_ast_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/summary/link.dart
diff --git a/pkg/analyzer/lib/src/summary/link.dart b/pkg/analyzer/lib/src/summary/link.dart
index 70ffce63841a5637852da45a82eb660785e1e7b3..18ea19ae307a6e99c181eba9c982cd96a7dbc493 100644
--- a/pkg/analyzer/lib/src/summary/link.dart
+++ b/pkg/analyzer/lib/src/summary/link.dart
@@ -130,8 +130,10 @@ abstract class ClassElementForLink
@override
ConstVariableNode get asConstVariable {
- // TODO(paulberry): implement.
- throw new UnimplementedError();
+ // When a class name is used as a constant variable, it doesn't depend on
+ // anything, so it is not necessary to include it in the constant
+ // dependency graph.
+ return null;
}
@override
@@ -441,14 +443,17 @@ abstract class CompilationUnitElementForLink implements CompilationUnitElement {
LinkedReference linkedReference = _linkedUnit.references[index];
String name = unlinkedReference.name;
int containingReference = unlinkedReference.prefixReference;
- if (containingReference != 0) {
+ if (containingReference != 0 &&
+ _linkedUnit.references[containingReference].kind !=
+ ReferenceKind.prefix) {
_references[index] =
_resolveRef(containingReference).getContainedName(name);
} else if (linkedReference.dependency == 0) {
_references[index] = enclosingElement.getContainedName(name);
} else {
- // TODO(paulberry): implement.
- throw new UnimplementedError();
+ LibraryElementForLink dependency =
+ enclosingElement._getDependency(linkedReference.dependency);
+ _references[index] = dependency.getContainedName(name);
}
}
return _references[index];
@@ -1107,8 +1112,11 @@ abstract class LibraryElementForLink<
List<UnitElement> _units;
final Map<String, ReferenceableElementForLink> _containedNames =
<String, ReferenceableElementForLink>{};
+ final List<LibraryElementForLink> _dependencies = <LibraryElementForLink>[];
- LibraryElementForLink(this._linker, this._absoluteUri);
+ LibraryElementForLink(this._linker, this._absoluteUri) {
+ _dependencies.length = _linkedLibrary.dependencies.length;
+ }
@override
List<UnitElement> get units {
@@ -1155,6 +1163,14 @@ abstract class LibraryElementForLink<
noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
/**
+ * Return the [LibraryElement] corresponding to the given dependency [index].
+ */
+ LibraryElementForLink _getDependency(int index) {
+ return _dependencies[index] ??= _linker.getLibrary(resolveRelativeUri(
+ _absoluteUri, Uri.parse(_linkedLibrary.dependencies[index].uri)));
+ }
+
+ /**
* Create a [UnitElement] for one of the library's compilation
* units.
*/
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/summarize_ast_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698