| 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/src/services/index/index.dart'; | 9 import 'package:analysis_server/src/services/index/index.dart'; |
| 10 import 'package:analysis_server/src/services/search/search_engine.dart'; | 10 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 requestor.add( | 49 requestor.add( |
| 50 element, | 50 element, |
| 51 IndexConstants.IS_READ_WRITTEN_BY, | 51 IndexConstants.IS_READ_WRITTEN_BY, |
| 52 MatchKind.READ_WRITE); | 52 MatchKind.READ_WRITE); |
| 53 requestor.add(element, IndexConstants.IS_WRITTEN_BY, MatchKind.WRITE); | 53 requestor.add(element, IndexConstants.IS_WRITTEN_BY, MatchKind.WRITE); |
| 54 return requestor.merge(); | 54 return requestor.merge(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 @override | 57 @override |
| 58 Future<List<SearchMatch>> searchReferences(Element element) { | 58 Future<List<SearchMatch>> searchReferences(Element element) { |
| 59 if (element.kind == ElementKind.ANGULAR_COMPONENT || | 59 if (element.kind == ElementKind.CLASS) { |
| 60 element.kind == ElementKind.ANGULAR_CONTROLLER || | |
| 61 element.kind == ElementKind.ANGULAR_FORMATTER || | |
| 62 element.kind == ElementKind.ANGULAR_PROPERTY || | |
| 63 element.kind == ElementKind.ANGULAR_SCOPE_PROPERTY || | |
| 64 element.kind == ElementKind.ANGULAR_SELECTOR) { | |
| 65 return _searchReferences_Angular(element as AngularElement); | |
| 66 } else if (element.kind == ElementKind.CLASS) { | |
| 67 return _searchReferences(element); | 60 return _searchReferences(element); |
| 68 } else if (element.kind == ElementKind.COMPILATION_UNIT) { | 61 } else if (element.kind == ElementKind.COMPILATION_UNIT) { |
| 69 return _searchReferences(element); | 62 return _searchReferences(element); |
| 70 } else if (element.kind == ElementKind.CONSTRUCTOR) { | 63 } else if (element.kind == ElementKind.CONSTRUCTOR) { |
| 71 return _searchReferences_Constructor(element as ConstructorElement); | 64 return _searchReferences_Constructor(element as ConstructorElement); |
| 72 } else if (element.kind == ElementKind.FIELD || | 65 } else if (element.kind == ElementKind.FIELD || |
| 73 element.kind == ElementKind.TOP_LEVEL_VARIABLE) { | 66 element.kind == ElementKind.TOP_LEVEL_VARIABLE) { |
| 74 return _searchReferences_Field(element as PropertyInducingElement); | 67 return _searchReferences_Field(element as PropertyInducingElement); |
| 75 } else if (element.kind == ElementKind.FUNCTION) { | 68 } else if (element.kind == ElementKind.FUNCTION) { |
| 76 return _searchReferences_Function(element as FunctionElement); | 69 return _searchReferences_Function(element as FunctionElement); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 117 |
| 125 Future<List<SearchMatch>> _searchReferences(Element element) { | 118 Future<List<SearchMatch>> _searchReferences(Element element) { |
| 126 _Requestor requestor = new _Requestor(_index); | 119 _Requestor requestor = new _Requestor(_index); |
| 127 requestor.add( | 120 requestor.add( |
| 128 element, | 121 element, |
| 129 IndexConstants.IS_REFERENCED_BY, | 122 IndexConstants.IS_REFERENCED_BY, |
| 130 MatchKind.REFERENCE); | 123 MatchKind.REFERENCE); |
| 131 return requestor.merge(); | 124 return requestor.merge(); |
| 132 } | 125 } |
| 133 | 126 |
| 134 Future<List<SearchMatch>> _searchReferences_Angular(AngularElement element) { | |
| 135 _Requestor requestor = new _Requestor(_index); | |
| 136 requestor.add( | |
| 137 element, | |
| 138 IndexConstants.ANGULAR_REFERENCE, | |
| 139 MatchKind.ANGULAR_REFERENCE); | |
| 140 requestor.add( | |
| 141 element, | |
| 142 IndexConstants.ANGULAR_CLOSING_TAG_REFERENCE, | |
| 143 MatchKind.ANGULAR_CLOSING_TAG_REFERENCE); | |
| 144 return requestor.merge(); | |
| 145 } | |
| 146 | |
| 147 Future<List<SearchMatch>> | 127 Future<List<SearchMatch>> |
| 148 _searchReferences_Constructor(ConstructorElement constructor) { | 128 _searchReferences_Constructor(ConstructorElement constructor) { |
| 149 _Requestor requestor = new _Requestor(_index); | 129 _Requestor requestor = new _Requestor(_index); |
| 150 requestor.add( | 130 requestor.add( |
| 151 constructor, | 131 constructor, |
| 152 IndexConstants.NAME_IS_DEFINED_BY, | 132 IndexConstants.NAME_IS_DEFINED_BY, |
| 153 MatchKind.DECLARATION); | 133 MatchKind.DECLARATION); |
| 154 requestor.add( | 134 requestor.add( |
| 155 constructor, | 135 constructor, |
| 156 IndexConstants.IS_REFERENCED_BY, | 136 IndexConstants.IS_REFERENCED_BY, |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 }); | 237 }); |
| 258 futures.add(matchesFuture); | 238 futures.add(matchesFuture); |
| 259 } | 239 } |
| 260 | 240 |
| 261 Future<List<SearchMatch>> merge() { | 241 Future<List<SearchMatch>> merge() { |
| 262 return Future.wait(futures).then((List<List<SearchMatch>> matchesList) { | 242 return Future.wait(futures).then((List<List<SearchMatch>> matchesList) { |
| 263 return matchesList.expand((matches) => matches).toList(); | 243 return matchesList.expand((matches) => matches).toList(); |
| 264 }); | 244 }); |
| 265 } | 245 } |
| 266 } | 246 } |
| OLD | NEW |