Index: pkg/analyzer_cli/lib/src/driver.dart |
diff --git a/pkg/analyzer_cli/lib/src/driver.dart b/pkg/analyzer_cli/lib/src/driver.dart |
index ed2895b1f650eea4b42412eda30593cc2312f714..e77699f4a59af8310ec94a5f9fb3d18c98cfaba5 100644 |
--- a/pkg/analyzer_cli/lib/src/driver.dart |
+++ b/pkg/analyzer_cli/lib/src/driver.dart |
@@ -19,6 +19,9 @@ import 'package:analyzer/source/package_map_resolver.dart'; |
import 'package:analyzer/source/pub_package_map_provider.dart'; |
import 'package:analyzer/source/sdk_ext.dart'; |
import 'package:analyzer/src/context/builder.dart'; |
+import 'package:analyzer/src/dart/analysis/byte_store.dart'; |
+import 'package:analyzer/src/dart/analysis/driver.dart'; |
+import 'package:analyzer/src/dart/analysis/file_state.dart'; |
import 'package:analyzer/src/dart/sdk/sdk.dart'; |
import 'package:analyzer/src/generated/constant.dart'; |
import 'package:analyzer/src/generated/engine.dart'; |
@@ -74,6 +77,8 @@ class Driver implements CommandLineStarter { |
static final PerformanceTag _analyzeAllTag = |
new PerformanceTag("Driver._analyzeAll"); |
+ static ByteStore analysisDriverByteStore = new MemoryByteStore(); |
+ |
/// The plugins that are defined outside the `analyzer_cli` package. |
List<Plugin> _userDefinedPlugins = <Plugin>[]; |
@@ -81,6 +86,8 @@ class Driver implements CommandLineStarter { |
/// `null` if [_analyzeAll] hasn't been called yet. |
InternalAnalysisContext _context; |
+ AnalysisDriver analysisDriver; |
+ |
/// The total number of source files loaded by an AnalysisContext. |
int _analyzedFileCount = 0; |
@@ -135,9 +142,9 @@ class Driver implements CommandLineStarter { |
io.exitCode = severity.ordinal; |
} |
} else if (options.shouldBatch) { |
- _BatchRunner.runAsBatch(args, (List<String> args) { |
+ _BatchRunner.runAsBatch(args, (List<String> args) async { |
CommandLineOptions options = CommandLineOptions.parse(args); |
- return _analyzeAll(options); |
+ return await _analyzeAll(options); |
}); |
} else { |
ErrorSeverity severity = await _analyzeAll(options); |
@@ -208,8 +215,15 @@ class Driver implements CommandLineStarter { |
} |
sourcesToAnalyze.add(source); |
} |
+ |
+ if (analysisDriver != null) { |
+ files.forEach((file) { |
+ analysisDriver.addFile(file.path); |
+ }); |
+ } else { |
+ context.applyChanges(changeSet); |
+ } |
} |
- context.applyChanges(changeSet); |
// Analyze the libraries. |
ErrorSeverity allResult = ErrorSeverity.NONE; |
@@ -540,9 +554,26 @@ class Driver implements CommandLineStarter { |
_context.sourceFactory = sourceFactory; |
- if (sdkBundle != null) { |
- _context.resultProvider = |
- new InputPackagesResultProvider(_context, summaryDataStore); |
+ if (options.enableNewAnalysisDriver) { |
+ PerformanceLog log = new PerformanceLog(null); |
+ AnalysisDriverScheduler scheduler = new AnalysisDriverScheduler(log); |
+ analysisDriver = new AnalysisDriver( |
+ scheduler, |
+ log, |
+ resourceProvider, |
+ analysisDriverByteStore, |
+ new FileContentOverlay(), |
+ 'test', |
+ context.sourceFactory, |
+ context.analysisOptions); |
+ analysisDriver.results.listen((_) {}); |
+ analysisDriver.exceptions.listen((_) {}); |
+ scheduler.start(); |
+ } else { |
+ if (sdkBundle != null) { |
+ _context.resultProvider = |
+ new InputPackagesResultProvider(_context, summaryDataStore); |
+ } |
} |
} |
@@ -640,8 +671,8 @@ class Driver implements CommandLineStarter { |
Future<ErrorSeverity> _runAnalyzer( |
Source source, CommandLineOptions options) async { |
int startTime = currentTimeMillis(); |
- AnalyzerImpl analyzer = new AnalyzerImpl( |
- _context.analysisOptions, _context, source, options, stats, startTime); |
+ AnalyzerImpl analyzer = new AnalyzerImpl(_context.analysisOptions, _context, |
+ analysisDriver, source, options, stats, startTime); |
ErrorSeverity errorSeverity = await analyzer.analyze(); |
if (errorSeverity == ErrorSeverity.ERROR) { |
io.exitCode = errorSeverity.ordinal; |