Index: pkg/analyzer_cli/lib/src/build_mode.dart |
diff --git a/pkg/analyzer_cli/lib/src/build_mode.dart b/pkg/analyzer_cli/lib/src/build_mode.dart |
index b68476b8b1a2c7d9d39d70c0612449e657d428dd..0fa7fa6d64e65beeb5cc8eeb0878d222d52d738b 100644 |
--- a/pkg/analyzer_cli/lib/src/build_mode.dart |
+++ b/pkg/analyzer_cli/lib/src/build_mode.dart |
@@ -199,9 +199,17 @@ class BuildMode { |
// Write summary. |
assembler = new PackageBundleAssembler(); |
if (_shouldOutputSummary) { |
- _serializeAstBasedSummary(explicitSources); |
+ if (options.buildSummaryOnlyUnlinked) { |
+ for (var src in explicitSources) { |
+ // Note: This adds the unit to the assembler if it needed to be |
+ // computed, so we don't need to explicitly do that. |
+ _unlinkedUnitForUri('${src.uri}'); |
+ } |
+ } else { |
+ _serializeAstBasedSummary(explicitSources); |
+ assembler.recordDependencies(summaryDataStore); |
+ } |
// Write the whole package bundle. |
- assembler.recordDependencies(summaryDataStore); |
PackageBundleBuilder bundle = assembler.assemble(); |
if (options.buildSummaryOutput != null) { |
io.File file = new io.File(options.buildSummaryOutput); |
@@ -350,38 +358,45 @@ class BuildMode { |
LinkedLibrary _getDependency(String absoluteUri) => |
summaryDataStore.linkedMap[absoluteUri]; |
- UnlinkedUnit _getUnit(String absoluteUri) { |
- // Maybe an input package contains the source. |
- { |
- UnlinkedUnit unlinkedUnit = summaryDataStore.unlinkedMap[absoluteUri]; |
- if (unlinkedUnit != null) { |
- return unlinkedUnit; |
- } |
- } |
- // Parse the source and serialize its AST. |
- Uri uri = Uri.parse(absoluteUri); |
- Source source = context.sourceFactory.forUri2(uri); |
- if (!source.exists()) { |
- // TODO(paulberry): we should report a warning/error because DDC |
- // compilations are unlikely to work. |
- return null; |
- } |
- return uriToUnit.putIfAbsent(uri, () { |
- CompilationUnit unit = context.computeResult(source, PARSED_UNIT); |
- UnlinkedUnitBuilder unlinkedUnit = serializeAstUnlinked(unit); |
- assembler.addUnlinkedUnit(source, unlinkedUnit); |
- return unlinkedUnit; |
- }); |
- } |
- |
Map<String, LinkedLibraryBuilder> linkResult = link( |
sourceUris, |
_getDependency, |
- _getUnit, |
+ _unlinkedUnitForUri, |
context.declaredVariables.get, |
options.strongMode); |
linkResult.forEach(assembler.addLinkedLibrary); |
} |
+ |
+ /** |
+ * Returns the [UnlinkedUnit] for [absoluteUri], either by computing it or |
+ * using the stored one in [uriToUnit]. |
+ * |
+ * If the [UnlinkedUnit] needed to be computed, it will also be added to the |
jakemac
2017/04/04 16:44:46
I don't really like this behavior, but I don't see
Paul Berry
2017/04/04 18:30:30
Actually what I would prefer is if we just compute
jakemac
2017/04/04 19:21:06
Acknowledged.
|
+ * [assembler]. |
+ */ |
+ UnlinkedUnit _unlinkedUnitForUri(String absoluteUri) { |
+ // Maybe an input package contains the source. |
+ { |
+ UnlinkedUnit unlinkedUnit = summaryDataStore.unlinkedMap[absoluteUri]; |
+ if (unlinkedUnit != null) { |
+ return unlinkedUnit; |
+ } |
+ } |
+ // Parse the source and serialize its AST. |
+ Uri uri = Uri.parse(absoluteUri); |
+ Source source = context.sourceFactory.forUri2(uri); |
+ if (!source.exists()) { |
+ // TODO(paulberry): we should report a warning/error because DDC |
+ // compilations are unlikely to work. |
+ return null; |
+ } |
+ return uriToUnit.putIfAbsent(uri, () { |
+ CompilationUnit unit = context.computeResult(source, PARSED_UNIT); |
+ UnlinkedUnitBuilder unlinkedUnit = serializeAstUnlinked(unit); |
+ assembler.addUnlinkedUnit(source, unlinkedUnit); |
+ return unlinkedUnit; |
+ }); |
+ } |
} |
/** |