| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Future findTopLevelDeclarations(protocol.Request request) async { |
| 119 var params = | 119 var params = |
| 120 new protocol.SearchFindTopLevelDeclarationsParams.fromRequest(request); | 120 new protocol.SearchFindTopLevelDeclarationsParams.fromRequest(request); |
| 121 try { |
| 122 // validate the regex |
| 123 new RegExp(params.pattern); |
| 124 } on FormatException catch (exception) { |
| 125 server.sendResponse(new protocol.Response.invalidParameter( |
| 126 request, 'pattern', exception.message)); |
| 127 return; |
| 128 } |
| 129 |
| 121 await server.onAnalysisComplete; | 130 await server.onAnalysisComplete; |
| 122 // respond | 131 // respond |
| 123 String searchId = (_nextSearchId++).toString(); | 132 String searchId = (_nextSearchId++).toString(); |
| 124 _sendSearchResult( | 133 _sendSearchResult( |
| 125 request, new protocol.SearchFindTopLevelDeclarationsResult(searchId)); | 134 request, new protocol.SearchFindTopLevelDeclarationsResult(searchId)); |
| 126 // search | 135 // search |
| 127 List<SearchMatch> matches = | 136 List<SearchMatch> matches = |
| 128 await searchEngine.searchTopLevelDeclarations(params.pattern); | 137 await searchEngine.searchTopLevelDeclarations(params.pattern); |
| 129 _sendSearchNotification(searchId, true, matches.map(toResult)); | 138 _sendSearchNotification(searchId, true, matches.map(toResult)); |
| 130 } | 139 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 void _sendTypeHierarchyNull(protocol.Request request) { | 225 void _sendTypeHierarchyNull(protocol.Request request) { |
| 217 protocol.Response response = | 226 protocol.Response response = |
| 218 new protocol.SearchGetTypeHierarchyResult().toResponse(request.id); | 227 new protocol.SearchGetTypeHierarchyResult().toResponse(request.id); |
| 219 server.sendResponse(response); | 228 server.sendResponse(response); |
| 220 } | 229 } |
| 221 | 230 |
| 222 static protocol.SearchResult toResult(SearchMatch match) { | 231 static protocol.SearchResult toResult(SearchMatch match) { |
| 223 return protocol.newSearchResult_fromMatch(match); | 232 return protocol.newSearchResult_fromMatch(match); |
| 224 } | 233 } |
| 225 } | 234 } |
| OLD | NEW |