Chromium Code Reviews| 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 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/analysis_server.dart'; | 9 import 'package:analysis_server/src/analysis_server.dart'; |
| 10 import 'package:analysis_server/src/constants.dart'; | 10 import 'package:analysis_server/src/constants.dart'; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 // respond | 108 // respond |
| 109 String searchId = (_nextSearchId++).toString(); | 109 String searchId = (_nextSearchId++).toString(); |
| 110 _sendSearchResult( | 110 _sendSearchResult( |
| 111 request, new protocol.SearchFindMemberReferencesResult(searchId)); | 111 request, new protocol.SearchFindMemberReferencesResult(searchId)); |
| 112 // search | 112 // search |
| 113 List<SearchMatch> matches = | 113 List<SearchMatch> matches = |
| 114 await searchEngine.searchMemberReferences(params.name); | 114 await searchEngine.searchMemberReferences(params.name); |
| 115 _sendSearchNotification(searchId, true, matches.map(toResult)); | 115 _sendSearchNotification(searchId, true, matches.map(toResult)); |
| 116 } | 116 } |
| 117 | 117 |
| 118 Future findTopLevelDeclarations(protocol.Request request) async { | 118 void findTopLevelDeclarations(protocol.Request request) { |
|
Brian Wilkerson
2016/07/13 23:42:37
Removing the `async` makes this much harder to rea
scheglov
2016/07/14 00:18:07
We could use something like this instead.
()
| |
| 119 var params = | 119 var params = |
| 120 new protocol.SearchFindTopLevelDeclarationsParams.fromRequest(request); | 120 new protocol.SearchFindTopLevelDeclarationsParams.fromRequest(request); |
| 121 await server.onAnalysisComplete; | 121 try { |
| 122 // respond | 122 new RegExp(params.pattern); |
| 123 String searchId = (_nextSearchId++).toString(); | 123 } on FormatException catch (exception) { |
| 124 _sendSearchResult( | 124 throw new protocol.RequestFailure(new protocol.Response.invalidParameter( |
| 125 request, new protocol.SearchFindTopLevelDeclarationsResult(searchId)); | 125 request, 'pattern', exception.message)); |
| 126 // search | 126 } |
| 127 List<SearchMatch> matches = | 127 |
| 128 await searchEngine.searchTopLevelDeclarations(params.pattern); | 128 server.onAnalysisComplete.then((_) { |
| 129 _sendSearchNotification(searchId, true, matches.map(toResult)); | 129 // respond |
| 130 String searchId = (_nextSearchId++).toString(); | |
| 131 _sendSearchResult( | |
| 132 request, new protocol.SearchFindTopLevelDeclarationsResult(searchId)); | |
| 133 // search | |
| 134 searchEngine | |
| 135 .searchTopLevelDeclarations(params.pattern) | |
| 136 .then((List<SearchMatch> matches) { | |
| 137 _sendSearchNotification(searchId, true, matches.map(toResult)); | |
| 138 }); | |
| 139 }); | |
| 130 } | 140 } |
| 131 | 141 |
| 132 /** | 142 /** |
| 133 * Implement the `search.getTypeHierarchy` request. | 143 * Implement the `search.getTypeHierarchy` request. |
| 134 */ | 144 */ |
| 135 Future getTypeHierarchy(protocol.Request request) async { | 145 Future getTypeHierarchy(protocol.Request request) async { |
| 136 var params = new protocol.SearchGetTypeHierarchyParams.fromRequest(request); | 146 var params = new protocol.SearchGetTypeHierarchyParams.fromRequest(request); |
| 137 String file = params.file; | 147 String file = params.file; |
| 138 // wait for analysis | 148 // wait for analysis |
| 139 if (params.superOnly == true) { | 149 if (params.superOnly == true) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 void _sendTypeHierarchyNull(protocol.Request request) { | 226 void _sendTypeHierarchyNull(protocol.Request request) { |
| 217 protocol.Response response = | 227 protocol.Response response = |
| 218 new protocol.SearchGetTypeHierarchyResult().toResponse(request.id); | 228 new protocol.SearchGetTypeHierarchyResult().toResponse(request.id); |
| 219 server.sendResponse(response); | 229 server.sendResponse(response); |
| 220 } | 230 } |
| 221 | 231 |
| 222 static protocol.SearchResult toResult(SearchMatch match) { | 232 static protocol.SearchResult toResult(SearchMatch match) { |
| 223 return protocol.newSearchResult_fromMatch(match); | 233 return protocol.newSearchResult_fromMatch(match); |
| 224 } | 234 } |
| 225 } | 235 } |
| OLD | NEW |