| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |