| OLD | NEW |
| 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:io' as io; | 6 import 'dart:io' as io; |
| 7 | 7 |
| 8 import 'package:analyzer/error/error.dart'; | 8 import 'package:analyzer/error/error.dart'; |
| 9 import 'package:analyzer/file_system/file_system.dart' as file_system; | 9 import 'package:analyzer/file_system/file_system.dart' as file_system; |
| 10 import 'package:analyzer/file_system/file_system.dart'; | 10 import 'package:analyzer/file_system/file_system.dart'; |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 disableAnalyticsForSession(); | 173 disableAnalyticsForSession(); |
| 174 } | 174 } |
| 175 | 175 |
| 176 // Ping analytics with our initial call. | 176 // Ping analytics with our initial call. |
| 177 analytics.sendScreenView('home'); | 177 analytics.sendScreenView('home'); |
| 178 | 178 |
| 179 var timer = analytics.startTimer('analyze'); | 179 var timer = analytics.startTimer('analyze'); |
| 180 | 180 |
| 181 // Do analysis. | 181 // Do analysis. |
| 182 if (options.buildMode) { | 182 if (options.buildMode) { |
| 183 ErrorSeverity severity = _buildModeAnalyze(options); | 183 ErrorSeverity severity = await _buildModeAnalyze(options); |
| 184 // Propagate issues to the exit code. | 184 // Propagate issues to the exit code. |
| 185 if (_shouldBeFatal(severity, options)) { | 185 if (_shouldBeFatal(severity, options)) { |
| 186 io.exitCode = severity.ordinal; | 186 io.exitCode = severity.ordinal; |
| 187 } | 187 } |
| 188 } else if (options.batchMode) { | 188 } else if (options.batchMode) { |
| 189 BatchRunner batchRunner = new BatchRunner(outSink, errorSink); | 189 BatchRunner batchRunner = new BatchRunner(outSink, errorSink); |
| 190 batchRunner.runAsBatch(args, (List<String> args) async { | 190 batchRunner.runAsBatch(args, (List<String> args) async { |
| 191 CommandLineOptions options = CommandLineOptions.parse(args); | 191 CommandLineOptions options = CommandLineOptions.parse(args); |
| 192 return await _analyzeAll(options); | 192 return await _analyzeAll(options); |
| 193 }); | 193 }); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 } | 358 } |
| 359 | 359 |
| 360 if (!options.machineFormat) { | 360 if (!options.machineFormat) { |
| 361 stats.print(outSink); | 361 stats.print(outSink); |
| 362 } | 362 } |
| 363 | 363 |
| 364 return allResult; | 364 return allResult; |
| 365 } | 365 } |
| 366 | 366 |
| 367 /// Perform analysis in build mode according to the given [options]. | 367 /// Perform analysis in build mode according to the given [options]. |
| 368 ErrorSeverity _buildModeAnalyze(CommandLineOptions options) { | 368 Future<ErrorSeverity> _buildModeAnalyze(CommandLineOptions options) async { |
| 369 return _analyzeAllTag.makeCurrentWhile(() { | 369 PerformanceTag previous = _analyzeAllTag.makeCurrent(); |
| 370 try { |
| 370 if (options.buildModePersistentWorker) { | 371 if (options.buildModePersistentWorker) { |
| 371 new AnalyzerWorkerLoop.std(resourceProvider, | 372 await new AnalyzerWorkerLoop.std(resourceProvider, |
| 372 dartSdkPath: options.dartSdkPath) | 373 dartSdkPath: options.dartSdkPath) |
| 373 .run(); | 374 .run(); |
| 375 return ErrorSeverity.NONE; |
| 374 } else { | 376 } else { |
| 375 return new BuildMode(resourceProvider, options, stats).analyze(); | 377 return await new BuildMode(resourceProvider, options, stats).analyze(); |
| 376 } | 378 } |
| 377 }); | 379 } finally { |
| 380 previous.makeCurrent(); |
| 381 } |
| 378 } | 382 } |
| 379 | 383 |
| 380 /// Decide on the appropriate policy for which files need to be fully parsed | 384 /// Decide on the appropriate policy for which files need to be fully parsed |
| 381 /// and which files need to be diet parsed, based on [options], and return an | 385 /// and which files need to be diet parsed, based on [options], and return an |
| 382 /// [AnalyzeFunctionBodiesPredicate] that implements this policy. | 386 /// [AnalyzeFunctionBodiesPredicate] that implements this policy. |
| 383 AnalyzeFunctionBodiesPredicate _chooseDietParsingPolicy( | 387 AnalyzeFunctionBodiesPredicate _chooseDietParsingPolicy( |
| 384 CommandLineOptions options) { | 388 CommandLineOptions options) { |
| 385 if (options.batchMode) { | 389 if (options.batchMode) { |
| 386 // As analyzer is currently implemented, once a file has been diet | 390 // As analyzer is currently implemented, once a file has been diet |
| 387 // parsed, it can't easily be un-diet parsed without creating a brand new | 391 // parsed, it can't easily be un-diet parsed without creating a brand new |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 for (var package in packages) { | 999 for (var package in packages) { |
| 996 var packageName = path.basename(package.path); | 1000 var packageName = path.basename(package.path); |
| 997 var realPath = package.resolveSymbolicLinksSync(); | 1001 var realPath = package.resolveSymbolicLinksSync(); |
| 998 result[packageName] = [ | 1002 result[packageName] = [ |
| 999 PhysicalResourceProvider.INSTANCE.getFolder(realPath) | 1003 PhysicalResourceProvider.INSTANCE.getFolder(realPath) |
| 1000 ]; | 1004 ]; |
| 1001 } | 1005 } |
| 1002 return result; | 1006 return result; |
| 1003 } | 1007 } |
| 1004 } | 1008 } |
| OLD | NEW |