| 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 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 return linterNode is YamlMap && linterNode.containsKey('rules'); | 71 return linterNode is YamlMap && linterNode.containsKey('rules'); |
| 72 } | 72 } |
| 73 | 73 |
| 74 typedef Future<ErrorSeverity> _BatchRunnerHandler(List<String> args); | 74 typedef Future<ErrorSeverity> _BatchRunnerHandler(List<String> args); |
| 75 | 75 |
| 76 class Driver implements CommandLineStarter { | 76 class Driver implements CommandLineStarter { |
| 77 static final PerformanceTag _analyzeAllTag = | 77 static final PerformanceTag _analyzeAllTag = |
| 78 new PerformanceTag("Driver._analyzeAll"); | 78 new PerformanceTag("Driver._analyzeAll"); |
| 79 | 79 |
| 80 static ByteStore analysisDriverMemoryByteStore = new MemoryByteStore(); | 80 static ByteStore analysisDriverMemoryByteStore = new MemoryByteStore(); |
| 81 static ByteStore analysisDriverFileByteStore = new MemoryCachingByteStore( | 81 static ByteStore analysisDriverFileByteStore = _createFileByteStore(); |
| 82 new EvictingFileByteStore( | |
| 83 PhysicalResourceProvider.INSTANCE | |
| 84 .getStateLocation('.analysis-driver') | |
| 85 .path, | |
| 86 1024 * 1024 * 1024 /*1 GiB*/), | |
| 87 64 * 1024 * 1024 /*64 MiB*/); | |
| 88 | 82 |
| 89 /// The plugins that are defined outside the `analyzer_cli` package. | 83 /// The plugins that are defined outside the `analyzer_cli` package. |
| 90 List<Plugin> _userDefinedPlugins = <Plugin>[]; | 84 List<Plugin> _userDefinedPlugins = <Plugin>[]; |
| 91 | 85 |
| 92 /// The context that was most recently created by a call to [_analyzeAll], or | 86 /// The context that was most recently created by a call to [_analyzeAll], or |
| 93 /// `null` if [_analyzeAll] hasn't been called yet. | 87 /// `null` if [_analyzeAll] hasn't been called yet. |
| 94 InternalAnalysisContext _context; | 88 InternalAnalysisContext _context; |
| 95 | 89 |
| 96 AnalysisDriver analysisDriver; | 90 AnalysisDriver analysisDriver; |
| 97 | 91 |
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 } | 781 } |
| 788 | 782 |
| 789 if (options.log) { | 783 if (options.log) { |
| 790 AnalysisEngine.instance.logger = new StdLogger(); | 784 AnalysisEngine.instance.logger = new StdLogger(); |
| 791 } | 785 } |
| 792 | 786 |
| 793 // Set context options. | 787 // Set context options. |
| 794 context.analysisOptions = analysisOptions; | 788 context.analysisOptions = analysisOptions; |
| 795 } | 789 } |
| 796 | 790 |
| 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 |
| 797 /// Perform a deep comparison of two string lists. | 807 /// Perform a deep comparison of two string lists. |
| 798 static bool _equalLists(List<String> l1, List<String> l2) { | 808 static bool _equalLists(List<String> l1, List<String> l2) { |
| 799 if (l1.length != l2.length) { | 809 if (l1.length != l2.length) { |
| 800 return false; | 810 return false; |
| 801 } | 811 } |
| 802 for (int i = 0; i < l1.length; i++) { | 812 for (int i = 0; i < l1.length; i++) { |
| 803 if (l1[i] != l2[i]) { | 813 if (l1[i] != l2[i]) { |
| 804 return false; | 814 return false; |
| 805 } | 815 } |
| 806 } | 816 } |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 for (var package in packages) { | 965 for (var package in packages) { |
| 956 var packageName = path.basename(package.path); | 966 var packageName = path.basename(package.path); |
| 957 var realPath = package.resolveSymbolicLinksSync(); | 967 var realPath = package.resolveSymbolicLinksSync(); |
| 958 result[packageName] = [ | 968 result[packageName] = [ |
| 959 PhysicalResourceProvider.INSTANCE.getFolder(realPath) | 969 PhysicalResourceProvider.INSTANCE.getFolder(realPath) |
| 960 ]; | 970 ]; |
| 961 } | 971 } |
| 962 return result; | 972 return result; |
| 963 } | 973 } |
| 964 } | 974 } |
| OLD | NEW |