@@ -1988,6 +1988,10 @@ abstract class ModelElement extends Nameable
1988
1988
newModelElement = new Parameter (e, library);
1989
1989
}
1990
1990
}
1991
+ // TODO(jcollins-g): Consider subclass for ModelFunctionTyped.
1992
+ if (e is GenericFunctionTypeElement ) {
1993
+ newModelElement = new ModelFunctionTyped (e, library);
1994
+ }
1991
1995
if (newModelElement == null ) throw "Unknown type ${e .runtimeType }" ;
1992
1996
if (enclosingClass != null ) assert (newModelElement is Inheritable );
1993
1997
if (library != null ) {
@@ -2097,7 +2101,8 @@ abstract class ModelElement extends Nameable
2097
2101
return md.map ((dynamic a) {
2098
2102
String annotation = (const HtmlEscape ()).convert (a.toSource ());
2099
2103
// 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);
2101
2106
if (me != null )
2102
2107
annotation = annotation.replaceFirst (me.name, me.linkedName);
2103
2108
return annotation;
@@ -2127,7 +2132,7 @@ abstract class ModelElement extends Nameable
2127
2132
}
2128
2133
2129
2134
bool get canHaveParameters =>
2130
- element is ExecutableElement || element is FunctionTypeAliasElement ;
2135
+ element is ExecutableElement || element is FunctionTypedElement ;
2131
2136
2132
2137
/// Returns the docs, stripped of their leading comments syntax.
2133
2138
ModelElement _documentationFrom;
@@ -2503,13 +2508,8 @@ abstract class ModelElement extends Nameable
2503
2508
2504
2509
List <ParameterElement > params;
2505
2510
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;
2513
2513
}
2514
2514
2515
2515
_parameters = new UnmodifiableListView <Parameter >(params
@@ -2866,12 +2866,25 @@ abstract class ModelElement extends Nameable
2866
2866
}
2867
2867
}
2868
2868
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
2870
2883
with SourceCodeMixin
2871
2884
implements EnclosedElement {
2872
2885
List <TypeParameter > typeParameters = [];
2873
2886
2874
- ModelFunction ( FunctionElement element, Library library)
2887
+ ModelFunctionTyped ( FunctionTypedElement element, Library library)
2875
2888
: super (element, library) {
2876
2889
_modelType = new ElementType (_func.type, this );
2877
2890
_calcTypeParameters ();
@@ -2901,9 +2914,6 @@ class ModelFunction extends ModelElement
2901
2914
return '${canonicalLibrary .dirName }/$fileName ' ;
2902
2915
}
2903
2916
2904
- @override
2905
- bool get isStatic => _func.isStatic;
2906
-
2907
2917
@override
2908
2918
String get kind => 'function' ;
2909
2919
@@ -2921,7 +2931,7 @@ class ModelFunction extends ModelElement
2921
2931
return '<${typeParameters .map ((t ) => t .name ).join (', ' )}>' ;
2922
2932
}
2923
2933
2924
- FunctionElement get _func => (element as FunctionElement );
2934
+ FunctionTypedElement get _func => (element as FunctionTypedElement );
2925
2935
}
2926
2936
2927
2937
/// Something that has a name.
@@ -3938,7 +3948,14 @@ class Parameter extends ModelElement implements EnclosedElement {
3938
3948
}
3939
3949
3940
3950
@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
+ }
3942
3959
3943
3960
bool get isOptional => _parameter.parameterKind.isOptional;
3944
3961
0 commit comments