| 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 68c9b2506d721e04e593e0c8e80d7773447c1f2e..e0c1eea5b4ccbaff496edf1e2ba42620f426046b 100644
|
| --- a/pkg/analyzer_cli/lib/src/driver.dart
|
| +++ b/pkg/analyzer_cli/lib/src/driver.dart
|
| @@ -6,9 +6,10 @@ library analyzer_cli.src.driver;
|
|
|
| import 'dart:async';
|
| import 'dart:convert';
|
| -import 'dart:io';
|
| +import 'dart:io' as io;
|
|
|
| import 'package:analyzer/file_system/file_system.dart' as file_system;
|
| +import 'package:analyzer/file_system/file_system.dart';
|
| import 'package:analyzer/file_system/physical_file_system.dart';
|
| import 'package:analyzer/plugin/options.dart';
|
| import 'package:analyzer/plugin/resolver_provider.dart';
|
| @@ -31,6 +32,7 @@ import 'package:analyzer/src/generated/source_io.dart';
|
| import 'package:analyzer/src/generated/utilities_general.dart'
|
| show PerformanceTag;
|
| import 'package:analyzer/src/services/lint.dart';
|
| +import 'package:analyzer/src/source/source_resource.dart';
|
| import 'package:analyzer/src/summary/summary_sdk.dart' show SummaryBasedDartSdk;
|
| import 'package:analyzer/src/task/options.dart';
|
| import 'package:analyzer_cli/src/analyzer_impl.dart';
|
| @@ -53,12 +55,12 @@ import 'package:yaml/yaml.dart';
|
| /// Shared IO sink for standard error reporting.
|
| ///
|
| /// *Visible for testing.*
|
| -StringSink errorSink = stderr;
|
| +StringSink errorSink = io.stderr;
|
|
|
| /// Shared IO sink for standard out reporting.
|
| ///
|
| /// *Visible for testing.*
|
| -StringSink outSink = stdout;
|
| +StringSink outSink = io.stdout;
|
|
|
| /// Test this option map to see if it specifies lint rules.
|
| bool containsLintRuleEntry(Map<String, YamlNode> options) {
|
| @@ -132,7 +134,7 @@ class Driver implements CommandLineStarter {
|
| ErrorSeverity severity = _buildModeAnalyze(options);
|
| // In case of error propagate exit code.
|
| if (severity == ErrorSeverity.ERROR) {
|
| - exitCode = severity.ordinal;
|
| + io.exitCode = severity.ordinal;
|
| }
|
| } else if (options.shouldBatch) {
|
| _BatchRunner.runAsBatch(args, (List<String> args) {
|
| @@ -143,7 +145,7 @@ class Driver implements CommandLineStarter {
|
| ErrorSeverity severity = _analyzeAll(options);
|
| // In case of error propagate exit code.
|
| if (severity == ErrorSeverity.ERROR) {
|
| - exitCode = severity.ordinal;
|
| + io.exitCode = severity.ordinal;
|
| }
|
| }
|
|
|
| @@ -154,7 +156,7 @@ class Driver implements CommandLineStarter {
|
| if (options.perfReport != null) {
|
| String json = makePerfReport(
|
| startTime, currentTimeMillis(), options, _analyzedFileCount, stats);
|
| - new File(options.perfReport).writeAsStringSync(json);
|
| + new io.File(options.perfReport).writeAsStringSync(json);
|
| }
|
| }
|
|
|
| @@ -191,14 +193,14 @@ class Driver implements CommandLineStarter {
|
| // Note that these files will all be analyzed in the same context.
|
| // This should be updated when the ContextManager re-work is complete
|
| // (See: https://github.com/dart-lang/sdk/issues/24133)
|
| - Iterable<File> files = _collectFiles(sourcePath);
|
| + Iterable<io.File> files = _collectFiles(sourcePath);
|
| if (files.isEmpty) {
|
| errorSink.writeln('No dart files found at: $sourcePath');
|
| - exitCode = ErrorSeverity.ERROR.ordinal;
|
| + io.exitCode = ErrorSeverity.ERROR.ordinal;
|
| return ErrorSeverity.ERROR;
|
| }
|
|
|
| - for (File file in files) {
|
| + for (io.File file in files) {
|
| Source source = _computeLibrarySource(file.absolute.path);
|
| if (!knownSources.contains(source)) {
|
| changeSet.addedSource(source);
|
| @@ -235,7 +237,7 @@ class Driver implements CommandLineStarter {
|
| if (!found) {
|
| errorSink.writeln("${part.fullName} is a part and cannot be analyzed.");
|
| errorSink.writeln("Please pass in a library that contains this part.");
|
| - exitCode = ErrorSeverity.ERROR.ordinal;
|
| + io.exitCode = ErrorSeverity.ERROR.ordinal;
|
| allResult = allResult.max(ErrorSeverity.ERROR);
|
| }
|
| }
|
| @@ -423,15 +425,15 @@ class Driver implements CommandLineStarter {
|
|
|
| /// Collect all analyzable files at [filePath], recursively if it's a
|
| /// directory, ignoring links.
|
| - Iterable<File> _collectFiles(String filePath) {
|
| - List<File> files = <File>[];
|
| - File file = new File(filePath);
|
| + Iterable<io.File> _collectFiles(String filePath) {
|
| + List<io.File> files = <io.File>[];
|
| + io.File file = new io.File(filePath);
|
| if (file.existsSync()) {
|
| files.add(file);
|
| } else {
|
| - Directory directory = new Directory(filePath);
|
| + io.Directory directory = new io.Directory(filePath);
|
| if (directory.existsSync()) {
|
| - for (FileSystemEntity entry
|
| + for (io.FileSystemEntity entry
|
| in directory.listSync(recursive: true, followLinks: false)) {
|
| String relative = path.relative(entry.path, from: directory.path);
|
| if (AnalysisEngine.isDartFileName(entry.path) &&
|
| @@ -449,17 +451,17 @@ class Driver implements CommandLineStarter {
|
| /// context.
|
| Source _computeLibrarySource(String sourcePath) {
|
| sourcePath = _normalizeSourcePath(sourcePath);
|
| - JavaFile sourceFile = new JavaFile(sourcePath);
|
| - Source source = sdk.fromFileUri(sourceFile.toURI());
|
| + File sourceFile = resourceProvider.getFile(sourcePath);
|
| + Source source = sdk.fromFileUri(sourceFile.toUri());
|
| if (source != null) {
|
| return source;
|
| }
|
| - source = new FileBasedSource(sourceFile, sourceFile.toURI());
|
| + source = new FileSource(sourceFile, sourceFile.toUri());
|
| Uri uri = _context.sourceFactory.restoreUri(source);
|
| if (uri == null) {
|
| return source;
|
| }
|
| - return new FileBasedSource(sourceFile, uri);
|
| + return new FileSource(sourceFile, uri);
|
| }
|
|
|
| /// Create an analysis context that is prepared to analyze sources according
|
| @@ -538,7 +540,7 @@ class Driver implements CommandLineStarter {
|
| String packageConfigPath = options.packageConfigPath;
|
| Uri fileUri = new Uri.file(packageConfigPath);
|
| try {
|
| - File configFile = new File.fromUri(fileUri).absolute;
|
| + io.File configFile = new io.File.fromUri(fileUri).absolute;
|
| List<int> bytes = configFile.readAsBytesSync();
|
| Map<String, Uri> map = pkgfile.parse(bytes, configFile.uri);
|
| packages = new MapPackages(map);
|
| @@ -609,10 +611,10 @@ class Driver implements CommandLineStarter {
|
| _context, incrementalSession, source, options, stats, startTime);
|
| var errorSeverity = analyzer.analyzeSync();
|
| if (errorSeverity == ErrorSeverity.ERROR) {
|
| - exitCode = errorSeverity.ordinal;
|
| + io.exitCode = errorSeverity.ordinal;
|
| }
|
| if (options.warningsAreFatal && errorSeverity == ErrorSeverity.WARNING) {
|
| - exitCode = errorSeverity.ordinal;
|
| + io.exitCode = errorSeverity.ordinal;
|
| }
|
| return errorSeverity;
|
| }
|
| @@ -721,7 +723,7 @@ class Driver implements CommandLineStarter {
|
|
|
| /// Convert [sourcePath] into an absolute path.
|
| static String _normalizeSourcePath(String sourcePath) =>
|
| - path.normalize(new File(sourcePath).absolute.path);
|
| + path.normalize(new io.File(sourcePath).absolute.path);
|
|
|
| static void _processAnalysisOptions(
|
| file_system.ResourceProvider resourceProvider,
|
| @@ -769,14 +771,14 @@ class _BatchRunner {
|
| ErrorSeverity batchResult = ErrorSeverity.NONE;
|
| // Read line from stdin.
|
| Stream cmdLine =
|
| - stdin.transform(UTF8.decoder).transform(new LineSplitter());
|
| + io.stdin.transform(UTF8.decoder).transform(new LineSplitter());
|
| cmdLine.listen((String line) {
|
| // Maybe finish.
|
| if (line.isEmpty) {
|
| var time = stopwatch.elapsedMilliseconds;
|
| outSink.writeln(
|
| '>>> BATCH END (${totalTests - testsFailed}/$totalTests) ${time}ms');
|
| - exitCode = batchResult.ordinal;
|
| + io.exitCode = batchResult.ordinal;
|
| }
|
| // Prepare arguments.
|
| var lineArgs = line.split(new RegExp('\\s+'));
|
| @@ -828,7 +830,7 @@ class _PackageInfo {
|
| class _PackageRootPackageMapBuilder {
|
| static Map<String, List<file_system.Folder>> buildPackageMap(
|
| String packageRootPath) {
|
| - var packageRoot = new Directory(packageRootPath);
|
| + var packageRoot = new io.Directory(packageRootPath);
|
| if (!packageRoot.existsSync()) {
|
| throw new _DriverError(
|
| 'Package root directory ($packageRootPath) does not exist.');
|
|
|