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'; |
11 | 11 |
12 import 'input_converter.dart'; | 12 import 'input_converter.dart'; |
13 import 'operation.dart'; | 13 import 'operation.dart'; |
14 | 14 |
15 const CONNECTED_MSG_FRAGMENT = ' <= {"event":"server.connected"'; | 15 const CONNECTED_MSG_FRAGMENT = ' <= {"event":"server.connected"'; |
16 final int NINE = '9'.codeUnitAt(0); | 16 final int NINE = '9'.codeUnitAt(0); |
17 const RECEIVED_FRAGMENT = ' <= {'; | 17 const RECEIVED_FRAGMENT = ' <= {'; |
18 const SENT_FRAGMENT = ' => {'; | 18 const SENT_FRAGMENT = ' => {'; |
19 final int ZERO = '0'.codeUnitAt(0); | 19 final int ZERO = '0'.codeUnitAt(0); |
20 | 20 |
21 /** | 21 /** |
22 * [LogFileInputConverter] converts a log file stream | 22 * [LogFileInputConverter] converts a log file stream |
23 * into a series of operations to be sent to the analysis server. | 23 * into a series of operations to be sent to the analysis server. |
24 */ | 24 */ |
25 class LogFileInputConverter extends CommonInputConverter { | 25 class LogFileInputConverter extends CommonInputConverter { |
26 LogFileInputConverter(Map<String, String> srcPathMap) : super(srcPathMap); | 26 LogFileInputConverter(String tmpSrcDirPath, Map<String, String> srcPathMap) |
| 27 : super(tmpSrcDirPath, srcPathMap); |
27 | 28 |
28 @override | 29 @override |
29 Operation convert(String line) { | 30 Operation convert(String line) { |
30 try { | 31 try { |
31 String timeStampString = _parseTimeStamp(line); | 32 String timeStampString = _parseTimeStamp(line); |
32 String data = line.substring(timeStampString.length); | 33 String data = line.substring(timeStampString.length); |
33 if (data.startsWith(RECEIVED_FRAGMENT)) { | 34 if (data.startsWith(RECEIVED_FRAGMENT)) { |
34 Map<String, dynamic> json = JSON.decode(data.substring(4)); | 35 Map<String, dynamic> json = JSON.decode(data.substring(4)); |
35 if (json.containsKey('event')) { | 36 if (json.containsKey('event')) { |
36 return convertNotification(json); | 37 return convertNotification(json); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 while (index < line.length) { | 74 while (index < line.length) { |
74 int code = line.codeUnitAt(index); | 75 int code = line.codeUnitAt(index); |
75 if (code < ZERO || NINE < code) { | 76 if (code < ZERO || NINE < code) { |
76 return line.substring(0, index); | 77 return line.substring(0, index); |
77 } | 78 } |
78 ++index; | 79 ++index; |
79 } | 80 } |
80 return line; | 81 return line; |
81 } | 82 } |
82 } | 83 } |
OLD | NEW |