| 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/analysis/index/index_core.dart'; |
| 10 import 'package:analysis_server/src/services/correction/source_range.dart'; | 10 import 'package:analysis_server/src/services/correction/source_range.dart'; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 _Requestor(this.index); | 200 _Requestor(this.index); |
| 201 | 201 |
| 202 void add(Element element, RelationshipImpl relationship, MatchKind kind) { | 202 void add(Element element, RelationshipImpl relationship, MatchKind kind) { |
| 203 Future relationsFuture = | 203 Future relationsFuture = |
| 204 index.getRelationships(new IndexableElement(element), relationship); | 204 index.getRelationships(new IndexableElement(element), relationship); |
| 205 Future matchesFuture = relationsFuture.then((List<LocationImpl> locations) { | 205 Future matchesFuture = relationsFuture.then((List<LocationImpl> locations) { |
| 206 List<SearchMatch> matches = <SearchMatch>[]; | 206 List<SearchMatch> matches = <SearchMatch>[]; |
| 207 for (LocationImpl location in locations) { | 207 for (LocationImpl location in locations) { |
| 208 IndexableObject indexable = location.indexable; | 208 IndexableObject indexable = location.indexable; |
| 209 if (indexable is IndexableElement) { | 209 if (indexable is IndexableElement) { |
| 210 matches.add(new SearchMatch(kind, indexable.element, | 210 matches.add(new SearchMatch( |
| 211 kind, |
| 212 indexable.element, |
| 211 new SourceRange(location.offset, location.length), | 213 new SourceRange(location.offset, location.length), |
| 212 location.isResolved, location.isQualified)); | 214 location.isResolved, |
| 215 location.isQualified)); |
| 213 } | 216 } |
| 214 } | 217 } |
| 215 return matches; | 218 return matches; |
| 216 }); | 219 }); |
| 217 futures.add(matchesFuture); | 220 futures.add(matchesFuture); |
| 218 } | 221 } |
| 219 | 222 |
| 220 Future<List<SearchMatch>> merge() { | 223 Future<List<SearchMatch>> merge() { |
| 221 return Future.wait(futures).then((List<List<SearchMatch>> matchesList) { | 224 return Future.wait(futures).then((List<List<SearchMatch>> matchesList) { |
| 222 return matchesList.expand((matches) => matches).toList(); | 225 return matchesList.expand((matches) => matches).toList(); |
| 223 }); | 226 }); |
| 224 } | 227 } |
| 225 } | 228 } |
| OLD | NEW |