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.package_analyzer; | 5 library analyzer_cli.src.package_analyzer; |
6 | 6 |
7 import 'dart:core' hide Resource; | 7 import 'dart:core' hide Resource; |
8 import 'dart:io' as io; | 8 import 'dart:io' as io; |
9 | 9 |
10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
(...skipping 13 matching lines...) Expand all Loading... |
24 import 'package:analyzer_cli/src/driver.dart'; | 24 import 'package:analyzer_cli/src/driver.dart'; |
25 import 'package:analyzer_cli/src/error_formatter.dart'; | 25 import 'package:analyzer_cli/src/error_formatter.dart'; |
26 import 'package:analyzer_cli/src/options.dart'; | 26 import 'package:analyzer_cli/src/options.dart'; |
27 import 'package:path/path.dart' as pathos; | 27 import 'package:path/path.dart' as pathos; |
28 | 28 |
29 /** | 29 /** |
30 * The hermetic whole package analyzer. | 30 * The hermetic whole package analyzer. |
31 */ | 31 */ |
32 class PackageAnalyzer { | 32 class PackageAnalyzer { |
33 final CommandLineOptions options; | 33 final CommandLineOptions options; |
| 34 final AnalysisStats stats; |
34 | 35 |
35 String packagePath; | 36 String packagePath; |
36 String packageLibPath; | 37 String packageLibPath; |
37 | 38 |
38 final ResourceProvider resourceProvider = PhysicalResourceProvider.INSTANCE; | 39 final ResourceProvider resourceProvider = PhysicalResourceProvider.INSTANCE; |
39 InternalAnalysisContext context; | 40 InternalAnalysisContext context; |
40 final List<Source> explicitSources = <Source>[]; | 41 final List<Source> explicitSources = <Source>[]; |
41 | 42 |
42 PackageAnalyzer(this.options); | 43 PackageAnalyzer(this.options, this.stats); |
43 | 44 |
44 /** | 45 /** |
45 * Perform package analysis according to the given [options]. | 46 * Perform package analysis according to the given [options]. |
46 */ | 47 */ |
47 ErrorSeverity analyze() { | 48 ErrorSeverity analyze() { |
48 packagePath = resourceProvider.pathContext.normalize(resourceProvider | 49 packagePath = resourceProvider.pathContext.normalize(resourceProvider |
49 .pathContext | 50 .pathContext |
50 .join(io.Directory.current.absolute.path, options.packageModePath)); | 51 .join(io.Directory.current.absolute.path, options.packageModePath)); |
51 packageLibPath = resourceProvider.pathContext.join(packagePath, 'lib'); | 52 packageLibPath = resourceProvider.pathContext.join(packagePath, 'lib'); |
52 if (packageLibPath == null) { | 53 if (packageLibPath == null) { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 } | 175 } |
175 | 176 |
176 /** | 177 /** |
177 * Print errors for all explicit sources. | 178 * Print errors for all explicit sources. |
178 */ | 179 */ |
179 void _printErrors() { | 180 void _printErrors() { |
180 StringSink sink = options.machineFormat ? errorSink : outSink; | 181 StringSink sink = options.machineFormat ? errorSink : outSink; |
181 ErrorFormatter formatter = new ErrorFormatter( | 182 ErrorFormatter formatter = new ErrorFormatter( |
182 sink, | 183 sink, |
183 options, | 184 options, |
| 185 stats, |
184 (AnalysisError error) => | 186 (AnalysisError error) => |
185 AnalyzerImpl.processError(error, options, context)); | 187 AnalyzerImpl.processError(error, options, context)); |
186 for (Source source in explicitSources) { | 188 for (Source source in explicitSources) { |
187 AnalysisErrorInfo errorInfo = context.getErrors(source); | 189 AnalysisErrorInfo errorInfo = context.getErrors(source); |
188 formatter.formatErrors([errorInfo]); | 190 formatter.formatErrors([errorInfo]); |
189 } | 191 } |
| 192 stats.print(sink); |
190 } | 193 } |
191 } | 194 } |
OLD | NEW |