| 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 search.domain; | 5 library search.domain; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/analysis_server.dart'; | 7 import 'package:analysis_server/src/analysis_server.dart'; |
| 8 import 'package:analysis_server/src/constants.dart'; | 8 import 'package:analysis_server/src/constants.dart'; |
| 9 import 'package:analysis_server/src/protocol.dart' as protocol; | 9 import 'package:analysis_server/src/protocol.dart' as protocol; |
| 10 import 'package:analysis_server/src/search/element_references.dart'; | 10 import 'package:analysis_server/src/search/element_references.dart'; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 SearchDomainHandler(this.server) { | 38 SearchDomainHandler(this.server) { |
| 39 searchEngine = server.searchEngine; | 39 searchEngine = server.searchEngine; |
| 40 } | 40 } |
| 41 | 41 |
| 42 protocol.Response findElementReferences(protocol.Request request) { | 42 protocol.Response findElementReferences(protocol.Request request) { |
| 43 var params = new protocol.SearchFindElementReferencesParams.fromRequest(requ
est); | 43 var params = new protocol.SearchFindElementReferencesParams.fromRequest(requ
est); |
| 44 // prepare elements | 44 // prepare elements |
| 45 List<Element> elements = server.getElementsAtOffset(params.file, | 45 List<Element> elements = server.getElementsAtOffset(params.file, |
| 46 params.offset); | 46 params.offset); |
| 47 elements = elements.map((Element element) { | 47 elements = elements.map((Element element) { |
| 48 if (element is ImportElement) { |
| 49 return element.prefix; |
| 50 } |
| 48 if (element is FieldFormalParameterElement) { | 51 if (element is FieldFormalParameterElement) { |
| 49 return element.field; | 52 return element.field; |
| 50 } | 53 } |
| 51 if (element is PropertyAccessorElement) { | 54 if (element is PropertyAccessorElement) { |
| 52 return element.variable; | 55 return element.variable; |
| 53 } | 56 } |
| 54 return element; | 57 return element; |
| 55 }).toList(); | 58 }).toList(); |
| 56 // schedule search | 59 // schedule search |
| 57 String searchId = (_nextSearchId++).toString(); | 60 String searchId = (_nextSearchId++).toString(); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 void _sendSearchNotification(String searchId, bool isLast, | 170 void _sendSearchNotification(String searchId, bool isLast, |
| 168 Iterable<protocol.SearchResult> results) { | 171 Iterable<protocol.SearchResult> results) { |
| 169 server.sendNotification(new protocol.SearchResultsParams(searchId, | 172 server.sendNotification(new protocol.SearchResultsParams(searchId, |
| 170 results.toList(), isLast).toNotification()); | 173 results.toList(), isLast).toNotification()); |
| 171 } | 174 } |
| 172 | 175 |
| 173 static protocol.SearchResult toResult(SearchMatch match) { | 176 static protocol.SearchResult toResult(SearchMatch match) { |
| 174 return new protocol.SearchResult.fromMatch(match); | 177 return new protocol.SearchResult.fromMatch(match); |
| 175 } | 178 } |
| 176 } | 179 } |
| OLD | NEW |