| Index: pkg/analyzer/lib/src/task/dart.dart
|
| diff --git a/pkg/analyzer/lib/src/task/dart.dart b/pkg/analyzer/lib/src/task/dart.dart
|
| index 1fb498e39bb926fc55d0841a761f310e15f5eec6..f9e7705febc1ae21bb2e94b6ea19c0f83288e798 100644
|
| --- a/pkg/analyzer/lib/src/task/dart.dart
|
| +++ b/pkg/analyzer/lib/src/task/dart.dart
|
| @@ -889,10 +889,7 @@ class BuildPublicNamespaceTask extends SourceBasedAnalysisTask {
|
| @override
|
| void internalPerform() {
|
| LibraryElement library = getRequiredInput(BUILT_LIBRARY_ELEMENT_INPUT_NAME);
|
| -
|
| - NamespaceBuilder builder = new NamespaceBuilder();
|
| - Namespace namespace = builder.createPublicNamespaceForLibrary(library);
|
| -
|
| + Namespace namespace = new PublicNamespaceBuilder().build(library);
|
| outputs[PUBLIC_NAMESPACE] = namespace;
|
| }
|
|
|
| @@ -1169,6 +1166,45 @@ class ParseDartTask extends SourceBasedAnalysisTask {
|
| }
|
|
|
| /**
|
| + * The helper for building the public [Namespace] of a [LibraryElement].
|
| + */
|
| +class PublicNamespaceBuilder {
|
| + final HashMap<String, Element> definedNames = new HashMap<String, Element>();
|
| +
|
| + /**
|
| + * Build a public [Namespace] of the given [library].
|
| + */
|
| + Namespace build(LibraryElement library) {
|
| + definedNames.clear();
|
| + _addPublicNames(library.definingCompilationUnit);
|
| + library.parts.forEach(_addPublicNames);
|
| + return new Namespace(definedNames);
|
| + }
|
| +
|
| + /**
|
| + * Add the given [element] if it has a publicly visible name.
|
| + */
|
| + void _addIfPublic(Element element) {
|
| + String name = element.name;
|
| + if (name != null && !Scope.isPrivateName(name)) {
|
| + definedNames[name] = element;
|
| + }
|
| + }
|
| +
|
| + /**
|
| + * Add all of the public top-level names that are defined in the given
|
| + * [compilationUnit].
|
| + */
|
| + void _addPublicNames(CompilationUnitElement compilationUnit) {
|
| + compilationUnit.accessors.forEach(_addIfPublic);
|
| + compilationUnit.enums.forEach(_addIfPublic);
|
| + compilationUnit.functions.forEach(_addIfPublic);
|
| + compilationUnit.functionTypeAliases.forEach(_addIfPublic);
|
| + compilationUnit.types.forEach(_addIfPublic);
|
| + }
|
| +}
|
| +
|
| +/**
|
| * A task that scans the content of a file, producing a set of Dart tokens.
|
| */
|
| class ScanDartTask extends SourceBasedAnalysisTask {
|
|
|