-
-
Notifications
You must be signed in to change notification settings - Fork 247
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
Upgrades analyzer, source_gen, dart_style #1140
Upgrades analyzer, source_gen, dart_style #1140
Conversation
WalkthroughThe pull request includes updates to the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
…y-upgrades-2024-12-20
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/freezed/lib/builder.dart (1)
17-30
: Consider documenting the format configuration option.The new format configuration option provides useful flexibility, but its purpose and usage should be documented.
Add a documentation comment above the
freezed
function:/// Builds generators for `build_runner` to run + /// + /// Configuration options: + /// - `format`: When set to `false`, disables output formatting. Default: `true` Builder freezed(BuilderOptions options) {packages/freezed/lib/src/ast.dart (1)
Line range hint
73-85
: Consider extracting common code into a helper method.The logic for handling generics is duplicated between
fullName
andescapedName
. Consider extracting it into a helper method.+ String _buildGenericsString(Element classElement) { + var generics = classElement.typeParameters + .map((e) => '\$${e.name}') + .join(', '); + return generics.isEmpty ? '' : '<$generics>'; + } String get fullName { final classElement = declaredElement!.enclosingElement3; - var generics = classElement.typeParameters - .map((e) => '\$${e.name}') - .join(', '); - if (generics.isNotEmpty) { - generics = '<$generics>'; - } + final generics = _buildGenericsString(classElement); // ... rest of the method } String get escapedName { final classElement = declaredElement!.enclosingElement3; - var generics = classElement.typeParameters - .map((e) => '\$${e.name}') - .join(', '); - if (generics.isNotEmpty) { - generics = '<$generics>'; - } + final generics = _buildGenericsString(classElement); // ... rest of the method }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
packages/freezed/lib/builder.dart
(1 hunks)packages/freezed/lib/src/ast.dart
(1 hunks)packages/freezed/lib/src/tools/recursive_import_locator.dart
(1 hunks)packages/freezed/lib/src/tools/type.dart
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: freezed (packages/freezed, stable, downgrade)
- GitHub Check: freezed (packages/freezed, stable, get)
🔇 Additional comments (4)
packages/freezed/lib/builder.dart (1)
9-16
: LGTM! Good refactoring to improve readability.The extraction of variables makes the code more maintainable and easier to understand.
packages/freezed/lib/src/ast.dart (1)
59-59
: Verify analyzer API compatibility.The change from
enclosingElement
toenclosingElement3
suggests adaptation to a newer analyzer API. Let's verify the API compatibility across versions.Also applies to: 67-67
✅ Verification successful
API change is valid and consistent.
The change from
enclosingElement
toenclosingElement3
is part of the analyzer package API updates. The codebase consistently usesenclosingElement3
and the package dependencies are properly configured to work with the latest analyzer versions (>=6.5.0).🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check analyzer API documentation for enclosingElement3 # Look for any deprecation notices or API changes # Search for enclosingElement3 usage and documentation rg -A 5 "enclosingElement3" # Search for any TODO or DEPRECATED comments related to element APIs rg -i "TODO|DEPRECATED.*element"Length of output: 2610
Script:
#!/bin/bash # Search for old API usage rg "enclosingElement[^3]" # Search for migration related files fd -g "*CHANGELOG*" -g "*MIGRATION*" -g "*UPGRADING*" -X cat {}Length of output: 252
Script:
#!/bin/bash # Search for old API usage with simpler pattern rg "enclosingElement\s*=" rg "enclosingElement;" # Check analyzer version in pubspec fd pubspec.yaml --exec cat {} # Search for changelog with correct syntax find . -type f -name "CHANGELOG.md" -exec cat {} \;Length of output: 29958
packages/freezed/lib/src/tools/type.dart (1)
44-46
: LGTM! More thorough import prefix resolution.The change to use
units.expand()
improves type resolution by considering import prefixes from all compilation units, not just the main one.packages/freezed/lib/src/tools/recursive_import_locator.dart (1)
34-41
: LGTM! Consistent improvement in library element collection.The change to use
units.expand()
aligns with the improvements in type.dart, providing more thorough collection of library elements across all compilation units.This change is part of a broader pattern of improvements in how library elements are collected and processed throughout the codebase.
This is challenging because source_gen 2.0.0 isn't supported by Flutter Stable. It requires Dart 3.6.0 But source_gen <2.0.0 doesn't support analyzer 7.0.0 |
mb, fixed |
Cannot upgrade
freezed_lint
untilcustom_lint
is upgraded which requires these changes. Sort of a chicken/egg problem.Summary by CodeRabbit
analyzer
now supports a broader range of versions.source_gen
upgraded to a major new version.dart_style
updated to a major new version.freezed
function.ConstructorX
extension.