diff --git a/lib/src/model.dart b/lib/src/model.dart index d5b6d623c7..b7bb0da02c 100644 --- a/lib/src/model.dart +++ b/lib/src/model.dart @@ -38,8 +38,6 @@ import 'package:analyzer/src/dart/element/member.dart' import 'package:analyzer/src/dart/sdk/sdk.dart'; import 'package:analyzer/src/generated/engine.dart'; import 'package:analyzer/src/generated/java_io.dart'; -import 'package:analyzer/src/generated/resolver.dart' - show Namespace, NamespaceBuilder; import 'package:analyzer/src/generated/sdk.dart'; import 'package:analyzer/src/generated/source.dart'; import 'package:analyzer/src/generated/source_io.dart'; @@ -153,11 +151,14 @@ mixin Extendable on ContainerMember { mixin ContainerMember on ModelElement implements EnclosedElement { /// True if this [ContainerMember] is inherited from a different class. bool get isInherited; + /// True if this [ContainerMember] is overriding a superclass. bool get isOverride; + /// True if this [ContainerMember] has a parameter whose type is overridden /// by a subtype. bool get isCovariant; + /// True if this [ContainerMember] is from an applicable [Extension]. /// False otherwise, including if this [ContainerMember]'s [enclosingElement] /// is the extension it was declared in. @@ -391,8 +392,8 @@ class ContainerAccessor extends Accessor with ContainerMember, Inheritable { PackageGraph packageGraph) : super(element, library, packageGraph, null); - ContainerAccessor.inherited(PropertyAccessorElement element, - Library library, PackageGraph packageGraph, this._enclosingElement, + ContainerAccessor.inherited(PropertyAccessorElement element, Library library, + PackageGraph packageGraph, this._enclosingElement, {Member originalMember}) : super(element, library, packageGraph, originalMember) { _isInherited = true; @@ -539,7 +540,6 @@ class Accessor extends ModelElement implements EnclosedElement { @override bool get isCanonical => enclosingCombo.isCanonical; - @override String get href { return enclosingCombo.href; @@ -999,8 +999,8 @@ class Class extends Container }).toSet(); for (ExecutableElement e in inheritedMethodElements) { - Method m = - ModelElement.from(e, library, packageGraph, enclosingContainer: this); + Method m = ModelElement.from(e, library, packageGraph, + enclosingContainer: this); _inheritedMethods.add(m); } _inheritedMethods.sort(byName); @@ -1025,8 +1025,8 @@ class Class extends Container !operatorNames.contains(e.name)); }).toSet(); for (ExecutableElement e in inheritedOperatorElements) { - Operator o = - ModelElement.from(e, library, packageGraph, enclosingContainer: this); + Operator o = ModelElement.from(e, library, packageGraph, + enclosingContainer: this); _inheritedOperators.add(o); } _inheritedOperators.sort(byName); @@ -1357,7 +1357,8 @@ class Extension extends Container if (f.setter != null) { setter = ContainerAccessor(f.setter, library, packageGraph); } - return ModelElement.from(f, library, packageGraph, getter: getter, setter: setter) as Field; + return ModelElement.from(f, library, packageGraph, + getter: getter, setter: setter) as Field; }).toList(growable: false) ..sort(byName); @@ -2347,7 +2348,7 @@ class _HashableChildLibraryElementVisitor class Library extends ModelElement with Categorization, TopLevelContainer { List _variables; - Namespace _exportedNamespace; + List _exportedAndLocalElements; String _name; factory Library(LibraryElement element, PackageGraph packageGraph) { @@ -2367,11 +2368,39 @@ class Library extends ModelElement with Categorization, TopLevelContainer { _HashableChildLibraryElementVisitor((Element e) => packageGraph._populateModelNodeFor(e, _compilationUnitMap)) .visitElement(element); - _exportedNamespace = - NamespaceBuilder().createExportNamespaceForLibrary(element); + + // Initialize the list of elements defined in this library and + // exported via its export directives. + Set exportedAndLocalElements = _libraryElement + .exportNamespace + .definedNames + .values + .toSet(); + // TODO(jcollins-g): Consider switch to [_libraryElement.topLevelElements]. + exportedAndLocalElements + .addAll(getDefinedElements(_libraryElement.definingCompilationUnit)); + for (CompilationUnitElement cu in _libraryElement.parts) { + exportedAndLocalElements.addAll(getDefinedElements(cu)); + } + _exportedAndLocalElements = exportedAndLocalElements.toList(); + _package._allLibraries.add(this); } + static Iterable getDefinedElements( + CompilationUnitElement compilationUnit) { + return quiver.concat([ + compilationUnit.accessors, + compilationUnit.enums, + compilationUnit.extensions, + compilationUnit.functions, + compilationUnit.functionTypeAliases, + compilationUnit.mixins, + compilationUnit.topLevelVariables, + compilationUnit.types, + ]); + } + List _allOriginalModelElementNames; final Package _package; @@ -2418,14 +2447,16 @@ class Library extends ModelElement with Categorization, TopLevelContainer { @override CharacterLocation get characterLocation { if (element.nameOffset == -1) { - assert(isAnonymous, 'Only anonymous libraries are allowed to have no declared location'); + assert(isAnonymous, + 'Only anonymous libraries are allowed to have no declared location'); return CharacterLocation(1, 1); } return super.characterLocation; } @override - CompilationUnitElement get compilationUnitElement => (element as LibraryElement).definingCompilationUnit; + CompilationUnitElement get compilationUnitElement => + (element as LibraryElement).definingCompilationUnit; @override Iterable get classes => allClasses.where((c) => !c.isErrorOrException); @@ -2433,24 +2464,11 @@ class Library extends ModelElement with Categorization, TopLevelContainer { @override Iterable get extensions { if (_extensions == null) { - // De-dupe extensions coming from multiple exported libraries at once. - Set extensionElements = Set(); - extensionElements.addAll(_libraryElement.definingCompilationUnit.extensions); - for (CompilationUnitElement cu in _libraryElement.parts) { - extensionElements.addAll(cu.extensions); - } - for (LibraryElement le in _libraryElement.exportedLibraries) { - extensionElements.addAll(le.definingCompilationUnit.extensions - .where((t) => _exportedNamespace.definedNames.values.contains(t.name))); - } - - extensionElements.addAll(_exportedNamespace.definedNames.values - .whereType()); - - _extensions = extensionElements + _extensions = _exportedAndLocalElements + .whereType() .map((e) => ModelElement.from(e, this, packageGraph) as Extension) .toList(growable: false) - ..sort(byName); + ..sort(byName); } return _extensions; } @@ -2605,40 +2623,37 @@ class Library extends ModelElement with Categorization, TopLevelContainer { @override List get enums { - if (_enums != null) return _enums; - List enumClasses = []; - enumClasses.addAll(_exportedNamespace.definedNames.values - .whereType() - .where((element) => element.isEnum)); - _enums = enumClasses - .map((e) => ModelElement.from(e, this, packageGraph) as Enum) - .toList(growable: false) - ..sort(byName); - + if (_enums == null) { + _enums = _exportedAndLocalElements + .whereType() + .where((element) => element.isEnum) + .map((e) => ModelElement.from(e, this, packageGraph) as Enum) + .toList(growable: false) + ..sort(byName); + } return _enums; } @override List get mixins { - if (_mixins != null) return _mixins; - - /// Can not be [MixinElementImpl] because [ClassHandle]s are sometimes - /// returned from _exportedNamespace. - List mixinClasses = []; - mixinClasses.addAll(_exportedNamespace.definedNames.values - .whereType() - .where((ClassElement c) => c.isMixin)); - _mixins = mixinClasses - .map((e) => ModelElement.from(e, this, packageGraph) as Mixin) - .toList(growable: false) - ..sort(byName); + if (_mixins == null) { + /// Can not be [MixinElementImpl] because [ClassHandle]s are sometimes + /// returned from _exportedElements. + _mixins = _exportedAndLocalElements + .whereType() + .where((ClassElement c) => c.isMixin) + .map((e) => ModelElement.from(e, this, packageGraph) as Mixin) + .toList(growable: false) + ..sort(byName); + } return _mixins; } @override List get exceptions { if (_exceptions == null) { - _exceptions = allClasses.where((c) => c.isErrorOrException).toList(growable: false); + _exceptions = + allClasses.where((c) => c.isErrorOrException).toList(growable: false); } return _exceptions; } @@ -2648,21 +2663,13 @@ class Library extends ModelElement with Categorization, TopLevelContainer { @override List get functions { - if (_functions != null) return _functions; - - Set elements = Set(); - elements.addAll(_libraryElement.definingCompilationUnit.functions); - for (CompilationUnitElement cu in _libraryElement.parts) { - elements.addAll(cu.functions); + if (_functions == null) { + _functions = + _exportedAndLocalElements.whereType().map((e) { + return ModelElement.from(e, this, packageGraph) as ModelFunction; + }).toList(growable: false) + ..sort(byName); } - elements.addAll( - _exportedNamespace.definedNames.values.whereType()); - - _functions = elements.map((e) { - return ModelElement.from(e, this, packageGraph) as ModelFunction; - }).toList(growable: false) - ..sort(byName); - return _functions; } @@ -2742,49 +2749,25 @@ class Library extends ModelElement with Categorization, TopLevelContainer { @override List get typedefs { - if (_typedefs != null) return _typedefs; - - Set elements = Set(); - elements - .addAll(_libraryElement.definingCompilationUnit.functionTypeAliases); - for (CompilationUnitElement cu in _libraryElement.parts) { - elements.addAll(cu.functionTypeAliases); + if (_typedefs == null) { + _typedefs = _exportedAndLocalElements + .whereType() + .map((e) => ModelElement.from(e, this, packageGraph) as Typedef) + .toList(growable: false) + ..sort(byName); } - - elements.addAll(_exportedNamespace.definedNames.values - .whereType()); - _typedefs = elements - .map((e) => ModelElement.from(e, this, packageGraph) as Typedef) - .toList(growable: false) - ..sort(byName); - return _typedefs; } List get allClasses { - if (_classes != null) return _classes; - - // De-dupe classes coming from multiple exported libraries at once. - Set types = Set(); - types.addAll(_libraryElement.definingCompilationUnit.types); - for (CompilationUnitElement cu in _libraryElement.parts) { - types.addAll(cu.types); - } - for (LibraryElement le in _libraryElement.exportedLibraries) { - types.addAll(le.definingCompilationUnit.types - .where((t) => _exportedNamespace.definedNames.values.contains(t.name))); + if (_classes == null) { + _classes = _exportedAndLocalElements + .whereType() + .where((e) => !e.isMixin && !e.isEnum) + .map((e) => ModelElement.from(e, this, packageGraph) as Class) + .toList(growable: false) + ..sort(byName); } - - types.addAll(_exportedNamespace.definedNames.values - .whereType() - .where((e) => !e.isMixin && !e.isEnum)); - - _classes = types - .map((e) => ModelElement.from(e, this, packageGraph) as Class) - .toList(growable: false) - ..sort(byName); - - assert(!_classes.any((Class c) => c is Mixin)); return _classes; } @@ -2795,34 +2778,29 @@ class Library extends ModelElement with Categorization, TopLevelContainer { } List _getVariables() { - if (_variables != null) return _variables; - - Set elements = Set(); - elements.addAll(_libraryElement.definingCompilationUnit.topLevelVariables); - for (CompilationUnitElement cu in _libraryElement.parts) { - elements.addAll(cu.topLevelVariables); - } - _exportedNamespace.definedNames.values.forEach((element) { - if (element is PropertyAccessorElement) { - elements.add(element.variable); - } - }); - _variables = []; - for (TopLevelVariableElement element in elements) { - Accessor getter; - if (element.getter != null) { - getter = ModelElement.from(element.getter, this, packageGraph); - } - Accessor setter; - if (element.setter != null) { - setter = ModelElement.from(element.setter, this, packageGraph); + if (_variables == null) { + Set elements = _exportedAndLocalElements + .whereType() + .toSet(); + elements.addAll(_exportedAndLocalElements + .whereType() + .map((a) => a.variable)); + _variables = []; + for (TopLevelVariableElement element in elements) { + Accessor getter; + if (element.getter != null) { + getter = ModelElement.from(element.getter, this, packageGraph); + } + Accessor setter; + if (element.setter != null) { + setter = ModelElement.from(element.setter, this, packageGraph); + } + ModelElement me = ModelElement.from(element, this, packageGraph, + getter: getter, setter: setter); + _variables.add(me); } - ModelElement me = ModelElement.from(element, this, packageGraph, - getter: getter, setter: setter); - _variables.add(me); + _variables.sort(byName); } - - _variables.sort(byName); return _variables; } @@ -2973,8 +2951,8 @@ class Method extends ModelElement _calcTypeParameters(); } - Method.inherited(MethodElement element, this._enclosingContainer, Library library, - PackageGraph packageGraph, + Method.inherited(MethodElement element, this._enclosingContainer, + Library library, PackageGraph packageGraph, {Member originalMember}) : super(element, library, packageGraph, originalMember) { _isInherited = true; @@ -3835,8 +3813,10 @@ abstract class ModelElement extends Canonicalization if (!_characterLocationIsSet) { LineInfo lineInfo = compilationUnitElement.lineInfo; _characterLocationIsSet = true; - assert(element.nameOffset >= 0, 'Invalid location data for element: $fullyQualifiedName'); - assert(lineInfo != null, 'No lineInfo data available for element: $fullyQualifiedName'); + assert(element.nameOffset >= 0, + 'Invalid location data for element: $fullyQualifiedName'); + assert(lineInfo != null, + 'No lineInfo data available for element: $fullyQualifiedName'); if (element.nameOffset >= 0) { _characterLocation = lineInfo?.getLocation(element.nameOffset); } @@ -3844,7 +3824,8 @@ abstract class ModelElement extends Canonicalization return _characterLocation; } - CompilationUnitElement get compilationUnitElement => element.getAncestor((e) => e is CompilationUnitElement); + CompilationUnitElement get compilationUnitElement => + element.getAncestor((e) => e is CompilationUnitElement); bool get hasAnnotations => annotations.isNotEmpty; @@ -5347,8 +5328,7 @@ class PackageGraph { List messageParts = [warningMessage]; if (warnable != null) { - messageParts - .add("$warnablePrefix $warnableName: ${warnable.location}"); + messageParts.add("$warnablePrefix $warnableName: ${warnable.location}"); } if (referredFrom != null) { for (Locatable referral in referredFrom) { diff --git a/test/dartdoc_integration_test.dart b/test/dartdoc_integration_test.dart index bc289d041a..1007c41a34 100644 --- a/test/dartdoc_integration_test.dart +++ b/test/dartdoc_integration_test.dart @@ -232,26 +232,21 @@ void main() { }, timeout: Timeout.factor(2)); test('--footer-text excludes version', () async { - String _testPackagePath = - path.fromUri(_currentFileUri.resolve('../testing/test_package_options')); + String _testPackagePath = path + .fromUri(_currentFileUri.resolve('../testing/test_package_options')); - var args = [ - dartdocPath, - '--output', - tempDir.path - ]; + var args = [dartdocPath, '--output', tempDir.path]; await subprocessLauncher.runStreamed(Platform.resolvedExecutable, args, workingDirectory: _testPackagePath); File outFile = File(path.join(tempDir.path, 'index.html')); - RegExp footerRegex = RegExp('
(.*\s*?\n?)+?
', multiLine: true); + RegExp footerRegex = + RegExp('
(.*\s*?\n?)+?
', multiLine: true); // get footer, check for version number RegExpMatch m = footerRegex.firstMatch(outFile.readAsStringSync()); RegExp version = RegExp(r'(\d+\.)?(\d+\.)?(\*|\d+)'); expect(version.hasMatch(m.group(0)), false); }); - }, timeout: Timeout.factor(4)); } - diff --git a/test/dartdoc_test.dart b/test/dartdoc_test.dart index 078d3e8d70..d049533348 100644 --- a/test/dartdoc_test.dart +++ b/test/dartdoc_test.dart @@ -258,7 +258,7 @@ void main() { expect(p.name, 'test_package'); expect(p.hasDocumentationFile, isTrue); // Total number of public libraries in test_package. - expect(packageGraph.defaultPackage.publicLibraries, hasLength(15)); + expect(packageGraph.defaultPackage.publicLibraries, hasLength(16)); expect(packageGraph.localPackages.length, equals(1)); }); @@ -327,7 +327,7 @@ void main() { PackageGraph p = results.packageGraph; expect(p.defaultPackage.name, 'test_package'); expect(p.defaultPackage.hasDocumentationFile, isTrue); - expect(p.localPublicLibraries, hasLength(14)); + expect(p.localPublicLibraries, hasLength(15)); expect(p.localPublicLibraries.map((lib) => lib.name).contains('fake'), isFalse); }); diff --git a/test/model_test.dart b/test/model_test.dart index c2a076e218..42317ce34b 100644 --- a/test/model_test.dart +++ b/test/model_test.dart @@ -494,7 +494,7 @@ void main() { expect( packageGraph .localPackages.first.defaultCategory.publicLibraries.length, - equals(8)); + equals(9)); }); test('Verify libraries with multiple categories show up in multiple places', @@ -518,7 +518,7 @@ void main() { expect( packageGraph .localPackages.first.defaultCategory.publicLibraries.length, - equals(8)); + equals(9)); }); }); @@ -588,7 +588,7 @@ void main() { }); test('libraries', () { - expect(packageGraph.localPublicLibraries, hasLength(13)); + expect(packageGraph.localPublicLibraries, hasLength(14)); expect(interceptorsLib.isPublic, isFalse); }); @@ -603,7 +603,7 @@ void main() { Package package = packageGraph.localPackages.first; expect(package.name, 'test_package'); - expect(package.publicLibraries, hasLength(13)); + expect(package.publicLibraries, hasLength(14)); }); test('multiple packages, sorted default', () { @@ -696,7 +696,8 @@ void main() { // If EventTarget really does start implementing hashCode, this will // fail. expect(hashCode.href, equals('dart-core/Object/hashCode.html')); - expect(hashCode.canonicalEnclosingContainer, equals(objectModelElement)); + expect( + hashCode.canonicalEnclosingContainer, equals(objectModelElement)); expect( EventTarget.publicSuperChainReversed .any((et) => et.name == 'Interceptor'), @@ -720,13 +721,17 @@ void main() { isDeprecated, someLib, reexportOneLib, - reexportTwoLib; - Class SomeClass, SomeOtherClass, YetAnotherClass, AUnicornClass; + reexportTwoLib, + reexportThreeLib; + Class SomeClass, + SomeOtherClass, + YetAnotherClass, + AUnicornClass, + ADuplicateClass; setUpAll(() { dartAsyncLib = utils.testPackageGraphSdk.libraries .firstWhere((l) => l.name == 'dart:async'); - anonLib = packageGraph.libraries .firstWhere((lib) => lib.name == 'anonymous_library'); @@ -736,10 +741,13 @@ void main() { .firstWhere((lib) => lib.name == 'reexport_one'); reexportTwoLib = packageGraph.libraries .firstWhere((lib) => lib.name == 'reexport_two'); + reexportThreeLib = packageGraph.libraries + .firstWhere((lib) => lib.name == 'reexport_three'); SomeClass = someLib.getClassByName('SomeClass'); SomeOtherClass = someLib.getClassByName('SomeOtherClass'); YetAnotherClass = someLib.getClassByName('YetAnotherClass'); AUnicornClass = someLib.getClassByName('AUnicornClass'); + ADuplicateClass = reexportThreeLib.getClassByName('ADuplicateClass'); isDeprecated = packageGraph.libraries .firstWhere((lib) => lib.name == 'is_deprecated'); @@ -871,6 +879,10 @@ void main() { expect(SomeOtherClass.canonicalLibrary, reexportOneLib); expect(SomeClass.canonicalLibrary, reexportTwoLib); }); + + test('with correct show/hide behavior', () { + expect(ADuplicateClass.definingLibrary.name, equals('shadowing_lib')); + }); }); group('Macros', () { @@ -2125,40 +2137,62 @@ void main() { .firstWhere((lib) => lib.name == 'reexport_one'); reexportTwoLib = packageGraph.libraries .firstWhere((lib) => lib.name == 'reexport_two'); - documentOnceReexportOne = reexportOneLib.extensions.firstWhere((e) => e.name == 'DocumentThisExtensionOnce'); - documentOnceReexportTwo = reexportTwoLib.extensions.firstWhere((e) => e.name == 'DocumentThisExtensionOnce'); + documentOnceReexportOne = reexportOneLib.extensions + .firstWhere((e) => e.name == 'DocumentThisExtensionOnce'); + documentOnceReexportTwo = reexportTwoLib.extensions + .firstWhere((e) => e.name == 'DocumentThisExtensionOnce'); ext = exLibrary.extensions.firstWhere((e) => e.name == 'AppleExtension'); - extensionReferencer = exLibrary.classes.firstWhere((c) => c.name == 'ExtensionReferencer'); + extensionReferencer = + exLibrary.classes.firstWhere((c) => c.name == 'ExtensionReferencer'); fancyList = exLibrary.extensions.firstWhere((e) => e.name == 'FancyList'); - doSomeStuff = exLibrary.classes.firstWhere((c) => c.name == 'ExtensionUser') - .allInstanceMethods.firstWhere((m) => m.name == 'doSomeStuff'); - doStuff = exLibrary.extensions.firstWhere((e) => e.name == 'SimpleStringExtension') - .instanceMethods.firstWhere((m) => m.name == 'doStuff'); + doSomeStuff = exLibrary.classes + .firstWhere((c) => c.name == 'ExtensionUser') + .allInstanceMethods + .firstWhere((m) => m.name == 'doSomeStuff'); + doStuff = exLibrary.extensions + .firstWhere((e) => e.name == 'SimpleStringExtension') + .instanceMethods + .firstWhere((m) => m.name == 'doStuff'); extensions = exLibrary.publicExtensions.toList(); }); test('basic canonicalization for extensions', () { expect(documentOnceReexportOne.isCanonical, isFalse); - expect(documentOnceReexportOne.href, equals(documentOnceReexportTwo.href)); + expect( + documentOnceReexportOne.href, equals(documentOnceReexportTwo.href)); expect(documentOnceReexportTwo.isCanonical, isTrue); }); // TODO(jcollins-g): implement feature and update tests test('documentation links do not crash in base cases', () { - packageGraph.packageWarningCounter.hasWarning(doStuff, PackageWarning.notImplemented, + + packageGraph.packageWarningCounter.hasWarning( + doStuff, + PackageWarning.notImplemented, 'Comment reference resolution inside extension methods is not yet implemented'); - packageGraph.packageWarningCounter.hasWarning(doSomeStuff, PackageWarning.notImplemented, + packageGraph.packageWarningCounter.hasWarning( + doSomeStuff, + PackageWarning.notImplemented, 'Comment reference resolution inside extension methods is not yet implemented'); expect(doStuff.documentationAsHtml, contains('another')); - expect(doSomeStuff.documentationAsHtml, contains('String.extensionNumber')); + expect(doSomeStuff.documentationAsHtml, + contains('String.extensionNumber')); }); - test('references from outside an extension refer correctly to the extension', () { - expect(extensionReferencer.documentationAsHtml, contains('_Shhh')); - expect(extensionReferencer.documentationAsHtml, contains('FancyList')); - expect(extensionReferencer.documentationAsHtml, contains('AnExtension.call')); - expect(extensionReferencer.documentationAsHtml, contains('DocumentThisExtensionOnce')); + test( + 'references from outside an extension refer correctly to the extension', + () { + expect(extensionReferencer.documentationAsHtml, + contains('_Shhh')); + expect(extensionReferencer.documentationAsHtml, + contains('FancyList')); + expect(extensionReferencer.documentationAsHtml, + contains('AnExtension.call')); + expect( + extensionReferencer.documentationAsHtml, + contains( + 'DocumentThisExtensionOnce')); }); test('has a fully qualified name', () { @@ -2190,10 +2224,8 @@ void main() { }); test('extended type has generics', () { - expect( - fancyList.extendedType.nameWithGenerics, - equals( - 'List<Z>')); + expect(fancyList.extendedType.nameWithGenerics, + equals('List<Z>')); }); test('get methods', () { @@ -2231,7 +2263,8 @@ void main() { setUpAll(() { animal = exLibrary.enums.firstWhere((e) => e.name == 'Animal'); - animalToString = animal.allInstanceMethods.firstWhere((m) => m.name == 'toString'); + animalToString = + animal.allInstanceMethods.firstWhere((m) => m.name == 'toString'); /// Trigger code reference resolution animal.documentationAsHtml; @@ -2876,11 +2909,11 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, }); test('Fields always have line and column information', () { - expect(implicitGetterExplicitSetter.characterLocation, isNotNull); - expect(explicitGetterImplicitSetter.characterLocation, isNotNull); - expect(explicitGetterSetter.characterLocation, isNotNull); - expect(constField.characterLocation, isNotNull); - expect(aProperty.characterLocation, isNotNull); + expect(implicitGetterExplicitSetter.characterLocation, isNotNull); + expect(explicitGetterImplicitSetter.characterLocation, isNotNull); + expect(explicitGetterSetter.characterLocation, isNotNull); + expect(constField.characterLocation, isNotNull); + expect(aProperty.characterLocation, isNotNull); }); test('covariant fields are recognized', () { @@ -3387,7 +3420,10 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, Constructor appleConstructorFromString; Constructor constructorTesterDefault, constructorTesterFromSomething; Constructor syntheticConstructor; - Class apple, constCat, constructorTester, referToADefaultConstructor, + Class apple, + constCat, + constructorTester, + referToADefaultConstructor, withSyntheticConstructor; setUpAll(() { apple = exLibrary.classes.firstWhere((c) => c.name == 'Apple'); @@ -3405,7 +3441,8 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, .firstWhere((c) => c.name == 'ConstructorTester.fromSomething'); referToADefaultConstructor = fakeLibrary.classes .firstWhere((c) => c.name == 'ReferToADefaultConstructor'); - withSyntheticConstructor = exLibrary.classes.firstWhere((c) => c.name == 'WithSyntheticConstructor'); + withSyntheticConstructor = exLibrary.classes + .firstWhere((c) => c.name == 'WithSyntheticConstructor'); syntheticConstructor = withSyntheticConstructor.defaultConstructor; }); diff --git a/testing/test_package/lib/reexport_three.dart b/testing/test_package/lib/reexport_three.dart new file mode 100644 index 0000000000..10e4b1a399 --- /dev/null +++ b/testing/test_package/lib/reexport_three.dart @@ -0,0 +1,6 @@ +library reexport_three; + +// Test show/hide handling. +export 'src/shadowing_lib.dart' show ADuplicateClass; +// ignore: directives_ordering +export 'src/shadow_lib.dart' hide ADuplicateClass; diff --git a/testing/test_package/lib/reexport_two.dart b/testing/test_package/lib/reexport_two.dart index e922e8aed6..d69e151bdb 100644 --- a/testing/test_package/lib/reexport_two.dart +++ b/testing/test_package/lib/reexport_two.dart @@ -5,6 +5,6 @@ /// {@category Unreal} library reexport_two; -export 'src/somelib.dart'; - +// Intentionally create some duplicates via reexporting. export 'src/mixins.dart' show MixedIn, AMixin; +export 'src/somelib.dart'; diff --git a/testing/test_package/lib/src/shadow_lib.dart b/testing/test_package/lib/src/shadow_lib.dart new file mode 100644 index 0000000000..8afe83d6aa --- /dev/null +++ b/testing/test_package/lib/src/shadow_lib.dart @@ -0,0 +1,7 @@ +library shadow_lib; + +class ADuplicateClass { + bool get aCompletelyDifferentGetter => true; +} + +class SomeOtherClass {} diff --git a/testing/test_package/lib/src/shadowing_lib.dart b/testing/test_package/lib/src/shadowing_lib.dart new file mode 100644 index 0000000000..4e728dc58f --- /dev/null +++ b/testing/test_package/lib/src/shadowing_lib.dart @@ -0,0 +1,7 @@ +library shadowing_lib; + +class ADuplicateClass { + bool get aGetter => true; +} + +class SomeMoreClassDeclaration {} \ No newline at end of file diff --git a/testing/test_package/lib/src/somelib.dart b/testing/test_package/lib/src/somelib.dart index 075745e6f5..697ec1f2b6 100644 --- a/testing/test_package/lib/src/somelib.dart +++ b/testing/test_package/lib/src/somelib.dart @@ -8,7 +8,6 @@ class YetAnotherClass {} class AUnicornClass {} - /// A private extension. extension _Unseen on Object { void doYouSeeMe() { }