@@ -1988,6 +1988,10 @@ abstract class ModelElement extends Nameable
19881988 newModelElement = new Parameter (e, library);
19891989 }
19901990 }
1991+ // TODO(jcollins-g): Consider subclass for ModelFunctionTyped.
1992+ if (e is GenericFunctionTypeElement ) {
1993+ newModelElement = new ModelFunctionTyped (e, library);
1994+ }
19911995 if (newModelElement == null ) throw "Unknown type ${e .runtimeType }" ;
19921996 if (enclosingClass != null ) assert (newModelElement is Inheritable );
19931997 if (library != null ) {
@@ -2097,7 +2101,8 @@ abstract class ModelElement extends Nameable
20972101 return md.map ((dynamic a) {
20982102 String annotation = (const HtmlEscape ()).convert (a.toSource ());
20992103 // a.element can be null if the element can't be resolved.
2100- var me = package.findCanonicalModelElementFor (a.element? .enclosingElement);
2104+ var me =
2105+ package.findCanonicalModelElementFor (a.element? .enclosingElement);
21012106 if (me != null )
21022107 annotation = annotation.replaceFirst (me.name, me.linkedName);
21032108 return annotation;
@@ -2127,7 +2132,7 @@ abstract class ModelElement extends Nameable
21272132 }
21282133
21292134 bool get canHaveParameters =>
2130- element is ExecutableElement || element is FunctionTypeAliasElement ;
2135+ element is ExecutableElement || element is FunctionTypedElement ;
21312136
21322137 /// Returns the docs, stripped of their leading comments syntax.
21332138 ModelElement _documentationFrom;
@@ -2503,13 +2508,8 @@ abstract class ModelElement extends Nameable
25032508
25042509 List <ParameterElement > params;
25052510
2506- if (element is ExecutableElement ) {
2507- // the as check silences the warning
2508- params = (element as ExecutableElement ).parameters;
2509- }
2510-
2511- if (element is FunctionTypeAliasElement ) {
2512- params = (element as FunctionTypeAliasElement ).parameters;
2511+ if (element is FunctionTypedElement ) {
2512+ params = (element as FunctionTypedElement ).parameters;
25132513 }
25142514
25152515 _parameters = new UnmodifiableListView <Parameter >(params
@@ -2866,12 +2866,25 @@ abstract class ModelElement extends Nameable
28662866 }
28672867}
28682868
2869- class ModelFunction extends ModelElement
2869+ class ModelFunction extends ModelFunctionTyped {
2870+ ModelFunction (FunctionElement element, Library library)
2871+ : super (element, library);
2872+
2873+ @override
2874+ bool get isStatic {
2875+ return _func.isStatic;
2876+ }
2877+
2878+ @override
2879+ FunctionElement get _func => (element as FunctionElement );
2880+ }
2881+
2882+ class ModelFunctionTyped extends ModelElement
28702883 with SourceCodeMixin
28712884 implements EnclosedElement {
28722885 List <TypeParameter > typeParameters = [];
28732886
2874- ModelFunction ( FunctionElement element, Library library)
2887+ ModelFunctionTyped ( FunctionTypedElement element, Library library)
28752888 : super (element, library) {
28762889 _modelType = new ElementType (_func.type, this );
28772890 _calcTypeParameters ();
@@ -2901,9 +2914,6 @@ class ModelFunction extends ModelElement
29012914 return '${canonicalLibrary .dirName }/$fileName ' ;
29022915 }
29032916
2904- @override
2905- bool get isStatic => _func.isStatic;
2906-
29072917 @override
29082918 String get kind => 'function' ;
29092919
@@ -2921,7 +2931,7 @@ class ModelFunction extends ModelElement
29212931 return '<${typeParameters .map ((t ) => t .name ).join (', ' )}>' ;
29222932 }
29232933
2924- FunctionElement get _func => (element as FunctionElement );
2934+ FunctionTypedElement get _func => (element as FunctionTypedElement );
29252935}
29262936
29272937/// Something that has a name.
@@ -3938,7 +3948,14 @@ class Parameter extends ModelElement implements EnclosedElement {
39383948 }
39393949
39403950 @override
3941- String get htmlId => '${_parameter .enclosingElement .name }-param-${name }' ;
3951+ String get htmlId {
3952+ String enclosingName = _parameter.enclosingElement.name;
3953+ if (_parameter.enclosingElement is GenericFunctionTypeElement ) {
3954+ // TODO(jcollins-g): Drop when GenericFunctionTypeElement populates name.
3955+ enclosingName = _parameter.enclosingElement.enclosingElement.name;
3956+ }
3957+ return '${enclosingName }-param-${name }' ;
3958+ }
39423959
39433960 bool get isOptional => _parameter.parameterKind.isOptional;
39443961
0 commit comments