| 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 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' as io; | 9 import 'dart:io' as io; |
| 10 | 10 |
| 11 import 'package:analyzer/error/error.dart'; | 11 import 'package:analyzer/error/error.dart'; |
| 12 import 'package:analyzer/file_system/file_system.dart' as file_system; | 12 import 'package:analyzer/file_system/file_system.dart' as file_system; |
| 13 import 'package:analyzer/file_system/file_system.dart'; | 13 import 'package:analyzer/file_system/file_system.dart'; |
| 14 import 'package:analyzer/file_system/physical_file_system.dart'; | 14 import 'package:analyzer/file_system/physical_file_system.dart'; |
| 15 import 'package:analyzer/plugin/resolver_provider.dart'; | 15 import 'package:analyzer/plugin/resolver_provider.dart'; |
| 16 import 'package:analyzer/source/analysis_options_provider.dart'; | 16 import 'package:analyzer/source/analysis_options_provider.dart'; |
| 17 import 'package:analyzer/source/package_map_provider.dart'; | 17 import 'package:analyzer/source/package_map_provider.dart'; |
| 18 import 'package:analyzer/source/package_map_resolver.dart'; | 18 import 'package:analyzer/source/package_map_resolver.dart'; |
| 19 import 'package:analyzer/source/pub_package_map_provider.dart'; | 19 import 'package:analyzer/source/pub_package_map_provider.dart'; |
| 20 import 'package:analyzer/source/sdk_ext.dart'; | 20 import 'package:analyzer/source/sdk_ext.dart'; |
| 21 import 'package:analyzer/src/context/builder.dart'; | 21 import 'package:analyzer/src/context/builder.dart'; |
| 22 import 'package:analyzer/src/dart/analysis/byte_store.dart'; | 22 import 'package:analyzer/src/dart/analysis/byte_store.dart'; |
| 23 import 'package:analyzer/src/dart/analysis/driver.dart'; | 23 import 'package:analyzer/src/dart/analysis/driver.dart'; |
| 24 import 'package:analyzer/src/dart/analysis/file_byte_store.dart'; | |
| 25 import 'package:analyzer/src/dart/analysis/file_state.dart'; | 24 import 'package:analyzer/src/dart/analysis/file_state.dart'; |
| 26 import 'package:analyzer/src/dart/sdk/sdk.dart'; | 25 import 'package:analyzer/src/dart/sdk/sdk.dart'; |
| 27 import 'package:analyzer/src/generated/constant.dart'; | 26 import 'package:analyzer/src/generated/constant.dart'; |
| 28 import 'package:analyzer/src/generated/engine.dart'; | 27 import 'package:analyzer/src/generated/engine.dart'; |
| 29 import 'package:analyzer/src/generated/interner.dart'; | 28 import 'package:analyzer/src/generated/interner.dart'; |
| 30 import 'package:analyzer/src/generated/java_engine.dart'; | 29 import 'package:analyzer/src/generated/java_engine.dart'; |
| 31 import 'package:analyzer/src/generated/sdk.dart'; | 30 import 'package:analyzer/src/generated/sdk.dart'; |
| 32 import 'package:analyzer/src/generated/source.dart'; | 31 import 'package:analyzer/src/generated/source.dart'; |
| 33 import 'package:analyzer/src/generated/source_io.dart'; | 32 import 'package:analyzer/src/generated/source_io.dart'; |
| 34 import 'package:analyzer/src/generated/utilities_general.dart' | 33 import 'package:analyzer/src/generated/utilities_general.dart' |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 return linterNode is YamlMap && linterNode.containsKey('rules'); | 70 return linterNode is YamlMap && linterNode.containsKey('rules'); |
| 72 } | 71 } |
| 73 | 72 |
| 74 typedef Future<ErrorSeverity> _BatchRunnerHandler(List<String> args); | 73 typedef Future<ErrorSeverity> _BatchRunnerHandler(List<String> args); |
| 75 | 74 |
| 76 class Driver implements CommandLineStarter { | 75 class Driver implements CommandLineStarter { |
| 77 static final PerformanceTag _analyzeAllTag = | 76 static final PerformanceTag _analyzeAllTag = |
| 78 new PerformanceTag("Driver._analyzeAll"); | 77 new PerformanceTag("Driver._analyzeAll"); |
| 79 | 78 |
| 80 static ByteStore analysisDriverMemoryByteStore = new MemoryByteStore(); | 79 static ByteStore analysisDriverMemoryByteStore = new MemoryByteStore(); |
| 81 static ByteStore analysisDriverFileByteStore = _createFileByteStore(); | |
| 82 | 80 |
| 83 /// The plugins that are defined outside the `analyzer_cli` package. | 81 /// The plugins that are defined outside the `analyzer_cli` package. |
| 84 List<Plugin> _userDefinedPlugins = <Plugin>[]; | 82 List<Plugin> _userDefinedPlugins = <Plugin>[]; |
| 85 | 83 |
| 86 /// The context that was most recently created by a call to [_analyzeAll], or | 84 /// The context that was most recently created by a call to [_analyzeAll], or |
| 87 /// `null` if [_analyzeAll] hasn't been called yet. | 85 /// `null` if [_analyzeAll] hasn't been called yet. |
| 88 InternalAnalysisContext _context; | 86 InternalAnalysisContext _context; |
| 89 | 87 |
| 90 AnalysisDriver analysisDriver; | 88 AnalysisDriver analysisDriver; |
| 91 | 89 |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 setupAnalysisContext(_context, options, analysisOptions); | 572 setupAnalysisContext(_context, options, analysisOptions); |
| 575 _context.sourceFactory = sourceFactory; | 573 _context.sourceFactory = sourceFactory; |
| 576 | 574 |
| 577 if (options.enableNewAnalysisDriver) { | 575 if (options.enableNewAnalysisDriver) { |
| 578 PerformanceLog log = new PerformanceLog(null); | 576 PerformanceLog log = new PerformanceLog(null); |
| 579 AnalysisDriverScheduler scheduler = new AnalysisDriverScheduler(log); | 577 AnalysisDriverScheduler scheduler = new AnalysisDriverScheduler(log); |
| 580 analysisDriver = new AnalysisDriver( | 578 analysisDriver = new AnalysisDriver( |
| 581 scheduler, | 579 scheduler, |
| 582 log, | 580 log, |
| 583 resourceProvider, | 581 resourceProvider, |
| 584 options.useAnalysisDriverMemoryByteStore | 582 analysisDriverMemoryByteStore, |
| 585 ? analysisDriverMemoryByteStore | |
| 586 : analysisDriverFileByteStore, | |
| 587 new FileContentOverlay(), | 583 new FileContentOverlay(), |
| 588 'test', | 584 'test', |
| 589 context.sourceFactory, | 585 context.sourceFactory, |
| 590 context.analysisOptions); | 586 context.analysisOptions); |
| 591 analysisDriver.results.listen((_) {}); | 587 analysisDriver.results.listen((_) {}); |
| 592 analysisDriver.exceptions.listen((_) {}); | 588 analysisDriver.exceptions.listen((_) {}); |
| 593 scheduler.start(); | 589 scheduler.start(); |
| 594 } else { | 590 } else { |
| 595 if (sdkBundle != null) { | 591 if (sdkBundle != null) { |
| 596 _context.resultProvider = | 592 _context.resultProvider = |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 } | 777 } |
| 782 | 778 |
| 783 if (options.log) { | 779 if (options.log) { |
| 784 AnalysisEngine.instance.logger = new StdLogger(); | 780 AnalysisEngine.instance.logger = new StdLogger(); |
| 785 } | 781 } |
| 786 | 782 |
| 787 // Set context options. | 783 // Set context options. |
| 788 context.analysisOptions = analysisOptions; | 784 context.analysisOptions = analysisOptions; |
| 789 } | 785 } |
| 790 | 786 |
| 791 /** | |
| 792 * If the state location can be accessed, return the file byte store, | |
| 793 * otherwise return the memory byte store. | |
| 794 */ | |
| 795 static ByteStore _createFileByteStore() { | |
| 796 const int M = 1024 * 1024 /*1 MiB*/; | |
| 797 const int G = 1024 * 1024 * 1024 /*1 GiB*/; | |
| 798 file_system.Folder stateLocation = | |
| 799 PhysicalResourceProvider.INSTANCE.getStateLocation('.analysis-driver'); | |
| 800 if (stateLocation == null) { | |
| 801 return new MemoryByteStore(); | |
| 802 } | |
| 803 return new MemoryCachingByteStore( | |
| 804 new EvictingFileByteStore(stateLocation.path, G), 64 * M); | |
| 805 } | |
| 806 | |
| 807 /// Perform a deep comparison of two string lists. | 787 /// Perform a deep comparison of two string lists. |
| 808 static bool _equalLists(List<String> l1, List<String> l2) { | 788 static bool _equalLists(List<String> l1, List<String> l2) { |
| 809 if (l1.length != l2.length) { | 789 if (l1.length != l2.length) { |
| 810 return false; | 790 return false; |
| 811 } | 791 } |
| 812 for (int i = 0; i < l1.length; i++) { | 792 for (int i = 0; i < l1.length; i++) { |
| 813 if (l1[i] != l2[i]) { | 793 if (l1[i] != l2[i]) { |
| 814 return false; | 794 return false; |
| 815 } | 795 } |
| 816 } | 796 } |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 for (var package in packages) { | 945 for (var package in packages) { |
| 966 var packageName = path.basename(package.path); | 946 var packageName = path.basename(package.path); |
| 967 var realPath = package.resolveSymbolicLinksSync(); | 947 var realPath = package.resolveSymbolicLinksSync(); |
| 968 result[packageName] = [ | 948 result[packageName] = [ |
| 969 PhysicalResourceProvider.INSTANCE.getFolder(realPath) | 949 PhysicalResourceProvider.INSTANCE.getFolder(realPath) |
| 970 ]; | 950 ]; |
| 971 } | 951 } |
| 972 return result; | 952 return result; |
| 973 } | 953 } |
| 974 } | 954 } |
| OLD | NEW |