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

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

Issue 1772823002: Record IS_ANCESTOR_OF relations. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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 | « pkg/analyzer/lib/src/summary/idl.dart ('k') | pkg/analyzer/test/src/summary/index_unit_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/index_unit.dart
diff --git a/pkg/analyzer/lib/src/summary/index_unit.dart b/pkg/analyzer/lib/src/summary/index_unit.dart
index 4dcb9808cb2935a85914de8c3ac96183d1cb213d..5f72b9bbb40e43823454056747867eb4128cfbe4 100644
--- a/pkg/analyzer/lib/src/summary/index_unit.dart
+++ b/pkg/analyzer/lib/src/summary/index_unit.dart
@@ -6,6 +6,7 @@ import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/element.dart';
+import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/element/member.dart';
import 'package:analyzer/src/generated/utilities_dart.dart';
import 'package:analyzer/src/summary/format.dart';
@@ -272,6 +273,10 @@ class _IndexContributor extends GeneralizingAstVisitor {
}
}
+ void recordIsAncestorOf(Element descendant) {
+ _recordIsAncestorOf(descendant, descendant, false, <ClassElement>[]);
+ }
+
/**
* Record that the name [node] has a relation of the given [kind].
*/
@@ -377,10 +382,17 @@ class _IndexContributor extends GeneralizingAstVisitor {
recordRelationOffset(objectElement, IndexRelationKind.IS_EXTENDED_BY,
node.name.offset, 0, true);
}
+ recordIsAncestorOf(node.element);
super.visitClassDeclaration(node);
}
@override
+ visitClassTypeAlias(ClassTypeAlias node) {
+ recordIsAncestorOf(node.element);
+ super.visitClassTypeAlias(node);
+ }
+
+ @override
visitConstructorFieldInitializer(ConstructorFieldInitializer node) {
SimpleIdentifier fieldName = node.fieldName;
if (fieldName != null) {
@@ -590,6 +602,37 @@ class _IndexContributor extends GeneralizingAstVisitor {
AstNode parent = node.parent;
return parent is Combinator || parent is Label;
}
+
+ void _recordIsAncestorOf(Element descendant, ClassElement ancestor,
+ bool includeThis, List<ClassElement> visitedElements) {
+ if (ancestor == null) {
+ return;
+ }
+ if (visitedElements.contains(ancestor)) {
+ return;
+ }
+ visitedElements.add(ancestor);
+ if (includeThis) {
+ int offset = descendant.nameOffset;
+ int length = descendant.nameLength;
+ assembler.addElementRelation(
+ ancestor, IndexRelationKind.IS_ANCESTOR_OF, offset, length, false);
+ }
+ {
+ InterfaceType superType = ancestor.supertype;
+ if (superType != null) {
+ _recordIsAncestorOf(
+ descendant, superType.element, true, visitedElements);
+ }
+ }
+ for (InterfaceType mixinType in ancestor.mixins) {
+ _recordIsAncestorOf(descendant, mixinType.element, true, visitedElements);
+ }
+ for (InterfaceType implementedType in ancestor.interfaces) {
+ _recordIsAncestorOf(
+ descendant, implementedType.element, true, visitedElements);
+ }
+ }
}
/**
« no previous file with comments | « pkg/analyzer/lib/src/summary/idl.dart ('k') | pkg/analyzer/test/src/summary/index_unit_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698