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

Side by Side Diff: pkg/analysis_server/lib/src/domain_analysis.dart

Issue 486003003: Start using code-generated protocol classes in analysis server. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
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 domain.analysis; 5 library domain.analysis;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
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/computer/computer_hover.dart'; 10 import 'package:analysis_server/src/computer/computer_hover.dart';
11 import 'package:analysis_server/src/computer/error.dart'; 11 import 'package:analysis_server/src/computer/error.dart';
12 import 'package:analysis_server/src/constants.dart'; 12 import 'package:analysis_server/src/constants.dart';
13 import 'package:analysis_server/src/protocol.dart'; 13 import 'package:analysis_server/src/protocol.dart';
14 import 'package:analysis_server/src/protocol2.dart';
14 import 'package:analysis_server/src/services/correction/change.dart'; 15 import 'package:analysis_server/src/services/correction/change.dart';
15 import 'package:analyzer/src/generated/ast.dart'; 16 import 'package:analyzer/src/generated/ast.dart';
16 import 'package:analyzer/src/generated/engine.dart'; 17 import 'package:analyzer/src/generated/engine.dart';
17 18
18 19
19 /** 20 /**
20 * Instances of the class [AnalysisDomainHandler] implement a [RequestHandler] 21 * Instances of the class [AnalysisDomainHandler] implement a [RequestHandler]
21 * that handles requests in the `analysis` domain. 22 * that handles requests in the `analysis` domain.
22 */ 23 */
23 class AnalysisDomainHandler implements RequestHandler { 24 class AnalysisDomainHandler implements RequestHandler {
24 /** 25 /**
25 * The analysis server that is using this handler to process requests. 26 * The analysis server that is using this handler to process requests.
26 */ 27 */
27 final AnalysisServer server; 28 final AnalysisServer server;
28 29
29 /** 30 /**
30 * Initialize a newly created handler to handle requests for the given [server ]. 31 * Initialize a newly created handler to handle requests for the given [server ].
31 */ 32 */
32 AnalysisDomainHandler(this.server); 33 AnalysisDomainHandler(this.server);
33 34
34 /** 35 /**
35 * Implement the `analysis.getErrors` request. 36 * Implement the `analysis.getErrors` request.
36 */ 37 */
37 Response getErrors(Request request) { 38 Response getErrors(Request request) {
38 String file = request.getRequiredParameter(FILE).asString(); 39 String file = new AnalysisGetErrorsParams.fromRequest(request).file;
39 server.onFileAnalysisComplete(file).then((_) { 40 server.onFileAnalysisComplete(file).then((_) {
40 Response response = new Response(request.id); 41 Response response = new Response(request.id);
41 AnalysisErrorInfo errorInfo = server.getErrors(file); 42 AnalysisErrorInfo errorInfo = server.getErrors(file);
42 if (errorInfo == null) { 43 if (errorInfo == null) {
43 response.setResult(ERRORS, []); 44 response.setResult(ERRORS, []);
44 } else { 45 } else {
45 response.setResult(ERRORS, engineErrorInfoToJson(errorInfo)); 46 response.setResult(ERRORS, engineErrorInfoToJson(errorInfo));
46 } 47 }
47 server.sendResponse(response); 48 server.sendResponse(response);
48 }).catchError((message) { 49 }).catchError((message) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 return new Response(request.id); 134 return new Response(request.id);
134 } 135 }
135 136
136 /** 137 /**
137 * Implement the 'analysis.setSubscriptions' request. 138 * Implement the 'analysis.setSubscriptions' request.
138 */ 139 */
139 Response setSubscriptions(Request request) { 140 Response setSubscriptions(Request request) {
140 // parse subscriptions 141 // parse subscriptions
141 Map<AnalysisService, Set<String>> subMap; 142 Map<AnalysisService, Set<String>> subMap;
142 { 143 {
143 RequestDatum subDatum = request.getRequiredParameter(SUBSCRIPTIONS); 144 Map<AnalysisService, List<String>> subscriptions =
144 Map<String, List<String>> subStringMap = subDatum.asStringListMap(); 145 new AnalysisSetSubscriptionsParams.fromRequest(request).subscriptions;
145 subMap = new HashMap<AnalysisService, Set<String>>(); 146 subMap = new HashMap<AnalysisService, Set<String>>();
146 subStringMap.forEach((String serviceName, List<String> paths) { 147 subscriptions.forEach((AnalysisService service, List<String> paths) {
147 AnalysisService service =
148 Enum2.valueOf(AnalysisService.VALUES, serviceName);
149 if (service == null) {
150 throw new RequestFailure(
151 new Response.unknownAnalysisService(request, serviceName));
152 }
153 subMap[service] = new HashSet.from(paths); 148 subMap[service] = new HashSet.from(paths);
154 }); 149 });
155 } 150 }
156 server.setAnalysisSubscriptions(subMap); 151 server.setAnalysisSubscriptions(subMap);
157 return new Response(request.id); 152 return new Response(request.id);
158 } 153 }
159 154
160 /** 155 /**
161 * Implement the 'analysis.updateContent' request. 156 * Implement the 'analysis.updateContent' request.
162 */ 157 */
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 * content of the file, and [changes] should be null. 'change' means that 253 * content of the file, and [changes] should be null. 'change' means that
259 * [changes] contains changes to be applied to the file, and [content] should 254 * [changes] contains changes to be applied to the file, and [content] should
260 * be null. 'remove' means that the file should be read from the filesystem, 255 * be null. 'remove' means that the file should be read from the filesystem,
261 * and both [content] and [changes] should be null. 256 * and both [content] and [changes] should be null.
262 */ 257 */
263 String type; 258 String type;
264 259
265 String content; 260 String content;
266 List<Edit> changes; 261 List<Edit> changes;
267 } 262 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/computer/error.dart ('k') | pkg/analysis_server/lib/src/domain_server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698