Compute export scopes for source libraries.
R=brianwilkerson@google.com, paulberry@google.com
Change-Id: Idd3ebaf6c17ed2744b9cfd8cf770e1fc0f3a42ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97680
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 6602462..d5b5c03 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -4552,6 +4552,12 @@
_unlinkedExportNonPublic = null,
super(null, offset);
+ ExportElementImpl.forLinkedNode(
+ LibraryElementImpl enclosing, LinkedNode linkedNode)
+ : _unlinkedExportPublic = null,
+ _unlinkedExportNonPublic = null,
+ super.forLinkedNode(enclosing, null, linkedNode);
+
/// Initialize using the given serialized information.
ExportElementImpl.forSerialized(this._unlinkedExportPublic,
this._unlinkedExportNonPublic, LibraryElementImpl enclosingLibrary)
@@ -4574,14 +4580,31 @@
}
@override
+ CompilationUnitElementImpl get enclosingUnit {
+ LibraryElementImpl enclosingLibrary = enclosingElement;
+ return enclosingLibrary._definingCompilationUnit;
+ }
+
+ @override
LibraryElement get exportedLibrary {
- if (_exportedLibrary == null) {
- if (_unlinkedExportNonPublic != null) {
- LibraryElementImpl library = enclosingElement as LibraryElementImpl;
- _exportedLibrary =
- library.resynthesizerContext.buildExportedLibrary(uri);
- }
+ if (_exportedLibrary != null) return _exportedLibrary;
+
+ if (linkedNode != null) {
+ var context = enclosingUnit.linkedContext;
+ var relativeUriStr = context.getStringContent(
+ linkedNode.uriBasedDirective_uri,
+ );
+ var relativeUri = Uri.parse(relativeUriStr);
+ var uri = resolveRelativeUri(librarySource.uri, relativeUri);
+ var elementFactory = context.bundleContext.elementFactory;
+ return _exportedLibrary = elementFactory.libraryOfUri('$uri');
}
+
+ if (_unlinkedExportNonPublic != null) {
+ LibraryElementImpl library = enclosingElement as LibraryElementImpl;
+ _exportedLibrary = library.resynthesizerContext.buildExportedLibrary(uri);
+ }
+
return _exportedLibrary;
}
@@ -4598,6 +4621,11 @@
@override
List<ElementAnnotation> get metadata {
+ if (linkedNode != null) {
+ if (_metadata != null) return _metadata;
+ var metadata = enclosingUnit.linkedContext.getMetadataOrEmpty(linkedNode);
+ return _metadata = _buildAnnotations2(enclosingUnit, metadata);
+ }
if (_metadata == null) {
if (_unlinkedExportNonPublic != null) {
return _metadata = _buildAnnotations(library.definingCompilationUnit,
@@ -6139,6 +6167,11 @@
@override
Namespace get exportNamespace {
+ if (linkedNode != null) {
+ if (_exportNamespace != null) return _exportNamespace;
+ var elements = linkedContext.bundleContext.elementFactory;
+ return _exportNamespace = elements.buildExportNamespace(source.uri);
+ }
if (resynthesizerContext != null) {
_exportNamespace ??= resynthesizerContext.buildExportNamespace();
}
@@ -6152,6 +6185,13 @@
@override
List<ExportElement> get exports {
if (_exports == null) {
+ if (linkedNode != null) {
+ return _exports = linkedNode.compilationUnit_directives
+ .where((node) => node.kind == LinkedNodeKind.exportDirective)
+ .map((node) {
+ return ExportElementImpl.forLinkedNode(this, node);
+ }).toList();
+ }
if (unlinkedDefiningUnit != null) {
List<UnlinkedExportNonPublic> unlinkedNonPublicExports =
unlinkedDefiningUnit.exports;
@@ -8446,7 +8486,11 @@
@override
String get name {
if (linkedNode != null) {
- return reference.name;
+ var name = reference.name;
+ if (isSetter) {
+ return '$name=';
+ }
+ return name;
}
if (serializedExecutable != null) {
return serializedExecutable.name;
diff --git a/pkg/analyzer/lib/src/summary2/builder/source_library_builder.dart b/pkg/analyzer/lib/src/summary2/builder/source_library_builder.dart
index 70ed1a0..3e6360f 100644
--- a/pkg/analyzer/lib/src/summary2/builder/source_library_builder.dart
+++ b/pkg/analyzer/lib/src/summary2/builder/source_library_builder.dart
@@ -9,7 +9,9 @@
import 'package:analyzer/src/summary/idl.dart';
import 'package:analyzer/src/summary2/ast_binary_writer.dart';
import 'package:analyzer/src/summary2/builder/prefix_builder.dart';
+import 'package:analyzer/src/summary2/combinator.dart';
import 'package:analyzer/src/summary2/declaration.dart';
+import 'package:analyzer/src/summary2/export.dart';
import 'package:analyzer/src/summary2/link.dart';
import 'package:analyzer/src/summary2/linked_unit_context.dart';
import 'package:analyzer/src/summary2/metadata_resolver.dart';
@@ -35,6 +37,8 @@
/// The export scope of the library.
final Scope exportScope = Scope.top();
+ final List<Export> exporters = [];
+
SourceLibraryBuilder(Linker linker, Uri uri, Reference reference,
LinkedNodeLibraryBuilder node)
: this._(linker, uri, reference, node, Scope.top());
@@ -43,8 +47,37 @@
this.linker, this.uri, this.reference, this.node, this.importScope)
: scope = Scope(importScope, <String, Declaration>{});
+ void addExporters() {
+ var unitContext = units[0].context;
+ for (var directive in units[0].node.compilationUnit_directives) {
+ if (directive.kind == LinkedNodeKind.exportDirective) {
+ var relativeUriStr = unitContext.getStringContent(
+ directive.uriBasedDirective_uri,
+ );
+ var relativeUri = Uri.parse(relativeUriStr);
+ var uri = resolveRelativeUri(this.uri, relativeUri);
+ var exported = linker.builders[uri];
+ if (exported != null) {
+ var combinatorNodeList = directive.namespaceDirective_combinators;
+ var combinators = combinatorNodeList.map((node) {
+ if (node.kind == LinkedNodeKind.showCombinator) {
+ var nodeList = node.showCombinator_shownNames;
+ var nameList = unitContext.getSimpleNameList(nodeList);
+ return Combinator.show(nameList);
+ } else {
+ var nodeList = node.hideCombinator_hiddenNames;
+ var nameList = unitContext.getSimpleNameList(nodeList);
+ return Combinator.hide(nameList);
+ }
+ }).toList();
+
+ exported.exporters.add(new Export(this, exported, combinators));
+ }
+ }
+ }
+ }
+
void addImportsToScope() {
- // TODO
var hasDartCore = false;
var unitContext = units[0].context;
for (var directive in units[0].node.compilationUnit_directives) {
@@ -148,7 +181,8 @@
var getter = getterRef.getChild(name);
scope.declare(name, Declaration(name, getter));
- if (!unit.context.isFinal(variable)) {
+ if (!unit.context.isConst(variable) &&
+ !unit.context.isFinal(variable)) {
var setter = setterRef.getChild(name);
scope.declare('$name=', Declaration(name, setter));
}
@@ -159,6 +193,12 @@
}
}
}
+ if ('$uri' == 'dart:core') {
+ scope.declare(
+ 'dynamic',
+ Declaration('dynamic', reference.getChild('dynamic')),
+ );
+ }
}
void addSyntheticConstructors() {
diff --git a/pkg/analyzer/lib/src/summary2/combinator.dart b/pkg/analyzer/lib/src/summary2/combinator.dart
new file mode 100644
index 0000000..5d7b20e
--- /dev/null
+++ b/pkg/analyzer/lib/src/summary2/combinator.dart
@@ -0,0 +1,16 @@
+// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class Combinator {
+ final bool isShow;
+ final Set<String> names;
+
+ Combinator(this.isShow, this.names);
+
+ Combinator.show(Iterable<String> names) : this(true, names.toSet());
+
+ Combinator.hide(Iterable<String> names) : this(false, names.toSet());
+
+ bool get isHide => !isShow;
+}
diff --git a/pkg/analyzer/lib/src/summary2/export.dart b/pkg/analyzer/lib/src/summary2/export.dart
new file mode 100644
index 0000000..c3237f7
--- /dev/null
+++ b/pkg/analyzer/lib/src/summary2/export.dart
@@ -0,0 +1,25 @@
+// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analyzer/src/summary2/builder/source_library_builder.dart';
+import 'package:analyzer/src/summary2/combinator.dart';
+import 'package:analyzer/src/summary2/declaration.dart';
+
+class Export {
+ final SourceLibraryBuilder exporter;
+ final SourceLibraryBuilder exported;
+ final List<Combinator> combinators;
+
+ Export(this.exporter, this.exported, this.combinators);
+
+ bool addToExportScope(String name, Declaration declaration) {
+ if (combinators != null) {
+ for (Combinator combinator in combinators) {
+ if (combinator.isShow && !combinator.names.contains(name)) return false;
+ if (combinator.isHide && combinator.names.contains(name)) return false;
+ }
+ }
+ return exporter.addToExportScope(name, declaration);
+ }
+}
diff --git a/pkg/analyzer/lib/src/summary2/link.dart b/pkg/analyzer/lib/src/summary2/link.dart
index 0845951..65fb784 100644
--- a/pkg/analyzer/lib/src/summary2/link.dart
+++ b/pkg/analyzer/lib/src/summary2/link.dart
@@ -95,6 +95,12 @@
_buildOutlines();
}
+ void _addExporters() {
+ for (var library in builders.values) {
+ library.addExporters();
+ }
+ }
+
void _addSyntheticConstructors() {
for (var library in builders.values) {
library.addSyntheticConstructors();
@@ -102,6 +108,7 @@
}
void _buildOutlines() {
+ _addExporters();
_computeLibraryScopes();
_addSyntheticConstructors();
_createTypeSystem();
@@ -111,14 +118,47 @@
}
void _computeLibraryScopes() {
+ var exporters = new Set<SourceLibraryBuilder>();
+ var exportees = new Set<SourceLibraryBuilder>();
+
for (var library in builders.values) {
library.addLocalDeclarations();
+ if (library.exporters.isNotEmpty) {
+ exportees.add(library);
+ for (var exporter in library.exporters) {
+ exporters.add(exporter.exporter);
+ }
+ }
}
for (var library in builders.values) {
library.buildInitialExportScope();
}
+ var both = new Set<SourceLibraryBuilder>();
+ for (var exported in exportees) {
+ if (exporters.contains(exported)) {
+ both.add(exported);
+ }
+ for (var export in exported.exporters) {
+ exported.exportScope.forEach(export.addToExportScope);
+ }
+ }
+
+ while (true) {
+ var hasChanges = false;
+ for (var exported in both) {
+ for (var export in exported.exporters) {
+ exported.exportScope.forEach((name, member) {
+ if (export.addToExportScope(name, member)) {
+ hasChanges = true;
+ }
+ });
+ }
+ }
+ if (!hasChanges) break;
+ }
+
for (var library in builders.values) {
library.addImportsToScope();
}
@@ -126,8 +166,6 @@
for (var library in builders.values) {
library.storeExportScope();
}
-
- // TODO(scheglov) process imports and exports
}
void _createTypeSystem() {
diff --git a/pkg/analyzer/lib/src/summary2/linked_element_factory.dart b/pkg/analyzer/lib/src/summary2/linked_element_factory.dart
index 7653ed6..980e032 100644
--- a/pkg/analyzer/lib/src/summary2/linked_element_factory.dart
+++ b/pkg/analyzer/lib/src/summary2/linked_element_factory.dart
@@ -5,6 +5,7 @@
import 'package:analyzer/dart/analysis/session.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/dart/element/element.dart';
+import 'package:analyzer/src/dart/resolver/scope.dart';
import 'package:analyzer/src/generated/engine.dart' show AnalysisContext;
import 'package:analyzer/src/summary/idl.dart';
import 'package:analyzer/src/summary2/linked_bundle_context.dart';
@@ -28,6 +29,18 @@
}
}
+ Namespace buildExportNamespace(Uri uri) {
+ var exportedNames = <String, Element>{};
+
+ var exportedReferences = exportsOfLibrary('$uri');
+ for (var exportedReference in exportedReferences) {
+ var element = elementOfReference(exportedReference);
+ exportedNames[element.name] = element;
+ }
+
+ return Namespace(exportedNames);
+ }
+
Element elementOfReference(Reference reference) {
if (reference.element != null) {
return reference.element;
@@ -90,9 +103,9 @@
return _function(enclosing, reference);
}
- if (parentName == '@getter') {
+ if (parentName == '@getter' || parentName == '@setter') {
var enclosing = elementOfReference(parent2);
- return _getter(enclosing, reference);
+ return _accessor(enclosing, reference);
}
if (parentName == '@method') {
@@ -126,6 +139,24 @@
throw StateError('Not found: $input');
}
+ PropertyAccessorElementImpl _accessor(
+ ElementImpl enclosing, Reference reference) {
+ if (enclosing is ClassElementImpl) {
+ enclosing.accessors;
+ // Requesting accessors sets elements for accessors and fields.
+ assert(reference.element != null);
+ return reference.element;
+ }
+ if (enclosing is CompilationUnitElementImpl) {
+ enclosing.accessors;
+ // Requesting accessors sets elements for accessors and variables.
+ assert(reference.element != null);
+ return reference.element;
+ }
+ // Only classes and units have accessors.
+ throw StateError('${enclosing.runtimeType}');
+ }
+
ClassElementImpl _class(
CompilationUnitElementImpl unit, Reference reference) {
if (reference.node == null) {
@@ -203,24 +234,6 @@
return reference.element;
}
- PropertyAccessorElementImpl _getter(
- ElementImpl enclosing, Reference reference) {
- if (enclosing is ClassElementImpl) {
- enclosing.accessors;
- // Requesting accessors sets elements for accessors and fields.
- assert(reference.element != null);
- return reference.element;
- }
- if (enclosing is CompilationUnitElementImpl) {
- enclosing.accessors;
- // Requesting accessors sets elements for accessors and variables.
- assert(reference.element != null);
- return reference.element;
- }
- // Only classes and units have accessors.
- throw StateError('${enclosing.runtimeType}');
- }
-
void _indexUnitDeclarations(CompilationUnitElementImpl unit) {
var context = unit.linkedContext;
var unitRef = unit.reference;
diff --git a/pkg/analyzer/lib/src/summary2/linked_unit_context.dart b/pkg/analyzer/lib/src/summary2/linked_unit_context.dart
index e6bf32c..1d50b06 100644
--- a/pkg/analyzer/lib/src/summary2/linked_unit_context.dart
+++ b/pkg/analyzer/lib/src/summary2/linked_unit_context.dart
@@ -129,6 +129,10 @@
return getTokenLexeme(node.simpleIdentifier_token);
}
+ List<String> getSimpleNameList(List<LinkedNode> nodeList) {
+ return nodeList.map(getSimpleName).toList();
+ }
+
int getSimpleOffset(LinkedNode node) {
return tokensContext.offset(node.simpleIdentifier_token);
}
diff --git a/pkg/analyzer/lib/src/summary2/reference.dart b/pkg/analyzer/lib/src/summary2/reference.dart
index c89239d..63db0be 100644
--- a/pkg/analyzer/lib/src/summary2/reference.dart
+++ b/pkg/analyzer/lib/src/summary2/reference.dart
@@ -48,6 +48,8 @@
bool get isClass => parent != null && parent.name == '@class';
+ bool get isDynamic => name == 'dynamic' && parent?.name == 'dart:core';
+
bool get isEnum => parent != null && parent.name == '@enum';
bool get isGenericTypeAlias => parent != null && parent.name == '@typeAlias';
diff --git a/pkg/analyzer/lib/src/summary2/reference_resolver.dart b/pkg/analyzer/lib/src/summary2/reference_resolver.dart
index 72ac0e4..021aff7 100644
--- a/pkg/analyzer/lib/src/summary2/reference_resolver.dart
+++ b/pkg/analyzer/lib/src/summary2/reference_resolver.dart
@@ -120,6 +120,8 @@
_nodeList(node.enumDeclaration_constants);
}
+ void _exportDirective(LinkedNodeBuilder node) {}
+
void _fieldDeclaration(LinkedNodeBuilder node) {
_node(node.fieldDeclaration_fields);
}
@@ -267,6 +269,8 @@
_enumDeclaration(node);
} else if (node.kind == LinkedNodeKind.enumConstantDeclaration) {
_enumConstantDeclaration(node);
+ } else if (node.kind == LinkedNodeKind.exportDirective) {
+ _exportDirective(node);
} else if (node.kind == LinkedNodeKind.fieldDeclaration) {
_fieldDeclaration(node);
} else if (node.kind == LinkedNodeKind.fieldFormalParameter) {
@@ -289,6 +293,8 @@
_libraryDirective(node);
} else if (node.kind == LinkedNodeKind.methodDeclaration) {
_methodDeclaration(node);
+ } else if (node.kind == LinkedNodeKind.partDirective) {
+ _partDirective(node);
} else if (node.kind == LinkedNodeKind.simpleFormalParameter) {
_simpleFormalParameter(node);
} else if (node.kind == LinkedNodeKind.topLevelVariableDeclaration) {
@@ -318,6 +324,8 @@
}
}
+ void _partDirective(LinkedNodeBuilder node) {}
+
void _simpleFormalParameter(LinkedNodeBuilder node) {
var typeNode = node.simpleFormalParameter_type;
if (typeNode != null) {
diff --git a/pkg/analyzer/lib/src/summary2/type_builder.dart b/pkg/analyzer/lib/src/summary2/type_builder.dart
index c2c6359..21a5e74 100644
--- a/pkg/analyzer/lib/src/summary2/type_builder.dart
+++ b/pkg/analyzer/lib/src/summary2/type_builder.dart
@@ -78,6 +78,10 @@
interfaceClass: referenceIndex,
interfaceTypeArguments: typeArguments,
);
+ } else if (reference.isDynamic) {
+ node.typeName_type = LinkedNodeTypeBuilder(
+ kind: LinkedNodeTypeKind.dynamic_,
+ );
} else if (reference.isGenericTypeAlias) {
node.typeName_type = LinkedNodeTypeBuilder(
kind: LinkedNodeTypeKind.genericTypeAlias,
diff --git a/pkg/analyzer/test/src/summary/element_text.dart b/pkg/analyzer/test/src/summary/element_text.dart
index 9ff6b27..c13df24 100644
--- a/pkg/analyzer/test/src/summary/element_text.dart
+++ b/pkg/analyzer/test/src/summary/element_text.dart
@@ -55,6 +55,7 @@
void checkElementText(LibraryElement library, String expected,
{bool withCodeRanges: false,
bool withConstElements: true,
+ bool withExportScope: false,
bool withOffsets: false,
bool withSyntheticAccessors: false,
bool withSyntheticFields: false,
@@ -62,6 +63,7 @@
var writer = new _ElementWriter(
withCodeRanges: withCodeRanges,
withConstElements: withConstElements,
+ withExportScope: withExportScope,
withOffsets: withOffsets,
withSyntheticAccessors: withSyntheticAccessors,
withSyntheticFields: withSyntheticFields,
@@ -127,6 +129,7 @@
*/
class _ElementWriter {
final bool withCodeRanges;
+ final bool withExportScope;
final bool withOffsets;
final bool withConstElements;
final bool withSyntheticAccessors;
@@ -137,6 +140,7 @@
_ElementWriter(
{this.withCodeRanges,
this.withConstElements: true,
+ this.withExportScope: false,
this.withOffsets: false,
this.withSyntheticAccessors: false,
this.withSyntheticFields: false,
@@ -405,6 +409,8 @@
e.parts.forEach(writePartElement);
e.units.forEach(writeUnitElement);
+
+ writeExportScope(e);
}
void writeList<T>(String open, String close, List<T> items, String separator,
@@ -932,6 +938,22 @@
e.functions.forEach(writeFunctionElement);
}
+ void writeExportScope(LibraryElement e) {
+ if (!withExportScope) return;
+
+ buffer.writeln();
+ buffer.writeln('-' * 20);
+ buffer.writeln('Exports:');
+
+ var map = e.exportNamespace.definedNames;
+ var names = map.keys.toList()..sort();
+ for (var name in names) {
+ var element = map[name];
+ var elementLocationStr = _getElementLocationString(element);
+ buffer.writeln(' $name: $elementLocationStr');
+ }
+ }
+
void writeUri(Source source) {
if (source != null) {
Uri uri = source.uri;
diff --git a/pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart b/pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart
index 43d2c22..a5fa356 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart
@@ -35,6 +35,7 @@
{bool allowErrors = false, bool dumpSummaries = false}) async {
var dartCoreSource = sourceFactory.forUri('dart:core');
var dartAsyncSource = sourceFactory.forUri('dart:async');
+ var dartMathSource = sourceFactory.forUri('dart:math');
var dartCoreCode = getFile(dartCoreSource.fullName).readAsStringSync();
dartCoreCode = r'''
@@ -123,9 +124,21 @@
class FutureOr<T> {}
''';
+ var dartMathCode = r'''
+library dart.math;
+
+const double E = 2.718281828459045;
+const double PI = 3.1415926535897932;
+const double LN10 = 2.302585092994046;
+
+T min<T extends num>(T a, T b) => null;
+T max<T extends num>(T a, T b) => null;
+''';
+
var dartCoreResult = _link({
dartCoreSource: dartCoreCode,
dartAsyncSource: dartAsyncCode,
+ dartMathSource: dartMathCode,
});
var source = addTestSource(text);
@@ -761,24 +774,6 @@
@override
@failingTest
- test_export_class() async {
- await super.test_export_class();
- }
-
- @override
- @failingTest
- test_export_class_type_alias() async {
- await super.test_export_class_type_alias();
- }
-
- @override
- @failingTest
- test_export_configurations_useDefault() async {
- await super.test_export_configurations_useDefault();
- }
-
- @override
- @failingTest
test_export_configurations_useFirst() async {
await super.test_export_configurations_useFirst();
}
@@ -791,18 +786,6 @@
@override
@failingTest
- test_export_function() async {
- await super.test_export_function();
- }
-
- @override
- @failingTest
- test_export_getter() async {
- await super.test_export_getter();
- }
-
- @override
- @failingTest
test_export_hide() async {
await super.test_export_hide();
}
@@ -815,60 +798,18 @@
@override
@failingTest
- test_export_setter() async {
- await super.test_export_setter();
- }
-
- @override
- @failingTest
test_export_show() async {
await super.test_export_show();
}
@override
@failingTest
- test_export_typedef() async {
- await super.test_export_typedef();
- }
-
- @override
- @failingTest
- test_export_variable() async {
- await super.test_export_variable();
- }
-
- @override
- @failingTest
- test_export_variable_const() async {
- await super.test_export_variable_const();
- }
-
- @override
- @failingTest
- test_export_variable_final() async {
- await super.test_export_variable_final();
- }
-
- @override
- @failingTest
- test_exportImport_configurations_useDefault() async {
- await super.test_exportImport_configurations_useDefault();
- }
-
- @override
- @failingTest
test_exportImport_configurations_useFirst() async {
await super.test_exportImport_configurations_useFirst();
}
@override
@failingTest
- test_exports() async {
- await super.test_exports();
- }
-
- @override
- @failingTest
test_field_covariant() async {
await super.test_field_covariant();
}
@@ -953,12 +894,6 @@
@override
@failingTest
- test_function_entry_point_in_export() async {
- await super.test_function_entry_point_in_export();
- }
-
- @override
- @failingTest
test_function_entry_point_in_export_hidden() async {
await super.test_function_entry_point_in_export_hidden();
}
@@ -1232,12 +1167,6 @@
@override
@failingTest
- test_invalid_nameConflict_imported_exported() async {
- await super.test_invalid_nameConflict_imported_exported();
- }
-
- @override
- @failingTest
test_invalid_setterParameter_fieldFormalParameter() async {
await super.test_invalid_setterParameter_fieldFormalParameter();
}
@@ -1274,36 +1203,6 @@
@override
@failingTest
- test_main_class_alias_via_export() async {
- await super.test_main_class_alias_via_export();
- }
-
- @override
- @failingTest
- test_main_class_via_export() async {
- await super.test_main_class_via_export();
- }
-
- @override
- @failingTest
- test_main_getter_via_export() async {
- await super.test_main_getter_via_export();
- }
-
- @override
- @failingTest
- test_main_typedef_via_export() async {
- await super.test_main_typedef_via_export();
- }
-
- @override
- @failingTest
- test_main_variable_via_export() async {
- await super.test_main_variable_via_export();
- }
-
- @override
- @failingTest
test_member_function_async() async {
await super.test_member_function_async();
}
@@ -1430,18 +1329,6 @@
@override
@failingTest
- test_nameConflict_exportedAndLocal() async {
- await super.test_nameConflict_exportedAndLocal();
- }
-
- @override
- @failingTest
- test_nameConflict_exportedAndLocal_exported() async {
- await super.test_nameConflict_exportedAndLocal_exported();
- }
-
- @override
- @failingTest
test_nameConflict_exportedAndParted() async {
await super.test_nameConflict_exportedAndParted();
}
diff --git a/pkg/analyzer/test/src/summary/resynthesize_common.dart b/pkg/analyzer/test/src/summary/resynthesize_common.dart
index bb73374..b25064c 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_common.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_common.dart
@@ -4601,9 +4601,16 @@
test_export_class() async {
addLibrarySource('/a.dart', 'class C {}');
var library = await checkLibrary('export "a.dart";');
- checkElementText(library, r'''
+ checkElementText(
+ library,
+ r'''
export 'a.dart';
-''');
+
+--------------------
+Exports:
+ C: a.dart;C
+''',
+ withExportScope: true);
}
test_export_class_type_alias() async {
@@ -4613,9 +4620,16 @@
class _E {}
''');
var library = await checkLibrary('export "a.dart";');
- checkElementText(library, r'''
+ checkElementText(
+ library,
+ r'''
export 'a.dart';
-''');
+
+--------------------
+Exports:
+ C: a.dart;C
+''',
+ withExportScope: true);
}
test_export_configurations_useDefault() async {
@@ -4629,9 +4643,16 @@
if (dart.library.io) 'foo_io.dart'
if (dart.library.html) 'foo_html.dart';
''');
- checkElementText(library, r'''
+ checkElementText(
+ library,
+ r'''
export 'foo.dart';
-''');
+
+--------------------
+Exports:
+ A: foo.dart;A
+''',
+ withExportScope: true);
expect(library.exports[0].exportedLibrary.source.shortName, 'foo.dart');
}
@@ -4646,9 +4667,16 @@
if (dart.library.io) 'foo_io.dart'
if (dart.library.html) 'foo_html.dart';
''');
- checkElementText(library, r'''
+ checkElementText(
+ library,
+ r'''
export 'foo_io.dart';
-''');
+
+--------------------
+Exports:
+ A: foo_io.dart;A
+''',
+ withExportScope: true);
expect(library.exports[0].exportedLibrary.source.shortName, 'foo_io.dart');
}
@@ -4663,9 +4691,16 @@
if (dart.library.io) 'foo_io.dart'
if (dart.library.html) 'foo_html.dart';
''');
- checkElementText(library, r'''
+ checkElementText(
+ library,
+ r'''
export 'foo_html.dart';
-''');
+
+--------------------
+Exports:
+ A: foo_html.dart;A
+''',
+ withExportScope: true);
ExportElement export = library.exports[0];
expect(export.exportedLibrary.source.shortName, 'foo_html.dart');
}
@@ -4673,9 +4708,16 @@
test_export_function() async {
addLibrarySource('/a.dart', 'f() {}');
var library = await checkLibrary('export "a.dart";');
- checkElementText(library, r'''
+ checkElementText(
+ library,
+ r'''
export 'a.dart';
-''');
+
+--------------------
+Exports:
+ f: a.dart;f
+''',
+ withExportScope: true);
}
test_export_getter() async {
@@ -4690,67 +4732,130 @@
addLibrary('dart:async');
var library =
await checkLibrary('export "dart:async" hide Stream, Future;');
- checkElementText(library, r'''
+ checkElementText(
+ library,
+ r'''
export 'dart:async' hide Stream, Future;
-''');
+
+--------------------
+Exports:
+ Completer: dart:async;Completer
+ FutureOr: dart:async;FutureOr
+ StreamIterator: dart:async;dart:async/stream.dart;StreamIterator
+ StreamSubscription: dart:async;dart:async/stream.dart;StreamSubscription
+ StreamTransformer: dart:async;dart:async/stream.dart;StreamTransformer
+ Timer: dart:async;Timer
+''',
+ withExportScope: true);
}
test_export_multiple_combinators() async {
addLibrary('dart:async');
var library =
await checkLibrary('export "dart:async" hide Stream show Future;');
- checkElementText(library, r'''
+ checkElementText(
+ library,
+ r'''
export 'dart:async' hide Stream show Future;
-''');
+
+--------------------
+Exports:
+ Future: dart:async;Future
+''',
+ withExportScope: true);
}
test_export_setter() async {
addLibrarySource('/a.dart', 'void set f(value) {}');
var library = await checkLibrary('export "a.dart";');
- checkElementText(library, r'''
+ checkElementText(
+ library,
+ r'''
export 'a.dart';
-''');
+
+--------------------
+Exports:
+ f=: a.dart;f=
+''',
+ withExportScope: true);
}
test_export_show() async {
addLibrary('dart:async');
var library =
await checkLibrary('export "dart:async" show Future, Stream;');
- checkElementText(library, r'''
+ checkElementText(
+ library,
+ r'''
export 'dart:async' show Future, Stream;
-''');
+
+--------------------
+Exports:
+ Future: dart:async;Future
+ Stream: dart:async;dart:async/stream.dart;Stream
+''',
+ withExportScope: true);
}
test_export_typedef() async {
addLibrarySource('/a.dart', 'typedef F();');
var library = await checkLibrary('export "a.dart";');
- checkElementText(library, r'''
+ checkElementText(
+ library,
+ r'''
export 'a.dart';
-''');
+
+--------------------
+Exports:
+ F: a.dart;F
+''',
+ withExportScope: true);
}
test_export_variable() async {
addLibrarySource('/a.dart', 'var x;');
var library = await checkLibrary('export "a.dart";');
- checkElementText(library, r'''
+ checkElementText(
+ library,
+ r'''
export 'a.dart';
-''');
+
+--------------------
+Exports:
+ x: a.dart;x?
+ x=: a.dart;x=
+''',
+ withExportScope: true);
}
test_export_variable_const() async {
addLibrarySource('/a.dart', 'const x = 0;');
var library = await checkLibrary('export "a.dart";');
- checkElementText(library, r'''
+ checkElementText(
+ library,
+ r'''
export 'a.dart';
-''');
+
+--------------------
+Exports:
+ x: a.dart;x?
+''',
+ withExportScope: true);
}
test_export_variable_final() async {
addLibrarySource('/a.dart', 'final x = 0;');
var library = await checkLibrary('export "a.dart";');
- checkElementText(library, r'''
+ checkElementText(
+ library,
+ r'''
export 'a.dart';
-''');
+
+--------------------
+Exports:
+ x: a.dart;x?
+''',
+ withExportScope: true);
}
test_exportImport_configurations_useDefault() async {
@@ -4805,10 +4910,16 @@
addLibrarySource('/a.dart', 'library a;');
addLibrarySource('/b.dart', 'library b;');
var library = await checkLibrary('export "a.dart"; export "b.dart";');
- checkElementText(library, r'''
+ checkElementText(
+ library,
+ r'''
export 'a.dart';
export 'b.dart';
-''');
+
+--------------------
+Exports:
+''',
+ withExportScope: true);
}
test_expr_invalid_typeParameter_asPrefix() async {