| OLD | NEW |
| 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.src.search.search_engine; | 5 library services.src.search.search_engine; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/analysis/index/index_core.dart'; |
| 9 import 'package:analysis_server/src/services/correction/source_range.dart'; | 10 import 'package:analysis_server/src/services/correction/source_range.dart'; |
| 10 import 'package:analysis_server/src/services/index/index.dart'; | 11 import 'package:analysis_server/src/services/index/index.dart'; |
| 12 import 'package:analysis_server/src/services/index/indexable_element.dart'; |
| 11 import 'package:analysis_server/src/services/search/search_engine.dart'; | 13 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| 12 import 'package:analyzer/src/generated/element.dart'; | 14 import 'package:analyzer/src/generated/element.dart'; |
| 13 import 'package:analyzer/src/generated/source.dart'; | 15 import 'package:analyzer/src/generated/source.dart'; |
| 14 | 16 |
| 15 /** | 17 /** |
| 16 * A [SearchEngine] implementation. | 18 * A [SearchEngine] implementation. |
| 17 */ | 19 */ |
| 18 class SearchEngineImpl implements SearchEngine { | 20 class SearchEngineImpl implements SearchEngine { |
| 19 final Index _index; | 21 final Index _index; |
| 20 | 22 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 } | 193 } |
| 192 } | 194 } |
| 193 | 195 |
| 194 class _Requestor { | 196 class _Requestor { |
| 195 final List<Future<List<SearchMatch>>> futures = <Future<List<SearchMatch>>>[]; | 197 final List<Future<List<SearchMatch>>> futures = <Future<List<SearchMatch>>>[]; |
| 196 final Index index; | 198 final Index index; |
| 197 | 199 |
| 198 _Requestor(this.index); | 200 _Requestor(this.index); |
| 199 | 201 |
| 200 void add(Element element, RelationshipImpl relationship, MatchKind kind) { | 202 void add(Element element, RelationshipImpl relationship, MatchKind kind) { |
| 201 Future relationsFuture = index.getRelationships(element, relationship); | 203 Future relationsFuture = |
| 204 index.getRelationships(new IndexableElement(element), relationship); |
| 202 Future matchesFuture = relationsFuture.then((List<LocationImpl> locations) { | 205 Future matchesFuture = relationsFuture.then((List<LocationImpl> locations) { |
| 203 List<SearchMatch> matches = <SearchMatch>[]; | 206 List<SearchMatch> matches = <SearchMatch>[]; |
| 204 for (LocationImpl location in locations) { | 207 for (LocationImpl location in locations) { |
| 205 matches.add(new SearchMatch(kind, location.element, | 208 IndexableObject indexable = location.indexable; |
| 206 new SourceRange(location.offset, location.length), | 209 if (indexable is IndexableElement) { |
| 207 location.isResolved, location.isQualified)); | 210 matches.add(new SearchMatch(kind, indexable.element, |
| 211 new SourceRange(location.offset, location.length), |
| 212 location.isResolved, location.isQualified)); |
| 213 } |
| 208 } | 214 } |
| 209 return matches; | 215 return matches; |
| 210 }); | 216 }); |
| 211 futures.add(matchesFuture); | 217 futures.add(matchesFuture); |
| 212 } | 218 } |
| 213 | 219 |
| 214 Future<List<SearchMatch>> merge() { | 220 Future<List<SearchMatch>> merge() { |
| 215 return Future.wait(futures).then((List<List<SearchMatch>> matchesList) { | 221 return Future.wait(futures).then((List<List<SearchMatch>> matchesList) { |
| 216 return matchesList.expand((matches) => matches).toList(); | 222 return matchesList.expand((matches) => matches).toList(); |
| 217 }); | 223 }); |
| 218 } | 224 } |
| 219 } | 225 } |
| OLD | NEW |