-
Notifications
You must be signed in to change notification settings - Fork 25
Remove deprecated members #211
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
Conversation
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.
Hello @xJac0b, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
Hello! Gemini here, providing a summary of this pull request. This PR focuses on updating the codebase to use the latest APIs from the Dart analyzer package. Specifically, it replaces deprecated members like declaredElement and staticElement with their modern equivalents, such as declaredFragment, element, element2, element3, declaredElement2, library2, name2, name3, variable3, enclosingElement2, and baseElement.nonSynthetic2. The changes are based on the official analyzer element model migration guide. The author states that no functional changes were introduced, meaning this is primarily a refactoring effort to maintain compatibility with newer versions of the analyzer.
Highlights
- Analyzer API Migration: The core of this PR is migrating away from deprecated members in the
analyzerpackage, adhering to the recommended migration path. - Replacement of Element Accessors: Deprecated accessors like
declaredElementandstaticElementare replaced with newer alternatives such asdeclaredFragment,element,element2, andelement3depending on the context and type. - Updated Element Properties: Properties accessed on elements, such as
librarySource,name,variable2, andenclosingElement3, are updated to their new names likelibrary2,name2,name3,variable3, andenclosingElement2. - Refactored Override Check: The logic for checking the
@overrideannotation has been refactored to directly inspect metadata rather than relying on a deprecated element property. - No Functional Changes: According to the author, these changes are purely for API compatibility and do not alter the behavior or logic of the existing lint rules.
Changelog
Click here to see the changelog
- lib/src/common/parameters/excluded_identifiers_list_parameter.dart
- Replaced
declaredElement?.namewithdeclaredFragment?.name2.
- Replaced
- lib/src/lints/avoid_debug_print_in_release/avoid_debug_print_in_release_rule.dart
- Replaced
staticElement?.librarySource?.uri.toString()withelement?.library2?.uri.toString()forPrefixedIdentifierandSimpleIdentifier.
- Replaced
- lib/src/lints/avoid_final_with_getter/visitors/avoid_final_with_getter_visitor.dart
- Updated import from
element.darttoelement2.dart. - Replaced
declaredElement: ExecutableElement(...)pattern withdeclaredFragment: ExecutableFragment(element: ExecutableElement2(...)).
- Updated import from
- lib/src/lints/avoid_final_with_getter/visitors/getter_variable_visitor.dart
- Updated import from
element.darttoelement2.dart. - Replaced
VariableDeclarationcase pattern usingdeclaredElementwith an explicit check onnode.declaredFragment?.element. - Refactored
getterReferenceIdextension getter to useelementandvariable3instead ofstaticElementandvariable2.
- Updated import from
- lib/src/lints/avoid_global_state/avoid_global_state_rule.dart
- Replaced
declaredElement?.isPrivatewithdeclaredElement2?.isPrivate.
- Replaced
- lib/src/lints/avoid_late_keyword/avoid_late_keyword_rule.dart
- Replaced
declaredElement?.isLatewithnode.isLate. - Replaced
declaredElement?.typewithdeclaredFragment?.element.type.
- Replaced
- lib/src/lints/avoid_returning_widgets/avoid_returning_widgets_rule.dart
- Added
_overrideconstant. - Replaced
declaredElement?.hasOverridecheck with aswitchstatement inspecting metadata for@override.
- Added
- lib/src/lints/avoid_unrelated_type_assertions/visitors/avoid_unrelated_type_assertions_visitor.dart
- Replaced
elementwithelement3when comparing elements ofDartType. - Replaced
castedType.element?.kindwithcastedType.element3?.kind.
- Replaced
- lib/src/lints/avoid_unused_parameters/visitors/avoid_unused_parameters_visitor.dart
- Updated import from
element.darttoelement2.dart. - Replaced
parameter.declaredElementwithparameter.declaredFragment?.element.baseElement.nonSynthetic2. - Updated the type of the
elementsset in_IdentifiersVisitorfromElementtoElement2. - Replaced
node.staticElementwithnode.elementin_IdentifiersVisitor. - Replaced
node.staticElement is MethodElementwithnode.element is MethodElement2in_InvocationsVisitor.
- Updated import from
- lib/src/lints/avoid_using_api/avoid_using_api_linter.dart
- Updated import from
element.darttoelement2.dart. - Replaced
node.staticElementswitch cases withnode.elementand updated element types (FunctionElement->LocalFunctionElement||TopLevelFunctionElement,PropertyAccessorElement->PropertyAccessorElement2). - Replaced
declaredElement?.type.element?.namewithdeclaredElement2?.type.element3?.name3. - Replaced
declaredElement?.type.element?.librarySource?.uri.toString()withdeclaredElement2?.type.element3?.library2?.uri.toString(). - Replaced
staticType.element?.librarySource?.uri.toString()withstaticType.element3?.library2?.uri.toString(). - Replaced
staticType.element?.namewithstaticType.element3?.name3. - Replaced
staticElement.librarySource?.uri.toString()withelement.library2?.uri.toString(). - Replaced
staticElement.namewithelement.name3. - Replaced
staticType.element?.namewithstaticType.element3?.name3. - Replaced
staticElement.namewithelement.name3. - Replaced
element?.namewithelement2?.name3. - Replaced
staticElement?.enclosingElement3withelement?.enclosingElement2. - Updated type check from
ExtensionElementtoExtensionElement2. - Replaced
enclosingElement.namewithenclosingElement.name3. - Replaced
enclosingElement.librarySource.uri.toString()withenclosingElement.library2.uri.toString().
- Updated import from
- lib/src/lints/avoid_using_api/avoid_using_api_utils.dart
- Replaced
staticElement?.librarySourcewithelement?.library2. - Replaced
element?.librarySourcewithelement2?.library2.
- Replaced
- lib/src/utils/typecast_utils.dart
- Replaced
source.element == target.elementwithsource.element3 == target.element3. - Replaced
e.element == target.elementwithe.element3 == target.element3.
- Replaced
- lib/src/utils/types_utils.dart
- Updated import from
element.darttoelement2.dart. - Replaced
this.elementwithelement3. - Updated type check from
InterfaceElementtoInterfaceElement2.
- Updated import from
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Old elements fade,
New fragments take their place,
Code evolves onward.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request effectively addresses the deprecation of analyzer package members by migrating to their new equivalents. The changes are consistent with the official migration guide and have been applied thoroughly across multiple files. The code remains clear, and the PR successfully achieves its goal of updating dependencies without introducing functional changes. Great job on this meticulous update!
Summary of Findings
- API Migration: The deprecated members from the
analyzerpackage (e.g.,declaredElement,staticElement,element,librarySource,name) have been correctly replaced with their modern equivalents (e.g.,declaredFragment,element(onSimpleIdentifier),element2/element3(on types/nodes),library2,name2/name3). This was done consistently across all affected files. - Override Check: The logic for checking if a method is an override (e.g., in
avoid_returning_widgets_rule.dart) has been updated fromElement.hasOverrideto inspecting AST node metadata, which aligns with the migration guide's recommendations. - Code Clarity: Despite the mechanical nature of many changes, the resulting code remains readable and maintains the original logic. In some cases, such as the direct use of
VariableDeclaration.isLate, the new API allows for even clearer code.
Merge Readiness
The changes in this pull request are well-executed and align with the stated objective of migrating deprecated analyzer API members. I found no issues of medium severity or higher. The code appears to be in good shape and, from my perspective, is ready for merging after any standard final checks by the team. As an AI, I am not authorized to approve pull requests.
|
@xJac0b, I'm seeing some of the tests fail locally for me right now. Please, take a look: To run tests, you can use the |
* fix: remove deprecated members * style: remove extra spacing
analyzerpackage (e.g.declaredElementandstaticElement) with their current equivalents.