| 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_core.dart'; | 9 import 'package:analysis_server/analysis/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'; |
| 11 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'; | 12 import 'package:analysis_server/src/services/index/indexable_element.dart'; |
| 13 import 'package:analysis_server/src/services/search/search_engine.dart'; | 13 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| 14 import 'package:analyzer/src/generated/element.dart'; | 14 import 'package:analyzer/src/generated/element.dart'; |
| 15 import 'package:analyzer/src/generated/source.dart'; | 15 import 'package:analyzer/src/generated/source.dart'; |
| 16 | 16 |
| 17 /** | 17 /** |
| 18 * A [SearchEngine] implementation. | 18 * A [SearchEngine] implementation. |
| 19 */ | 19 */ |
| 20 class SearchEngineImpl implements SearchEngine { | 20 class SearchEngineImpl implements SearchEngine { |
| 21 final Index _index; | 21 final Index _index; |
| 22 | 22 |
| 23 SearchEngineImpl(this._index); | 23 SearchEngineImpl(this._index); |
| 24 | 24 |
| 25 @override | 25 @override |
| 26 Future<List<SearchMatch>> searchAllSubtypes(ClassElement type) { |
| 27 _Requestor requestor = new _Requestor(_index); |
| 28 requestor.addElement( |
| 29 type, IndexConstants.HAS_ANCESTOR, MatchKind.DECLARATION); |
| 30 return requestor.merge(); |
| 31 } |
| 32 |
| 33 @override |
| 26 Future<List<SearchMatch>> searchElementDeclarations(String name) { | 34 Future<List<SearchMatch>> searchElementDeclarations(String name) { |
| 27 IndexableName indexableName = new IndexableName(name); | 35 IndexableName indexableName = new IndexableName(name); |
| 28 _Requestor requestor = new _Requestor(_index); | 36 _Requestor requestor = new _Requestor(_index); |
| 29 requestor.add(indexableName, IndexConstants.NAME_IS_DEFINED_BY, | 37 requestor.add(indexableName, IndexConstants.NAME_IS_DEFINED_BY, |
| 30 MatchKind.DECLARATION); | 38 MatchKind.DECLARATION); |
| 31 return requestor.merge(); | 39 return requestor.merge(); |
| 32 } | 40 } |
| 33 | 41 |
| 34 @override | 42 @override |
| 35 Future<List<SearchMatch>> searchMemberDeclarations(String name) { | 43 Future<List<SearchMatch>> searchMemberDeclarations(String name) { |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 IndexableElement indexable = new IndexableElement(element); | 247 IndexableElement indexable = new IndexableElement(element); |
| 240 add(indexable, relationship, kind); | 248 add(indexable, relationship, kind); |
| 241 } | 249 } |
| 242 | 250 |
| 243 Future<List<SearchMatch>> merge() { | 251 Future<List<SearchMatch>> merge() { |
| 244 return Future.wait(futures).then((List<List<SearchMatch>> matchesList) { | 252 return Future.wait(futures).then((List<List<SearchMatch>> matchesList) { |
| 245 return matchesList.expand((matches) => matches).toList(); | 253 return matchesList.expand((matches) => matches).toList(); |
| 246 }); | 254 }); |
| 247 } | 255 } |
| 248 } | 256 } |
| OLD | NEW |