| 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 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 analysisOptions.analyzeFunctionBodiesPredicate = | 577 analysisOptions.analyzeFunctionBodiesPredicate = |
| 578 _chooseDietParsingPolicy(options); | 578 _chooseDietParsingPolicy(options); |
| 579 | 579 |
| 580 // If we have the analysis driver, and the new analysis options are the | 580 // If we have the analysis driver, and the new analysis options are the |
| 581 // same, we can reuse this analysis driver. | 581 // same, we can reuse this analysis driver. |
| 582 if (_context != null && | 582 if (_context != null && |
| 583 _equalAnalysisOptions(_context.analysisOptions, analysisOptions)) { | 583 _equalAnalysisOptions(_context.analysisOptions, analysisOptions)) { |
| 584 return; | 584 return; |
| 585 } | 585 } |
| 586 | 586 |
| 587 // Set up logging. |
| 588 if (options.log) { |
| 589 AnalysisEngine.instance.logger = new StdLogger(); |
| 590 } |
| 591 |
| 587 // Save stats from previous context before clobbering it. | 592 // Save stats from previous context before clobbering it. |
| 588 if (_context != null) { | 593 if (_context != null) { |
| 589 _analyzedFileCount += _context.sources.length; | 594 _analyzedFileCount += _context.sources.length; |
| 590 } | 595 } |
| 591 | 596 |
| 592 // Find package info. | 597 // Find package info. |
| 593 _PackageInfo packageInfo = _findPackages(options); | 598 _PackageInfo packageInfo = _findPackages(options); |
| 594 | 599 |
| 595 // Process embedders. | 600 // Process embedders. |
| 596 Map<file_system.Folder, YamlMap> embedderMap = | 601 Map<file_system.Folder, YamlMap> embedderMap = |
| (...skipping 22 matching lines...) Expand all Loading... |
| 619 summaryDataStore.addBundle(null, sdkBundle); | 624 summaryDataStore.addBundle(null, sdkBundle); |
| 620 } | 625 } |
| 621 | 626 |
| 622 // Choose a package resolution policy and a diet parsing policy based on | 627 // Choose a package resolution policy and a diet parsing policy based on |
| 623 // the command-line options. | 628 // the command-line options. |
| 624 SourceFactory sourceFactory = _chooseUriResolutionPolicy(options, | 629 SourceFactory sourceFactory = _chooseUriResolutionPolicy(options, |
| 625 embedderMap, packageInfo, summaryDataStore, true, analysisOptions); | 630 embedderMap, packageInfo, summaryDataStore, true, analysisOptions); |
| 626 | 631 |
| 627 // Create a context. | 632 // Create a context. |
| 628 _context = AnalysisEngine.instance.createAnalysisContext(); | 633 _context = AnalysisEngine.instance.createAnalysisContext(); |
| 629 setupAnalysisContext(_context, options, analysisOptions); | 634 _context.analysisOptions = analysisOptions; |
| 630 _context.sourceFactory = sourceFactory; | 635 _context.sourceFactory = sourceFactory; |
| 636 declareVariables(context.declaredVariables, options); |
| 631 | 637 |
| 632 if (options.enableNewAnalysisDriver) { | 638 if (options.enableNewAnalysisDriver) { |
| 633 PerformanceLog log = new PerformanceLog(null); | 639 PerformanceLog log = new PerformanceLog(null); |
| 634 AnalysisDriverScheduler scheduler = new AnalysisDriverScheduler(log); | 640 AnalysisDriverScheduler scheduler = new AnalysisDriverScheduler(log); |
| 635 analysisDriver = new AnalysisDriver( | 641 analysisDriver = new AnalysisDriver( |
| 636 scheduler, | 642 scheduler, |
| 637 log, | 643 log, |
| 638 resourceProvider, | 644 resourceProvider, |
| 639 analysisDriverMemoryByteStore, | 645 analysisDriverMemoryByteStore, |
| 640 new FileContentOverlay(), | 646 new FileContentOverlay(), |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 contextOptions.generateImplicitErrors = options.showPackageWarnings; | 860 contextOptions.generateImplicitErrors = options.showPackageWarnings; |
| 855 contextOptions.generateSdkErrors = options.showSdkWarnings; | 861 contextOptions.generateSdkErrors = options.showSdkWarnings; |
| 856 if (options.enableAssertInitializer != null) { | 862 if (options.enableAssertInitializer != null) { |
| 857 contextOptions.enableAssertInitializer = options.enableAssertInitializer; | 863 contextOptions.enableAssertInitializer = options.enableAssertInitializer; |
| 858 } | 864 } |
| 859 | 865 |
| 860 _directoryToAnalysisOptions[contextRootDirectory] = contextOptions; | 866 _directoryToAnalysisOptions[contextRootDirectory] = contextOptions; |
| 861 return contextOptions; | 867 return contextOptions; |
| 862 } | 868 } |
| 863 | 869 |
| 864 static void setAnalysisContextOptions( | 870 /// Copy variables defined in the [options] into [declaredVariables]. |
| 865 file_system.ResourceProvider resourceProvider, | 871 static void declareVariables( |
| 866 AnalysisContext context, | 872 DeclaredVariables declaredVariables, CommandLineOptions options) { |
| 867 CommandLineOptions options) { | |
| 868 AnalysisOptionsImpl analysisOptions = | |
| 869 createAnalysisOptionsForCommandLineOptions(resourceProvider, options); | |
| 870 setupAnalysisContext(context, options, analysisOptions); | |
| 871 } | |
| 872 | |
| 873 static void setupAnalysisContext(AnalysisContext context, | |
| 874 CommandLineOptions options, AnalysisOptionsImpl analysisOptions) { | |
| 875 Map<String, String> definedVariables = options.definedVariables; | 873 Map<String, String> definedVariables = options.definedVariables; |
| 876 if (definedVariables.isNotEmpty) { | 874 if (definedVariables.isNotEmpty) { |
| 877 DeclaredVariables declaredVariables = context.declaredVariables; | |
| 878 definedVariables.forEach((String variableName, String value) { | 875 definedVariables.forEach((String variableName, String value) { |
| 879 declaredVariables.define(variableName, value); | 876 declaredVariables.define(variableName, value); |
| 880 }); | 877 }); |
| 881 } | 878 } |
| 882 | |
| 883 if (options.log) { | |
| 884 AnalysisEngine.instance.logger = new StdLogger(); | |
| 885 } | |
| 886 | |
| 887 // Set context options. | |
| 888 context.analysisOptions = analysisOptions; | |
| 889 } | 879 } |
| 890 | 880 |
| 891 /// Return whether the [newOptions] are equal to the [previous]. | 881 /// Return whether the [newOptions] are equal to the [previous]. |
| 892 static bool _equalCommandLineOptions( | 882 static bool _equalCommandLineOptions( |
| 893 CommandLineOptions previous, CommandLineOptions newOptions) { | 883 CommandLineOptions previous, CommandLineOptions newOptions) { |
| 894 if (previous == null || newOptions == null) { | 884 if (previous == null || newOptions == null) { |
| 895 return false; | 885 return false; |
| 896 } | 886 } |
| 897 if (newOptions.packageRootPath != previous.packageRootPath) { | 887 if (newOptions.packageRootPath != previous.packageRootPath) { |
| 898 return false; | 888 return false; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 for (var package in packages) { | 995 for (var package in packages) { |
| 1006 var packageName = path.basename(package.path); | 996 var packageName = path.basename(package.path); |
| 1007 var realPath = package.resolveSymbolicLinksSync(); | 997 var realPath = package.resolveSymbolicLinksSync(); |
| 1008 result[packageName] = [ | 998 result[packageName] = [ |
| 1009 PhysicalResourceProvider.INSTANCE.getFolder(realPath) | 999 PhysicalResourceProvider.INSTANCE.getFolder(realPath) |
| 1010 ]; | 1000 ]; |
| 1011 } | 1001 } |
| 1012 return result; | 1002 return result; |
| 1013 } | 1003 } |
| 1014 } | 1004 } |
| OLD | NEW |