| Index: pkg/analyzer/lib/src/summary/prelink.dart
|
| diff --git a/pkg/analyzer/lib/src/summary/prelink.dart b/pkg/analyzer/lib/src/summary/prelink.dart
|
| index 5a1cc93d8880a486143c16c5b628fa46ac174a5e..bfa20ca561ca292e9fad6bbda2d5a1172ba68219 100644
|
| --- a/pkg/analyzer/lib/src/summary/prelink.dart
|
| +++ b/pkg/analyzer/lib/src/summary/prelink.dart
|
| @@ -3,6 +3,7 @@
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| import 'package:analyzer/src/summary/format.dart';
|
| +import 'package:analyzer/src/summary/name_filter.dart';
|
|
|
| /**
|
| * Create a [PrelinkedLibraryBuilder] corresponding to the given
|
| @@ -40,95 +41,6 @@ typedef UnlinkedPublicNamespace GetImportCallback(String relativeUri);
|
| typedef UnlinkedUnit GetPartCallback(String relativeUri);
|
|
|
| /**
|
| - * A [NameFilter] represents the set of filtering rules implied by zero or more
|
| - * combinators in an `export` or `import` statement.
|
| - */
|
| -class NameFilter {
|
| - /**
|
| - * A [NameFilter] representing no filtering at all (i.e. no combinators).
|
| - */
|
| - static final NameFilter identity =
|
| - new NameFilter._(hiddenNames: new Set<String>());
|
| -
|
| - /**
|
| - * If this [NameFilter] accepts a finite number of names and hides all
|
| - * others, the (possibly empty) set of names it accepts. Otherwise `null`.
|
| - */
|
| - final Set<String> shownNames;
|
| -
|
| - /**
|
| - * If [shownNames] is `null`, the (possibly empty) set of names not accepted
|
| - * by this filter (all other names are accepted). If [shownNames] is not
|
| - * `null`, then [hiddenNames] will be `null`.
|
| - */
|
| - final Set<String> hiddenNames;
|
| -
|
| - /**
|
| - * Create a [NameFilter] based on the given [combinator].
|
| - */
|
| - factory NameFilter.forCombinator(UnlinkedCombinator combinator) {
|
| - if (combinator.shows.isNotEmpty) {
|
| - return new NameFilter._(shownNames: combinator.shows.toSet());
|
| - } else {
|
| - return new NameFilter._(hiddenNames: combinator.hides.toSet());
|
| - }
|
| - }
|
| -
|
| - /**
|
| - * Create a [NameFilter] based on the given (possibly empty) sequence of
|
| - * [combinators].
|
| - */
|
| - factory NameFilter.forCombinators(List<UnlinkedCombinator> combinators) {
|
| - NameFilter result = identity;
|
| - for (UnlinkedCombinator combinator in combinators) {
|
| - result = result.merge(new NameFilter.forCombinator(combinator));
|
| - }
|
| - return result;
|
| - }
|
| -
|
| - const NameFilter._({this.shownNames, this.hiddenNames});
|
| -
|
| - /**
|
| - * Determine if the given [name] is accepted by this [NameFilter].
|
| - */
|
| - bool accepts(String name) {
|
| - if (name.endsWith('=')) {
|
| - name = name.substring(0, name.length - 1);
|
| - }
|
| - if (shownNames != null) {
|
| - return shownNames.contains(name);
|
| - } else {
|
| - return !hiddenNames.contains(name);
|
| - }
|
| - }
|
| -
|
| - /**
|
| - * Produce a new [NameFilter] by combining this [NameFilter] with another
|
| - * one. The new [NameFilter] will only accept names that would be accepted
|
| - * by both input filters.
|
| - */
|
| - NameFilter merge(NameFilter other) {
|
| - if (shownNames != null) {
|
| - if (other.shownNames != null) {
|
| - return new NameFilter._(
|
| - shownNames: shownNames.intersection(other.shownNames));
|
| - } else {
|
| - return new NameFilter._(
|
| - shownNames: shownNames.difference(other.hiddenNames));
|
| - }
|
| - } else {
|
| - if (other.shownNames != null) {
|
| - return new NameFilter._(
|
| - shownNames: other.shownNames.difference(hiddenNames));
|
| - } else {
|
| - return new NameFilter._(
|
| - hiddenNames: hiddenNames.union(other.hiddenNames));
|
| - }
|
| - }
|
| - }
|
| -}
|
| -
|
| -/**
|
| * A [_Meaning] stores all the information necessary to find the declaration
|
| * referred to by a name in a namespace.
|
| */
|
| @@ -290,7 +202,8 @@ class _Prelinker {
|
| }
|
| });
|
| chaseExports(
|
| - filter.merge(new NameFilter.forCombinators(export.combinators)),
|
| + filter.merge(
|
| + new NameFilter.forUnlinkedCombinators(export.combinators)),
|
| exportUri,
|
| seenUris);
|
| }
|
| @@ -347,7 +260,7 @@ class _Prelinker {
|
| void filterExportNamespace(String relativeUri,
|
| List<UnlinkedCombinator> combinators, Map<String, _Meaning> result) {
|
| Map<String, _Meaning> exportNamespace = computeExportNamespace(relativeUri);
|
| - NameFilter filter = new NameFilter.forCombinators(combinators);
|
| + NameFilter filter = new NameFilter.forUnlinkedCombinators(combinators);
|
| exportNamespace.forEach((String name, _Meaning meaning) {
|
| if (filter.accepts(name) && !result.containsKey(name)) {
|
| result[name] = meaning;
|
|
|