| 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'; |
| 8 |
| 7 import 'package:analysis_server/src/analysis_server.dart'; | 9 import 'package:analysis_server/src/analysis_server.dart'; |
| 8 import 'package:analysis_server/src/constants.dart'; | 10 import 'package:analysis_server/src/constants.dart'; |
| 9 import 'package:analysis_server/src/protocol.dart'; | 11 import 'package:analysis_server/src/protocol.dart'; |
| 10 | 12 |
| 11 /** | 13 /** |
| 12 * Instances of the class [AnalysisDomainHandler] implement a [RequestHandler] | 14 * Instances of the class [AnalysisDomainHandler] implement a [RequestHandler] |
| 13 * that handles requests in the `analysis` domain. | 15 * that handles requests in the `analysis` domain. |
| 14 */ | 16 */ |
| 15 class AnalysisDomainHandler implements RequestHandler { | 17 class AnalysisDomainHandler implements RequestHandler { |
| 16 /** | 18 /** |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 // TODO(scheglov) implement | 78 // TODO(scheglov) implement |
| 77 return null; | 79 return null; |
| 78 } | 80 } |
| 79 | 81 |
| 80 Response setSubscriptions(Request request) { | 82 Response setSubscriptions(Request request) { |
| 81 // parse subscriptions | 83 // parse subscriptions |
| 82 Map<AnalysisService, Set<String>> subMap; | 84 Map<AnalysisService, Set<String>> subMap; |
| 83 { | 85 { |
| 84 RequestDatum subDatum = request.getRequiredParameter(SUBSCRIPTIONS); | 86 RequestDatum subDatum = request.getRequiredParameter(SUBSCRIPTIONS); |
| 85 Map<String, List<String>> subStringMap = subDatum.asStringListMap(); | 87 Map<String, List<String>> subStringMap = subDatum.asStringListMap(); |
| 86 subMap = new Map<AnalysisService, Set<String>>(); | 88 subMap = new HashMap<AnalysisService, Set<String>>(); |
| 87 subStringMap.forEach((String serviceName, List<String> paths) { | 89 subStringMap.forEach((String serviceName, List<String> paths) { |
| 88 AnalysisService service = Enum2.valueOf(AnalysisService.VALUES, serviceN
ame); | 90 AnalysisService service = Enum2.valueOf(AnalysisService.VALUES, serviceN
ame); |
| 89 if (service == null) { | 91 if (service == null) { |
| 90 throw new RequestFailure( | 92 throw new RequestFailure( |
| 91 new Response.unknownAnalysisService(request, serviceName)); | 93 new Response.unknownAnalysisService(request, serviceName)); |
| 92 } | 94 } |
| 93 subMap[service] = new Set.from(paths); | 95 subMap[service] = new HashSet.from(paths); |
| 94 }); | 96 }); |
| 95 } | 97 } |
| 96 server.setAnalysisSubscriptions(subMap); | 98 server.setAnalysisSubscriptions(subMap); |
| 97 return new Response(request.id); | 99 return new Response(request.id); |
| 98 } | 100 } |
| 99 | 101 |
| 100 Response updateContent(Request request) { | 102 Response updateContent(Request request) { |
| 101 var changes = new Map<String, ContentChange>(); | 103 var changes = new HashMap<String, ContentChange>(); |
| 102 RequestDatum filesDatum = request.getRequiredParameter(FILES); | 104 RequestDatum filesDatum = request.getRequiredParameter(FILES); |
| 103 filesDatum.forEachMap((file, changeDatum) { | 105 filesDatum.forEachMap((file, changeDatum) { |
| 104 var change = new ContentChange(); | 106 var change = new ContentChange(); |
| 105 change.content = changeDatum[CONTENT].asString(); | 107 change.content = changeDatum[CONTENT].asString(); |
| 106 if (changeDatum.hasKey(OFFSET)) { | 108 if (changeDatum.hasKey(OFFSET)) { |
| 107 change.offset = changeDatum[OFFSET].asInt(); | 109 change.offset = changeDatum[OFFSET].asInt(); |
| 108 change.oldLength = changeDatum[OLD_LENGTH].asInt(); | 110 change.oldLength = changeDatum[OLD_LENGTH].asInt(); |
| 109 change.newLength = changeDatum[NEW_LENGTH].asInt(); | 111 change.newLength = changeDatum[NEW_LENGTH].asInt(); |
| 110 } | 112 } |
| 111 changes[file] = change; | 113 changes[file] = change; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 128 | 130 |
| 129 /** | 131 /** |
| 130 * A description of the change to the content of a file. | 132 * A description of the change to the content of a file. |
| 131 */ | 133 */ |
| 132 class ContentChange { | 134 class ContentChange { |
| 133 String content; | 135 String content; |
| 134 int offset; | 136 int offset; |
| 135 int oldLength; | 137 int oldLength; |
| 136 int newLength; | 138 int newLength; |
| 137 } | 139 } |
| OLD | NEW |