| 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 14 matching lines...) Expand all Loading... |
| 25 class LogFileInputConverter extends CommonInputConverter { | 25 class LogFileInputConverter extends CommonInputConverter { |
| 26 LogFileInputConverter(String tmpSrcDirPath, PathMap srcPathMap) | 26 LogFileInputConverter(String tmpSrcDirPath, PathMap srcPathMap) |
| 27 : super(tmpSrcDirPath, srcPathMap); | 27 : super(tmpSrcDirPath, srcPathMap); |
| 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 = asMap(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 { | 38 } else { |
| 39 return convertResponse(json); | 39 return convertResponse(json); |
| 40 } | 40 } |
| 41 } else if (data.startsWith(SENT_FRAGMENT)) { | 41 } else if (data.startsWith(SENT_FRAGMENT)) { |
| 42 Map<String, dynamic> json = JSON.decode(data.substring(4)); | 42 Map<String, dynamic> json = asMap(JSON.decode(data.substring(4))); |
| 43 if (json.containsKey('method')) { | 43 if (json.containsKey('method')) { |
| 44 return convertRequest(json); | 44 return convertRequest(json); |
| 45 } | 45 } |
| 46 return null; | 46 return null; |
| 47 } | 47 } |
| 48 logger.log(Level.INFO, 'unknown input line: $line'); | 48 logger.log(Level.INFO, 'unknown input line: $line'); |
| 49 return null; | 49 return null; |
| 50 } catch (e, s) { | 50 } catch (e, s) { |
| 51 throw new AnalysisException( | 51 throw new AnalysisException( |
| 52 'Failed to parse line\n $line', new CaughtException(e, s)); | 52 'Failed to parse line\n $line', new CaughtException(e, s)); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 75 while (index < line.length) { | 75 while (index < line.length) { |
| 76 int code = line.codeUnitAt(index); | 76 int code = line.codeUnitAt(index); |
| 77 if (code < ZERO || NINE < code) { | 77 if (code < ZERO || NINE < code) { |
| 78 return line.substring(0, index); | 78 return line.substring(0, index); |
| 79 } | 79 } |
| 80 ++index; | 80 ++index; |
| 81 } | 81 } |
| 82 return line; | 82 return line; |
| 83 } | 83 } |
| 84 } | 84 } |
| OLD | NEW |