Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Side by Side Diff: pkg/analyzer_cli/lib/src/driver.dart

Issue 2257023002: Replace uses of FileBasedSource in cli (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analyzer_cli/lib/src/build_mode.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 library analyzer_cli.src.driver; 5 library analyzer_cli.src.driver;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io' as io;
10 10
11 import 'package:analyzer/file_system/file_system.dart' as file_system; 11 import 'package:analyzer/file_system/file_system.dart' as file_system;
12 import 'package:analyzer/file_system/file_system.dart';
12 import 'package:analyzer/file_system/physical_file_system.dart'; 13 import 'package:analyzer/file_system/physical_file_system.dart';
13 import 'package:analyzer/plugin/options.dart'; 14 import 'package:analyzer/plugin/options.dart';
14 import 'package:analyzer/plugin/resolver_provider.dart'; 15 import 'package:analyzer/plugin/resolver_provider.dart';
15 import 'package:analyzer/source/analysis_options_provider.dart'; 16 import 'package:analyzer/source/analysis_options_provider.dart';
16 import 'package:analyzer/source/package_map_provider.dart'; 17 import 'package:analyzer/source/package_map_provider.dart';
17 import 'package:analyzer/source/package_map_resolver.dart'; 18 import 'package:analyzer/source/package_map_resolver.dart';
18 import 'package:analyzer/source/pub_package_map_provider.dart'; 19 import 'package:analyzer/source/pub_package_map_provider.dart';
19 import 'package:analyzer/source/sdk_ext.dart'; 20 import 'package:analyzer/source/sdk_ext.dart';
20 import 'package:analyzer/src/context/builder.dart'; 21 import 'package:analyzer/src/context/builder.dart';
21 import 'package:analyzer/src/dart/sdk/sdk.dart'; 22 import 'package:analyzer/src/dart/sdk/sdk.dart';
22 import 'package:analyzer/src/generated/constant.dart'; 23 import 'package:analyzer/src/generated/constant.dart';
23 import 'package:analyzer/src/generated/engine.dart'; 24 import 'package:analyzer/src/generated/engine.dart';
24 import 'package:analyzer/src/generated/error.dart'; 25 import 'package:analyzer/src/generated/error.dart';
25 import 'package:analyzer/src/generated/interner.dart'; 26 import 'package:analyzer/src/generated/interner.dart';
26 import 'package:analyzer/src/generated/java_engine.dart'; 27 import 'package:analyzer/src/generated/java_engine.dart';
27 import 'package:analyzer/src/generated/java_io.dart'; 28 import 'package:analyzer/src/generated/java_io.dart';
28 import 'package:analyzer/src/generated/sdk.dart'; 29 import 'package:analyzer/src/generated/sdk.dart';
29 import 'package:analyzer/src/generated/source.dart'; 30 import 'package:analyzer/src/generated/source.dart';
30 import 'package:analyzer/src/generated/source_io.dart'; 31 import 'package:analyzer/src/generated/source_io.dart';
31 import 'package:analyzer/src/generated/utilities_general.dart' 32 import 'package:analyzer/src/generated/utilities_general.dart'
32 show PerformanceTag; 33 show PerformanceTag;
33 import 'package:analyzer/src/services/lint.dart'; 34 import 'package:analyzer/src/services/lint.dart';
35 import 'package:analyzer/src/source/source_resource.dart';
34 import 'package:analyzer/src/summary/summary_sdk.dart' show SummaryBasedDartSdk; 36 import 'package:analyzer/src/summary/summary_sdk.dart' show SummaryBasedDartSdk;
35 import 'package:analyzer/src/task/options.dart'; 37 import 'package:analyzer/src/task/options.dart';
36 import 'package:analyzer_cli/src/analyzer_impl.dart'; 38 import 'package:analyzer_cli/src/analyzer_impl.dart';
37 import 'package:analyzer_cli/src/build_mode.dart'; 39 import 'package:analyzer_cli/src/build_mode.dart';
38 import 'package:analyzer_cli/src/error_formatter.dart'; 40 import 'package:analyzer_cli/src/error_formatter.dart';
39 import 'package:analyzer_cli/src/incremental_analyzer.dart'; 41 import 'package:analyzer_cli/src/incremental_analyzer.dart';
40 import 'package:analyzer_cli/src/options.dart'; 42 import 'package:analyzer_cli/src/options.dart';
41 import 'package:analyzer_cli/src/perf_report.dart'; 43 import 'package:analyzer_cli/src/perf_report.dart';
42 import 'package:analyzer_cli/starter.dart'; 44 import 'package:analyzer_cli/starter.dart';
43 import 'package:linter/src/plugin/linter_plugin.dart'; 45 import 'package:linter/src/plugin/linter_plugin.dart';
44 import 'package:package_config/discovery.dart' as pkg_discovery; 46 import 'package:package_config/discovery.dart' as pkg_discovery;
45 import 'package:package_config/packages.dart' show Packages; 47 import 'package:package_config/packages.dart' show Packages;
46 import 'package:package_config/packages_file.dart' as pkgfile show parse; 48 import 'package:package_config/packages_file.dart' as pkgfile show parse;
47 import 'package:package_config/src/packages_impl.dart' show MapPackages; 49 import 'package:package_config/src/packages_impl.dart' show MapPackages;
48 import 'package:path/path.dart' as path; 50 import 'package:path/path.dart' as path;
49 import 'package:plugin/manager.dart'; 51 import 'package:plugin/manager.dart';
50 import 'package:plugin/plugin.dart'; 52 import 'package:plugin/plugin.dart';
51 import 'package:yaml/yaml.dart'; 53 import 'package:yaml/yaml.dart';
52 54
53 /// Shared IO sink for standard error reporting. 55 /// Shared IO sink for standard error reporting.
54 /// 56 ///
55 /// *Visible for testing.* 57 /// *Visible for testing.*
56 StringSink errorSink = stderr; 58 StringSink errorSink = io.stderr;
57 59
58 /// Shared IO sink for standard out reporting. 60 /// Shared IO sink for standard out reporting.
59 /// 61 ///
60 /// *Visible for testing.* 62 /// *Visible for testing.*
61 StringSink outSink = stdout; 63 StringSink outSink = io.stdout;
62 64
63 /// Test this option map to see if it specifies lint rules. 65 /// Test this option map to see if it specifies lint rules.
64 bool containsLintRuleEntry(Map<String, YamlNode> options) { 66 bool containsLintRuleEntry(Map<String, YamlNode> options) {
65 var linterNode = options['linter']; 67 var linterNode = options['linter'];
66 return linterNode is YamlMap && linterNode.containsKey('rules'); 68 return linterNode is YamlMap && linterNode.containsKey('rules');
67 } 69 }
68 70
69 typedef ErrorSeverity _BatchRunnerHandler(List<String> args); 71 typedef ErrorSeverity _BatchRunnerHandler(List<String> args);
70 72
71 class Driver implements CommandLineStarter { 73 class Driver implements CommandLineStarter {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 _processPlugins(); 127 _processPlugins();
126 128
127 // Parse commandline options. 129 // Parse commandline options.
128 CommandLineOptions options = CommandLineOptions.parse(args); 130 CommandLineOptions options = CommandLineOptions.parse(args);
129 131
130 // Do analysis. 132 // Do analysis.
131 if (options.buildMode) { 133 if (options.buildMode) {
132 ErrorSeverity severity = _buildModeAnalyze(options); 134 ErrorSeverity severity = _buildModeAnalyze(options);
133 // In case of error propagate exit code. 135 // In case of error propagate exit code.
134 if (severity == ErrorSeverity.ERROR) { 136 if (severity == ErrorSeverity.ERROR) {
135 exitCode = severity.ordinal; 137 io.exitCode = severity.ordinal;
136 } 138 }
137 } else if (options.shouldBatch) { 139 } else if (options.shouldBatch) {
138 _BatchRunner.runAsBatch(args, (List<String> args) { 140 _BatchRunner.runAsBatch(args, (List<String> args) {
139 CommandLineOptions options = CommandLineOptions.parse(args); 141 CommandLineOptions options = CommandLineOptions.parse(args);
140 return _analyzeAll(options); 142 return _analyzeAll(options);
141 }); 143 });
142 } else { 144 } else {
143 ErrorSeverity severity = _analyzeAll(options); 145 ErrorSeverity severity = _analyzeAll(options);
144 // In case of error propagate exit code. 146 // In case of error propagate exit code.
145 if (severity == ErrorSeverity.ERROR) { 147 if (severity == ErrorSeverity.ERROR) {
146 exitCode = severity.ordinal; 148 io.exitCode = severity.ordinal;
147 } 149 }
148 } 150 }
149 151
150 if (_context != null) { 152 if (_context != null) {
151 _analyzedFileCount += _context.sources.length; 153 _analyzedFileCount += _context.sources.length;
152 } 154 }
153 155
154 if (options.perfReport != null) { 156 if (options.perfReport != null) {
155 String json = makePerfReport( 157 String json = makePerfReport(
156 startTime, currentTimeMillis(), options, _analyzedFileCount, stats); 158 startTime, currentTimeMillis(), options, _analyzedFileCount, stats);
157 new File(options.perfReport).writeAsStringSync(json); 159 new io.File(options.perfReport).writeAsStringSync(json);
158 } 160 }
159 } 161 }
160 162
161 ErrorSeverity _analyzeAll(CommandLineOptions options) { 163 ErrorSeverity _analyzeAll(CommandLineOptions options) {
162 return _analyzeAllTag.makeCurrentWhile(() { 164 return _analyzeAllTag.makeCurrentWhile(() {
163 return _analyzeAllImpl(options); 165 return _analyzeAllImpl(options);
164 }); 166 });
165 } 167 }
166 168
167 /// Perform analysis according to the given [options]. 169 /// Perform analysis according to the given [options].
(...skipping 16 matching lines...) Expand all
184 Set<Source> knownSources = context.sources.toSet(); 186 Set<Source> knownSources = context.sources.toSet();
185 List<Source> sourcesToAnalyze = <Source>[]; 187 List<Source> sourcesToAnalyze = <Source>[];
186 ChangeSet changeSet = new ChangeSet(); 188 ChangeSet changeSet = new ChangeSet();
187 for (String sourcePath in options.sourceFiles) { 189 for (String sourcePath in options.sourceFiles) {
188 sourcePath = sourcePath.trim(); 190 sourcePath = sourcePath.trim();
189 191
190 // Collect files for analysis. 192 // Collect files for analysis.
191 // Note that these files will all be analyzed in the same context. 193 // Note that these files will all be analyzed in the same context.
192 // This should be updated when the ContextManager re-work is complete 194 // This should be updated when the ContextManager re-work is complete
193 // (See: https://github.com/dart-lang/sdk/issues/24133) 195 // (See: https://github.com/dart-lang/sdk/issues/24133)
194 Iterable<File> files = _collectFiles(sourcePath); 196 Iterable<io.File> files = _collectFiles(sourcePath);
195 if (files.isEmpty) { 197 if (files.isEmpty) {
196 errorSink.writeln('No dart files found at: $sourcePath'); 198 errorSink.writeln('No dart files found at: $sourcePath');
197 exitCode = ErrorSeverity.ERROR.ordinal; 199 io.exitCode = ErrorSeverity.ERROR.ordinal;
198 return ErrorSeverity.ERROR; 200 return ErrorSeverity.ERROR;
199 } 201 }
200 202
201 for (File file in files) { 203 for (io.File file in files) {
202 Source source = _computeLibrarySource(file.absolute.path); 204 Source source = _computeLibrarySource(file.absolute.path);
203 if (!knownSources.contains(source)) { 205 if (!knownSources.contains(source)) {
204 changeSet.addedSource(source); 206 changeSet.addedSource(source);
205 } 207 }
206 sourcesToAnalyze.add(source); 208 sourcesToAnalyze.add(source);
207 } 209 }
208 } 210 }
209 context.applyChanges(changeSet); 211 context.applyChanges(changeSet);
210 212
211 // Analyze the libraries. 213 // Analyze the libraries.
(...skipping 16 matching lines...) Expand all
228 for (Source part in parts) { 230 for (Source part in parts) {
229 bool found = false; 231 bool found = false;
230 for (var lib in context.getLibrariesContaining(part)) { 232 for (var lib in context.getLibrariesContaining(part)) {
231 if (libUris.contains(lib.uri)) { 233 if (libUris.contains(lib.uri)) {
232 found = true; 234 found = true;
233 } 235 }
234 } 236 }
235 if (!found) { 237 if (!found) {
236 errorSink.writeln("${part.fullName} is a part and cannot be analyzed."); 238 errorSink.writeln("${part.fullName} is a part and cannot be analyzed.");
237 errorSink.writeln("Please pass in a library that contains this part."); 239 errorSink.writeln("Please pass in a library that contains this part.");
238 exitCode = ErrorSeverity.ERROR.ordinal; 240 io.exitCode = ErrorSeverity.ERROR.ordinal;
239 allResult = allResult.max(ErrorSeverity.ERROR); 241 allResult = allResult.max(ErrorSeverity.ERROR);
240 } 242 }
241 } 243 }
242 244
243 if (!options.machineFormat) { 245 if (!options.machineFormat) {
244 stats.print(outSink); 246 stats.print(outSink);
245 } 247 }
246 248
247 return allResult; 249 return allResult;
248 } 250 }
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 } 418 }
417 419
418 // Finally files. 420 // Finally files.
419 resolvers.add(new file_system.ResourceUriResolver(resourceProvider)); 421 resolvers.add(new file_system.ResourceUriResolver(resourceProvider));
420 422
421 return new SourceFactory(resolvers, packageInfo.packages); 423 return new SourceFactory(resolvers, packageInfo.packages);
422 } 424 }
423 425
424 /// Collect all analyzable files at [filePath], recursively if it's a 426 /// Collect all analyzable files at [filePath], recursively if it's a
425 /// directory, ignoring links. 427 /// directory, ignoring links.
426 Iterable<File> _collectFiles(String filePath) { 428 Iterable<io.File> _collectFiles(String filePath) {
427 List<File> files = <File>[]; 429 List<io.File> files = <io.File>[];
428 File file = new File(filePath); 430 io.File file = new io.File(filePath);
429 if (file.existsSync()) { 431 if (file.existsSync()) {
430 files.add(file); 432 files.add(file);
431 } else { 433 } else {
432 Directory directory = new Directory(filePath); 434 io.Directory directory = new io.Directory(filePath);
433 if (directory.existsSync()) { 435 if (directory.existsSync()) {
434 for (FileSystemEntity entry 436 for (io.FileSystemEntity entry
435 in directory.listSync(recursive: true, followLinks: false)) { 437 in directory.listSync(recursive: true, followLinks: false)) {
436 String relative = path.relative(entry.path, from: directory.path); 438 String relative = path.relative(entry.path, from: directory.path);
437 if (AnalysisEngine.isDartFileName(entry.path) && 439 if (AnalysisEngine.isDartFileName(entry.path) &&
438 !_isInHiddenDir(relative)) { 440 !_isInHiddenDir(relative)) {
439 files.add(entry); 441 files.add(entry);
440 } 442 }
441 } 443 }
442 } 444 }
443 } 445 }
444 return files; 446 return files;
445 } 447 }
446 448
447 /// Convert the given [sourcePath] (which may be relative to the current 449 /// Convert the given [sourcePath] (which may be relative to the current
448 /// working directory) to a [Source] object that can be fed to the analysis 450 /// working directory) to a [Source] object that can be fed to the analysis
449 /// context. 451 /// context.
450 Source _computeLibrarySource(String sourcePath) { 452 Source _computeLibrarySource(String sourcePath) {
451 sourcePath = _normalizeSourcePath(sourcePath); 453 sourcePath = _normalizeSourcePath(sourcePath);
452 JavaFile sourceFile = new JavaFile(sourcePath); 454 File sourceFile = resourceProvider.getFile(sourcePath);
453 Source source = sdk.fromFileUri(sourceFile.toURI()); 455 Source source = sdk.fromFileUri(sourceFile.toUri());
454 if (source != null) { 456 if (source != null) {
455 return source; 457 return source;
456 } 458 }
457 source = new FileBasedSource(sourceFile, sourceFile.toURI()); 459 source = new FileSource(sourceFile, sourceFile.toUri());
458 Uri uri = _context.sourceFactory.restoreUri(source); 460 Uri uri = _context.sourceFactory.restoreUri(source);
459 if (uri == null) { 461 if (uri == null) {
460 return source; 462 return source;
461 } 463 }
462 return new FileBasedSource(sourceFile, uri); 464 return new FileSource(sourceFile, uri);
463 } 465 }
464 466
465 /// Create an analysis context that is prepared to analyze sources according 467 /// Create an analysis context that is prepared to analyze sources according
466 /// to the given [options], and store it in [_context]. 468 /// to the given [options], and store it in [_context].
467 void _createAnalysisContext(CommandLineOptions options) { 469 void _createAnalysisContext(CommandLineOptions options) {
468 if (_canContextBeReused(options)) { 470 if (_canContextBeReused(options)) {
469 return; 471 return;
470 } 472 }
471 _previousOptions = options; 473 _previousOptions = options;
472 474
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 return new _PackageInfo(null, null); 533 return new _PackageInfo(null, null);
532 } 534 }
533 535
534 Packages packages; 536 Packages packages;
535 Map<String, List<file_system.Folder>> packageMap; 537 Map<String, List<file_system.Folder>> packageMap;
536 538
537 if (options.packageConfigPath != null) { 539 if (options.packageConfigPath != null) {
538 String packageConfigPath = options.packageConfigPath; 540 String packageConfigPath = options.packageConfigPath;
539 Uri fileUri = new Uri.file(packageConfigPath); 541 Uri fileUri = new Uri.file(packageConfigPath);
540 try { 542 try {
541 File configFile = new File.fromUri(fileUri).absolute; 543 io.File configFile = new io.File.fromUri(fileUri).absolute;
542 List<int> bytes = configFile.readAsBytesSync(); 544 List<int> bytes = configFile.readAsBytesSync();
543 Map<String, Uri> map = pkgfile.parse(bytes, configFile.uri); 545 Map<String, Uri> map = pkgfile.parse(bytes, configFile.uri);
544 packages = new MapPackages(map); 546 packages = new MapPackages(map);
545 packageMap = _getPackageMap(packages); 547 packageMap = _getPackageMap(packages);
546 } catch (e) { 548 } catch (e) {
547 printAndFail( 549 printAndFail(
548 'Unable to read package config data from $packageConfigPath: $e'); 550 'Unable to read package config data from $packageConfigPath: $e');
549 } 551 }
550 } else if (options.packageRootPath != null) { 552 } else if (options.packageRootPath != null) {
551 packageMap = _PackageRootPackageMapBuilder 553 packageMap = _PackageRootPackageMapBuilder
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 manager.processPlugins(plugins); 604 manager.processPlugins(plugins);
603 } 605 }
604 606
605 /// Analyze a single source. 607 /// Analyze a single source.
606 ErrorSeverity _runAnalyzer(Source source, CommandLineOptions options) { 608 ErrorSeverity _runAnalyzer(Source source, CommandLineOptions options) {
607 int startTime = currentTimeMillis(); 609 int startTime = currentTimeMillis();
608 AnalyzerImpl analyzer = new AnalyzerImpl( 610 AnalyzerImpl analyzer = new AnalyzerImpl(
609 _context, incrementalSession, source, options, stats, startTime); 611 _context, incrementalSession, source, options, stats, startTime);
610 var errorSeverity = analyzer.analyzeSync(); 612 var errorSeverity = analyzer.analyzeSync();
611 if (errorSeverity == ErrorSeverity.ERROR) { 613 if (errorSeverity == ErrorSeverity.ERROR) {
612 exitCode = errorSeverity.ordinal; 614 io.exitCode = errorSeverity.ordinal;
613 } 615 }
614 if (options.warningsAreFatal && errorSeverity == ErrorSeverity.WARNING) { 616 if (options.warningsAreFatal && errorSeverity == ErrorSeverity.WARNING) {
615 exitCode = errorSeverity.ordinal; 617 io.exitCode = errorSeverity.ordinal;
616 } 618 }
617 return errorSeverity; 619 return errorSeverity;
618 } 620 }
619 621
620 void _setupSdk(CommandLineOptions options, bool useSummaries) { 622 void _setupSdk(CommandLineOptions options, bool useSummaries) {
621 if (sdk == null) { 623 if (sdk == null) {
622 if (options.dartSdkSummaryPath != null) { 624 if (options.dartSdkSummaryPath != null) {
623 sdk = new SummaryBasedDartSdk( 625 sdk = new SummaryBasedDartSdk(
624 options.dartSdkSummaryPath, options.strongMode); 626 options.dartSdkSummaryPath, options.strongMode);
625 } else { 627 } else {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 if (!file.exists) { 716 if (!file.exists) {
715 filePath = AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE; 717 filePath = AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE;
716 file = resourceProvider.getFile(filePath); 718 file = resourceProvider.getFile(filePath);
717 } 719 }
718 } 720 }
719 return file; 721 return file;
720 } 722 }
721 723
722 /// Convert [sourcePath] into an absolute path. 724 /// Convert [sourcePath] into an absolute path.
723 static String _normalizeSourcePath(String sourcePath) => 725 static String _normalizeSourcePath(String sourcePath) =>
724 path.normalize(new File(sourcePath).absolute.path); 726 path.normalize(new io.File(sourcePath).absolute.path);
725 727
726 static void _processAnalysisOptions( 728 static void _processAnalysisOptions(
727 file_system.ResourceProvider resourceProvider, 729 file_system.ResourceProvider resourceProvider,
728 AnalysisContext context, 730 AnalysisContext context,
729 CommandLineOptions options) { 731 CommandLineOptions options) {
730 file_system.File file = _getOptionsFile(resourceProvider, options); 732 file_system.File file = _getOptionsFile(resourceProvider, options);
731 List<OptionsProcessor> optionsProcessors = 733 List<OptionsProcessor> optionsProcessors =
732 AnalysisEngine.instance.optionsPlugin.optionsProcessors; 734 AnalysisEngine.instance.optionsPlugin.optionsProcessors;
733 try { 735 try {
734 AnalysisOptionsProvider analysisOptionsProvider = 736 AnalysisOptionsProvider analysisOptionsProvider =
(...skipping 27 matching lines...) Expand all
762 /// use in unit testing. 764 /// use in unit testing.
763 static void runAsBatch(List<String> sharedArgs, _BatchRunnerHandler handler) { 765 static void runAsBatch(List<String> sharedArgs, _BatchRunnerHandler handler) {
764 outSink.writeln('>>> BATCH START'); 766 outSink.writeln('>>> BATCH START');
765 Stopwatch stopwatch = new Stopwatch(); 767 Stopwatch stopwatch = new Stopwatch();
766 stopwatch.start(); 768 stopwatch.start();
767 int testsFailed = 0; 769 int testsFailed = 0;
768 int totalTests = 0; 770 int totalTests = 0;
769 ErrorSeverity batchResult = ErrorSeverity.NONE; 771 ErrorSeverity batchResult = ErrorSeverity.NONE;
770 // Read line from stdin. 772 // Read line from stdin.
771 Stream cmdLine = 773 Stream cmdLine =
772 stdin.transform(UTF8.decoder).transform(new LineSplitter()); 774 io.stdin.transform(UTF8.decoder).transform(new LineSplitter());
773 cmdLine.listen((String line) { 775 cmdLine.listen((String line) {
774 // Maybe finish. 776 // Maybe finish.
775 if (line.isEmpty) { 777 if (line.isEmpty) {
776 var time = stopwatch.elapsedMilliseconds; 778 var time = stopwatch.elapsedMilliseconds;
777 outSink.writeln( 779 outSink.writeln(
778 '>>> BATCH END (${totalTests - testsFailed}/$totalTests) ${time}ms') ; 780 '>>> BATCH END (${totalTests - testsFailed}/$totalTests) ${time}ms') ;
779 exitCode = batchResult.ordinal; 781 io.exitCode = batchResult.ordinal;
780 } 782 }
781 // Prepare arguments. 783 // Prepare arguments.
782 var lineArgs = line.split(new RegExp('\\s+')); 784 var lineArgs = line.split(new RegExp('\\s+'));
783 var args = new List<String>(); 785 var args = new List<String>();
784 args.addAll(sharedArgs); 786 args.addAll(sharedArgs);
785 args.addAll(lineArgs); 787 args.addAll(lineArgs);
786 args.remove('-b'); 788 args.remove('-b');
787 args.remove('--batch'); 789 args.remove('--batch');
788 // Analyze single set of arguments. 790 // Analyze single set of arguments.
789 try { 791 try {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 } 823 }
822 824
823 /// [SdkExtUriResolver] needs a Map from package name to folder. In the case 825 /// [SdkExtUriResolver] needs a Map from package name to folder. In the case
824 /// that the analyzer is invoked with a --package-root option, we need to 826 /// that the analyzer is invoked with a --package-root option, we need to
825 /// manually create this mapping. Given [packageRootPath], 827 /// manually create this mapping. Given [packageRootPath],
826 /// [_PackageRootPackageMapBuilder] creates a simple mapping from package name 828 /// [_PackageRootPackageMapBuilder] creates a simple mapping from package name
827 /// to full path on disk (resolving any symbolic links). 829 /// to full path on disk (resolving any symbolic links).
828 class _PackageRootPackageMapBuilder { 830 class _PackageRootPackageMapBuilder {
829 static Map<String, List<file_system.Folder>> buildPackageMap( 831 static Map<String, List<file_system.Folder>> buildPackageMap(
830 String packageRootPath) { 832 String packageRootPath) {
831 var packageRoot = new Directory(packageRootPath); 833 var packageRoot = new io.Directory(packageRootPath);
832 if (!packageRoot.existsSync()) { 834 if (!packageRoot.existsSync()) {
833 throw new _DriverError( 835 throw new _DriverError(
834 'Package root directory ($packageRootPath) does not exist.'); 836 'Package root directory ($packageRootPath) does not exist.');
835 } 837 }
836 var packages = packageRoot.listSync(followLinks: false); 838 var packages = packageRoot.listSync(followLinks: false);
837 var result = new Map<String, List<file_system.Folder>>(); 839 var result = new Map<String, List<file_system.Folder>>();
838 for (var package in packages) { 840 for (var package in packages) {
839 var packageName = path.basename(package.path); 841 var packageName = path.basename(package.path);
840 var realPath = package.resolveSymbolicLinksSync(); 842 var realPath = package.resolveSymbolicLinksSync();
841 result[packageName] = [ 843 result[packageName] = [
842 PhysicalResourceProvider.INSTANCE.getFolder(realPath) 844 PhysicalResourceProvider.INSTANCE.getFolder(realPath)
843 ]; 845 ];
844 } 846 }
845 return result; 847 return result;
846 } 848 }
847 } 849 }
OLDNEW
« no previous file with comments | « pkg/analyzer_cli/lib/src/build_mode.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698