| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 element.kind == ElementKind.TOP_LEVEL_VARIABLE) { | 74 element.kind == ElementKind.TOP_LEVEL_VARIABLE) { |
| 75 return _searchReferences_Field(element as PropertyInducingElement); | 75 return _searchReferences_Field(element as PropertyInducingElement); |
| 76 } else if (element.kind == ElementKind.FUNCTION) { | 76 } else if (element.kind == ElementKind.FUNCTION) { |
| 77 return _searchReferences_Function(element as FunctionElement); | 77 return _searchReferences_Function(element as FunctionElement); |
| 78 } else if (element.kind == ElementKind.GETTER || | 78 } else if (element.kind == ElementKind.GETTER || |
| 79 element.kind == ElementKind.SETTER) { | 79 element.kind == ElementKind.SETTER) { |
| 80 return _searchReferences_PropertyAccessor( | 80 return _searchReferences_PropertyAccessor( |
| 81 element as PropertyAccessorElement); | 81 element as PropertyAccessorElement); |
| 82 } else if (element.kind == ElementKind.IMPORT) { | 82 } else if (element.kind == ElementKind.IMPORT) { |
| 83 return _searchReferences_Import(element as ImportElement); | 83 return _searchReferences_Import(element as ImportElement); |
| 84 } else if (element.kind == ElementKind.LABEL) { |
| 85 return _searchReferences_Label(element as LabelElement); |
| 84 } else if (element.kind == ElementKind.LIBRARY) { | 86 } else if (element.kind == ElementKind.LIBRARY) { |
| 85 return _searchReferences_Library(element as LibraryElement); | 87 return _searchReferences_Library(element as LibraryElement); |
| 86 } else if (element.kind == ElementKind.LOCAL_VARIABLE) { | 88 } else if (element.kind == ElementKind.LOCAL_VARIABLE) { |
| 87 return _searchReferences_LocalVariable(element as LocalVariableElement); | 89 return _searchReferences_LocalVariable(element as LocalVariableElement); |
| 88 } else if (element.kind == ElementKind.METHOD) { | 90 } else if (element.kind == ElementKind.METHOD) { |
| 89 return _searchReferences_Method(element as MethodElement); | 91 return _searchReferences_Method(element as MethodElement); |
| 90 } else if (element.kind == ElementKind.PARAMETER) { | 92 } else if (element.kind == ElementKind.PARAMETER) { |
| 91 return _searchReferences_Parameter(element as ParameterElement); | 93 return _searchReferences_Parameter(element as ParameterElement); |
| 92 } else if (element.kind == ElementKind.FUNCTION_TYPE_ALIAS) { | 94 } else if (element.kind == ElementKind.FUNCTION_TYPE_ALIAS) { |
| 93 return _searchReferences_FunctionTypeAlias( | 95 return _searchReferences_FunctionTypeAlias( |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 } | 137 } |
| 136 | 138 |
| 137 Future<List<SearchMatch>> _searchReferences_Class(ClassElement clazz) { | 139 Future<List<SearchMatch>> _searchReferences_Class(ClassElement clazz) { |
| 138 _Requestor requestor = new _Requestor(_index); | 140 _Requestor requestor = new _Requestor(_index); |
| 139 requestor.add(clazz, IndexConstants.IS_REFERENCED_BY, MatchKind.REFERENCE); | 141 requestor.add(clazz, IndexConstants.IS_REFERENCED_BY, MatchKind.REFERENCE); |
| 140 return requestor.merge(); | 142 return requestor.merge(); |
| 141 } | 143 } |
| 142 | 144 |
| 143 Future<List<SearchMatch>> | 145 Future<List<SearchMatch>> |
| 144 _searchReferences_CompilationUnit(CompilationUnitElement unit) { | 146 _searchReferences_CompilationUnit(CompilationUnitElement unit) { |
| 145 // TODO(merge?) | |
| 146 _Requestor requestor = new _Requestor(_index); | 147 _Requestor requestor = new _Requestor(_index); |
| 147 requestor.add(unit, IndexConstants.IS_REFERENCED_BY, MatchKind.REFERENCE); | 148 requestor.add(unit, IndexConstants.IS_REFERENCED_BY, MatchKind.REFERENCE); |
| 148 return requestor.merge(); | 149 return requestor.merge(); |
| 149 } | 150 } |
| 150 | 151 |
| 151 Future<List<SearchMatch>> | 152 Future<List<SearchMatch>> |
| 152 _searchReferences_Constructor(ConstructorElement constructor) { | 153 _searchReferences_Constructor(ConstructorElement constructor) { |
| 153 _Requestor requestor = new _Requestor(_index); | 154 _Requestor requestor = new _Requestor(_index); |
| 154 requestor.add( | 155 requestor.add( |
| 155 constructor, | 156 constructor, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 requestor.add(alias, IndexConstants.IS_REFERENCED_BY, MatchKind.REFERENCE); | 200 requestor.add(alias, IndexConstants.IS_REFERENCED_BY, MatchKind.REFERENCE); |
| 200 return requestor.merge(); | 201 return requestor.merge(); |
| 201 } | 202 } |
| 202 | 203 |
| 203 Future<List<SearchMatch>> _searchReferences_Import(ImportElement imp) { | 204 Future<List<SearchMatch>> _searchReferences_Import(ImportElement imp) { |
| 204 _Requestor requestor = new _Requestor(_index); | 205 _Requestor requestor = new _Requestor(_index); |
| 205 requestor.add(imp, IndexConstants.IS_REFERENCED_BY, MatchKind.REFERENCE); | 206 requestor.add(imp, IndexConstants.IS_REFERENCED_BY, MatchKind.REFERENCE); |
| 206 return requestor.merge(); | 207 return requestor.merge(); |
| 207 } | 208 } |
| 208 | 209 |
| 210 Future<List<SearchMatch>> _searchReferences_Label(LabelElement variable) { |
| 211 _Requestor requestor = new _Requestor(_index); |
| 212 requestor.add( |
| 213 variable, |
| 214 IndexConstants.IS_REFERENCED_BY, |
| 215 MatchKind.REFERENCE); |
| 216 return requestor.merge(); |
| 217 } |
| 218 |
| 209 Future<List<SearchMatch>> _searchReferences_Library(LibraryElement library) { | 219 Future<List<SearchMatch>> _searchReferences_Library(LibraryElement library) { |
| 210 _Requestor requestor = new _Requestor(_index); | 220 _Requestor requestor = new _Requestor(_index); |
| 211 requestor.add( | 221 requestor.add( |
| 212 library, | 222 library, |
| 213 IndexConstants.IS_REFERENCED_BY, | 223 IndexConstants.IS_REFERENCED_BY, |
| 214 MatchKind.REFERENCE); | 224 MatchKind.REFERENCE); |
| 215 return requestor.merge(); | 225 return requestor.merge(); |
| 216 } | 226 } |
| 217 | 227 |
| 218 Future<List<SearchMatch>> | 228 Future<List<SearchMatch>> |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 }); | 313 }); |
| 304 futures.add(matchesFuture); | 314 futures.add(matchesFuture); |
| 305 } | 315 } |
| 306 | 316 |
| 307 Future<List<SearchMatch>> merge() { | 317 Future<List<SearchMatch>> merge() { |
| 308 return Future.wait(futures).then((List<List<SearchMatch>> matchesList) { | 318 return Future.wait(futures).then((List<List<SearchMatch>> matchesList) { |
| 309 return matchesList.expand((matches) => matches).toList(); | 319 return matchesList.expand((matches) => matches).toList(); |
| 310 }); | 320 }); |
| 311 } | 321 } |
| 312 } | 322 } |
| OLD | NEW |