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

Change all late final Iterable fields to Lists #3649

Merged
merged 2 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions lib/src/element_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class ParameterizedElementType extends DefinedElementType with Rendered {
packageGraph.rendererFactory.parameterizedElementTypeRenderer;

@override
late final Iterable<ElementType> typeArguments = type.typeArguments
late final List<ElementType> typeArguments = type.typeArguments
.map((f) => modelBuilder.typeFrom(f, library))
.toList(growable: false);
}
Expand All @@ -238,7 +238,7 @@ mixin Aliased implements ElementType, ModelBuilderInterface {
late final ModelElement aliasElement =
modelBuilder.fromElement(typeAliasElement);

late final Iterable<ElementType> aliasArguments = type.alias!.typeArguments
late final List<ElementType> aliasArguments = type.alias!.typeArguments
.map((f) => modelBuilder.typeFrom(f, library))
.toList(growable: false);
}
Expand Down Expand Up @@ -422,7 +422,7 @@ class CallableElementType extends DefinedElementType with Rendered, Callable {
packageGraph.rendererFactory.callableElementTypeRenderer;

@override
late final Iterable<ElementType> typeArguments = type.alias?.typeArguments
late final List<ElementType> typeArguments = type.alias?.typeArguments
.map((f) => modelBuilder.typeFrom(f, library))
.toList(growable: false) ??
const [];
Expand Down
2 changes: 1 addition & 1 deletion lib/src/model/container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ abstract class Container extends ModelElement
publicInstanceMethods.toList(growable: false)..sort();

@nonVirtual
late final Iterable<Operator> declaredOperators =
late final List<Operator> declaredOperators =
declaredMethods.whereType<Operator>().toList(growable: false);

@override
Expand Down
5 changes: 3 additions & 2 deletions lib/src/model/enum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ class Enum extends InheritingContainer
declaredFields.where((f) => f is! EnumField && f.isConst);

@override
late final Iterable<Field> publicEnumValues =
model_utils.filterNonPublic(allFields).whereType<EnumField>();
late final List<Field> publicEnumValues = model_utils
.filterNonPublic(allFields.whereType<EnumField>())
.toList(growable: false);

@override
bool get hasPublicEnumValues => publicEnumValues.isNotEmpty;
Expand Down
7 changes: 4 additions & 3 deletions lib/src/model/inheriting_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import 'package:meta/meta.dart';
/// Note that [Constructor]s are not considered to be modifiers so a
/// [hasModifiers] override is not necessary for this mixin.
mixin Constructable on InheritingContainer {
late final Iterable<Constructor> constructors = element.constructors
late final List<Constructor> constructors = element.constructors
.map((e) => modelBuilder.from(e, library) as Constructor)
.toList(growable: false);

Expand Down Expand Up @@ -246,8 +246,9 @@ abstract class InheritingContainer extends Container
}

@override
late final Iterable<Method> declaredMethods =
element.methods.map((e) => modelBuilder.from(e, library) as Method);
late final List<Method> declaredMethods = element.methods
.map((e) => modelBuilder.from(e, library) as Method)
.toList(growable: false);

@override
late final List<TypeParameter> typeParameters = element.typeParameters
Expand Down
28 changes: 14 additions & 14 deletions lib/src/model/library.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class Library extends ModelElement
/// documented with this library, but these ModelElements and names correspond
/// to the defining library where each originally came from with respect
/// to inheritance and reexporting. Most useful for error reporting.
late final Iterable<String> allOriginalModelElementNames =
late final List<String> allOriginalModelElementNames =
allModelElements.map((e) {
if (e is GetterSetterCombo) {
Accessor? getter;
Expand Down Expand Up @@ -142,13 +142,13 @@ class Library extends ModelElement
Iterable<Class> get classes => allClasses.where((c) => !c.isErrorOrException);

@override
late final Iterable<Extension> extensions = _exportedAndLocalElements
late final List<Extension> extensions = _exportedAndLocalElements
.whereType<ExtensionElement>()
.map((e) => modelBuilder.from(e, this) as Extension)
.toList(growable: false);

@override
late final Iterable<ExtensionType> extensionTypes = _exportedAndLocalElements
late final List<ExtensionType> extensionTypes = _exportedAndLocalElements
.whereType<ExtensionTypeElement>()
.map((e) => modelBuilder.from(e, this) as ExtensionType)
.toList(growable: false);
Expand Down Expand Up @@ -331,16 +331,16 @@ class Library extends ModelElement
// This code should not be used for Dart SDK libraries.
assert(!element.source.uri.isScheme('dart'));
var fullName = element.source.fullName;
if (!pathContext.isWithin(fullName, package.packagePath) &&
package.packagePath.contains('/google3/')) {
// In google3, `fullName` is specified as if the root of google3 was `/`.
// And `package.packagePath` contains the true google3 root.
var root = pathContext
.joinAll(pathContext.split(package.packagePath)..removeLast());
fullName = '$root$fullName';
}
var relativePath =
pathContext.relative(fullName, from: package.packagePath);
if (!pathContext.isWithin(fullName, package.packagePath) &&
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confess I don't know how the formatter got into this state...

package.packagePath.contains('/google3/')) {
// In google3, `fullName` is specified as if the root of google3 was `/`.
// And `package.packagePath` contains the true google3 root.
var root = pathContext
.joinAll(pathContext.split(package.packagePath)..removeLast());
fullName = '$root$fullName';
}
var relativePath =
pathContext.relative(fullName, from: package.packagePath);
assert(relativePath.startsWith('lib${pathContext.separator}'));
const libDirectoryLength = 'lib/'.length;
return relativePath.substring(libDirectoryLength);
Expand All @@ -355,7 +355,7 @@ class Library extends ModelElement

/// All variables ("properties") except constants.
@override
late final Iterable<TopLevelVariable> properties =
late final List<TopLevelVariable> properties =
_variables.where((v) => !v.isConst).toList(growable: false);

@override
Expand Down
4 changes: 2 additions & 2 deletions lib/src/model/package_graph.dart
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder {
}

@visibleForTesting
late final Iterable<Library> libraries =
late final List<Library> libraries =
packages.expand((p) => p.libraries).toList(growable: false)..sort();

int get libraryCount => libraries.length;
Expand Down Expand Up @@ -905,7 +905,7 @@ class PackageGraph with CommentReferable, Nameable, ModelBuilder {
return allElements;
}

late final Iterable<ModelElement> allLocalModelElements = [
late final List<ModelElement> allLocalModelElements = [
for (var library in _localLibraries) ...library.allModelElements
];

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 @@ -57,19 +57,19 @@ 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 Iterable<Container> publicClassesSorted =
late final List<Container> publicClassesSorted =
publicClasses.toList(growable: false)..sort();

Iterable<Extension> get publicExtensions =>
model_utils.filterNonPublic(extensions);

late final Iterable<Extension> publicExtensionsSorted =
late final List<Extension> publicExtensionsSorted =
publicExtensions.toList(growable: false)..sort();

Iterable<ExtensionType> get publicExtensionTypes =>
model_utils.filterNonPublic(extensionTypes);

late final Iterable<ExtensionType> publicExtensionTypesSorted =
late final List<ExtensionType> publicExtensionTypesSorted =
publicExtensionTypes.toList(growable: false)..sort();

Iterable<TopLevelVariable> get publicConstants =>
Expand All @@ -80,34 +80,34 @@ mixin TopLevelContainer implements Nameable {

Iterable<Enum> get publicEnums => model_utils.filterNonPublic(enums);

late final Iterable<Enum> publicEnumsSorted =
publicEnums.toList(growable: false)..sort();
late final List<Enum> publicEnumsSorted = publicEnums.toList(growable: false)
..sort();

Iterable<Class> get _publicExceptions =>
model_utils.filterNonPublic(exceptions);

late final Iterable<Class> publicExceptionsSorted =
late final List<Class> publicExceptionsSorted =
_publicExceptions.toList(growable: false)..sort();

Iterable<ModelFunctionTyped> get publicFunctions =>
model_utils.filterNonPublic(functions!);

late final Iterable<ModelFunctionTyped> publicFunctionsSorted =
late final List<ModelFunctionTyped> publicFunctionsSorted =
publicFunctions.toList(growable: false)..sort();

Iterable<Mixin> get publicMixins => model_utils.filterNonPublic(mixins);

late final Iterable<Mixin> publicMixinsSorted =
late final List<Mixin> publicMixinsSorted =
publicMixins.toList(growable: false)..sort();

Iterable<TopLevelVariable> get publicProperties =>
model_utils.filterNonPublic(properties);

late final Iterable<TopLevelVariable> publicPropertiesSorted =
late final List<TopLevelVariable> publicPropertiesSorted =
publicProperties.toList(growable: false)..sort();

Iterable<Typedef> get publicTypedefs => model_utils.filterNonPublic(typedefs);

late final Iterable<Typedef> publicTypedefsSorted =
late final List<Typedef> publicTypedefsSorted =
publicTypedefs.toList(growable: false)..sort();
}
Loading