OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:collection'; | 6 import 'dart:collection'; |
7 import 'dart:typed_data'; | 7 import 'dart:typed_data'; |
8 | 8 |
9 import 'package:analyzer/context/context_root.dart'; | 9 import 'package:analyzer/context/context_root.dart'; |
10 import 'package:analyzer/context/declared_variables.dart'; | 10 import 'package:analyzer/context/declared_variables.dart'; |
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1079 | 1079 |
1080 /** | 1080 /** |
1081 * Load the [AnalysisResult] for the given [file] from the [bytes]. Set | 1081 * Load the [AnalysisResult] for the given [file] from the [bytes]. Set |
1082 * optional [content] and [resolvedUnit]. | 1082 * optional [content] and [resolvedUnit]. |
1083 */ | 1083 */ |
1084 AnalysisResult _getAnalysisResultFromBytes( | 1084 AnalysisResult _getAnalysisResultFromBytes( |
1085 FileState file, String signature, List<int> bytes, | 1085 FileState file, String signature, List<int> bytes, |
1086 {String content, CompilationUnit resolvedUnit}) { | 1086 {String content, CompilationUnit resolvedUnit}) { |
1087 var unit = new AnalysisDriverResolvedUnit.fromBuffer(bytes); | 1087 var unit = new AnalysisDriverResolvedUnit.fromBuffer(bytes); |
1088 List<AnalysisError> errors = _getErrorsFromSerialized(file, unit.errors); | 1088 List<AnalysisError> errors = _getErrorsFromSerialized(file, unit.errors); |
| 1089 _updateHasErrorOrWarningFlag(file, errors); |
1089 return new AnalysisResult( | 1090 return new AnalysisResult( |
1090 this, | 1091 this, |
1091 _sourceFactory, | 1092 _sourceFactory, |
1092 file.path, | 1093 file.path, |
1093 file.uri, | 1094 file.uri, |
1094 file.exists, | 1095 file.exists, |
1095 content, | 1096 content, |
1096 file.contentHash, | 1097 file.contentHash, |
1097 file.lineInfo, | 1098 file.lineInfo, |
1098 signature, | 1099 signature, |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 String sec = _twoDigits(time.second); | 1236 String sec = _twoDigits(time.second); |
1236 String ms = _threeDigits(time.millisecond); | 1237 String ms = _threeDigits(time.millisecond); |
1237 String key = 'exception_${time.year}$m$d' '_$h$min$sec' + '_$ms'; | 1238 String key = 'exception_${time.year}$m$d' '_$h$min$sec' + '_$ms'; |
1238 | 1239 |
1239 _byteStore.put(key, bytes); | 1240 _byteStore.put(key, bytes); |
1240 return key; | 1241 return key; |
1241 } catch (_) { | 1242 } catch (_) { |
1242 return null; | 1243 return null; |
1243 } | 1244 } |
1244 } | 1245 } |
| 1246 |
| 1247 /** |
| 1248 * Given the list of [errors] for the [file], update the [file]'s |
| 1249 * [FileState.hasErrorOrWarning] flag. |
| 1250 */ |
| 1251 void _updateHasErrorOrWarningFlag( |
| 1252 FileState file, List<AnalysisError> errors) { |
| 1253 for (AnalysisError error in errors) { |
| 1254 ErrorSeverity severity = error.errorCode.errorSeverity; |
| 1255 if (severity == ErrorSeverity.ERROR || |
| 1256 severity == ErrorSeverity.WARNING) { |
| 1257 file.hasErrorOrWarning = true; |
| 1258 return; |
| 1259 } |
| 1260 } |
| 1261 file.hasErrorOrWarning = false; |
| 1262 } |
1245 } | 1263 } |
1246 | 1264 |
1247 /** | 1265 /** |
1248 * A generic schedulable interface via the AnalysisDriverScheduler. Currently | 1266 * A generic schedulable interface via the AnalysisDriverScheduler. Currently |
1249 * only implemented by [AnalysisDriver] and the angular plugin, at least as | 1267 * only implemented by [AnalysisDriver] and the angular plugin, at least as |
1250 * a temporary measure until the official plugin API is ready (and a different | 1268 * a temporary measure until the official plugin API is ready (and a different |
1251 * scheduler is used) | 1269 * scheduler is used) |
1252 */ | 1270 */ |
1253 abstract class AnalysisDriverGeneric { | 1271 abstract class AnalysisDriverGeneric { |
1254 /** | 1272 /** |
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1987 libraryDeclarations.add(new TopLevelDeclarationInSource( | 2005 libraryDeclarations.add(new TopLevelDeclarationInSource( |
1988 file.source, declaration, isExported)); | 2006 file.source, declaration, isExported)); |
1989 } | 2007 } |
1990 } | 2008 } |
1991 } | 2009 } |
1992 | 2010 |
1993 // We're not done yet. | 2011 // We're not done yet. |
1994 return false; | 2012 return false; |
1995 } | 2013 } |
1996 } | 2014 } |
OLD | NEW |