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

adding static methods should not be breaking #182

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 .fvmrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"flutter": "3.19.5",
"flutter": "3.22.2",
"flavors": {}
}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Version 0.19.0
- introduces `force-use-flutter` option for all commands to force dart_apitool to use the `flutter` command.
- extend type usage tracking and fix situations in which types that are used in @visibleForTesting contexts were detected as not exported
- fix: don't treat adding static elements (methods, fields) or consts to a required interface as breaking

## Version 0.18.0
- add missing export to json output for `extract` command
Expand Down
17 changes: 14 additions & 3 deletions lib/src/analyze/package_api_analyzer.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ mixin _$FileToAnalyzeEntry {
List<String> get hiddenNames => throw _privateConstructorUsedError;
Set<String> get exportedBy => throw _privateConstructorUsedError;

@JsonKey(ignore: true)
/// Create a copy of _FileToAnalyzeEntry
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$FileToAnalyzeEntryCopyWith<_FileToAnalyzeEntry> get copyWith =>
throw _privateConstructorUsedError;
}
Expand Down Expand Up @@ -49,6 +51,8 @@ class __$FileToAnalyzeEntryCopyWithImpl<$Res, $Val extends _FileToAnalyzeEntry>
// ignore: unused_field
final $Res Function($Val) _then;

/// Create a copy of _FileToAnalyzeEntry
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Expand Down Expand Up @@ -101,6 +105,8 @@ class __$$_FileToAnalyzeEntryImplCopyWithImpl<$Res>
$Res Function(_$_FileToAnalyzeEntryImpl) _then)
: super(_value, _then);

/// Create a copy of _FileToAnalyzeEntry
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Expand Down Expand Up @@ -198,7 +204,9 @@ class _$_FileToAnalyzeEntryImpl implements __FileToAnalyzeEntry {
const DeepCollectionEquality().hash(_hiddenNames),
const DeepCollectionEquality().hash(_exportedBy));

@JsonKey(ignore: true)
/// Create a copy of _FileToAnalyzeEntry
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$_FileToAnalyzeEntryImplCopyWith<_$_FileToAnalyzeEntryImpl> get copyWith =>
Expand All @@ -221,8 +229,11 @@ abstract class __FileToAnalyzeEntry implements _FileToAnalyzeEntry {
List<String> get hiddenNames;
@override
Set<String> get exportedBy;

/// Create a copy of _FileToAnalyzeEntry
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
_$$_FileToAnalyzeEntryImplCopyWith<_$_FileToAnalyzeEntryImpl> get copyWith =>
throw _privateConstructorUsedError;
}
66 changes: 37 additions & 29 deletions lib/src/diff/package_api_differ.dart
Original file line number Diff line number Diff line change
Expand Up @@ -274,38 +274,44 @@ class PackageApiDiffer {
final changes = <ApiChange>[];
for (final oldEx in executableListDiff.matches.keys) {
final newEx = executableListDiff.matches[oldEx]!;
changes.addAll(_calculateExecutableDiff(
oldEx,
newEx,
context,
isInterfaceRequired: isInterfaceRequired,
isExperimental: newEx.isExperimental || isExperimental,
typeHierarchy: typeHierarchy,
));
changes.addAll(
_calculateExecutableDiff(
oldEx,
newEx,
context,
isInterfaceRequired: isInterfaceRequired,
isExperimental: newEx.isExperimental || isExperimental,
typeHierarchy: typeHierarchy,
),
);
}
for (final removedExecutable in executableListDiff.remainingOld) {
changes.add(ApiChange(
changeCode: ApiChangeCode.ce10,
affectedDeclaration: removedExecutable,
contextTrace: _contextTraceFromStack(context),
type: ApiChangeType.remove,
isExperimental: isExperimental,
changeDescription:
'${_getExecutableTypeName(removedExecutable.type, context.isNotEmpty)} "${removedExecutable.name}" removed',
));
changes.add(
ApiChange(
changeCode: ApiChangeCode.ce10,
affectedDeclaration: removedExecutable,
contextTrace: _contextTraceFromStack(context),
type: ApiChangeType.remove,
isExperimental: isExperimental,
changeDescription:
'${_getExecutableTypeName(removedExecutable.type, context.isNotEmpty)} "${removedExecutable.name}" removed',
),
);
}
for (final addedExecutable in executableListDiff.remainingNew) {
changes.add(ApiChange(
changeCode: ApiChangeCode.ce11,
affectedDeclaration: addedExecutable,
contextTrace: _contextTraceFromStack(context),
type: isInterfaceRequired ?? false
? ApiChangeType.addBreaking
: ApiChangeType.addCompatibleMinor,
isExperimental: isExperimental,
changeDescription:
'${_getExecutableTypeName(addedExecutable.type, context.isNotEmpty)} "${addedExecutable.name}" added${(isInterfaceRequired ?? false) ? ' (required)' : ''}',
));
changes.add(
ApiChange(
changeCode: ApiChangeCode.ce11,
affectedDeclaration: addedExecutable,
contextTrace: _contextTraceFromStack(context),
type: (isInterfaceRequired ?? false) && !addedExecutable.isStatic
? ApiChangeType.addBreaking
: ApiChangeType.addCompatibleMinor,
isExperimental: isExperimental,
changeDescription:
'${_getExecutableTypeName(addedExecutable.type, context.isNotEmpty)} "${addedExecutable.name}" added${(isInterfaceRequired ?? false) ? ' (required)' : ''}',
),
);
}
return changes;
}
Expand Down Expand Up @@ -823,7 +829,9 @@ class PackageApiDiffer {
changeCode: ApiChangeCode.cf02,
affectedDeclaration: addedField,
contextTrace: _contextTraceFromStack(context),
type: (isInterfaceRequired ?? false)
type: (isInterfaceRequired ?? false) &&
!addedField.isStatic &&
!addedField.isConst
? ApiChangeType.addBreaking
: ApiChangeType.addCompatibleMinor,
isExperimental: isExperimental,
Expand Down
76 changes: 48 additions & 28 deletions lib/src/model/executable_declaration.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ mixin _$ExecutableParameterDeclaration {
/// the relative path of the library
String get relativePath => throw _privateConstructorUsedError;

@JsonKey(ignore: true)
/// Create a copy of ExecutableParameterDeclaration
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$ExecutableParameterDeclarationCopyWith<ExecutableParameterDeclaration>
get copyWith => throw _privateConstructorUsedError;
}
Expand Down Expand Up @@ -75,6 +77,8 @@ class _$ExecutableParameterDeclarationCopyWithImpl<$Res,
// ignore: unused_field
final $Res Function($Val) _then;

/// Create a copy of ExecutableParameterDeclaration
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Expand Down Expand Up @@ -154,6 +158,8 @@ class __$$ExecutableParameterDeclarationImplCopyWithImpl<$Res>
$Res Function(_$ExecutableParameterDeclarationImpl) _then)
: super(_value, _then);

/// Create a copy of ExecutableParameterDeclaration
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Expand Down Expand Up @@ -288,7 +294,9 @@ class _$ExecutableParameterDeclarationImpl
typeFullLibraryName,
relativePath);

@JsonKey(ignore: true)
/// Create a copy of ExecutableParameterDeclaration
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ExecutableParameterDeclarationImplCopyWith<
Expand All @@ -311,40 +319,42 @@ abstract class _ExecutableParameterDeclaration
_$ExecutableParameterDeclarationImpl;
const _ExecutableParameterDeclaration._() : super._();

@override

/// whether the parameter is required
bool get isRequired;
@override
bool get isRequired;

/// whether the parameter is named
bool get isNamed;
@override
bool get isNamed;

/// the name of the parameter
String get name;
@override
String get name;

/// whether the parameter is deprecated
bool get isDeprecated;
@override
bool get isDeprecated;

/// whether the parameter is experimental
bool get isExperimental;
@override
bool get isExperimental;

/// type name of this parameter
String get typeName;
@override
String get typeName;

/// the type library path
String? get typeFullLibraryName;
@override
String? get typeFullLibraryName;

/// the relative path of the library
@override
String get relativePath;

/// Create a copy of ExecutableParameterDeclaration
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ExecutableParameterDeclarationImplCopyWith<
_$ExecutableParameterDeclarationImpl>
get copyWith => throw _privateConstructorUsedError;
Expand Down Expand Up @@ -385,7 +395,9 @@ mixin _$ExecutableDeclaration {
/// the relative path of the library
String get relativePath => throw _privateConstructorUsedError;

@JsonKey(ignore: true)
/// Create a copy of ExecutableDeclaration
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$ExecutableDeclarationCopyWith<ExecutableDeclaration> get copyWith =>
throw _privateConstructorUsedError;
}
Expand Down Expand Up @@ -421,6 +433,8 @@ class _$ExecutableDeclarationCopyWithImpl<$Res,
// ignore: unused_field
final $Res Function($Val) _then;

/// Create a copy of ExecutableDeclaration
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Expand Down Expand Up @@ -517,6 +531,8 @@ class __$$ExecutableDeclarationImplCopyWithImpl<$Res>
$Res Function(_$ExecutableDeclarationImpl) _then)
: super(_value, _then);

/// Create a copy of ExecutableDeclaration
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Expand Down Expand Up @@ -716,7 +732,9 @@ class _$ExecutableDeclarationImpl extends _ExecutableDeclaration {
const DeepCollectionEquality().hash(_entryPoints),
relativePath);

@JsonKey(ignore: true)
/// Create a copy of ExecutableDeclaration
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ExecutableDeclarationImplCopyWith<_$ExecutableDeclarationImpl>
Expand All @@ -739,50 +757,52 @@ abstract class _ExecutableDeclaration extends ExecutableDeclaration {
required final String relativePath}) = _$ExecutableDeclarationImpl;
const _ExecutableDeclaration._() : super._();

@override

/// name of the return type
String get returnTypeName;
@override // full library name of the return type
String? get returnTypeFullLibraryName;
@override
String get returnTypeName; // full library name of the return type
@override
String? get returnTypeFullLibraryName;

/// name of the executable
String get name;
@override
String get name;

/// whether the executable is deprecated
bool get isDeprecated;
@override
bool get isDeprecated;

/// whether the executable is experimental
bool get isExperimental;
@override
bool get isExperimental;

/// list of the executables parameters ([ExecutableOParameterDeclaration]s)
List<ExecutableParameterDeclaration> get parameters;
@override
List<ExecutableParameterDeclaration> get parameters;

/// type parameter names of this executable
List<String> get typeParameterNames;
@override
List<String> get typeParameterNames;

/// type of the executable
ExecutableType get type;
@override
ExecutableType get type;

/// whether the executable is a static method
bool get isStatic;
@override
bool get isStatic;

/// entry points for this executable
Set<String>? get entryPoints;
@override
Set<String>? get entryPoints;

/// the relative path of the library
@override
String get relativePath;

/// Create a copy of ExecutableDeclaration
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ExecutableDeclarationImplCopyWith<_$ExecutableDeclarationImpl>
get copyWith => throw _privateConstructorUsedError;
}
3 changes: 3 additions & 0 deletions lib/src/model/field_declaration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class FieldDeclaration with _$FieldDeclaration implements Declaration {
/// whether this field is static
required bool isStatic,

/// whether this field is a constant
required bool isConst,

/// whether this field is experimental
required bool isExperimental,

Expand Down
Loading
Loading