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.build_mode; | 5 library analyzer_cli.src.build_mode; |
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/ast/ast.dart' show CompilationUnit; | 10 import 'package:analyzer/dart/ast/ast.dart' show CompilationUnit; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 class BuildMode { | 122 class BuildMode { |
123 final CommandLineOptions options; | 123 final CommandLineOptions options; |
124 final AnalysisStats stats; | 124 final AnalysisStats stats; |
125 | 125 |
126 final ResourceProvider resourceProvider = PhysicalResourceProvider.INSTANCE; | 126 final ResourceProvider resourceProvider = PhysicalResourceProvider.INSTANCE; |
127 SummaryDataStore summaryDataStore; | 127 SummaryDataStore summaryDataStore; |
128 InternalAnalysisContext context; | 128 InternalAnalysisContext context; |
129 Map<Uri, JavaFile> uriToFileMap; | 129 Map<Uri, JavaFile> uriToFileMap; |
130 final List<Source> explicitSources = <Source>[]; | 130 final List<Source> explicitSources = <Source>[]; |
131 | 131 |
132 PackageBundleAssembler assembler = new PackageBundleAssembler(); | 132 PackageBundleAssembler assembler; |
133 final Set<Source> processedSources = new Set<Source>(); | 133 final Set<Source> processedSources = new Set<Source>(); |
134 final Map<Uri, UnlinkedUnit> uriToUnit = <Uri, UnlinkedUnit>{}; | 134 final Map<Uri, UnlinkedUnit> uriToUnit = <Uri, UnlinkedUnit>{}; |
135 | 135 |
136 BuildMode(this.options, this.stats); | 136 BuildMode(this.options, this.stats); |
137 | 137 |
138 /** | 138 /** |
139 * Perform package analysis according to the given [options]. | 139 * Perform package analysis according to the given [options]. |
140 */ | 140 */ |
141 ErrorSeverity analyze() { | 141 ErrorSeverity analyze() { |
142 // Write initial progress message. | 142 // Write initial progress message. |
(...skipping 30 matching lines...) Expand all Loading... |
173 // Perform full analysis. | 173 // Perform full analysis. |
174 while (true) { | 174 while (true) { |
175 AnalysisResult analysisResult = context.performAnalysisTask(); | 175 AnalysisResult analysisResult = context.performAnalysisTask(); |
176 if (!analysisResult.hasMoreWork) { | 176 if (!analysisResult.hasMoreWork) { |
177 break; | 177 break; |
178 } | 178 } |
179 } | 179 } |
180 } | 180 } |
181 | 181 |
182 // Write summary. | 182 // Write summary. |
| 183 assembler = new PackageBundleAssembler( |
| 184 excludeHashes: options.buildSummaryExcludeInformative); |
183 if (options.buildSummaryOutput != null) { | 185 if (options.buildSummaryOutput != null) { |
184 if (options.buildSummaryOnlyAst && !options.buildSummaryFallback) { | 186 if (options.buildSummaryOnlyAst && !options.buildSummaryFallback) { |
185 _serializeAstBasedSummary(explicitSources); | 187 _serializeAstBasedSummary(explicitSources); |
186 } else { | 188 } else { |
187 for (Source source in explicitSources) { | 189 for (Source source in explicitSources) { |
188 if (context.computeKindOf(source) == SourceKind.LIBRARY) { | 190 if (context.computeKindOf(source) == SourceKind.LIBRARY) { |
189 if (options.buildSummaryFallback) { | 191 if (options.buildSummaryFallback) { |
190 assembler.addFallbackLibrary(source); | 192 assembler.addFallbackLibrary(source); |
191 } else { | 193 } else { |
192 LibraryElement libraryElement = | 194 LibraryElement libraryElement = |
193 context.computeLibraryElement(source); | 195 context.computeLibraryElement(source); |
194 assembler.serializeLibraryElement(libraryElement); | 196 assembler.serializeLibraryElement(libraryElement); |
195 } | 197 } |
196 } | 198 } |
197 if (options.buildSummaryFallback) { | 199 if (options.buildSummaryFallback) { |
198 assembler.addFallbackUnit(source); | 200 assembler.addFallbackUnit(source); |
199 } | 201 } |
200 } | 202 } |
201 } | 203 } |
202 // Write the whole package bundle. | 204 // Write the whole package bundle. |
203 PackageBundleBuilder sdkBundle = assembler.assemble(); | 205 PackageBundleBuilder sdkBundle = assembler.assemble(); |
204 if (options.buildSummaryExcludeInformative) { | 206 if (options.buildSummaryExcludeInformative) { |
205 sdkBundle.flushInformative(); | 207 sdkBundle.flushInformative(); |
206 sdkBundle.unlinkedUnitHashes = null; | |
207 } | 208 } |
208 io.File file = new io.File(options.buildSummaryOutput); | 209 io.File file = new io.File(options.buildSummaryOutput); |
209 file.writeAsBytesSync(sdkBundle.toBuffer(), mode: io.FileMode.WRITE_ONLY); | 210 file.writeAsBytesSync(sdkBundle.toBuffer(), mode: io.FileMode.WRITE_ONLY); |
210 } | 211 } |
211 | 212 |
212 if (options.buildSummaryOnly) { | 213 if (options.buildSummaryOnly) { |
213 return ErrorSeverity.NONE; | 214 return ErrorSeverity.NONE; |
214 } else { | 215 } else { |
215 // Process errors. | 216 // Process errors. |
216 _printErrors(outputPath: options.buildAnalysisOutput); | 217 _printErrors(outputPath: options.buildAnalysisOutput); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 'Illegal input file (must be "\$uri|\$path"): $sourceFile'); | 352 'Illegal input file (must be "\$uri|\$path"): $sourceFile'); |
352 return null; | 353 return null; |
353 } | 354 } |
354 Uri uri = Uri.parse(sourceFile.substring(0, pipeIndex)); | 355 Uri uri = Uri.parse(sourceFile.substring(0, pipeIndex)); |
355 String path = sourceFile.substring(pipeIndex + 1); | 356 String path = sourceFile.substring(pipeIndex + 1); |
356 uriToFileMap[uri] = new JavaFile(path); | 357 uriToFileMap[uri] = new JavaFile(path); |
357 } | 358 } |
358 return uriToFileMap; | 359 return uriToFileMap; |
359 } | 360 } |
360 } | 361 } |
OLD | NEW |