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

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

Issue 1322323005: Support for 'superOnly' in 'search.getTypeHierarchy'. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/search/type_hierarchy.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 List<SearchMatch> matches = 120 List<SearchMatch> matches =
121 await searchEngine.searchTopLevelDeclarations(params.pattern); 121 await searchEngine.searchTopLevelDeclarations(params.pattern);
122 _sendSearchNotification(searchId, true, matches.map(toResult)); 122 _sendSearchNotification(searchId, true, matches.map(toResult));
123 } 123 }
124 124
125 /** 125 /**
126 * Implement the `search.getTypeHierarchy` request. 126 * Implement the `search.getTypeHierarchy` request.
127 */ 127 */
128 Future getTypeHierarchy(protocol.Request request) async { 128 Future getTypeHierarchy(protocol.Request request) async {
129 var params = new protocol.SearchGetTypeHierarchyParams.fromRequest(request); 129 var params = new protocol.SearchGetTypeHierarchyParams.fromRequest(request);
130 await server.onAnalysisComplete; 130 String file = params.file;
131 // wait for analysis
132 if (params.superOnly == true) {
133 await server.onFileAnalysisComplete(file);
134 } else {
135 await server.onAnalysisComplete;
136 }
131 // prepare element 137 // prepare element
132 List<Element> elements = 138 List<Element> elements = server.getElementsAtOffset(file, params.offset);
133 server.getElementsAtOffset(params.file, params.offset);
134 if (elements.isEmpty) { 139 if (elements.isEmpty) {
135 protocol.Response response = 140 _sendTypeHierarchyNull(request);
136 new protocol.SearchGetTypeHierarchyResult().toResponse(request.id); 141 return;
142 }
143 Element element = elements.first;
144 // maybe supertype hierarchy only
145 if (params.superOnly == true) {
146 TypeHierarchyComputer computer =
147 new TypeHierarchyComputer(searchEngine, element);
148 List<protocol.TypeHierarchyItem> items = computer.computeSuper();
149 protocol.Response response = new protocol.SearchGetTypeHierarchyResult(
150 hierarchyItems: items).toResponse(request.id);
137 server.sendResponse(response); 151 server.sendResponse(response);
138 return; 152 return;
139 } 153 }
140 Element element = elements.first;
141 // prepare type hierarchy 154 // prepare type hierarchy
142 TypeHierarchyComputer computer = new TypeHierarchyComputer(searchEngine); 155 TypeHierarchyComputer computer =
143 List<protocol.TypeHierarchyItem> items = await computer.compute(element); 156 new TypeHierarchyComputer(searchEngine, element);
157 List<protocol.TypeHierarchyItem> items = await computer.compute();
144 protocol.Response response = new protocol.SearchGetTypeHierarchyResult( 158 protocol.Response response = new protocol.SearchGetTypeHierarchyResult(
145 hierarchyItems: items).toResponse(request.id); 159 hierarchyItems: items).toResponse(request.id);
146 server.sendResponse(response); 160 server.sendResponse(response);
147 } 161 }
148 162
149 @override 163 @override
150 protocol.Response handleRequest(protocol.Request request) { 164 protocol.Response handleRequest(protocol.Request request) {
151 if (searchEngine == null) { 165 if (searchEngine == null) {
152 return new protocol.Response.noIndexGenerated(request); 166 return new protocol.Response.noIndexGenerated(request);
153 } 167 }
(...skipping 29 matching lines...) Expand all
183 } 197 }
184 198
185 /** 199 /**
186 * Send a search response with the given [result] to the given [request]. 200 * Send a search response with the given [result] to the given [request].
187 */ 201 */
188 void _sendSearchResult(protocol.Request request, result) { 202 void _sendSearchResult(protocol.Request request, result) {
189 protocol.Response response = result.toResponse(request.id); 203 protocol.Response response = result.toResponse(request.id);
190 server.sendResponse(response); 204 server.sendResponse(response);
191 } 205 }
192 206
207 void _sendTypeHierarchyNull(protocol.Request request) {
208 protocol.Response response =
209 new protocol.SearchGetTypeHierarchyResult().toResponse(request.id);
210 server.sendResponse(response);
211 }
212
193 static protocol.SearchResult toResult(SearchMatch match) { 213 static protocol.SearchResult toResult(SearchMatch match) {
194 return protocol.newSearchResult_fromMatch(match); 214 return protocol.newSearchResult_fromMatch(match);
195 } 215 }
196 } 216 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/search/type_hierarchy.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698