| Index: pkg/analyzer/test/src/summary/summarize_ast_test.dart
|
| diff --git a/pkg/analyzer/test/src/summary/summarize_ast_test.dart b/pkg/analyzer/test/src/summary/summarize_ast_test.dart
|
| index d6210a69219a10f7236977239bf95e45abd84ad5..0a5b7408090a6c433df4ebf8025640a3d16ed97f 100644
|
| --- a/pkg/analyzer/test/src/summary/summarize_ast_test.dart
|
| +++ b/pkg/analyzer/test/src/summary/summarize_ast_test.dart
|
| @@ -16,6 +16,7 @@ import 'package:analyzer/src/generated/source.dart';
|
| import 'package:analyzer/src/summary/format.dart';
|
| import 'package:analyzer/src/summary/idl.dart';
|
| import 'package:analyzer/src/summary/link.dart';
|
| +import 'package:analyzer/src/summary/package_bundle_reader.dart';
|
| import 'package:analyzer/src/summary/summarize_ast.dart';
|
| import 'package:analyzer/src/summary/summarize_elements.dart';
|
| import 'package:unittest/unittest.dart';
|
| @@ -205,7 +206,7 @@ abstract class LinkedSummarizeAstTest extends SummaryLinkerTest
|
|
|
| @override
|
| void serializeLibraryText(String text, {bool allowErrors: false}) {
|
| - Map<String, UnlinkedUnitBuilder> uriToUnit = this.uriToUnit;
|
| + Map<String, UnlinkedUnitBuilder> uriToUnit = this._filesToLink.uriToUnit;
|
| LinkerInputs linkerInputs = createLinkerInputs(text);
|
| linked = link(linkerInputs.linkedLibraries, linkerInputs.getDependency,
|
| linkerInputs.getUnit, strongMode)[linkerInputs.testDartUri.toString()];
|
| @@ -288,23 +289,9 @@ class LinkerInputs {
|
| */
|
| abstract class SummaryLinkerTest {
|
| /**
|
| - * Map from absolute URI to the [UnlinkedUnit] for each compilation unit
|
| - * passed to [addNamedSource].
|
| - */
|
| - Map<String, UnlinkedUnitBuilder> uriToUnit = <String, UnlinkedUnitBuilder>{};
|
| -
|
| - /**
|
| - * Map from absolute URI to the [LinkedLibrary] for each compilation unit in a
|
| - * package bundle passed to [addBundle].
|
| + * Information about the files to be linked.
|
| */
|
| - Map<String, LinkedLibrary> _dependentLinkedLibraries =
|
| - <String, LinkedLibrary>{};
|
| -
|
| - /**
|
| - * Map from absolute URI to the [UnlinkedUnit] for each compilation unit in a
|
| - * package bundle passed to [addBundle].
|
| - */
|
| - Map<String, UnlinkedUnit> _dependentUnlinkedUnits = <String, UnlinkedUnit>{};
|
| + _FilesToLink _filesToLink = new _FilesToLink();
|
|
|
| /**
|
| * A test will set this to `true` if it contains `import`, `export`, or
|
| @@ -316,15 +303,8 @@ abstract class SummaryLinkerTest {
|
| * Add the given package bundle as a dependency so that it may be referenced
|
| * by the files under test.
|
| */
|
| - void addBundle(PackageBundle bundle) {
|
| - for (int i = 0; i < bundle.linkedLibraryUris.length; i++) {
|
| - _dependentLinkedLibraries[bundle.linkedLibraryUris[i]] =
|
| - bundle.linkedLibraries[i];
|
| - }
|
| - for (int i = 0; i < bundle.unlinkedUnitUris.length; i++) {
|
| - _dependentUnlinkedUnits[bundle.unlinkedUnitUris[i]] =
|
| - bundle.unlinkedUnits[i];
|
| - }
|
| + void addBundle(String path, PackageBundle bundle) {
|
| + _filesToLink.summaryDataStore.addBundle(path, bundle);
|
| }
|
|
|
| /**
|
| @@ -335,7 +315,7 @@ abstract class SummaryLinkerTest {
|
| CompilationUnit unit = _parseText(contents);
|
| List<int> lineStarts = StringUtilities.computeLineStarts(contents);
|
| UnlinkedUnitBuilder unlinkedUnit = serializeAstUnlinked(unit, lineStarts);
|
| - uriToUnit[absUri(filePath)] = unlinkedUnit;
|
| + _filesToLink.uriToUnit[absUri(filePath)] = unlinkedUnit;
|
| // Tests using SummaryLinkerTest don't actually need the returned
|
| // Source, so we can safely return `null`.
|
| return null;
|
| @@ -347,19 +327,16 @@ abstract class SummaryLinkerTest {
|
| List<int> lineStarts = StringUtilities.computeLineStarts(text);
|
| UnlinkedUnitBuilder unlinkedDefiningUnit =
|
| serializeAstUnlinked(unit, lineStarts);
|
| - uriToUnit[testDartUri.toString()] = unlinkedDefiningUnit;
|
| + _filesToLink.uriToUnit[testDartUri.toString()] = unlinkedDefiningUnit;
|
| LinkerInputs linkerInputs = new LinkerInputs(
|
| allowMissingFiles,
|
| - uriToUnit,
|
| + _filesToLink.uriToUnit,
|
| testDartUri,
|
| unlinkedDefiningUnit,
|
| - _dependentLinkedLibraries,
|
| - _dependentUnlinkedUnits);
|
| - // Reset uriToUnit, _dependentLinkedLibraries, and _dependentUnlinkedUnits
|
| - // in case the test needs to start a new package bundle.
|
| - uriToUnit = <String, UnlinkedUnitBuilder>{};
|
| - _dependentLinkedLibraries = <String, LinkedLibrary>{};
|
| - _dependentUnlinkedUnits = <String, UnlinkedUnit>{};
|
| + _filesToLink.summaryDataStore.linkedMap,
|
| + _filesToLink.summaryDataStore.unlinkedMap);
|
| + // Reset _filesToLink in case the test needs to start a new package bundle.
|
| + _filesToLink = new _FilesToLink();
|
| return linkerInputs;
|
| }
|
|
|
| @@ -397,3 +374,21 @@ abstract class SummaryLinkerTest {
|
| return parser.parseCompilationUnit(token);
|
| }
|
| }
|
| +
|
| +/**
|
| + * [_FilesToLink] stores information about a set of files to be linked together.
|
| + * This information is grouped into a class to allow it to be reset easily when
|
| + * [SummaryLinkerTest.createLinkerInputs] is called.
|
| + */
|
| +class _FilesToLink {
|
| + /**
|
| + * Map from absolute URI to the [UnlinkedUnit] for each compilation unit
|
| + * passed to [addNamedSource].
|
| + */
|
| + Map<String, UnlinkedUnitBuilder> uriToUnit = <String, UnlinkedUnitBuilder>{};
|
| +
|
| + /**
|
| + * Information about summaries to be included in the link process.
|
| + */
|
| + SummaryDataStore summaryDataStore = new SummaryDataStore([]);
|
| +}
|
|
|