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

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

Issue 1713753002: Allow linked types to refer to local executables. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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
Index: pkg/analyzer/lib/src/summary/summarize_elements.dart
diff --git a/pkg/analyzer/lib/src/summary/summarize_elements.dart b/pkg/analyzer/lib/src/summary/summarize_elements.dart
index 2580e38c7255379dff7c29eaaf5ceea0054686d0..2fe21f85d6ca1c1c76546460aebbcc0b0dbd9282 100644
--- a/pkg/analyzer/lib/src/summary/summarize_elements.dart
+++ b/pkg/analyzer/lib/src/summary/summarize_elements.dart
@@ -51,6 +51,16 @@ ReferenceKind _getReferenceKind(Element element) {
return ReferenceKind.topLevelPropertyAccessor;
} else if (element is MethodElement) {
return ReferenceKind.method;
+ } else if (element is TopLevelVariableElement) {
+ // Summaries don't need to distinguish between references to a variable and
+ // references to its getter.
+ return ReferenceKind.topLevelPropertyAccessor;
+ } else if (element is LocalVariableElement) {
+ return ReferenceKind.variable;
+ } else if (element is FieldElement) {
+ // Summaries don't need to distinguish between references to a field and
+ // references to its getter.
+ return ReferenceKind.propertyAccessor;
} else {
throw new Exception('Unexpected element kind: ${element.runtimeType}');
}
@@ -1009,10 +1019,29 @@ class _CompilationUnitSerializer {
linkedReference =
new LinkedReferenceBuilder(kind: kind, unit: unit, name: name);
Element enclosing = element?.enclosingElement;
- if (enclosing is ClassElement) {
+ if (enclosing != null && enclosing is! CompilationUnitElement) {
linkedReference.containingReference =
_getElementReferenceId(enclosing, linked: linked);
- linkedReference.numTypeParameters = enclosing.typeParameters.length;
+ if (enclosing is ClassElement) {
+ linkedReference.numTypeParameters = enclosing.typeParameters.length;
+ } else if (enclosing is ExecutableElement) {
+ if (element is FunctionElement) {
+ assert(enclosing.functions.contains(element));
+ linkedReference.localIndex = enclosing.functions.indexOf(element);
+ } else if (element is LocalVariableElement) {
+ assert(enclosing.localVariables.contains(element));
+ linkedReference.localIndex =
+ enclosing.localVariables.indexOf(element);
+ } else {
+ throw new StateError(
+ 'Unexpected enclosed element type: ${element.runtimeType}');
+ }
+ } else if (enclosing is VariableElement) {
+ assert(identical(enclosing.initializer, element));
+ } else {
+ throw new StateError(
+ 'Unexpected enclosing element type: ${enclosing.runtimeType}');
+ }
}
index = linkedReferences.length;
linkedReferences.add(linkedReference);

Powered by Google App Engine
This is Rietveld 408576698