diff --git a/packages/custom_lint_core/lib/src/change_reporter.dart b/packages/custom_lint_core/lib/src/change_reporter.dart index 47112da3..be277319 100644 --- a/packages/custom_lint_core/lib/src/change_reporter.dart +++ b/packages/custom_lint_core/lib/src/change_reporter.dart @@ -65,9 +65,13 @@ abstract class ChangeBuilder { /// /// The builder passed to the [buildFileEdit] function has additional support /// for working with Dart source files. + /// + /// Use the [customPath] if the collection of edits should be written to another + /// dart file. void addDartFileEdit( void Function(DartFileEditBuilder builder) buildFileEdit, { ImportPrefixGenerator importPrefixGenerator, + String? customPath, }); /// Use the [buildFileEdit] function to create a collection of edits to the @@ -76,9 +80,13 @@ abstract class ChangeBuilder { /// /// The builder passed to the [buildFileEdit] function has no special support /// for any particular kind of file. + /// + /// Use the [customPath] if the collection of edits should be written to another + /// file. void addGenericFileEdit( - void Function(analyzer_plugin.FileEditBuilder builder) buildFileEdit, - ); + void Function(analyzer_plugin.FileEditBuilder builder) buildFileEdit, { + String? customPath, + }); /// Use the [buildFileEdit] function to create a collection of edits to the /// currently analyzed file. The edits will be added to the source change @@ -86,8 +94,12 @@ abstract class ChangeBuilder { /// /// The builder passed to the [buildFileEdit] function has additional support /// for working with YAML source files. + /// + /// Use the [customPath] if the collection of edits should be written to another + /// YAML file. void addYamlFileEdit( void Function(YamlFileEditBuilder builder) buildFileEdit, + String? customPath, ); } @@ -110,12 +122,13 @@ class _ChangeBuilderImpl implements ChangeBuilder { void addDartFileEdit( void Function(DartFileEditBuilder builder) buildFileEdit, { ImportPrefixGenerator? importPrefixGenerator, + String? customPath, }) { _operations.add( importPrefixGenerator == null - ? _innerChangeBuilder.addDartFileEdit(path, buildFileEdit) + ? _innerChangeBuilder.addDartFileEdit(customPath ?? path, buildFileEdit) : _innerChangeBuilder.addDartFileEdit( - path, + customPath ?? path, buildFileEdit, importPrefixGenerator: importPrefixGenerator, ), @@ -124,19 +137,21 @@ class _ChangeBuilderImpl implements ChangeBuilder { @override void addGenericFileEdit( - void Function(analyzer_plugin.FileEditBuilder builder) buildFileEdit, - ) { + void Function(analyzer_plugin.FileEditBuilder builder) buildFileEdit, { + String? customPath, + }) { _operations.add( - _innerChangeBuilder.addGenericFileEdit(path, buildFileEdit), + _innerChangeBuilder.addGenericFileEdit(customPath ?? path, buildFileEdit), ); } @override void addYamlFileEdit( void Function(YamlFileEditBuilder builder) buildFileEdit, + String? customPath, ) { _operations.add( - _innerChangeBuilder.addYamlFileEdit(path, buildFileEdit), + _innerChangeBuilder.addYamlFileEdit(customPath ?? path, buildFileEdit), ); }