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

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

Issue 973683004: Fully parse SDK files when analyzing in batch mode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 | « pkg/analyzer/bin/analyzer.dart ('k') | 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 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:io'; 9 import 'dart:io';
10 10
(...skipping 22 matching lines...) Expand all
33 * The maximum number of sources for which AST structures should be kept in the cache. 33 * The maximum number of sources for which AST structures should be kept in the cache.
34 */ 34 */
35 const int _MAX_CACHE_SIZE = 512; 35 const int _MAX_CACHE_SIZE = 512;
36 36
37 /// Analyzes single library [File]. 37 /// Analyzes single library [File].
38 class AnalyzerImpl { 38 class AnalyzerImpl {
39 final String sourcePath; 39 final String sourcePath;
40 40
41 final CommandLineOptions options; 41 final CommandLineOptions options;
42 final int startTime; 42 final int startTime;
43
44 /**
45 * True if the analyzer is running in batch mode.
46 */
47 final bool isBatch;
48
43 ContentCache contentCache = new ContentCache(); 49 ContentCache contentCache = new ContentCache();
44 50
45 SourceFactory sourceFactory; 51 SourceFactory sourceFactory;
46 AnalysisContext context; 52 AnalysisContext context;
47 Source librarySource; 53 Source librarySource;
48 /// All [Source]s references by the analyzed library. 54 /// All [Source]s references by the analyzed library.
49 final Set<Source> sources = new Set<Source>(); 55 final Set<Source> sources = new Set<Source>();
50 56
51 /// All [AnalysisErrorInfo]s in the analyzed library. 57 /// All [AnalysisErrorInfo]s in the analyzed library.
52 final List<AnalysisErrorInfo> errorInfos = new List<AnalysisErrorInfo>(); 58 final List<AnalysisErrorInfo> errorInfos = new List<AnalysisErrorInfo>();
53 59
54 /// [HashMap] between sources and analysis error infos. 60 /// [HashMap] between sources and analysis error infos.
55 final HashMap<Source, AnalysisErrorInfo> sourceErrorsMap = 61 final HashMap<Source, AnalysisErrorInfo> sourceErrorsMap =
56 new HashMap<Source, AnalysisErrorInfo>(); 62 new HashMap<Source, AnalysisErrorInfo>();
57 63
58 AnalyzerImpl(String sourcePath, this.options, this.startTime) 64 AnalyzerImpl(String sourcePath, this.options, this.startTime, this.isBatch)
59 : sourcePath = _normalizeSourcePath(sourcePath) { 65 : sourcePath = _normalizeSourcePath(sourcePath) {
60 if (sdk == null) { 66 if (sdk == null) {
61 sdk = new DirectoryBasedDartSdk(new JavaFile(options.dartSdkPath)); 67 sdk = new DirectoryBasedDartSdk(new JavaFile(options.dartSdkPath));
62 } 68 }
63 } 69 }
64 70
65 /// Returns the maximal [ErrorSeverity] of the recorded errors. 71 /// Returns the maximal [ErrorSeverity] of the recorded errors.
66 ErrorSeverity get maxErrorSeverity { 72 ErrorSeverity get maxErrorSeverity {
67 var status = ErrorSeverity.NONE; 73 var status = ErrorSeverity.NONE;
68 for (AnalysisErrorInfo errorInfo in errorInfos) { 74 for (AnalysisErrorInfo errorInfo in errorInfos) {
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 }).catchError((ex, st) { 262 }).catchError((ex, st) {
257 AnalysisEngine.instance.logger.logError("$ex\n$st"); 263 AnalysisEngine.instance.logger.logError("$ex\n$st");
258 }); 264 });
259 } 265 }
260 266
261 bool _analyzeFunctionBodiesPredicate(Source source) { 267 bool _analyzeFunctionBodiesPredicate(Source source) {
262 // TODO(paulberry): This function will need to be updated when we add the 268 // TODO(paulberry): This function will need to be updated when we add the
263 // ability to suppress errors, warnings, and hints for files reached via 269 // ability to suppress errors, warnings, and hints for files reached via
264 // custom URI's using the "--url-mapping" flag. 270 // custom URI's using the "--url-mapping" flag.
265 if (source.uri.scheme == 'dart') { 271 if (source.uri.scheme == 'dart') {
272 if (isBatch) {
273 // When running in batch mode, the SDK files are cached from one
274 // analysis run to the next. So we need to parse function bodies even
275 // if the user hasn't asked for errors/warnings from the SDK, since
276 // they might ask for errors/warnings from the SDK in the future.
277 return true;
278 }
266 return options.showSdkWarnings; 279 return options.showSdkWarnings;
267 } 280 }
268 if (source.uri.scheme == 'package') { 281 if (source.uri.scheme == 'package') {
269 return options.showPackageWarnings; 282 return options.showPackageWarnings;
270 } 283 }
271 return true; 284 return true;
272 } 285 }
273 286
274 /// The sync version of analysis. 287 /// The sync version of analysis.
275 ErrorSeverity _analyzeSync(int printMode) { 288 ErrorSeverity _analyzeSync(int printMode) {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 } 458 }
446 } 459 }
447 460
448 @override 461 @override
449 void logInformation2(String message, Object exception) { 462 void logInformation2(String message, Object exception) {
450 if (log) { 463 if (log) {
451 stdout.writeln(message); 464 stdout.writeln(message);
452 } 465 }
453 } 466 }
454 } 467 }
OLDNEW
« no previous file with comments | « pkg/analyzer/bin/analyzer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698