Skip to content

Commit

Permalink
Use enclosingElement
Browse files Browse the repository at this point in the history
  • Loading branch information
rrousselGit committed Nov 2, 2024
1 parent 00f8962 commit 0c775d3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ extension RefInvocationX on MethodInvocation {
final functionOwner = function.staticElement
.cast<MethodElement>()
?.declaration
.enclosingElement3;
// ignore: deprecated_member_use, required to support lower versions of analyzer
.enclosingElement;

if (functionOwner == null ||
// Since Ref is sealed, checking that the function is from the package:riverpod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ extension WidgetRefInvocationX on MethodInvocation {
final functionOwner = function.staticElement
.cast<MethodElement>()
?.declaration
.enclosingElement3;
// ignore: deprecated_member_use, required to support lower versions of analyzer
.enclosingElement;

if (functionOwner == null ||
// Since Ref is sealed, checking that the function is from the package:riverpod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ ClassElement? _findStateFromReturnType(ClassElement node) {
}

ClassElement? _findStateWithMatchingGeneric(ClassElement node) {
for (final clazz in node.enclosingElement3.classes) {
for (final clazz in node
// ignore: deprecated_member_use, required to support lower versions of analyzer
.enclosingElement
.classes) {
final type = clazz.supertype;
if (type != null && isState(type) && _findStateWidget(clazz) == node) {
return clazz;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ class UnknownScopedUsage extends RiverpodLintRule {
if (override?.provider == identifier) return;

final enclosingConstructorType = identifier
.node.staticParameterElement?.enclosingElement3
.node
.staticParameterElement
// ignore: deprecated_member_use, required to support lower versions of analyzer
?.enclosingElement
.safeCast<ConstructorElement>()
?.returnType;
// Silence the warning if passed to a widget constructor.
Expand Down

0 comments on commit 0c775d3

Please sign in to comment.