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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 if (_topLevelNameDeclarationsTasks.isNotEmpty) { | 402 if (_topLevelNameDeclarationsTasks.isNotEmpty) { |
403 return AnalysisDriverPriority.interactive; | 403 return AnalysisDriverPriority.interactive; |
404 } | 404 } |
405 if (_priorityFiles.isNotEmpty) { | 405 if (_priorityFiles.isNotEmpty) { |
406 for (String path in _priorityFiles) { | 406 for (String path in _priorityFiles) { |
407 if (_fileTracker.isFilePending(path)) { | 407 if (_fileTracker.isFilePending(path)) { |
408 return AnalysisDriverPriority.priority; | 408 return AnalysisDriverPriority.priority; |
409 } | 409 } |
410 } | 410 } |
411 } | 411 } |
| 412 if (_fileTracker.hasChangedFiles) { |
| 413 return AnalysisDriverPriority.changedFiles; |
| 414 } |
| 415 if (_fileTracker.hasPendingChangedFiles) { |
| 416 return AnalysisDriverPriority.generalChanged; |
| 417 } |
| 418 if (_fileTracker.hasPendingImportFiles) { |
| 419 return AnalysisDriverPriority.generalImportChanged; |
| 420 } |
| 421 if (_fileTracker.hasPendingErrorFiles) { |
| 422 return AnalysisDriverPriority.generalWithErrors; |
| 423 } |
412 if (_fileTracker.hasPendingFiles) { | 424 if (_fileTracker.hasPendingFiles) { |
413 return AnalysisDriverPriority.general; | 425 return AnalysisDriverPriority.general; |
414 } | 426 } |
415 if (_fileTracker.hasChangedFiles) { | |
416 return AnalysisDriverPriority.general; | |
417 } | |
418 if (_requestedParts.isNotEmpty || _partsToAnalyze.isNotEmpty) { | 427 if (_requestedParts.isNotEmpty || _partsToAnalyze.isNotEmpty) { |
419 return AnalysisDriverPriority.general; | 428 return AnalysisDriverPriority.general; |
420 } | 429 } |
421 return AnalysisDriverPriority.nothing; | 430 return AnalysisDriverPriority.nothing; |
422 } | 431 } |
423 | 432 |
424 /** | 433 /** |
425 * Add the file with the given [path] to the set of files to analyze. | 434 * Add the file with the given [path] to the set of files to analyze. |
426 * | 435 * |
427 * The [path] must be absolute and normalized. | 436 * The [path] must be absolute and normalized. |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1079 | 1088 |
1080 /** | 1089 /** |
1081 * Load the [AnalysisResult] for the given [file] from the [bytes]. Set | 1090 * Load the [AnalysisResult] for the given [file] from the [bytes]. Set |
1082 * optional [content] and [resolvedUnit]. | 1091 * optional [content] and [resolvedUnit]. |
1083 */ | 1092 */ |
1084 AnalysisResult _getAnalysisResultFromBytes( | 1093 AnalysisResult _getAnalysisResultFromBytes( |
1085 FileState file, String signature, List<int> bytes, | 1094 FileState file, String signature, List<int> bytes, |
1086 {String content, CompilationUnit resolvedUnit}) { | 1095 {String content, CompilationUnit resolvedUnit}) { |
1087 var unit = new AnalysisDriverResolvedUnit.fromBuffer(bytes); | 1096 var unit = new AnalysisDriverResolvedUnit.fromBuffer(bytes); |
1088 List<AnalysisError> errors = _getErrorsFromSerialized(file, unit.errors); | 1097 List<AnalysisError> errors = _getErrorsFromSerialized(file, unit.errors); |
| 1098 _updateHasErrorOrWarningFlag(file, errors); |
1089 return new AnalysisResult( | 1099 return new AnalysisResult( |
1090 this, | 1100 this, |
1091 _sourceFactory, | 1101 _sourceFactory, |
1092 file.path, | 1102 file.path, |
1093 file.uri, | 1103 file.uri, |
1094 file.exists, | 1104 file.exists, |
1095 content, | 1105 content, |
1096 file.contentHash, | 1106 file.contentHash, |
1097 file.lineInfo, | 1107 file.lineInfo, |
1098 signature, | 1108 signature, |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 String sec = _twoDigits(time.second); | 1245 String sec = _twoDigits(time.second); |
1236 String ms = _threeDigits(time.millisecond); | 1246 String ms = _threeDigits(time.millisecond); |
1237 String key = 'exception_${time.year}$m$d' '_$h$min$sec' + '_$ms'; | 1247 String key = 'exception_${time.year}$m$d' '_$h$min$sec' + '_$ms'; |
1238 | 1248 |
1239 _byteStore.put(key, bytes); | 1249 _byteStore.put(key, bytes); |
1240 return key; | 1250 return key; |
1241 } catch (_) { | 1251 } catch (_) { |
1242 return null; | 1252 return null; |
1243 } | 1253 } |
1244 } | 1254 } |
| 1255 |
| 1256 /** |
| 1257 * Given the list of [errors] for the [file], update the [file]'s |
| 1258 * [FileState.hasErrorOrWarning] flag. |
| 1259 */ |
| 1260 void _updateHasErrorOrWarningFlag( |
| 1261 FileState file, List<AnalysisError> errors) { |
| 1262 for (AnalysisError error in errors) { |
| 1263 ErrorSeverity severity = error.errorCode.errorSeverity; |
| 1264 if (severity == ErrorSeverity.ERROR || |
| 1265 severity == ErrorSeverity.WARNING) { |
| 1266 file.hasErrorOrWarning = true; |
| 1267 return; |
| 1268 } |
| 1269 } |
| 1270 file.hasErrorOrWarning = false; |
| 1271 } |
1245 } | 1272 } |
1246 | 1273 |
1247 /** | 1274 /** |
1248 * A generic schedulable interface via the AnalysisDriverScheduler. Currently | 1275 * A generic schedulable interface via the AnalysisDriverScheduler. Currently |
1249 * only implemented by [AnalysisDriver] and the angular plugin, at least as | 1276 * 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 | 1277 * a temporary measure until the official plugin API is ready (and a different |
1251 * scheduler is used) | 1278 * scheduler is used) |
1252 */ | 1279 */ |
1253 abstract class AnalysisDriverGeneric { | 1280 abstract class AnalysisDriverGeneric { |
1254 /** | 1281 /** |
(...skipping 15 matching lines...) Expand all Loading... |
1270 * Perform a single chunk of work and produce [results]. | 1297 * Perform a single chunk of work and produce [results]. |
1271 */ | 1298 */ |
1272 Future<Null> performWork(); | 1299 Future<Null> performWork(); |
1273 } | 1300 } |
1274 | 1301 |
1275 /** | 1302 /** |
1276 * Priorities of [AnalysisDriver] work. The farther a priority to the beginning | 1303 * Priorities of [AnalysisDriver] work. The farther a priority to the beginning |
1277 * of the list, the earlier the corresponding [AnalysisDriver] should be asked | 1304 * of the list, the earlier the corresponding [AnalysisDriver] should be asked |
1278 * to perform work. | 1305 * to perform work. |
1279 */ | 1306 */ |
1280 enum AnalysisDriverPriority { nothing, general, priority, interactive } | 1307 enum AnalysisDriverPriority { |
| 1308 nothing, |
| 1309 general, |
| 1310 generalWithErrors, |
| 1311 generalImportChanged, |
| 1312 generalChanged, |
| 1313 changedFiles, |
| 1314 priority, |
| 1315 interactive |
| 1316 } |
1281 | 1317 |
1282 /** | 1318 /** |
1283 * Instances of this class schedule work in multiple [AnalysisDriver]s so that | 1319 * Instances of this class schedule work in multiple [AnalysisDriver]s so that |
1284 * work with the highest priority is performed first. | 1320 * work with the highest priority is performed first. |
1285 */ | 1321 */ |
1286 class AnalysisDriverScheduler { | 1322 class AnalysisDriverScheduler { |
1287 /** | 1323 /** |
1288 * Time interval in milliseconds before pumping the event queue. | 1324 * Time interval in milliseconds before pumping the event queue. |
1289 * | 1325 * |
1290 * Relinquishing execution flow and running the event loop after every task | 1326 * Relinquishing execution flow and running the event loop after every task |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1987 libraryDeclarations.add(new TopLevelDeclarationInSource( | 2023 libraryDeclarations.add(new TopLevelDeclarationInSource( |
1988 file.source, declaration, isExported)); | 2024 file.source, declaration, isExported)); |
1989 } | 2025 } |
1990 } | 2026 } |
1991 } | 2027 } |
1992 | 2028 |
1993 // We're not done yet. | 2029 // We're not done yet. |
1994 return false; | 2030 return false; |
1995 } | 2031 } |
1996 } | 2032 } |
OLD | NEW |