refactorMethodBody method
Returns AiGuidance for refactoring a single method body.
Sends a prompt to the local LLM; falls back deterministically when the LLM is unavailable.
Implementation
Future<AiGuidance> refactorMethodBody({
required String className,
required List<String> stateFields,
required String methodName,
required String methodBody,
NotifierType notifierType = NotifierType.stateNotifier,
}) async {
final prompt = _buildMethodPrompt(
className: className,
stateFields: stateFields,
methodName: methodName,
methodBody: methodBody,
notifierType: notifierType,
);
final fallback = _fallbackMethodGuidance(
className: className,
stateFields: stateFields,
methodName: methodName,
notifierType: notifierType,
);
return _completeGuidance(
title: 'Refactor $className.$methodName',
subject: '$className.$methodName',
category: 'logic-refactor',
rationale:
'$className.$methodName mutates local state and should move to immutable Riverpod state transitions.',
prompt: prompt,
fallbackRecommendation: fallback,
);
}