| Index: pkg/analyzer/lib/src/dart/analysis/driver.dart
|
| diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart
|
| index d21c7ce5ce28c818f870bfe7c0f1cb932ca55f33..fd2e61b1011cac59cd8b34c933002ddaf1becf9b 100644
|
| --- a/pkg/analyzer/lib/src/dart/analysis/driver.dart
|
| +++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart
|
| @@ -68,7 +68,7 @@ import 'package:meta/meta.dart';
|
| *
|
| * TODO(scheglov) Clean up the list of implicitly analyzed files.
|
| */
|
| -class AnalysisDriver {
|
| +class AnalysisDriver implements AnalysisDriverGeneric {
|
| /**
|
| * The version of data format, should be incremented on every format change.
|
| */
|
| @@ -258,7 +258,7 @@ class AnalysisDriver {
|
| _sdkBundle = sdkBundle {
|
| _testView = new AnalysisDriverTestView(this);
|
| _createFileTracker(logger);
|
| - _scheduler._add(this);
|
| + _scheduler.add(this);
|
| _search = new Search(this);
|
| }
|
|
|
| @@ -370,7 +370,7 @@ class AnalysisDriver {
|
| /**
|
| * Return the priority of work that the driver needs to perform.
|
| */
|
| - AnalysisDriverPriority get _workPriority {
|
| + AnalysisDriverPriority get workPriority {
|
| if (_requestedFiles.isNotEmpty) {
|
| return AnalysisDriverPriority.interactive;
|
| }
|
| @@ -933,6 +933,21 @@ class AnalysisDriver {
|
| return signature.toHex();
|
| }
|
|
|
| + ApiSignature getUnitKeyByPath(String path) {
|
| + var file = fsState.getFileForPath(path);
|
| + ApiSignature signature = new ApiSignature();
|
| + signature.addUint32List(_salt);
|
| + signature.addString(file.transitiveSignature);
|
| + return signature;
|
| + }
|
| +
|
| + ApiSignature getResolvedUnitKeyByPath(String path) {
|
| + ApiSignature signature = getUnitKeyByPath(path);
|
| + var file = fsState.getFileForPath(path);
|
| + signature.addString(file.contentHash);
|
| + return signature;
|
| + }
|
| +
|
| /**
|
| * Return the lint code with the given [errorName], or `null` if there is no
|
| * lint registered with that name or the lint is not enabled in the analysis
|
| @@ -954,7 +969,7 @@ class AnalysisDriver {
|
| /**
|
| * Perform a single chunk of work and produce [results].
|
| */
|
| - Future<Null> _performWork() async {
|
| + Future<Null> performWork() async {
|
| if (_fileTracker.verifyChangedFilesIfNeeded()) {
|
| return;
|
| }
|
| @@ -1213,6 +1228,18 @@ class AnalysisDriver {
|
| }
|
|
|
| /**
|
| + * A generic schedulable interface via the AnalysisDriverScheduler. Currently
|
| + * only implemented by [AnalysisDriver] and the angular plugin, at least as
|
| + * a temporary measure until the official plugin API is ready (and a different
|
| + * scheduler is used)
|
| + */
|
| +abstract class AnalysisDriverGeneric {
|
| + bool get hasFilesToAnalyze;
|
| + AnalysisDriverPriority get workPriority;
|
| + Future<Null> performWork();
|
| +}
|
| +
|
| +/**
|
| * Priorities of [AnalysisDriver] work. The farther a priority to the beginning
|
| * of the list, the earlier the corresponding [AnalysisDriver] should be asked
|
| * to perform work.
|
| @@ -1246,7 +1273,7 @@ class AnalysisDriverScheduler {
|
| static const int _NUMBER_OF_EVENT_QUEUE_PUMPINGS = 128;
|
|
|
| final PerformanceLog _logger;
|
| - final List<AnalysisDriver> _drivers = [];
|
| + final List<AnalysisDriverGeneric> _drivers = [];
|
| final Monitor _hasWork = new Monitor();
|
| final StatusSupport _statusSupport = new StatusSupport();
|
|
|
| @@ -1268,7 +1295,7 @@ class AnalysisDriverScheduler {
|
| * Return `true` if there is a driver with a file to analyze.
|
| */
|
| bool get _hasFilesToAnalyze {
|
| - for (AnalysisDriver driver in _drivers) {
|
| + for (AnalysisDriverGeneric driver in _drivers) {
|
| if (driver.hasFilesToAnalyze) {
|
| return true;
|
| }
|
| @@ -1280,7 +1307,7 @@ class AnalysisDriverScheduler {
|
| * Notify that there is a change to the [driver], it it might need to
|
| * perform some work.
|
| */
|
| - void notify(AnalysisDriver driver) {
|
| + void notify(AnalysisDriverGeneric driver) {
|
| _hasWork.notify();
|
| _statusSupport.preTransitionToAnalyzing();
|
| }
|
| @@ -1308,7 +1335,7 @@ class AnalysisDriverScheduler {
|
| /**
|
| * Add the given [driver] and schedule it to perform its work.
|
| */
|
| - void _add(AnalysisDriver driver) {
|
| + void add(AnalysisDriverGeneric driver) {
|
| _drivers.add(driver);
|
| _hasWork.notify();
|
| }
|
| @@ -1317,7 +1344,7 @@ class AnalysisDriverScheduler {
|
| * Remove the given [driver] from the scheduler, so that it will not be
|
| * asked to perform any new work.
|
| */
|
| - void _remove(AnalysisDriver driver) {
|
| + void _remove(AnalysisDriverGeneric driver) {
|
| _drivers.remove(driver);
|
| _hasWork.notify();
|
| }
|
| @@ -1345,10 +1372,10 @@ class AnalysisDriverScheduler {
|
| }
|
|
|
| // Find the driver with the highest priority.
|
| - AnalysisDriver bestDriver;
|
| + AnalysisDriverGeneric bestDriver;
|
| AnalysisDriverPriority bestPriority = AnalysisDriverPriority.nothing;
|
| for (AnalysisDriver driver in _drivers) {
|
| - AnalysisDriverPriority priority = driver._workPriority;
|
| + AnalysisDriverPriority priority = driver.workPriority;
|
| if (priority.index > bestPriority.index) {
|
| bestDriver = driver;
|
| bestPriority = priority;
|
| @@ -1368,7 +1395,7 @@ class AnalysisDriverScheduler {
|
| }
|
|
|
| // Ask the driver to perform a chunk of work.
|
| - await bestDriver._performWork();
|
| + await bestDriver.performWork();
|
|
|
| // Schedule one more cycle.
|
| _hasWork.notify();
|
|
|