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

Unified Diff: pkg/analysis_server/lib/src/services/index/index_contributor.dart

Issue 1371463002: Record HAS_ANCESTOR relations into index. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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/analysis_server/lib/src/services/index/index_contributor.dart
diff --git a/pkg/analysis_server/lib/src/services/index/index_contributor.dart b/pkg/analysis_server/lib/src/services/index/index_contributor.dart
index 6170802e631590b376ce4527b70ffe3a37429ce4..2f766e81ab111d562b2fb10369086fcd82a03689 100644
--- a/pkg/analysis_server/lib/src/services/index/index_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/index/index_contributor.dart
@@ -110,6 +110,7 @@ class _IndexContributor extends GeneralizingAstVisitor {
enterScope(element);
try {
_recordTopLevelElementDefinition(element);
+ _recordHasAncestor(element);
{
ExtendsClause extendsClause = node.extendsClause;
if (extendsClause != null) {
@@ -154,6 +155,7 @@ class _IndexContributor extends GeneralizingAstVisitor {
enterScope(element);
try {
_recordTopLevelElementDefinition(element);
+ _recordHasAncestor(element);
{
TypeName superclassNode = node.superclass;
if (superclassNode != null) {
@@ -645,6 +647,40 @@ class _IndexContributor extends GeneralizingAstVisitor {
return false;
}
+ void _recordHasAncestor(ClassElement element) {
+ int offset = element.nameOffset;
+ int length = element.name.length;
+ LocationImpl location = _createLocationForOffset(offset, length);
+ _recordHasAncestor0(location, element, false, <ClassElement>[]);
+ }
+
+ void _recordHasAncestor0(LocationImpl location, ClassElement element,
+ bool includeThis, List<ClassElement> visitedElements) {
+ if (element == null) {
+ return;
+ }
+ if (visitedElements.contains(element)) {
+ return;
+ }
+ visitedElements.add(element);
+ if (includeThis) {
+ recordRelationshipElement(element, IndexConstants.HAS_ANCESTOR, location);
+ }
+ {
+ InterfaceType superType = element.supertype;
+ if (superType != null) {
+ _recordHasAncestor0(location, superType.element, true, visitedElements);
+ }
+ }
+ for (InterfaceType mixinType in element.mixins) {
+ _recordHasAncestor0(location, mixinType.element, true, visitedElements);
+ }
+ for (InterfaceType implementedType in element.interfaces) {
+ _recordHasAncestor0(
+ location, implementedType.element, true, visitedElements);
+ }
+ }
+
/**
* Records [ImportElement] reference if given [SimpleIdentifier] references some
* top-level element and not qualified with import prefix.
« no previous file with comments | « pkg/analysis_server/lib/src/services/index/index.dart ('k') | pkg/analysis_server/lib/src/services/search/hierarchy.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698