| 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 while (true) { | 177 while (true) { |
| 178 AnalysisResult analysisResult = context.performAnalysisTask(); | 178 AnalysisResult analysisResult = context.performAnalysisTask(); |
| 179 if (!analysisResult.hasMoreWork) { | 179 if (!analysisResult.hasMoreWork) { |
| 180 break; | 180 break; |
| 181 } | 181 } |
| 182 } | 182 } |
| 183 } | 183 } |
| 184 | 184 |
| 185 // Write summary. | 185 // Write summary. |
| 186 assembler = new PackageBundleAssembler( | 186 assembler = new PackageBundleAssembler( |
| 187 excludeHashes: options.buildSummaryExcludeInformative); | 187 excludeHashes: options.buildSummaryExcludeInformative && |
| 188 if (options.buildSummaryOutput != null) { | 188 options.buildSummaryOutputSemantic == null); |
| 189 if (options.buildSummaryOutput != null || |
| 190 options.buildSummaryOutputSemantic != null) { |
| 189 if (options.buildSummaryOnlyAst && !options.buildSummaryFallback) { | 191 if (options.buildSummaryOnlyAst && !options.buildSummaryFallback) { |
| 190 _serializeAstBasedSummary(explicitSources); | 192 _serializeAstBasedSummary(explicitSources); |
| 191 } else { | 193 } else { |
| 192 for (Source source in explicitSources) { | 194 for (Source source in explicitSources) { |
| 193 if (context.computeKindOf(source) == SourceKind.LIBRARY) { | 195 if (context.computeKindOf(source) == SourceKind.LIBRARY) { |
| 194 if (options.buildSummaryFallback) { | 196 if (options.buildSummaryFallback) { |
| 195 assembler.addFallbackLibrary(source); | 197 assembler.addFallbackLibrary(source); |
| 196 } else { | 198 } else { |
| 197 LibraryElement libraryElement = | 199 LibraryElement libraryElement = |
| 198 context.computeLibraryElement(source); | 200 context.computeLibraryElement(source); |
| 199 assembler.serializeLibraryElement(libraryElement); | 201 assembler.serializeLibraryElement(libraryElement); |
| 200 } | 202 } |
| 201 } | 203 } |
| 202 if (options.buildSummaryFallback) { | 204 if (options.buildSummaryFallback) { |
| 203 assembler.addFallbackUnit(source); | 205 assembler.addFallbackUnit(source); |
| 204 } | 206 } |
| 205 } | 207 } |
| 206 } | 208 } |
| 207 // Write the whole package bundle. | 209 // Write the whole package bundle. |
| 208 PackageBundleBuilder sdkBundle = assembler.assemble(); | 210 PackageBundleBuilder sdkBundle = assembler.assemble(); |
| 209 if (options.buildSummaryExcludeInformative) { | 211 if (options.buildSummaryExcludeInformative) { |
| 210 sdkBundle.flushInformative(); | 212 sdkBundle.flushInformative(); |
| 211 } | 213 } |
| 212 io.File file = new io.File(options.buildSummaryOutput); | 214 if (options.buildSummaryOutput != null) { |
| 213 file.writeAsBytesSync(sdkBundle.toBuffer(), mode: io.FileMode.WRITE_ONLY); | 215 io.File file = new io.File(options.buildSummaryOutput); |
| 216 file.writeAsBytesSync(sdkBundle.toBuffer(), |
| 217 mode: io.FileMode.WRITE_ONLY); |
| 218 } |
| 219 if (options.buildSummaryOutputSemantic != null) { |
| 220 sdkBundle.flushInformative(); |
| 221 io.File file = new io.File(options.buildSummaryOutputSemantic); |
| 222 file.writeAsBytesSync(sdkBundle.toBuffer(), |
| 223 mode: io.FileMode.WRITE_ONLY); |
| 224 } |
| 214 } | 225 } |
| 215 | 226 |
| 216 if (options.buildSummaryOnly) { | 227 if (options.buildSummaryOnly) { |
| 217 return ErrorSeverity.NONE; | 228 return ErrorSeverity.NONE; |
| 218 } else { | 229 } else { |
| 219 // Process errors. | 230 // Process errors. |
| 220 _printErrors(outputPath: options.buildAnalysisOutput); | 231 _printErrors(outputPath: options.buildAnalysisOutput); |
| 221 return _computeMaxSeverity(); | 232 return _computeMaxSeverity(); |
| 222 } | 233 } |
| 223 } | 234 } |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 'Illegal input file (must be "\$uri|\$path"): $sourceFile'); | 382 'Illegal input file (must be "\$uri|\$path"): $sourceFile'); |
| 372 return null; | 383 return null; |
| 373 } | 384 } |
| 374 Uri uri = Uri.parse(sourceFile.substring(0, pipeIndex)); | 385 Uri uri = Uri.parse(sourceFile.substring(0, pipeIndex)); |
| 375 String path = sourceFile.substring(pipeIndex + 1); | 386 String path = sourceFile.substring(pipeIndex + 1); |
| 376 uriToFileMap[uri] = new JavaFile(path); | 387 uriToFileMap[uri] = new JavaFile(path); |
| 377 } | 388 } |
| 378 return uriToFileMap; | 389 return uriToFileMap; |
| 379 } | 390 } |
| 380 } | 391 } |
| OLD | NEW |