diff --git a/lib/dartdoc.dart b/lib/dartdoc.dart index f8c121dfa5..cf1a1a1aad 100644 --- a/lib/dartdoc.dart +++ b/lib/dartdoc.dart @@ -377,7 +377,7 @@ class Dartdoc { var links = doc.querySelectorAll('a'); var stringLinks = links .map((link) => link.attributes['href']) - .where((href) => href != null) + .where((href) => href != null && href != '') .toList(); return Tuple2(stringLinks, baseHref); diff --git a/lib/src/model/comment_referable.dart b/lib/src/model/comment_referable.dart index df55624d0c..d7696cfa0e 100644 --- a/lib/src/model/comment_referable.dart +++ b/lib/src/model/comment_referable.dart @@ -37,16 +37,9 @@ extension on Scope { /// [CommentReferable.referenceChildren] out of collections of other /// [CommmentReferable]s. extension CommentReferableEntryGenerators on Iterable { - /// Discards all entries that do not collide with [referable], - /// and generates an [MapEntry] using [referable]'s - /// [CommentReferable.referenceName] as a prefix for the item that does. - Iterable> onlyExplicitOnCollisionWith( - CommentReferable referable) => - where((r) => r.referenceName == referable.referenceName).map( - (r) => MapEntry('${referable.referenceName}.${r.referenceName}', r)); - - /// Like [onlyExplicitOnCollisionWith], except does not discard non-conflicting - /// items. + /// Creates ordinary references except if there is a conflict with + /// [referable], it will generate a [MapEntry] using [referable]'s + /// [CommentReferable.referenceName] as a prefix for the conflicting item. Iterable> explicitOnCollisionWith( CommentReferable referable) => map((r) { diff --git a/lib/src/model/getter_setter_combo.dart b/lib/src/model/getter_setter_combo.dart index 06f3a7c796..134cd6c045 100644 --- a/lib/src/model/getter_setter_combo.dart +++ b/lib/src/model/getter_setter_combo.dart @@ -244,12 +244,7 @@ mixin GetterSetterCombo on ModelElement { if (_referenceChildren == null) { _referenceChildren = {}; if (hasParameters) { - // Parameters in combos rarely matter for anything and are not part - // of the usual interface to a combo, so only reference them as part of - // [Container] fallbacks or if someone wants to explicitly specify a - // colliding parameter name. - _referenceChildren - .addEntries(parameters.onlyExplicitOnCollisionWith(this)); + _referenceChildren.addEntries(parameters.explicitOnCollisionWith(this)); } _referenceChildren .addEntries(modelType.typeArguments.explicitOnCollisionWith(this)); diff --git a/lib/src/model/parameter.dart b/lib/src/model/parameter.dart index a017f64d35..0d39fa89a4 100644 --- a/lib/src/model/parameter.dart +++ b/lib/src/model/parameter.dart @@ -13,7 +13,6 @@ class Parameter extends ModelElement implements EnclosedElement { ParameterElement element, Library library, PackageGraph packageGraph, {ParameterMember originalMember}) : super(element, library, packageGraph, originalMember); - String get defaultValue { if (!hasDefaultValue) return null; return element.defaultValueCode; @@ -85,17 +84,16 @@ class Parameter extends ModelElement implements EnclosedElement { Map get referenceChildren { if (_referenceChildren == null) { _referenceChildren = {}; - if (isCallable) { - _referenceChildren - .addEntriesIfAbsent(parameters.explicitOnCollisionWith(this)); + var _modelType = modelType; + if (_modelType is Callable) { + _referenceChildren.addEntriesIfAbsent( + _modelType.parameters.explicitOnCollisionWith(this)); } _referenceChildren.addEntriesIfAbsent( modelType.typeArguments.explicitOnCollisionWith(this)); - if (modelType is Callable) { - _referenceChildren.addEntriesIfAbsent((modelType as Callable) - .returnType - .typeArguments - .explicitOnCollisionWith(this)); + if (_modelType is Callable) { + _referenceChildren.addEntriesIfAbsent( + _modelType.returnType.typeArguments.explicitOnCollisionWith(this)); } } return _referenceChildren; diff --git a/test/end2end/model_test.dart b/test/end2end/model_test.dart index acdf6ac315..66552dc856 100644 --- a/test/end2end/model_test.dart +++ b/test/end2end/model_test.dart @@ -2363,7 +2363,8 @@ void main() { function1, topLevelFunction, aFunctionUsingRenamedLib; - TopLevelVariable incorrectDocReference, + TopLevelVariable aSetterWithFunctionParameter, + incorrectDocReference, incorrectDocReferenceFromEx, nameWithTwoUnderscores, nameWithSingleUnderscore, @@ -2392,6 +2393,7 @@ void main() { redHerring, yetAnotherName, somethingShadowyParameter; + Parameter fParam, fParamA, fParamB, fParamC; Field forInheriting, action, initializeMe, @@ -2515,9 +2517,32 @@ void main() { .firstWhere((m) => m.name == 'aMethod'); yetAnotherName = aMethod.allParameters.firstWhere((p) => p.name == 'yetAnotherName'); + + aSetterWithFunctionParameter = fakeLibrary.properties + .firstWhere((p) => p.name == 'aSetterWithFunctionParameter'); + fParam = aSetterWithFunctionParameter.parameters + .firstWhere((p) => p.name == 'fParam'); + fParamA = (fParam.modelType as Callable) + .parameters + .firstWhere((p) => p.name == 'fParamA'); + fParamB = (fParam.modelType as Callable) + .parameters + .firstWhere((p) => p.name == 'fParamB'); + fParamC = (fParam.modelType as Callable) + .parameters + .firstWhere((p) => p.name == 'fParamC'); }); group('Parameter references work properly', () { + test('via a setter with a function parameter', () { + expect(bothLookup(aSetterWithFunctionParameter, 'fParam.fParamA'), + equals(MatchingLinkResult(fParamA))); + expect(bothLookup(aSetterWithFunctionParameter, 'fParam.fParamB'), + equals(MatchingLinkResult(fParamB))); + expect(bothLookup(aSetterWithFunctionParameter, 'fParam.fParamC'), + equals(MatchingLinkResult(fParamC))); + }); + test('in class scope overridden by fields', () { expect(bothLookup(FactoryConstructorThings, 'aName'), equals(MatchingLinkResult(aNameField))); diff --git a/testing/test_package/lib/fake.dart b/testing/test_package/lib/fake.dart index 32565a8ec0..79c536d0dc 100644 --- a/testing/test_package/lib/fake.dart +++ b/testing/test_package/lib/fake.dart @@ -1306,4 +1306,8 @@ class TypeParameterThingsExtendedQ extends TypeParameterThings(String aParam, QTypeParam anotherParam) => null; -} \ No newline at end of file +} + +/// We should still be able to reference [fParam.fParamA], [fParam.fParamB], +/// and [fParam.fParamC]. +void set aSetterWithFunctionParameter(bool fParam(int fParamA, String fParamB, String fParamC)) {} \ No newline at end of file