check method
void
check(
- DcqRegistry registry
)
Implementation
@override
void check(DcqRegistry registry) {
registry.addMethodInvocation((node) {
if (!isHookCall(node.methodName.name)) return;
// Walk up to find if we're inside build, a custom hook, or another method.
var current = node.parent;
while (current != null) {
if (current is MethodDeclaration && current.name.lexeme == 'build') {
return; // Inside build — fine.
}
if (current is MethodDeclaration &&
_isHookFunction(current.name.lexeme)) {
return; // Inside a use* hook method — fine.
}
if (current is FunctionDeclaration &&
_isHookFunction(current.name.lexeme)) {
return; // Inside a use* hook function — fine.
}
if (current is FunctionDeclaration || current is MethodDeclaration) {
// Only flag if we're inside a HookWidget class.
if (_isInHookWidgetClass(current)) {
reportAtNode(node);
}
return;
}
current = current.parent;
}
});
}