Skip to content

Commit

Permalink
Remove unneeded 'anonymous' model and type
Browse files Browse the repository at this point in the history
  • Loading branch information
jcollins-g committed Dec 2, 2019
1 parent e2cef19 commit d0d2466
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 83 deletions.
39 changes: 3 additions & 36 deletions lib/src/element_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,32 +39,21 @@ abstract class ElementType extends Privacy {
if (f is FunctionType) {
assert(f is ParameterizedType);
if (isGenericTypeAlias) {
assert(element is! ModelFunctionAnonymous);
return CallableGenericTypeAliasElementType(
f, library, packageGraph, element, returnedFrom);
} else {
if (element is ModelFunctionAnonymous) {
return CallableAnonymousElementType(
f, library, packageGraph, element, returnedFrom);
} else {
assert(element is! ModelFunctionAnonymous);
return CallableElementType(
f, library, packageGraph, element, returnedFrom);
}
}
return CallableElementType(
f, library, packageGraph, element, returnedFrom);
} else if (isGenericTypeAlias) {
assert(f is TypeParameterType);
assert(element is! ModelFunctionAnonymous);
return GenericTypeAliasElementType(
f, library, packageGraph, element, returnedFrom);
}
if (f is TypeParameterType) {
assert(element is! ModelFunctionAnonymous);
return TypeParameterElementType(
f, library, packageGraph, element, returnedFrom);
}
assert(f is ParameterizedType);
assert(element is! ModelFunctionAnonymous);
return ParameterizedElementType(
f, library, packageGraph, element, returnedFrom);
}
Expand Down Expand Up @@ -329,10 +318,7 @@ abstract class CallableElementTypeMixin implements ParameterizedElementType {
dartTypeArguments = type.typeFormals.map(_legacyTypeParameterType);
}
} else {
DefinedElementType elementType = returnedFrom as DefinedElementType;
if (type.typeFormals.isEmpty &&
element is! ModelFunctionAnonymous &&
elementType?.element is! ModelFunctionAnonymous) {
if (type.typeFormals.isEmpty) {
dartTypeArguments = type.typeArguments;
} else if (returnedFrom != null &&
returnedFrom.type.element is GenericFunctionTypeElement) {
Expand Down Expand Up @@ -384,25 +370,6 @@ class CallableElementType extends ParameterizedElementType
String get superLinkedName => super.linkedName;
}

/// This is an anonymous function using the generic function syntax (declared
/// literally with "Function").
class CallableAnonymousElementType extends CallableElementType {
CallableAnonymousElementType(FunctionType t, Library library,
PackageGraph packageGraph, ModelElement element, ElementType returnedFrom)
: super(t, library, packageGraph, element, returnedFrom);
@override
String get name => 'Function';

@override
String get linkedName {
if (_linkedName == null) {
_linkedName =
CallableAnonymousElementTypeRendererHtml().renderLinkedName(this);
}
return _linkedName;
}
}

/// Types backed by a [GenericTypeAliasElement] that may or may not be callable.
abstract class GenericTypeAliasElementTypeMixin {}

Expand Down
28 changes: 0 additions & 28 deletions lib/src/model/model_function.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,6 @@ class ModelFunction extends ModelFunctionTyped with Categorization {
FunctionElement get _func => (element as FunctionElement);
}

/// A [ModelElement] for a [FunctionTypedElement] that is an
/// explicit typedef.
///
/// Distinct from ModelFunctionTypedef in that it doesn't
/// have a name, but we document it as "Function" to match how these are
/// written in declarations.
class ModelFunctionAnonymous extends ModelFunctionTyped {
ModelFunctionAnonymous(
FunctionTypedElement element, PackageGraph packageGraph)
: super(element, null, packageGraph);

@override
ModelElement get enclosingElement {
// These are not considered to be a part of libraries, so we can simply
// blindly instantiate a ModelElement for their enclosing element.
return ModelElement.fromElement(element.enclosingElement, packageGraph);
}

@override
String get name => 'Function';

@override
String get linkedName => 'Function';

@override
bool get isPublic => false;
}

/// A [ModelElement] for a [FunctionTypedElement] that is part of an
/// explicit typedef.
class ModelFunctionTypedef extends ModelFunctionTyped {
Expand Down
16 changes: 0 additions & 16 deletions lib/src/render/element_type_renderer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,3 @@ class CallableElementTypeRendererHtml
return buf.toString();
}
}

class CallableAnonymousElementTypeRendererHtml
extends ElementTypeRenderer<CallableAnonymousElementType> {
@override
String renderLinkedName(CallableAnonymousElementType elementType) {
StringBuffer buf = StringBuffer();
buf.write(elementType.returnType.linkedName);
buf.write(' ');
buf.write(elementType.superLinkedName);
buf.write('<span class="signature">(');
buf.write(ParameterRendererHtml()
.renderLinkedParams(elementType.element.parameters));
buf.write(')</span>');
return buf.toString();
}
}
1 change: 0 additions & 1 deletion lib/src/render/parameter_renderer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ abstract class ParameterRenderer {
if (showNames) {
buf.write(' ${parameterName(param.name)}');
} else if (paramModelType.isTypedef ||
paramModelType is CallableAnonymousElementType ||
paramModelType.type is FunctionType) {
buf.write(' ${parameterName(paramModelType.name)}');
}
Expand Down
2 changes: 0 additions & 2 deletions testing/test_package/lib/fake.dart
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,6 @@ functionUsingMixinReturningFunction() {
GenericClass<int> using = aMixinReturningFunction();
}

String Function(int) aFunctionReturningFunction() => (int i) => i.toString();

/// A super class, with many powers. Link to [Apple] from another library.
@deprecated
class SuperAwesomeClass {
Expand Down

0 comments on commit d0d2466

Please sign in to comment.