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

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

Issue 1944773002: Support references to top level getters in the summary linker. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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/task/strong/inferred_type_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 e68b5dfff37e9ace384f5118fb2ac45442681b4f..a022e8c6196dcca6db2ad1a855b0943864734424 100644
--- a/pkg/analyzer/lib/src/summary/link.dart
+++ b/pkg/analyzer/lib/src/summary/link.dart
@@ -368,7 +368,7 @@ class ClassElementForLink_Class extends ClassElementForLink
List<MethodElementForLink> _methods;
List<InterfaceType> _mixins;
List<InterfaceType> _interfaces;
- List<PropertyAccessorElement> _accessors;
+ List<PropertyAccessorElementForLink> _accessors;
ClassElementForLink_Class(
CompilationUnitElementForLink enclosingElement, this._unlinkedClass)
@@ -377,7 +377,7 @@ class ClassElementForLink_Class extends ClassElementForLink
@override
List<PropertyAccessorElement> get accessors {
if (_accessors == null) {
- _accessors = <PropertyAccessorElement>[];
+ _accessors = <PropertyAccessorElementForLink>[];
Map<String, SyntheticVariableElementForLink> syntheticVariables =
<String, SyntheticVariableElementForLink>{};
for (UnlinkedExecutable unlinkedExecutable
@@ -392,7 +392,7 @@ class ClassElementForLink_Class extends ClassElementForLink
SyntheticVariableElementForLink syntheticVariable = syntheticVariables
.putIfAbsent(name, () => new SyntheticVariableElementForLink());
PropertyAccessorElementForLink_Executable accessor =
- new PropertyAccessorElementForLink_Executable(
+ new PropertyAccessorElementForLink_Executable(enclosingElement,
this, unlinkedExecutable, syntheticVariable);
_accessors.add(accessor);
if (unlinkedExecutable.kind == UnlinkedExecutableKind.getter) {
@@ -699,6 +699,7 @@ abstract class CompilationUnitElementForLink
List<TopLevelVariableElementForLink> _topLevelVariables;
List<ClassElementForLink_Enum> _enums;
List<TopLevelFunctionElementForLink> _functions;
+ List<PropertyAccessorElementForLink> _accessors;
/**
* Index of this unit in the list of units in the enclosing library.
@@ -711,6 +712,38 @@ abstract class CompilationUnitElementForLink
_unlinkedUnit = unlinkedUnit;
@override
+ List<PropertyAccessorElementForLink> get accessors {
+ if (_accessors == null) {
+ _accessors = <PropertyAccessorElementForLink>[];
+ Map<String, SyntheticVariableElementForLink> syntheticVariables =
+ <String, SyntheticVariableElementForLink>{};
+ for (UnlinkedExecutable unlinkedExecutable in _unlinkedUnit.executables) {
+ if (unlinkedExecutable.kind == UnlinkedExecutableKind.getter ||
+ unlinkedExecutable.kind == UnlinkedExecutableKind.setter) {
+ String name = unlinkedExecutable.name;
+ if (unlinkedExecutable.kind == UnlinkedExecutableKind.setter) {
+ assert(name.endsWith('='));
+ name = name.substring(0, name.length - 1);
+ }
+ SyntheticVariableElementForLink syntheticVariable = syntheticVariables
+ .putIfAbsent(name, () => new SyntheticVariableElementForLink());
+ PropertyAccessorElementForLink_Executable accessor =
+ new PropertyAccessorElementForLink_Executable(
+ this, null, unlinkedExecutable, syntheticVariable);
+ _accessors.add(accessor);
+ if (unlinkedExecutable.kind == UnlinkedExecutableKind.getter) {
+ syntheticVariable._getter = accessor;
+ } else {
+ syntheticVariable._setter = accessor;
+ }
+ }
+ }
+ // TODO(paulberry): also add synthetic accessors.
+ }
+ return _accessors;
+ }
+
+ @override
LibraryElementForLink get enclosingElement;
@override
@@ -810,6 +843,13 @@ abstract class CompilationUnitElementForLink
for (TopLevelFunctionElementForLink function in functions) {
_containedNames[function.name] = function;
}
+ for (PropertyAccessorElementForLink accessor in accessors) {
+ // TODO(paulberry): consider handling synthetic accessors and getting
+ // rid of the loop above for topLevelVariables.
+ if (!accessor.isSynthetic) {
+ _containedNames[accessor.name] = accessor;
+ }
+ }
// TODO(paulberry): fill in other top level entities (typedefs
// and executables).
}
@@ -3484,11 +3524,11 @@ class PropertyAccessorElementForLink_Executable extends ExecutableElementForLink
SyntheticVariableElementForLink variable;
PropertyAccessorElementForLink_Executable(
+ CompilationUnitElementForLink enclosingUnit,
ClassElementForLink_Class enclosingClass,
UnlinkedExecutable unlinkedExecutable,
this.variable)
- : super(enclosingClass.enclosingElement, enclosingClass,
- unlinkedExecutable);
+ : super(enclosingUnit, enclosingClass, unlinkedExecutable);
@override
ConstructorElementForLink get asConstructor => null;
« no previous file with comments | « no previous file | pkg/analyzer/test/src/task/strong/inferred_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698