Skip to content
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

Convert many fields on Container and TopLevelContainer to getters #3710

Merged
merged 1 commit into from
Mar 9, 2024
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
2 changes: 1 addition & 1 deletion lib/src/generator/templates.runtime_renderers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14390,7 +14390,7 @@ class _Renderer_TopLevelContainer extends RendererBase<TopLevelContainer> {
renderVariable: (CT_ c, Property<CT_> self,
List<String> remainingNames) =>
self.renderSimpleVariable(
c, remainingNames, 'Iterable<TopLevelVariable>'),
c, remainingNames, 'List<TopLevelVariable>'),
renderIterable: (CT_ c, RendererBase<CT_> r,
List<MustachioNode> ast, StringSink sink) {
return c.publicConstantsSorted.map((e) =>
Expand Down
14 changes: 7 additions & 7 deletions lib/src/model/container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ abstract class Container extends ModelElement
@nonVirtual
bool get hasPublicInstanceMethods => instanceMethods.any((e) => e.isPublic);

late final List<Method> publicInstanceMethodsSorted =
List<Method> get publicInstanceMethodsSorted =>
instanceMethods.wherePublic.toList(growable: false)..sort();

@nonVirtual
Expand All @@ -113,7 +113,7 @@ abstract class Container extends ModelElement
bool get hasPublicInstanceOperators =>
instanceOperators.any((e) => e.isPublic);

late final List<Operator> publicInstanceOperatorsSorted =
List<Operator> get publicInstanceOperatorsSorted =>
instanceOperators.wherePublic.toList(growable: false)..sort();

/// Fields fully declared in this [Container].
Expand All @@ -128,14 +128,14 @@ abstract class Container extends ModelElement
@nonVirtual
bool get hasPublicInstanceFields => instanceFields.any((e) => e.isPublic);

late final List<Field> publicInstanceFieldsSorted =
List<Field> get publicInstanceFieldsSorted =>
instanceFields.wherePublic.toList(growable: false)..sort(byName);

Iterable<Field> get constantFields => declaredFields.where((f) => f.isConst);

bool get hasPublicConstantFields => constantFields.any((e) => e.isPublic);

late final List<Field> publicConstantFieldsSorted =
List<Field> get publicConstantFieldsSorted =>
constantFields.wherePublic.toList(growable: false)..sort(byName);

/// The total list of public enum values.
Expand Down Expand Up @@ -194,7 +194,7 @@ abstract class Container extends ModelElement

bool get hasPublicStaticFields => staticFields.any((e) => e.isPublic);

late final List<Field> publicStaticFieldsSorted =
List<Field> get publicStaticFieldsSorted =>
staticFields.wherePublic.toList(growable: false)..sort();

Iterable<Field> get staticFields => declaredFields.where((f) => f.isStatic);
Expand All @@ -205,15 +205,15 @@ abstract class Container extends ModelElement
bool get hasPublicVariableStaticFields =>
variableStaticFields.any((e) => e.isPublic);

late final List<Field> publicVariableStaticFieldsSorted =
List<Field> get publicVariableStaticFieldsSorted =>
variableStaticFields.wherePublic.toList(growable: false)..sort();

Iterable<Method> get staticMethods =>
declaredMethods.where((m) => m.isStatic);

bool get hasPublicStaticMethods => staticMethods.any((e) => e.isPublic);

late final List<Method> publicStaticMethodsSorted =
List<Method> get publicStaticMethodsSorted =>
staticMethods.wherePublic.toList(growable: false)..sort();

/// For subclasses to add items after the main pass but before the
Expand Down
20 changes: 10 additions & 10 deletions lib/src/model/top_level_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,33 +55,33 @@ mixin TopLevelContainer implements Nameable {
// TODO(jcollins-g): Setting this type parameter to `Container` magically
// fixes a number of type problems in the AOT compiler, but I am mystified as
// to why that should be the case.
late final List<Container> publicClassesSorted =
List<Container> get publicClassesSorted =>
classes.wherePublic.toList(growable: false)..sort();

late final List<Extension> publicExtensionsSorted =
List<Extension> get publicExtensionsSorted =>
extensions.wherePublic.toList(growable: false)..sort();

late final List<ExtensionType> publicExtensionTypesSorted =
List<ExtensionType> get publicExtensionTypesSorted =>
extensionTypes.wherePublic.toList(growable: false)..sort();

Iterable<TopLevelVariable> get publicConstantsSorted =>
List<TopLevelVariable> get publicConstantsSorted =>
constants.wherePublic.toList(growable: false)..sort();

late final List<Enum> publicEnumsSorted =
List<Enum> get publicEnumsSorted =>
enums.wherePublic.toList(growable: false)..sort();

late final List<Class> publicExceptionsSorted =
List<Class> get publicExceptionsSorted =>
exceptions.wherePublic.toList(growable: false)..sort();

late final List<ModelFunctionTyped> publicFunctionsSorted =
List<ModelFunctionTyped> get publicFunctionsSorted =>
functions.wherePublic.toList(growable: false)..sort();

late final List<Mixin> publicMixinsSorted =
List<Mixin> get publicMixinsSorted =>
mixins.wherePublic.toList(growable: false)..sort();

late final List<TopLevelVariable> publicPropertiesSorted =
List<TopLevelVariable> get publicPropertiesSorted =>
properties.wherePublic.toList(growable: false)..sort();

late final List<Typedef> publicTypedefsSorted =
List<Typedef> get publicTypedefsSorted =>
typedefs.wherePublic.toList(growable: false)..sort();
}