Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(322)

Unified Diff: pkg/analysis_server/lib/src/search/search_domain.dart

Issue 2149853002: Handle bad regexs in search.findTopLevelDeclarations. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/lib/src/search/search_domain.dart
diff --git a/pkg/analysis_server/lib/src/search/search_domain.dart b/pkg/analysis_server/lib/src/search/search_domain.dart
index 4a0e1b7a4eed93d1bc69f3b069862cf01f2f5fa5..f72b2962b6a689af46cf3284283c9e94e8183af6 100644
--- a/pkg/analysis_server/lib/src/search/search_domain.dart
+++ b/pkg/analysis_server/lib/src/search/search_domain.dart
@@ -115,18 +115,28 @@ class SearchDomainHandler implements protocol.RequestHandler {
_sendSearchNotification(searchId, true, matches.map(toResult));
}
- Future findTopLevelDeclarations(protocol.Request request) async {
+ 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. ()
var params =
new protocol.SearchFindTopLevelDeclarationsParams.fromRequest(request);
- await server.onAnalysisComplete;
- // respond
- String searchId = (_nextSearchId++).toString();
- _sendSearchResult(
- request, new protocol.SearchFindTopLevelDeclarationsResult(searchId));
- // search
- List<SearchMatch> matches =
- await searchEngine.searchTopLevelDeclarations(params.pattern);
- _sendSearchNotification(searchId, true, matches.map(toResult));
+ try {
+ new RegExp(params.pattern);
+ } on FormatException catch (exception) {
+ throw new protocol.RequestFailure(new protocol.Response.invalidParameter(
+ request, 'pattern', exception.message));
+ }
+
+ server.onAnalysisComplete.then((_) {
+ // respond
+ String searchId = (_nextSearchId++).toString();
+ _sendSearchResult(
+ request, new protocol.SearchFindTopLevelDeclarationsResult(searchId));
+ // search
+ searchEngine
+ .searchTopLevelDeclarations(params.pattern)
+ .then((List<SearchMatch> matches) {
+ _sendSearchNotification(searchId, true, matches.map(toResult));
+ });
+ });
}
/**

Powered by Google App Engine
This is Rietveld 408576698