Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(628)

Side by Side Diff: pkg/analyzer_cli/lib/src/analyzer_impl.dart

Issue 1810103003: Analyzer directory recursing (tk 2) (#25129). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: re-apply tk 1 Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.analyzer_impl; 5 library analyzer_cli.src.analyzer_impl;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:analyzer/dart/element/element.dart'; 10 import 'package:analyzer/dart/element/element.dart';
(...skipping 22 matching lines...) Expand all
33 static final PerformanceTag _prepareErrorsTag = 33 static final PerformanceTag _prepareErrorsTag =
34 new PerformanceTag("AnalyzerImpl.prepareErrors"); 34 new PerformanceTag("AnalyzerImpl.prepareErrors");
35 static final PerformanceTag _resolveLibraryTag = 35 static final PerformanceTag _resolveLibraryTag =
36 new PerformanceTag("AnalyzerImpl._resolveLibrary"); 36 new PerformanceTag("AnalyzerImpl._resolveLibrary");
37 37
38 final CommandLineOptions options; 38 final CommandLineOptions options;
39 final int startTime; 39 final int startTime;
40 40
41 final AnalysisContext context; 41 final AnalysisContext context;
42 42
43 /// Accumulated analysis statistics.
44 final AnalysisStats stats;
45
43 final Source librarySource; 46 final Source librarySource;
44 47
45 /// All [Source]s references by the analyzed library. 48 /// All [Source]s references by the analyzed library.
46 final Set<Source> sources = new Set<Source>(); 49 final Set<Source> sources = new Set<Source>();
47 50
48 /// All [AnalysisErrorInfo]s in the analyzed library. 51 /// All [AnalysisErrorInfo]s in the analyzed library.
49 final List<AnalysisErrorInfo> errorInfos = new List<AnalysisErrorInfo>(); 52 final List<AnalysisErrorInfo> errorInfos = new List<AnalysisErrorInfo>();
50 53
51 /// [HashMap] between sources and analysis error infos. 54 /// [HashMap] between sources and analysis error infos.
52 final HashMap<Source, AnalysisErrorInfo> sourceErrorsMap = 55 final HashMap<Source, AnalysisErrorInfo> sourceErrorsMap =
53 new HashMap<Source, AnalysisErrorInfo>(); 56 new HashMap<Source, AnalysisErrorInfo>();
54 57
55 /// If the file specified on the command line is part of a package, the name 58 /// If the file specified on the command line is part of a package, the name
56 /// of that package. Otherwise `null`. This allows us to analyze the file 59 /// of that package. Otherwise `null`. This allows us to analyze the file
57 /// specified on the command line as though it is reached via a "package:" 60 /// specified on the command line as though it is reached via a "package:"
58 /// URI, but avoid suppressing its output in the event that the user has not 61 /// URI, but avoid suppressing its output in the event that the user has not
59 /// specified the "--package-warnings" option. 62 /// specified the "--package-warnings" option.
60 String _selfPackageName; 63 String _selfPackageName;
61 64
62 AnalyzerImpl(this.context, this.librarySource, this.options, this.startTime); 65 AnalyzerImpl(this.context, this.librarySource, this.options, this.stats,
66 this.startTime);
63 67
64 /// Returns the maximal [ErrorSeverity] of the recorded errors. 68 /// Returns the maximal [ErrorSeverity] of the recorded errors.
65 ErrorSeverity get maxErrorSeverity { 69 ErrorSeverity get maxErrorSeverity {
66 var status = ErrorSeverity.NONE; 70 var status = ErrorSeverity.NONE;
67 for (AnalysisErrorInfo errorInfo in errorInfos) { 71 for (AnalysisErrorInfo errorInfo in errorInfos) {
68 for (AnalysisError error in errorInfo.errors) { 72 for (AnalysisError error in errorInfo.errors) {
69 if (_processError(error) == null) { 73 if (_processError(error) == null) {
70 continue; 74 continue;
71 } 75 }
72 var severity = computeSeverity(error, options); 76 var severity = computeSeverity(error, options);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 _printErrors() { 217 _printErrors() {
214 // The following is a hack. We currently print out to stderr to ensure that 218 // The following is a hack. We currently print out to stderr to ensure that
215 // when in batch mode we print to stderr, this is because the prints from 219 // when in batch mode we print to stderr, this is because the prints from
216 // batch are made to stderr. The reason that options.shouldBatch isn't used 220 // batch are made to stderr. The reason that options.shouldBatch isn't used
217 // is because when the argument flags are constructed in BatchRunner and 221 // is because when the argument flags are constructed in BatchRunner and
218 // passed in from batch mode which removes the batch flag to prevent the 222 // passed in from batch mode which removes the batch flag to prevent the
219 // "cannot have the batch flag and source file" error message. 223 // "cannot have the batch flag and source file" error message.
220 StringSink sink = options.machineFormat ? errorSink : outSink; 224 StringSink sink = options.machineFormat ? errorSink : outSink;
221 225
222 // Print errors. 226 // Print errors.
223 ErrorFormatter formatter = new ErrorFormatter(sink, options, _processError); 227 ErrorFormatter formatter =
228 new ErrorFormatter(sink, options, stats, _processError);
224 formatter.formatErrors(errorInfos); 229 formatter.formatErrors(errorInfos);
225 } 230 }
226 231
227 ProcessedSeverity _processError(AnalysisError error) => 232 ProcessedSeverity _processError(AnalysisError error) =>
228 processError(error, options, context); 233 processError(error, options, context);
229 234
230 LibraryElement _resolveLibrary() { 235 LibraryElement _resolveLibrary() {
231 return _resolveLibraryTag.makeCurrentWhile(() { 236 return _resolveLibraryTag.makeCurrentWhile(() {
232 return context.computeLibraryElement(librarySource); 237 return context.computeLibraryElement(librarySource);
233 }); 238 });
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 } 328 }
324 329
325 @override 330 @override
326 void logInformation(String message, [CaughtException exception]) { 331 void logInformation(String message, [CaughtException exception]) {
327 outSink.writeln(message); 332 outSink.writeln(message);
328 if (exception != null) { 333 if (exception != null) {
329 outSink.writeln(exception); 334 outSink.writeln(exception);
330 } 335 }
331 } 336 }
332 } 337 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer_cli/lib/src/driver.dart » ('j') | pkg/analyzer_cli/lib/src/driver.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698