| 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 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1442 * If the status is currently idle, the returned future will be signaled | 1442 * If the status is currently idle, the returned future will be signaled |
| 1443 * immediately. | 1443 * immediately. |
| 1444 */ | 1444 */ |
| 1445 Future<Null> waitForIdle() => _statusSupport.waitForIdle(); | 1445 Future<Null> waitForIdle() => _statusSupport.waitForIdle(); |
| 1446 | 1446 |
| 1447 /** | 1447 /** |
| 1448 * Remove the given [driver] from the scheduler, so that it will not be | 1448 * Remove the given [driver] from the scheduler, so that it will not be |
| 1449 * asked to perform any new work. | 1449 * asked to perform any new work. |
| 1450 */ | 1450 */ |
| 1451 void _remove(AnalysisDriverGeneric driver) { | 1451 void _remove(AnalysisDriverGeneric driver) { |
| 1452 driverWatcher?.removedDriver(driver); | 1452 if (driver is AnalysisDriver) { |
| 1453 driverWatcher?.removedDriver(driver); |
| 1454 } |
| 1455 |
| 1453 _drivers.remove(driver); | 1456 _drivers.remove(driver); |
| 1454 _hasWork.notify(); | 1457 _hasWork.notify(); |
| 1455 } | 1458 } |
| 1456 | 1459 |
| 1457 /** | 1460 /** |
| 1458 * Run infinitely analysis cycle, selecting the drivers with the highest | 1461 * Run infinitely analysis cycle, selecting the drivers with the highest |
| 1459 * priority first. | 1462 * priority first. |
| 1460 */ | 1463 */ |
| 1461 Future<Null> _run() async { | 1464 Future<Null> _run() async { |
| 1462 Stopwatch timer = new Stopwatch()..start(); | 1465 Stopwatch timer = new Stopwatch()..start(); |
| 1463 PerformanceLogSection analysisSection; | 1466 PerformanceLogSection analysisSection; |
| 1464 while (true) { | 1467 while (true) { |
| 1465 // Pump the event queue. | 1468 // Pump the event queue. |
| 1466 if (timer.elapsedMilliseconds > _MS_BEFORE_PUMPING_EVENT_QUEUE) { | 1469 if (timer.elapsedMilliseconds > _MS_BEFORE_PUMPING_EVENT_QUEUE) { |
| 1467 await _pumpEventQueue(_NUMBER_OF_EVENT_QUEUE_PUMPINGS); | 1470 await _pumpEventQueue(_NUMBER_OF_EVENT_QUEUE_PUMPINGS); |
| 1468 timer.reset(); | 1471 timer.reset(); |
| 1469 } | 1472 } |
| 1470 | 1473 |
| 1471 await _hasWork.signal; | 1474 await _hasWork.signal; |
| 1472 | 1475 |
| 1473 // Transition to analyzing if there are files to analyze. | 1476 // Transition to analyzing if there are files to analyze. |
| 1474 if (_hasFilesToAnalyze) { | 1477 if (_hasFilesToAnalyze) { |
| 1475 _statusSupport.transitionToAnalyzing(); | 1478 _statusSupport.transitionToAnalyzing(); |
| 1476 analysisSection ??= _logger.enter('Analyzing'); | 1479 analysisSection ??= _logger.enter('Analyzing'); |
| 1477 } | 1480 } |
| 1478 | 1481 |
| 1479 // Find the driver with the highest priority. | 1482 // Find the driver with the highest priority. |
| 1480 AnalysisDriverGeneric bestDriver; | 1483 AnalysisDriverGeneric bestDriver; |
| 1481 AnalysisDriverPriority bestPriority = AnalysisDriverPriority.nothing; | 1484 AnalysisDriverPriority bestPriority = AnalysisDriverPriority.nothing; |
| 1482 for (AnalysisDriver driver in _drivers) { | 1485 for (AnalysisDriverGeneric driver in _drivers) { |
| 1483 AnalysisDriverPriority priority = driver.workPriority; | 1486 AnalysisDriverPriority priority = driver.workPriority; |
| 1484 if (priority.index > bestPriority.index) { | 1487 if (priority.index > bestPriority.index) { |
| 1485 bestDriver = driver; | 1488 bestDriver = driver; |
| 1486 bestPriority = priority; | 1489 bestPriority = priority; |
| 1487 } | 1490 } |
| 1488 } | 1491 } |
| 1489 | 1492 |
| 1490 // Transition to idle if no files to analyze. | 1493 // Transition to idle if no files to analyze. |
| 1491 if (!_hasFilesToAnalyze) { | 1494 if (!_hasFilesToAnalyze) { |
| 1492 _statusSupport.transitionToIdle(); | 1495 _statusSupport.transitionToIdle(); |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2053 libraryDeclarations.add(new TopLevelDeclarationInSource( | 2056 libraryDeclarations.add(new TopLevelDeclarationInSource( |
| 2054 file.source, declaration, isExported)); | 2057 file.source, declaration, isExported)); |
| 2055 } | 2058 } |
| 2056 } | 2059 } |
| 2057 } | 2060 } |
| 2058 | 2061 |
| 2059 // We're not done yet. | 2062 // We're not done yet. |
| 2060 return false; | 2063 return false; |
| 2061 } | 2064 } |
| 2062 } | 2065 } |
| OLD | NEW |