Skip to content

Access to type using specific types and getters. #2283

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 1 commit into from
Aug 5, 2020
Merged
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
18 changes: 11 additions & 7 deletions lib/src/model/model_element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,7 @@ abstract class ModelElement extends Canonicalization
.renderLinkedParams(parameters, showMetadata: false, showNames: false);

ElementType get modelType {
var element = this.element;
if (_modelType == null) {
// TODO(jcollins-g): Need an interface for a "member with a type" (or changed object model).
if (_originalMember != null &&
Expand All @@ -962,13 +963,16 @@ abstract class ModelElement extends Canonicalization
_modelType = ElementType.from(
(_originalMember as ParameterMember).type, library, packageGraph);
}
} else if (element is ExecutableElement ||
element is FunctionTypedElement ||
element is ParameterElement ||
element is TypeDefiningElement ||
element is PropertyInducingElement) {
_modelType =
ElementType.from((element as dynamic).type, library, packageGraph);
} else if (element is ClassElement) {
_modelType = ElementType.from(element.thisType, library, packageGraph);
} else if (element is FunctionTypedElement) {
_modelType = ElementType.from(element.type, library, packageGraph);
} else if (element is ParameterElement) {
_modelType = ElementType.from(element.type, library, packageGraph);
} else if (element is PropertyInducingElement) {
_modelType = ElementType.from(element.type, library, packageGraph);
} else {
throw UnimplementedError('(${element.runtimeType}) $element');
}
}
return _modelType;
Expand Down