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

Side by Side Diff: pkg/analysis_server/lib/src/search/search_domain.dart

Issue 2409403002: Issue 27542. Guard against CompilationUnitElement is null in SearchMatch.element getter. (Closed)
Patch Set: Created 4 years, 2 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 unified diff | Download patch
OLDNEW
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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 var params = 91 var params =
92 new protocol.SearchFindMemberDeclarationsParams.fromRequest(request); 92 new protocol.SearchFindMemberDeclarationsParams.fromRequest(request);
93 await server.onAnalysisComplete; 93 await server.onAnalysisComplete;
94 // respond 94 // respond
95 String searchId = (_nextSearchId++).toString(); 95 String searchId = (_nextSearchId++).toString();
96 _sendSearchResult( 96 _sendSearchResult(
97 request, new protocol.SearchFindMemberDeclarationsResult(searchId)); 97 request, new protocol.SearchFindMemberDeclarationsResult(searchId));
98 // search 98 // search
99 List<SearchMatch> matches = 99 List<SearchMatch> matches =
100 await searchEngine.searchMemberDeclarations(params.name); 100 await searchEngine.searchMemberDeclarations(params.name);
101 matches = SearchMatch.withNotNullElement(matches);
101 _sendSearchNotification(searchId, true, matches.map(toResult)); 102 _sendSearchNotification(searchId, true, matches.map(toResult));
102 } 103 }
103 104
104 Future findMemberReferences(protocol.Request request) async { 105 Future findMemberReferences(protocol.Request request) async {
105 var params = 106 var params =
106 new protocol.SearchFindMemberReferencesParams.fromRequest(request); 107 new protocol.SearchFindMemberReferencesParams.fromRequest(request);
107 await server.onAnalysisComplete; 108 await server.onAnalysisComplete;
108 // respond 109 // respond
109 String searchId = (_nextSearchId++).toString(); 110 String searchId = (_nextSearchId++).toString();
110 _sendSearchResult( 111 _sendSearchResult(
111 request, new protocol.SearchFindMemberReferencesResult(searchId)); 112 request, new protocol.SearchFindMemberReferencesResult(searchId));
112 // search 113 // search
113 List<SearchMatch> matches = 114 List<SearchMatch> matches =
114 await searchEngine.searchMemberReferences(params.name); 115 await searchEngine.searchMemberReferences(params.name);
116 matches = SearchMatch.withNotNullElement(matches);
115 _sendSearchNotification(searchId, true, matches.map(toResult)); 117 _sendSearchNotification(searchId, true, matches.map(toResult));
116 } 118 }
117 119
118 Future findTopLevelDeclarations(protocol.Request request) async { 120 Future findTopLevelDeclarations(protocol.Request request) async {
119 var params = 121 var params =
120 new protocol.SearchFindTopLevelDeclarationsParams.fromRequest(request); 122 new protocol.SearchFindTopLevelDeclarationsParams.fromRequest(request);
121 try { 123 try {
122 // validate the regex 124 // validate the regex
123 new RegExp(params.pattern); 125 new RegExp(params.pattern);
124 } on FormatException catch (exception) { 126 } on FormatException catch (exception) {
125 server.sendResponse(new protocol.Response.invalidParameter( 127 server.sendResponse(new protocol.Response.invalidParameter(
126 request, 'pattern', exception.message)); 128 request, 'pattern', exception.message));
127 return; 129 return;
128 } 130 }
129 131
130 await server.onAnalysisComplete; 132 await server.onAnalysisComplete;
131 // respond 133 // respond
132 String searchId = (_nextSearchId++).toString(); 134 String searchId = (_nextSearchId++).toString();
133 _sendSearchResult( 135 _sendSearchResult(
134 request, new protocol.SearchFindTopLevelDeclarationsResult(searchId)); 136 request, new protocol.SearchFindTopLevelDeclarationsResult(searchId));
135 // search 137 // search
136 List<SearchMatch> matches = 138 List<SearchMatch> matches =
137 await searchEngine.searchTopLevelDeclarations(params.pattern); 139 await searchEngine.searchTopLevelDeclarations(params.pattern);
140 matches = SearchMatch.withNotNullElement(matches);
138 _sendSearchNotification(searchId, true, matches.map(toResult)); 141 _sendSearchNotification(searchId, true, matches.map(toResult));
139 } 142 }
140 143
141 /** 144 /**
142 * Implement the `search.getTypeHierarchy` request. 145 * Implement the `search.getTypeHierarchy` request.
143 */ 146 */
144 Future getTypeHierarchy(protocol.Request request) async { 147 Future getTypeHierarchy(protocol.Request request) async {
145 var params = new protocol.SearchGetTypeHierarchyParams.fromRequest(request); 148 var params = new protocol.SearchGetTypeHierarchyParams.fromRequest(request);
146 String file = params.file; 149 String file = params.file;
147 // wait for analysis 150 // wait for analysis
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 void _sendTypeHierarchyNull(protocol.Request request) { 228 void _sendTypeHierarchyNull(protocol.Request request) {
226 protocol.Response response = 229 protocol.Response response =
227 new protocol.SearchGetTypeHierarchyResult().toResponse(request.id); 230 new protocol.SearchGetTypeHierarchyResult().toResponse(request.id);
228 server.sendResponse(response); 231 server.sendResponse(response);
229 } 232 }
230 233
231 static protocol.SearchResult toResult(SearchMatch match) { 234 static protocol.SearchResult toResult(SearchMatch match) {
232 return protocol.newSearchResult_fromMatch(match); 235 return protocol.newSearchResult_fromMatch(match);
233 } 236 }
234 } 237 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698