Skip to content

Remove some unused fields from ElementType #3558

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
Oct 30, 2023
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
12 changes: 4 additions & 8 deletions lib/src/element_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -283,25 +283,21 @@ abstract class DefinedElementType extends ElementType {
f as ParameterizedType, library, packageGraph, modelElement);
}

Element get element => modelElement.element;

@override
String get name => type.documentableElement!.name!;

@override
String get fullyQualifiedName => modelElement.fullyQualifiedName;

bool get isParameterType => type is TypeParameterType;

/// Whether the underlying, canonical element is public.
///
/// This avoids discarding the resolved type information as canonicalization
/// would ordinarily do.
@override
bool get isPublic {
var canonicalClass = modelElement.packageGraph
.findCanonicalModelElementFor(modelElement.element) ??
modelElement;
var canonicalClass =
packageGraph.findCanonicalModelElementFor(modelElement.element) ??
modelElement;
return canonicalClass.isPublic;
}

Expand Down Expand Up @@ -360,7 +356,7 @@ abstract class DefinedElementType extends ElementType {
@internal
@override
CommentReferable get definingCommentReferable =>
modelBuilder.fromElement(element);
modelBuilder.fromElement(modelElement.element);
}

/// Any callable [ElementType] will mix-in this class, whether anonymous or not,
Expand Down
19 changes: 0 additions & 19 deletions lib/src/generator/templates.runtime_renderers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3753,18 +3753,6 @@ class _Renderer_DefinedElementType extends RendererBase<DefinedElementType> {
CT_,
() => {
..._Renderer_ElementType.propertyMap<CT_>(),
'element': Property(
getValue: (CT_ c) => c.element,
renderVariable: (CT_ c, Property<CT_> self,
List<String> remainingNames) =>
self.renderSimpleVariable(c, remainingNames, 'Element'),
isNullValue: (CT_ c) => false,
renderValue: (CT_ c, RendererBase<CT_> r,
List<MustachioNode> ast, StringSink sink) {
renderSimple(c.element, ast, r.template, sink,
parent: r, getters: _invisibleGetters['Element']!);
},
),
'fullyQualifiedName': Property(
getValue: (CT_ c) => c.fullyQualifiedName,
renderVariable:
Expand Down Expand Up @@ -3799,13 +3787,6 @@ class _Renderer_DefinedElementType extends RendererBase<DefinedElementType> {
parent: r, getters: _invisibleGetters['DartType']!);
},
),
'isParameterType': Property(
getValue: (CT_ c) => c.isParameterType,
renderVariable: (CT_ c, Property<CT_> self,
List<String> remainingNames) =>
self.renderSimpleVariable(c, remainingNames, 'bool'),
getBool: (CT_ c) => c.isParameterType == true,
),
'isPublic': Property(
getValue: (CT_ c) => c.isPublic,
renderVariable: (CT_ c, Property<CT_> self,
Expand Down
23 changes: 12 additions & 11 deletions lib/src/model/inheriting_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -361,18 +361,19 @@ abstract class InheritingContainer extends Container
while (parent != null) {
typeChain.add(parent);
final parentType = parent.type;
if (parentType is InterfaceType) {
// Avoid adding [Object] to the [superChain] ([_supertype] already has
// this check).
if (parentType.superclass?.superclass == null) {
break;
} else {
parent = modelBuilder.typeFrom(parentType.superclass!, library)
as DefinedElementType?;
}
} else {
parent = (parent.modelElement as Class).supertype;
if (parentType is! InterfaceType) {
throw StateError('ancestor of $this is $parent with model element '
'${parent.modelElement}');
}

var superclass = parentType.superclass;
// Avoid adding [Object] to the [superChain] ([_supertype] already has
// this check).
if (superclass == null || superclass.superclass == null) {
break;
}
parent =
modelBuilder.typeFrom(superclass, library) as DefinedElementType?;
}
return typeChain;
}
Expand Down