From 138d860685216770825c8588288110c5d3cae141 Mon Sep 17 00:00:00 2001 From: matthiaslarisch Date: Fri, 8 Sep 2023 07:03:48 +0200 Subject: [PATCH 1/2] add new parameter customPath to method addGenericFileEdit --- .../custom_lint_core/lib/src/change_reporter.dart | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/custom_lint_core/lib/src/change_reporter.dart b/packages/custom_lint_core/lib/src/change_reporter.dart index 47112da3..d2208d97 100644 --- a/packages/custom_lint_core/lib/src/change_reporter.dart +++ b/packages/custom_lint_core/lib/src/change_reporter.dart @@ -76,9 +76,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 @@ -124,10 +128,11 @@ 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), ); } From 14c6d4381646b79d76358bd28986ac90d289a39d Mon Sep 17 00:00:00 2001 From: matthiaslarisch Date: Tue, 12 Sep 2023 16:04:12 +0200 Subject: [PATCH 2/2] Update change_reporter.dart added the customPath parameter to the other "addXFileEdit" methods --- .../lib/src/change_reporter.dart | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/custom_lint_core/lib/src/change_reporter.dart b/packages/custom_lint_core/lib/src/change_reporter.dart index d2208d97..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 @@ -90,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, ); } @@ -114,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, ), @@ -139,9 +148,10 @@ class _ChangeBuilderImpl implements ChangeBuilder { @override void addYamlFileEdit( void Function(YamlFileEditBuilder builder) buildFileEdit, + String? customPath, ) { _operations.add( - _innerChangeBuilder.addYamlFileEdit(path, buildFileEdit), + _innerChangeBuilder.addYamlFileEdit(customPath ?? path, buildFileEdit), ); }