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

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

Issue 1772923002: Add an analyzer_cli option to disable analysis (for faster summary generation) (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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
« no previous file with comments | « pkg/analyzer_cli/lib/src/options.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) 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 io.exitCode = ErrorSeverity.ERROR.ordinal; 74 io.exitCode = ErrorSeverity.ERROR.ordinal;
75 return ErrorSeverity.ERROR; 75 return ErrorSeverity.ERROR;
76 } 76 }
77 Source source = _createSourceInContext(file); 77 Source source = _createSourceInContext(file);
78 explicitSources.add(source); 78 explicitSources.add(source);
79 changeSet.addedSource(source); 79 changeSet.addedSource(source);
80 } 80 }
81 } 81 }
82 context.applyChanges(changeSet); 82 context.applyChanges(changeSet);
83 83
84 // Perform full analysis. 84 if (!options.packageSummaryOnly) {
85 while (true) { 85 // Perform full analysis.
86 AnalysisResult analysisResult = context.performAnalysisTask(); 86 while (true) {
87 if (!analysisResult.hasMoreWork) { 87 AnalysisResult analysisResult = context.performAnalysisTask();
88 break; 88 if (!analysisResult.hasMoreWork) {
89 break;
90 }
89 } 91 }
90 } 92 }
91 93
92 // Write summary for Dart libraries. 94 // Write summary for Dart libraries.
93 if (options.packageSummaryOutput != null) { 95 if (options.packageSummaryOutput != null) {
94 PackageBundleAssembler assembler = new PackageBundleAssembler(); 96 PackageBundleAssembler assembler = new PackageBundleAssembler();
95 for (Source source in context.librarySources) { 97 for (Source source in context.librarySources) {
96 if (pathos.isWithin(packageLibPath, source.fullName)) { 98 if (pathos.isWithin(packageLibPath, source.fullName)) {
97 LibraryElement libraryElement = context.getLibraryElement(source); 99 LibraryElement libraryElement = context.computeLibraryElement(source);
98 if (libraryElement != null) { 100 if (libraryElement != null) {
99 assembler.serializeLibraryElement(libraryElement); 101 assembler.serializeLibraryElement(libraryElement);
100 } 102 }
101 } 103 }
102 } 104 }
103 // Write the whole package bundle. 105 // Write the whole package bundle.
104 PackageBundleBuilder sdkBundle = assembler.assemble(); 106 PackageBundleBuilder sdkBundle = assembler.assemble();
105 io.File file = new io.File(options.packageSummaryOutput); 107 io.File file = new io.File(options.packageSummaryOutput);
106 file.writeAsBytesSync(sdkBundle.toBuffer(), mode: io.FileMode.WRITE_ONLY); 108 file.writeAsBytesSync(sdkBundle.toBuffer(), mode: io.FileMode.WRITE_ONLY);
107 } 109 }
108 110
109 // Process errors. 111 if (options.packageSummaryOnly) {
110 _printErrors(); 112 return ErrorSeverity.NONE;
111 return _computeMaxSeverity(); 113 } else {
114 // Process errors.
115 _printErrors();
116 return _computeMaxSeverity();
117 }
112 } 118 }
113 119
114 ErrorSeverity _computeMaxSeverity() { 120 ErrorSeverity _computeMaxSeverity() {
115 ErrorSeverity maxSeverity = ErrorSeverity.NONE; 121 ErrorSeverity maxSeverity = ErrorSeverity.NONE;
116 for (Source source in explicitSources) { 122 for (Source source in explicitSources) {
117 AnalysisErrorInfo errorInfo = context.getErrors(source); 123 AnalysisErrorInfo errorInfo = context.getErrors(source);
118 for (AnalysisError error in errorInfo.errors) { 124 for (AnalysisError error in errorInfo.errors) {
119 ProcessedSeverity processedSeverity = 125 ProcessedSeverity processedSeverity =
120 AnalyzerImpl.processError(error, options, context); 126 AnalyzerImpl.processError(error, options, context);
121 if (processedSeverity != null) { 127 if (processedSeverity != null) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 sink, 181 sink,
176 options, 182 options,
177 (AnalysisError error) => 183 (AnalysisError error) =>
178 AnalyzerImpl.processError(error, options, context)); 184 AnalyzerImpl.processError(error, options, context));
179 for (Source source in explicitSources) { 185 for (Source source in explicitSources) {
180 AnalysisErrorInfo errorInfo = context.getErrors(source); 186 AnalysisErrorInfo errorInfo = context.getErrors(source);
181 formatter.formatErrors([errorInfo]); 187 formatter.formatErrors([errorInfo]);
182 } 188 }
183 } 189 }
184 } 190 }
OLDNEW
« no previous file with comments | « pkg/analyzer_cli/lib/src/options.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698