Skip to content

Commit

Permalink
Merge pull request #1145 from rrousselGit/CI
Browse files Browse the repository at this point in the history
CI
  • Loading branch information
rrousselGit authored Jan 6, 2025
2 parents 306fc2e + 382597c commit 0a0ecee
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 118 deletions.
180 changes: 90 additions & 90 deletions packages/_internal/pubspec.lock

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions packages/freezed/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Unreleased path

Support analyzer 7.0.0

## 2.5.7 - 2024-07-15

- `freezed_annotation` upgraded to `2.4.4`
Expand Down
1 change: 0 additions & 1 deletion packages/freezed/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ linter:
- omit_local_variable_types
- only_throw_errors
- overridden_fields
- package_api_docs
- package_names
- package_prefixed_library_names
- prefer_adjacent_string_concatenation
Expand Down
7 changes: 6 additions & 1 deletion packages/freezed/lib/builder.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:build/build.dart';
import 'package:dart_style/dart_style.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:source_gen/source_gen.dart';

Expand All @@ -8,7 +9,11 @@ import 'src/freezed_generator.dart';
Builder freezed(BuilderOptions options) {
return PartBuilder(
[FreezedGenerator(Freezed.fromJson(options.config))],
formatOutput: options.config['format'] == false ? (str) => str : null,
formatOutput: (str, version) {
if (options.config['format'] == false) return str;

return DartFormatter(languageVersion: version).format(str);
},
'.freezed.dart',
header: '''
// coverage:ignore-file
Expand Down
6 changes: 3 additions & 3 deletions packages/freezed/lib/src/ast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extension ClassX on ClassDeclaration {
extension ConstructorX on ConstructorDeclaration {
String get fullName {
// ignore: deprecated_member_use, latest analyzer with enclosingElement3 not available in stable channel
final classElement = declaredElement!.enclosingElement;
final classElement = declaredElement!.enclosingElement3;

var generics =
classElement.typeParameters.map((e) => '\$${e.name}').join(', ');
Expand All @@ -66,14 +66,14 @@ extension ConstructorX on ConstructorDeclaration {
}

// ignore: deprecated_member_use, latest analyzer with enclosingElement3 not available in stable channel
final className = classElement.enclosingElement.name;
final className = classElement.enclosingElement3.name;

return name == null ? '$className$generics' : '$className$generics.$name';
}

String get escapedName {
// ignore: deprecated_member_use, latest analyzer with enclosingElement3 not available in stable channel
final classElement = declaredElement!.enclosingElement;
final classElement = declaredElement!.enclosingElement3;

var generics =
classElement.typeParameters.map((e) => '\$${e.name}').join(', ');
Expand Down
10 changes: 8 additions & 2 deletions packages/freezed/lib/src/tools/recursive_import_locator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,14 @@ extension FindAllAvailableTopLevelElements on LibraryElement {
yield* topLevelElements;

final librariesToCheck = checkExports
? libraryExports.map(_LibraryDirectives.fromExport).nonNulls
: libraryImports.map(_LibraryDirectives.fromImport).nonNulls;
? units
.expand((e) => e.libraryExports)
.map(_LibraryDirectives.fromExport)
.nonNulls
: units
.expand((e) => e.libraryImports)
.map(_LibraryDirectives.fromImport)
.nonNulls;

for (final directive in librariesToCheck) {
if (!visitedLibraryPaths.add(directive.key)) {
Expand Down
16 changes: 8 additions & 8 deletions packages/freezed/lib/src/tools/type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ String resolveFullTypeStringFrom(
LibraryElement originLibrary,
DartType type,
) {
final owner = originLibrary.prefixes.firstWhereOrNull(
(e) {
return e.imports.any((l) {
return l.importedLibrary!.anyTransitiveExport((library) {
return library.id == _getElementForType(type)?.library?.id;
});
final owner = originLibrary.units
.expand((e) => e.libraryImportPrefixes)
.firstWhereOrNull((e) {
return e.imports.any((l) {
return l.importedLibrary!.anyTransitiveExport((library) {
return library.id == _getElementForType(type)?.library?.id;
});
},
);
});
});

String? displayType = type.getDisplayString();

Expand Down
9 changes: 4 additions & 5 deletions packages/freezed/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ environment:
sdk: ">=3.0.0 <4.0.0"

dependencies:
analyzer: ">=6.5.0 <7.0.0"
analyzer: ">=7.0.0 <8.0.0"
build: ^2.3.1
build_config: ^1.1.0
collection: ^1.15.0
meta: ^1.9.1
source_gen: ^1.4.0
source_gen: ^2.0.0
freezed_annotation: ^2.4.4
json_annotation: ^4.8.0
# Indirect dependency, but fixes a compiler error when using `pub downgrade`
dart_style: ^2.3.6
dart_style: ^3.0.1

dev_dependencies:
json_serializable: ^6.3.2
Expand All @@ -28,4 +27,4 @@ dev_dependencies:
test: ^1.21.0
matcher: ^0.12.14
source_gen_test: ^1.0.6
expect_error: ^1.0.5
expect_error: ^1.0.8
4 changes: 2 additions & 2 deletions packages/freezed/test/integration/json.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ const pUnionJson = _$PUnionJsonWithExtendsFromJson;
class _PUnionJsonWithExtends extends Base with _$PUnionJsonWithExtends {
_PUnionJsonWithExtends._();

// ignore: unused_element
// ignore: unused_element, unused_element_parameter
factory _PUnionJsonWithExtends.first({int? first}) =
_PUnionJsonFirstWithExtends;
// ignore: unused_element
// ignore: unused_element, unused_element_parameter
factory _PUnionJsonWithExtends.second({int? second}) =
_PUnionJsonSecondWithExtends;

Expand Down
6 changes: 0 additions & 6 deletions packages/freezed_lint/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,5 @@ dev_dependencies:
freezed_lint: any

dependency_overrides:
freezed:
path: ../../freezed
freezed_annotation:
path: ../../freezed_annotation
freezed_lint:
path: ../


0 comments on commit 0a0ecee

Please sign in to comment.