Skip to content

Typedef implements ModelFunctionTyped. #2376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 8 additions & 16 deletions lib/src/model/model_function.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@ class ModelFunction extends ModelFunctionTyped with Categorization {
: super(element, library, packageGraph);

@override
bool get isStatic {
return _func.isStatic;
}
bool get isStatic => element.isStatic;

@override
String get name => element.name ?? '';

@override
FunctionElement get _func => (element as FunctionElement);
FunctionElement get element => super.element;
}

/// A [ModelElement] for a [FunctionTypedElement] that is part of an
Expand All @@ -39,19 +37,15 @@ class ModelFunctionTyped extends ModelElement
with TypeParameters
implements EnclosedElement {
@override
List<TypeParameter> typeParameters = [];
final List<TypeParameter> typeParameters;

ModelFunctionTyped(
FunctionTypedElement element, Library library, PackageGraph packageGraph)
: super(element, library, packageGraph, null) {
_calcTypeParameters();
}

void _calcTypeParameters() {
typeParameters = _func.typeParameters.map((f) {
return ModelElement.from(f, library, packageGraph) as TypeParameter;
}).toList();
}
: typeParameters = <TypeParameter>[
for (var p in element.typeParameters)
ModelElement.from(p, library, packageGraph),
],
super(element, library, packageGraph, null);

@override
ModelElement get enclosingElement => library;
Expand Down Expand Up @@ -79,6 +73,4 @@ class ModelFunctionTyped extends ModelElement

@override
DefinedElementType get modelType => super.modelType;

FunctionTypedElement get _func => (element as FunctionTypedElement);
}
5 changes: 3 additions & 2 deletions lib/src/model/top_level_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,14 @@ abstract class TopLevelContainer implements Nameable {
Iterable<Class> get publicExceptions =>
model_utils.filterNonPublic(exceptions);

Iterable<ModelFunction> get publicFunctions =>
Iterable<ModelFunctionTyped> get publicFunctions =>
model_utils.filterNonPublic(functions);

Iterable<Mixin> get publicMixins => model_utils.filterNonPublic(mixins);

Iterable<TopLevelVariable> get publicProperties =>
model_utils.filterNonPublic(properties);

Iterable<Typedef> get publicTypedefs => model_utils.filterNonPublic(typedefs);
Iterable<ModelFunctionTyped> get publicTypedefs =>
model_utils.filterNonPublic(typedefs);
}
4 changes: 3 additions & 1 deletion lib/src/model/typedef.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:dartdoc/src/render/typedef_renderer.dart';

class Typedef extends ModelElement
with TypeParameters, Categorization
implements EnclosedElement {
implements EnclosedElement, ModelFunctionTyped {
Typedef(FunctionTypeAliasElement element, Library library,
PackageGraph packageGraph)
: super(element, library, packageGraph, null);
Expand Down Expand Up @@ -44,11 +44,13 @@ class Typedef extends ModelElement
}

// Food for mustache.
@override
bool get isInherited => false;

@override
String get kind => 'typedef';

@override
String get linkedReturnType => modelType.createLinkedReturnTypeName();

@override
Expand Down