codemod library

Classes

FileContext
A helper class for a file located at path that provides access to its contents and analyzed formats like CompilationUnit and LibraryElement.
Patch
A representation of a change to a source file.

Mixins

AstVisitingSuggestor<R>
Mixin that implements the Suggestor interface and makes it easier to write suggestors that operate as an AstVisitor.

Functions

aggregate(Iterable<Suggestor> suggestors) Suggestor
Aggregates multiple Suggestors into a single suggestor that yields the aggregate of Patches generated by each individual suggestor. runInteractiveCodemod( filesFromGlob(Glob('**.dart', recursive: true)), aggregate( suggestorA, suggestorB, suggestorC, ... ), );
filePathsFromGlob(Glob glob, {bool? ignoreHiddenFiles}) Iterable<String>
Returns file paths matched by glob and filtered to exclude any of the following by default:
isDartHiddenFile(File file) bool
isHiddenFile(File file) bool
isNotDartHiddenFile(File file) bool
isNotHiddenFile(File file) bool
runInteractiveCodemod(Iterable<String> filePaths, Suggestor suggestor, {Iterable<String> args = const [], bool defaultYes = false, String? additionalHelpOutput, String? changesRequiredOutput}) Future<int>
Interactively runs a "codemod" by using stdout to display a diff for each potential patch and stdin to accept input from the user on what to do with said patch; returns an appropriate exit code when complete.
runInteractiveCodemodSequence(Iterable<String> filePaths, Iterable<Suggestor> suggestors, {Iterable<String> args = const [], bool defaultYes = false, String? additionalHelpOutput, String? changesRequiredOutput}) Future<int>
Exactly the same as runInteractiveCodemod except that it runs all of the given suggestors sequentially (meaning that the set of files found by query is iterated over for each suggestor).

Typedefs

Suggestor = Stream<Patch> Function(FileContext context)
Function signature representing the core driver of a "codemod" (code modification).