| 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.log_file; | 5 library input.transformer.log_file; |
| 6 | 6 |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/generated/java_engine.dart'; | 9 import 'package:analyzer/src/generated/java_engine.dart'; |
| 10 import 'package:logging/logging.dart'; | 10 import 'package:logging/logging.dart'; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 @override | 29 @override |
| 30 Operation convert(String line) { | 30 Operation convert(String line) { |
| 31 try { | 31 try { |
| 32 String timeStampString = _parseTimeStamp(line); | 32 String timeStampString = _parseTimeStamp(line); |
| 33 String data = line.substring(timeStampString.length); | 33 String data = line.substring(timeStampString.length); |
| 34 if (data.startsWith(RECEIVED_FRAGMENT)) { | 34 if (data.startsWith(RECEIVED_FRAGMENT)) { |
| 35 Map<String, dynamic> json = JSON.decode(data.substring(4)); | 35 Map<String, dynamic> json = JSON.decode(data.substring(4)); |
| 36 if (json.containsKey('event')) { | 36 if (json.containsKey('event')) { |
| 37 return convertNotification(json); | 37 return convertNotification(json); |
| 38 } else { |
| 39 return convertResponse(json); |
| 38 } | 40 } |
| 39 return null; | |
| 40 } else if (data.startsWith(SENT_FRAGMENT)) { | 41 } else if (data.startsWith(SENT_FRAGMENT)) { |
| 41 Map<String, dynamic> json = JSON.decode(data.substring(4)); | 42 Map<String, dynamic> json = JSON.decode(data.substring(4)); |
| 42 if (json.containsKey('method')) { | 43 if (json.containsKey('method')) { |
| 43 return convertRequest(json); | 44 return convertRequest(json); |
| 44 } | 45 } |
| 45 return null; | 46 return null; |
| 46 } | 47 } |
| 47 logger.log(Level.INFO, 'unknown input line: $line'); | 48 logger.log(Level.INFO, 'unknown input line: $line'); |
| 48 return null; | 49 return null; |
| 49 } catch (e, s) { | 50 } catch (e, s) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 74 while (index < line.length) { | 75 while (index < line.length) { |
| 75 int code = line.codeUnitAt(index); | 76 int code = line.codeUnitAt(index); |
| 76 if (code < ZERO || NINE < code) { | 77 if (code < ZERO || NINE < code) { |
| 77 return line.substring(0, index); | 78 return line.substring(0, index); |
| 78 } | 79 } |
| 79 ++index; | 80 ++index; |
| 80 } | 81 } |
| 81 return line; | 82 return line; |
| 82 } | 83 } |
| 83 } | 84 } |
| OLD | NEW |