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

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

Issue 492483002: Change analysis.updateOptions to use generated classes. (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
« no previous file with comments | « pkg/analysis_server/doc/api.html ('k') | pkg/analysis_server/test/domain_analysis_test.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 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/protocol2.dart';
15 import 'package:analysis_server/src/services/correction/change.dart'; 15 import 'package:analysis_server/src/services/correction/change.dart';
16 import 'package:analyzer/src/generated/ast.dart'; 16 import 'package:analyzer/src/generated/ast.dart';
17 import 'package:analyzer/src/generated/engine.dart'; 17 import 'package:analyzer/src/generated/engine.dart' as engine;
18 18
19 19
20 /** 20 /**
21 * Instances of the class [AnalysisDomainHandler] implement a [RequestHandler] 21 * Instances of the class [AnalysisDomainHandler] implement a [RequestHandler]
22 * that handles requests in the `analysis` domain. 22 * that handles requests in the `analysis` domain.
23 */ 23 */
24 class AnalysisDomainHandler implements RequestHandler { 24 class AnalysisDomainHandler implements RequestHandler {
25 /** 25 /**
26 * The analysis server that is using this handler to process requests. 26 * The analysis server that is using this handler to process requests.
27 */ 27 */
28 final AnalysisServer server; 28 final AnalysisServer server;
29 29
30 /** 30 /**
31 * 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 ].
32 */ 32 */
33 AnalysisDomainHandler(this.server); 33 AnalysisDomainHandler(this.server);
34 34
35 /** 35 /**
36 * Implement the `analysis.getErrors` request. 36 * Implement the `analysis.getErrors` request.
37 */ 37 */
38 Response getErrors(Request request) { 38 Response getErrors(Request request) {
39 String file = new AnalysisGetErrorsParams.fromRequest(request).file; 39 String file = new AnalysisGetErrorsParams.fromRequest(request).file;
40 server.onFileAnalysisComplete(file).then((_) { 40 server.onFileAnalysisComplete(file).then((_) {
41 Response response = new Response(request.id); 41 Response response = new Response(request.id);
42 AnalysisErrorInfo errorInfo = server.getErrors(file); 42 engine.AnalysisErrorInfo errorInfo = server.getErrors(file);
43 if (errorInfo == null) { 43 if (errorInfo == null) {
44 response.setResult(ERRORS, []); 44 response.setResult(ERRORS, []);
45 } else { 45 } else {
46 response.setResult(ERRORS, engineErrorInfoToJson(errorInfo)); 46 response.setResult(ERRORS, engineErrorInfoToJson(errorInfo));
47 } 47 }
48 server.sendResponse(response); 48 server.sendResponse(response);
49 }).catchError((message) { 49 }).catchError((message) {
50 if (message is! String) { 50 if (message is! String) {
51 AnalysisEngine.instance.logger.logError( 51 engine.AnalysisEngine.instance.logger.logError(
52 'Illegal error message during getErrors: $message'); 52 'Illegal error message during getErrors: $message');
53 message = ''; 53 message = '';
54 } 54 }
55 Response response = new Response.getErrorsError(request, message); 55 Response response = new Response.getErrorsError(request, message);
56 response.setResult(ERRORS, []); 56 response.setResult(ERRORS, []);
57 server.sendResponse(response); 57 server.sendResponse(response);
58 }); 58 });
59 // delay response 59 // delay response
60 return Response.DELAYED_RESPONSE; 60 return Response.DELAYED_RESPONSE;
61 } 61 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 } 186 }
187 server.updateContent(changes); 187 server.updateContent(changes);
188 return new Response(request.id); 188 return new Response(request.id);
189 } 189 }
190 190
191 /** 191 /**
192 * Implement the 'analysis.updateOptions' request. 192 * Implement the 'analysis.updateOptions' request.
193 */ 193 */
194 Response updateOptions(Request request) { 194 Response updateOptions(Request request) {
195 // options 195 // options
196 RequestDatum optionsDatum = request.getRequiredParameter(OPTIONS); 196 var params = new AnalysisUpdateOptionsParams.fromRequest(request);
197 AnalysisOptions newOptions = params.options;
197 List<OptionUpdater> updaters = new List<OptionUpdater>(); 198 List<OptionUpdater> updaters = new List<OptionUpdater>();
198 optionsDatum.forEachMap((String optionName, RequestDatum optionDatum) { 199 // TODO(paulberry): analyzeAngular and analyzePolymer are not in the API.
199 if (optionName == ANALYZE_ANGULAR) { 200 // if (newOptions.analyzeAngular != null) {
200 bool optionValue = optionDatum.asBool(); 201 // updaters.add((engine.AnalysisOptionsImpl options) {
201 updaters.add((AnalysisOptionsImpl options) { 202 // options.analyzeAngular = newOptions.analyzeAngular;
202 options.analyzeAngular = optionValue; 203 // });
203 }); 204 // }
204 } else if (optionName == ANALYZE_POLYMER) { 205 // if (newOptions.analyzePolymer != null) {
205 bool optionValue = optionDatum.asBool(); 206 // updaters.add((engine.AnalysisOptionsImpl options) {
206 updaters.add((AnalysisOptionsImpl options) { 207 // options.analyzePolymer = newOptions.analyzePolymer;
207 options.analyzePolymer = optionValue; 208 // });
208 }); 209 // }
209 } else if (optionName == ENABLE_ASYNC) { 210 if (newOptions.enableAsync != null) {
210 // TODO(brianwilkerson) Uncomment this when the option is supported. 211 // TODO(brianwilkerson) Uncomment this when the option is supported.
Brian Wilkerson 2014/08/19 19:50:17 The enableAsync and enableEnum options should be s
Paul Berry 2014/08/19 19:58:06 Ok. I went ahead and uncommented the code.
211 // bool optionValue = optionDatum.asBool(); 212 // updaters.add((engine.AnalysisOptionsImpl options) {
212 // updaters.add((AnalysisOptionsImpl options) { 213 // options.enableAsync = newOptions.enableAsync;
213 // options.enableAsync = optionValue; 214 // });
214 // }); 215 }
215 } else if (optionName == ENABLE_DEFERRED_LOADING) { 216 if (newOptions.enableDeferredLoading != null) {
216 bool optionValue = optionDatum.asBool(); 217 updaters.add((engine.AnalysisOptionsImpl options) {
217 updaters.add((AnalysisOptionsImpl options) { 218 options.enableDeferredLoading = newOptions.enableDeferredLoading;
218 options.enableDeferredLoading = optionValue; 219 });
219 }); 220 }
220 } else if (optionName == ENABLE_ENUMS) { 221 if (newOptions.enableEnums != null) {
221 // TODO(brianwilkerson) Uncomment this when the option is supported. 222 // TODO(brianwilkerson) Uncomment this when the option is supported.
222 // bool optionValue = optionDatum.asBool(); 223 // updaters.add((engine.AnalysisOptionsImpl options) {
223 // updaters.add((AnalysisOptionsImpl options) { 224 // options.enableEnums = newOptions.enableEnums;
224 // options.enableEnums = optionValue; 225 // });
225 // }); 226 }
226 } else if (optionName == GENERATE_DART2JS_HINTS) { 227 if (newOptions.generateDart2jsHints != null) {
227 bool optionValue = optionDatum.asBool(); 228 updaters.add((engine.AnalysisOptionsImpl options) {
228 updaters.add((AnalysisOptionsImpl options) { 229 options.dart2jsHint = newOptions.generateDart2jsHints;
229 options.dart2jsHint = optionValue; 230 });
230 }); 231 }
231 } else if (optionName == GENERATE_HINTS) { 232 if (newOptions.generateHints != null) {
232 bool optionValue = optionDatum.asBool(); 233 updaters.add((engine.AnalysisOptionsImpl options) {
233 updaters.add((AnalysisOptionsImpl options) { 234 options.hint = newOptions.generateHints;
234 options.hint = optionValue; 235 });
235 }); 236 }
236 } else {
237 throw new RequestFailure(
238 new Response.unknownOptionName(request, optionName));
239 }
240 });
241 server.updateOptions(updaters); 237 server.updateOptions(updaters);
242 return new Response(request.id); 238 return new Response(request.id);
243 } 239 }
244 } 240 }
245 241
246 242
247 /** 243 /**
248 * A description of the change to the content of a file. 244 * A description of the change to the content of a file.
249 */ 245 */
250 class ContentChange { 246 class ContentChange {
251 /** 247 /**
252 * Type of content change. 'add' means that [content] contains the full 248 * Type of content change. 'add' means that [content] contains the full
253 * content of the file, and [changes] should be null. 'change' means that 249 * content of the file, and [changes] should be null. 'change' means that
254 * [changes] contains changes to be applied to the file, and [content] should 250 * [changes] contains changes to be applied to the file, and [content] should
255 * be null. 'remove' means that the file should be read from the filesystem, 251 * be null. 'remove' means that the file should be read from the filesystem,
256 * and both [content] and [changes] should be null. 252 * and both [content] and [changes] should be null.
257 */ 253 */
258 String type; 254 String type;
259 255
260 String content; 256 String content;
261 List<Edit> changes; 257 List<Edit> changes;
262 } 258 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/doc/api.html ('k') | pkg/analysis_server/test/domain_analysis_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698