| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 input.transformer; | 5 library input.transformer; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 | 10 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 final PathMap srcPathMap; | 65 final PathMap srcPathMap; |
| 66 | 66 |
| 67 /** | 67 /** |
| 68 * The root directory for all source being modified | 68 * The root directory for all source being modified |
| 69 * during performance measurement. | 69 * during performance measurement. |
| 70 */ | 70 */ |
| 71 final String tmpSrcDirPath; | 71 final String tmpSrcDirPath; |
| 72 | 72 |
| 73 CommonInputConverter(this.tmpSrcDirPath, this.srcPathMap); | 73 CommonInputConverter(this.tmpSrcDirPath, this.srcPathMap); |
| 74 | 74 |
| 75 Map<String, dynamic> asMap(dynamic value) => value as Map<String, dynamic>; |
| 76 |
| 75 /** | 77 /** |
| 76 * Return an operation for the notification or `null` if none. | 78 * Return an operation for the notification or `null` if none. |
| 77 */ | 79 */ |
| 78 Operation convertNotification(Map<String, dynamic> json) { | 80 Operation convertNotification(Map<String, dynamic> json) { |
| 79 String event = json['event']; | 81 String event = json['event']; |
| 80 if (event == SERVER_STATUS) { | 82 if (event == SERVER_STATUS) { |
| 81 // {"event":"server.status","params":{"analysis":{"isAnalyzing":false}}} | 83 // {"event":"server.status","params":{"analysis":{"isAnalyzing":false}}} |
| 82 Map<String, dynamic> params = json['params']; | 84 Map<String, dynamic> params = asMap(json['params']); |
| 83 if (params != null) { | 85 if (params != null) { |
| 84 Map<String, dynamic> analysis = params['analysis']; | 86 Map<String, dynamic> analysis = asMap(params['analysis']); |
| 85 if (analysis != null && analysis['isAnalyzing'] == false) { | 87 if (analysis != null && analysis['isAnalyzing'] == false) { |
| 86 return new WaitForAnalysisCompleteOperation(); | 88 return new WaitForAnalysisCompleteOperation(); |
| 87 } | 89 } |
| 88 } | 90 } |
| 89 } | 91 } |
| 90 if (event == SERVER_CONNECTED) { | 92 if (event == SERVER_CONNECTED) { |
| 91 // {"event":"server.connected","params":{"version":"1.7.0"}} | 93 // {"event":"server.connected","params":{"version":"1.7.0"}} |
| 92 return new StartServerOperation(); | 94 return new StartServerOperation(); |
| 93 } | 95 } |
| 94 if (eventsSeen.add(event)) { | 96 if (eventsSeen.add(event)) { |
| 95 logger.log(Level.INFO, 'Ignored notification: $event\n $json'); | 97 logger.log(Level.INFO, 'Ignored notification: $event\n $json'); |
| 96 } | 98 } |
| 97 return null; | 99 return null; |
| 98 } | 100 } |
| 99 | 101 |
| 100 /** | 102 /** |
| 101 * Return an operation for the request or `null` if none. | 103 * Return an operation for the request or `null` if none. |
| 102 */ | 104 */ |
| 103 Operation convertRequest(Map<String, dynamic> origJson) { | 105 Operation convertRequest(Map<String, dynamic> origJson) { |
| 104 Map<String, dynamic> json = translateSrcPaths(origJson); | 106 Map<String, dynamic> json = asMap(translateSrcPaths(origJson)); |
| 105 requestMap[json['id']] = json; | 107 requestMap[json['id']] = json; |
| 106 String method = json['method']; | 108 String method = json['method']; |
| 107 // Sanity check operations that modify source | 109 // Sanity check operations that modify source |
| 108 // to ensure that the operation is on source in temp space | 110 // to ensure that the operation is on source in temp space |
| 109 if (method == ANALYSIS_UPDATE_CONTENT) { | 111 if (method == ANALYSIS_UPDATE_CONTENT) { |
| 110 // Track overlays in parallel with the analysis server | 112 // Track overlays in parallel with the analysis server |
| 111 // so that when an overlay is removed, the file can be updated on disk | 113 // so that when an overlay is removed, the file can be updated on disk |
| 112 Request request = new Request.fromJson(json); | 114 Request request = new Request.fromJson(json); |
| 113 var params = new AnalysisUpdateContentParams.fromRequest(request); | 115 var params = new AnalysisUpdateContentParams.fromRequest(request); |
| 114 params.files.forEach((String filePath, change) { | 116 params.files.forEach((String filePath, change) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 method == SERVER_SET_SUBSCRIPTIONS) { | 167 method == SERVER_SET_SUBSCRIPTIONS) { |
| 166 return new RequestOperation(this, json); | 168 return new RequestOperation(this, json); |
| 167 } | 169 } |
| 168 throw 'unknown request: $method\n $json'; | 170 throw 'unknown request: $method\n $json'; |
| 169 } | 171 } |
| 170 | 172 |
| 171 /** | 173 /** |
| 172 * Return an operation for the recorded/expected response. | 174 * Return an operation for the recorded/expected response. |
| 173 */ | 175 */ |
| 174 Operation convertResponse(Map<String, dynamic> json) { | 176 Operation convertResponse(Map<String, dynamic> json) { |
| 175 return new ResponseOperation( | 177 return new ResponseOperation(this, asMap(requestMap.remove(json['id'])), |
| 176 this, requestMap.remove(json['id']), translateSrcPaths(json)); | 178 asMap(translateSrcPaths(json))); |
| 177 } | 179 } |
| 178 | 180 |
| 179 void logOverlayContent() { | 181 void logOverlayContent() { |
| 180 logger.log(Level.WARNING, '${overlays.length} overlays'); | 182 logger.log(Level.WARNING, '${overlays.length} overlays'); |
| 181 List<String> allPaths = overlays.keys.toList()..sort(); | 183 List<String> allPaths = overlays.keys.toList()..sort(); |
| 182 for (String filePath in allPaths) { | 184 for (String filePath in allPaths) { |
| 183 logger.log(Level.WARNING, 'overlay $filePath\n${overlays[filePath]}'); | 185 logger.log(Level.WARNING, 'overlay $filePath\n${overlays[filePath]}'); |
| 184 } | 186 } |
| 185 } | 187 } |
| 186 | 188 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 if (op != null) { | 390 if (op != null) { |
| 389 outSink.add(op); | 391 outSink.add(op); |
| 390 } | 392 } |
| 391 } | 393 } |
| 392 | 394 |
| 393 @override | 395 @override |
| 394 void close() { | 396 void close() { |
| 395 outSink.close(); | 397 outSink.close(); |
| 396 } | 398 } |
| 397 } | 399 } |
| OLD | NEW |