Skip to content

Commit

Permalink
No need for resolved AST
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronlademann-wf committed Mar 6, 2024
1 parent 439e321 commit 6fff852
Showing 1 changed file with 2 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:over_react_codemod/src/util/class_suggestor.dart';
import 'package:codemod/codemod.dart';

/// Suggestor that finds instances of `useRef` function invocations that
/// pass an argument, and replaces them with `useRefInit` to prep for
Expand All @@ -29,9 +28,7 @@ import 'package:over_react_codemod/src/util/class_suggestor.dart';
/// // After
/// final ref = useRefInit(someNonNulLValue);
/// ```
class UseRefInitMigration extends RecursiveAstVisitor with ClassSuggestor {
ResolvedUnitResult? _result;

class UseRefInitMigration extends RecursiveAstVisitor with AstVisitingSuggestor {
@override
visitArgumentList(ArgumentList node) {
super.visitArgumentList(node);
Expand All @@ -51,14 +48,4 @@ class UseRefInitMigration extends RecursiveAstVisitor with ClassSuggestor {
}
}
}

@override
Future<void> generatePatches() async {
_result = await context.getResolvedUnit();
if (_result == null) {
throw Exception(
'Could not get resolved result for "${context.relativePath}"');
}
_result!.unit.accept(this);
}
}

0 comments on commit 6fff852

Please sign in to comment.