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

Side by Side Diff: pkg/analysis_server/lib/src/services/search/hierarchy.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, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library services.hierarchy; 5 library services.hierarchy;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analysis_server/src/services/search/element_visitors.dart'; 10 import 'package:analysis_server/src/services/search/element_visitors.dart';
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 members.addAll(getClassMembers(superClass)); 125 members.addAll(getClassMembers(superClass));
126 } 126 }
127 return members; 127 return members;
128 } 128 }
129 129
130 /** 130 /**
131 * Returns a [Set] with all direct and indirect subclasses of [seed]. 131 * Returns a [Set] with all direct and indirect subclasses of [seed].
132 */ 132 */
133 Future<Set<ClassElement>> getSubClasses( 133 Future<Set<ClassElement>> getSubClasses(
134 SearchEngine searchEngine, ClassElement seed) { 134 SearchEngine searchEngine, ClassElement seed) {
135 Set<ClassElement> subs = new HashSet<ClassElement>(); 135 return searchEngine.searchAllSubtypes(seed).then((List<SearchMatch> matches) {
136 // prepare queue 136 Set<ClassElement> ancestors = new HashSet<ClassElement>();
137 List<ClassElement> queue = new List<ClassElement>(); 137 for (SearchMatch match in matches) {
138 queue.add(seed); 138 ClassElement ancestor = match.element;
139 // schedule subclasss search 139 ancestors.add(ancestor);
140 addSubClasses() {
141 // add direct subclasses of the next class
142 while (queue.isNotEmpty) {
143 ClassElement clazz = queue.removeLast();
144 if (subs.add(clazz)) {
145 return getDirectSubClasses(searchEngine, clazz).then((directSubs) {
146 queue.addAll(directSubs);
147 return new Future(addSubClasses);
148 });
149 }
150 } 140 }
151 // done 141 return ancestors;
152 subs.remove(seed); 142 });
153 return subs;
154 }
155 return new Future(addSubClasses);
156 } 143 }
157 144
158 /** 145 /**
159 * Returns a [Set] with all direct and indirect superclasses of [seed]. 146 * Returns a [Set] with all direct and indirect superclasses of [seed].
160 */ 147 */
161 Set<ClassElement> getSuperClasses(ClassElement seed) { 148 Set<ClassElement> getSuperClasses(ClassElement seed) {
162 Set<ClassElement> result = new HashSet<ClassElement>(); 149 Set<ClassElement> result = new HashSet<ClassElement>();
163 // prepare queue 150 // prepare queue
164 List<ClassElement> queue = new List<ClassElement>(); 151 List<ClassElement> queue = new List<ClassElement>();
165 queue.add(seed); 152 queue.add(seed);
(...skipping 26 matching lines...) Expand all
192 * its variable, otherwise returns [element]. 179 * its variable, otherwise returns [element].
193 */ 180 */
194 Element getSyntheticAccessorVariable(Element element) { 181 Element getSyntheticAccessorVariable(Element element) {
195 if (element is PropertyAccessorElement) { 182 if (element is PropertyAccessorElement) {
196 if (element.isSynthetic) { 183 if (element.isSynthetic) {
197 return element.variable; 184 return element.variable;
198 } 185 }
199 } 186 }
200 return element; 187 return element;
201 } 188 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698