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

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

Issue 202633002: Collect analysis errors from change notifications. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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_impl; 5 library analyzer_impl;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'dart:io'; 9 import 'dart:io';
10 10
11 import 'package:path/path.dart' as pathos; 11 import 'package:path/path.dart' as pathos;
12 12
13 import 'generated/ast.dart'; 13 import 'generated/ast.dart';
14 import 'generated/engine.dart'; 14 import 'generated/engine.dart';
15 import 'generated/element.dart'; 15 import 'generated/element.dart';
16 import 'generated/error.dart'; 16 import 'generated/error.dart';
17 import 'generated/java_io.dart'; 17 import 'generated/java_io.dart';
18 import 'generated/sdk.dart'; 18 import 'generated/sdk.dart';
19 import 'generated/sdk_io.dart'; 19 import 'generated/sdk_io.dart';
20 import 'generated/source_io.dart'; 20 import 'generated/source_io.dart';
21 import '../options.dart'; 21 import '../options.dart';
22 22
23 import 'dart:collection';
24
23 import 'package:analyzer/src/generated/java_core.dart' show JavaSystem; 25 import 'package:analyzer/src/generated/java_core.dart' show JavaSystem;
24 import 'package:analyzer/src/error_formatter.dart'; 26 import 'package:analyzer/src/error_formatter.dart';
25 27
26 /** 28 /**
27 * The maximum number of sources for which AST structures should be kept in the cache. 29 * The maximum number of sources for which AST structures should be kept in the cache.
28 */ 30 */
29 const int _MAX_CACHE_SIZE = 512; 31 const int _MAX_CACHE_SIZE = 512;
30 32
31 DartSdk sdk; 33 DartSdk sdk;
32 34
33 /// Analyzes single library [File]. 35 /// Analyzes single library [File].
34 class AnalyzerImpl { 36 class AnalyzerImpl {
35 final String sourcePath; 37 final String sourcePath;
36 final CommandLineOptions options; 38 final CommandLineOptions options;
37 final int startTime; 39 final int startTime;
38 40
39 ContentCache contentCache = new ContentCache(); 41 ContentCache contentCache = new ContentCache();
40 SourceFactory sourceFactory; 42 SourceFactory sourceFactory;
41 AnalysisContext context; 43 AnalysisContext context;
42 Source librarySource; 44 Source librarySource;
43 45
44 /// All [Source]s references by the analyzed library. 46 /// All [Source]s references by the analyzed library.
45 final Set<Source> sources = new Set<Source>(); 47 final Set<Source> sources = new Set<Source>();
46 48
47 /// All [AnalysisErrorInfo]s in the analyzed library. 49 /// All [AnalysisErrorInfo]s in the analyzed library.
48 final List<AnalysisErrorInfo> errorInfos = new List<AnalysisErrorInfo>(); 50 final List<AnalysisErrorInfo> errorInfos = new List<AnalysisErrorInfo>();
49 51
52 /// [HashMap] between sources and analysis error infos.
53 final HashMap<Source, AnalysisErrorInfo> sourceErrorsMap = new HashMap<Source, AnalysisErrorInfo>();
54
50 AnalyzerImpl(this.sourcePath, this.options, this.startTime) { 55 AnalyzerImpl(this.sourcePath, this.options, this.startTime) {
51 if (sdk == null) { 56 if (sdk == null) {
52 sdk = new DirectoryBasedDartSdk(new JavaFile(options.dartSdkPath)); 57 sdk = new DirectoryBasedDartSdk(new JavaFile(options.dartSdkPath));
53 } 58 }
54 } 59 }
55 60
56 /** 61 /**
57 * Treats the [sourcePath] as the top level library and analyzes it using a 62 * Treats the [sourcePath] as the top level library and analyzes it using a
58 * synchronous algorithm over the analysis engine. 63 * synchronous algorithm over the analysis engine.
59 */ 64 */
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 127
123 /// The async version of the analysis 128 /// The async version of the analysis
124 void _analyzeAsync() { 129 void _analyzeAsync() {
125 new Future(context.performAnalysisTask).then((AnalysisResult result) { 130 new Future(context.performAnalysisTask).then((AnalysisResult result) {
126 List<ChangeNotice> notices = result.changeNotices; 131 List<ChangeNotice> notices = result.changeNotices;
127 if (result.hasMoreWork) { 132 if (result.hasMoreWork) {
128 // There is more work, record the set of sources, and then call self 133 // There is more work, record the set of sources, and then call self
129 // again to perform next task 134 // again to perform next task
130 for (ChangeNotice notice in notices) { 135 for (ChangeNotice notice in notices) {
131 sources.add(notice.source); 136 sources.add(notice.source);
137 sourceErrorsMap[notice.source] = notice;
132 } 138 }
133 return _analyzeAsync(); 139 return _analyzeAsync();
134 } 140 }
135 // 141 //
136 // There are not any more tasks, set error code and print performance 142 // There are not any more tasks, set error code and print performance
137 // numbers. 143 // numbers.
138 // 144 //
139 // prepare errors 145 // prepare errors
140 prepareErrors(); 146 sourceErrorsMap.forEach((k,v) {
147 errorInfos.add(sourceErrorsMap[k]);
148 });
141 149
142 // print errors and performance numbers 150 // print errors and performance numbers
143 _printErrorsAndPerf(); 151 _printErrorsAndPerf();
144 152
145 // compute max severity and set exitCode 153 // compute max severity and set exitCode
146 ErrorSeverity status = maxErrorSeverity; 154 ErrorSeverity status = maxErrorSeverity;
147 if (status == ErrorSeverity.WARNING && options.warningsAreFatal) { 155 if (status == ErrorSeverity.WARNING && options.warningsAreFatal) {
148 status = ErrorSeverity.ERROR; 156 status = ErrorSeverity.ERROR;
149 } 157 }
150 exitCode = status.ordinal; 158 exitCode = status.ordinal;
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 } 364 }
357 } 365 }
358 366
359 @override 367 @override
360 void logInformation2(String message, Exception exception) { 368 void logInformation2(String message, Exception exception) {
361 if (log) { 369 if (log) {
362 stdout.writeln(message); 370 stdout.writeln(message);
363 } 371 }
364 } 372 }
365 } 373 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698