| 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:analyzer/src/generated/engine.dart'; |
| 9 import 'package:analysis_server/src/analysis_server.dart'; | 10 import 'package:analysis_server/src/analysis_server.dart'; |
| 10 import 'package:analysis_server/src/constants.dart'; | 11 import 'package:analysis_server/src/constants.dart'; |
| 11 import 'package:analysis_server/src/protocol.dart'; | 12 import 'package:analysis_server/src/protocol.dart'; |
| 12 | 13 |
| 13 /** | 14 /** |
| 14 * Instances of the class [AnalysisDomainHandler] implement a [RequestHandler] | 15 * Instances of the class [AnalysisDomainHandler] implement a [RequestHandler] |
| 15 * that handles requests in the `analysis` domain. | 16 * that handles requests in the `analysis` domain. |
| 16 */ | 17 */ |
| 17 class AnalysisDomainHandler implements RequestHandler { | 18 class AnalysisDomainHandler implements RequestHandler { |
| 18 /** | 19 /** |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 server.updateContent(changes); | 119 server.updateContent(changes); |
| 119 return new Response(request.id); | 120 return new Response(request.id); |
| 120 } | 121 } |
| 121 | 122 |
| 122 /** | 123 /** |
| 123 * Implement the 'analysis.updateOptions' request. | 124 * Implement the 'analysis.updateOptions' request. |
| 124 */ | 125 */ |
| 125 Response updateOptions(Request request) { | 126 Response updateOptions(Request request) { |
| 126 // options | 127 // options |
| 127 RequestDatum optionsDatum = request.getRequiredParameter(OPTIONS); | 128 RequestDatum optionsDatum = request.getRequiredParameter(OPTIONS); |
| 128 // TODO(scheglov) implement | 129 List<OptionUpdater> updaters = new List<OptionUpdater>(); |
| 129 return null; | 130 optionsDatum.forEachMap((String optionName, RequestDatum optionDatum) { |
| 131 if (optionName == ANALYZE_ANGULAR) { |
| 132 bool optionValue = optionDatum.asBool(); |
| 133 updaters.add((AnalysisOptionsImpl options) { |
| 134 options.analyzeAngular = optionValue; |
| 135 }); |
| 136 } else if (optionName == ANALYZE_POLYMER) { |
| 137 bool optionValue = optionDatum.asBool(); |
| 138 updaters.add((AnalysisOptionsImpl options) { |
| 139 options.analyzePolymer = optionValue; |
| 140 }); |
| 141 } else if (optionName == ENABLE_ASYNC) { |
| 142 // TODO(brianwilkerson) Uncomment this when the option is supported. |
| 143 // bool optionValue = optionDatum.asBool(); |
| 144 // updaters.add((AnalysisOptionsImpl options) { |
| 145 // options.enableAsync = optionValue; |
| 146 // }); |
| 147 } else if (optionName == ENABLE_DEFERRED_LOADING) { |
| 148 bool optionValue = optionDatum.asBool(); |
| 149 updaters.add((AnalysisOptionsImpl options) { |
| 150 options.enableDeferredLoading = optionValue; |
| 151 }); |
| 152 } else if (optionName == ENABLE_ENUMS) { |
| 153 // TODO(brianwilkerson) Uncomment this when the option is supported. |
| 154 // bool optionValue = optionDatum.asBool(); |
| 155 // updaters.add((AnalysisOptionsImpl options) { |
| 156 // options.enableEnums = optionValue; |
| 157 // }); |
| 158 } else if (optionName == GENERATE_DART2JS_HINTS) { |
| 159 bool optionValue = optionDatum.asBool(); |
| 160 updaters.add((AnalysisOptionsImpl options) { |
| 161 options.dart2jsHint = optionValue; |
| 162 }); |
| 163 } else if (optionName == GENERATE_HINTS) { |
| 164 bool optionValue = optionDatum.asBool(); |
| 165 updaters.add((AnalysisOptionsImpl options) { |
| 166 options.hint = optionValue; |
| 167 }); |
| 168 } else { |
| 169 throw new RequestFailure(new Response.unknownOptionName(request, |
| 170 optionName)); |
| 171 } |
| 172 }); |
| 173 server.updateOptions(updaters); |
| 174 return new Response(request.id); |
| 130 } | 175 } |
| 131 | 176 |
| 132 /** | 177 /** |
| 133 * Implement the 'analysis.updateSdks' request. | 178 * Implement the 'analysis.updateSdks' request. |
| 134 */ | 179 */ |
| 135 Response updateSdks(Request request) { | 180 Response updateSdks(Request request) { |
| 136 // added | 181 // added |
| 137 RequestDatum addedDatum = request.getRequiredParameter(ADDED); | 182 RequestDatum addedDatum = request.getRequiredParameter(ADDED); |
| 138 List<String> added = addedDatum.asStringList(); | 183 List<String> added = addedDatum.asStringList(); |
| 139 // removed | 184 // removed |
| (...skipping 10 matching lines...) Expand all Loading... |
| 150 | 195 |
| 151 /** | 196 /** |
| 152 * A description of the change to the content of a file. | 197 * A description of the change to the content of a file. |
| 153 */ | 198 */ |
| 154 class ContentChange { | 199 class ContentChange { |
| 155 String content; | 200 String content; |
| 156 int offset; | 201 int offset; |
| 157 int oldLength; | 202 int oldLength; |
| 158 int newLength; | 203 int newLength; |
| 159 } | 204 } |
| OLD | NEW |