31
31
import com .diffplug .spotless .kotlin .KtLintStep ;
32
32
import com .diffplug .spotless .kotlin .KtfmtStep ;
33
33
34
- public abstract class BaseKotlinExtension extends FormatExtension {
35
- public BaseKotlinExtension (SpotlessExtension spotless ) {
34
+ abstract class BaseKotlinExtension extends FormatExtension {
35
+ protected BaseKotlinExtension (SpotlessExtension spotless ) {
36
36
super (spotless );
37
37
}
38
38
@@ -70,11 +70,10 @@ public KtfmtConfig ktfmt(String version) {
70
70
protected abstract boolean isScript ();
71
71
72
72
public class DiktatConfig {
73
-
74
73
private final String version ;
75
74
private FileSignature config ;
76
75
77
- DiktatConfig (String version ) {
76
+ private DiktatConfig (String version ) {
78
77
Objects .requireNonNull (version , "version" );
79
78
this .version = version ;
80
79
addStep (createStep ());
@@ -97,24 +96,17 @@ private FormatterStep createStep() {
97
96
}
98
97
99
98
public class KtfmtConfig {
100
- final String version ;
101
- KtfmtStep .Style style ;
102
- KtfmtStep .KtfmtFormattingOptions options ;
103
-
99
+ private final String version ;
104
100
private final ConfigurableStyle configurableStyle = new ConfigurableStyle ();
101
+ private KtfmtStep .Style style ;
102
+ private KtfmtStep .KtfmtFormattingOptions options ;
105
103
106
- KtfmtConfig (String version ) {
104
+ private KtfmtConfig (String version ) {
107
105
Objects .requireNonNull (version );
108
106
this .version = Objects .requireNonNull (version );
109
107
addStep (createStep ());
110
108
}
111
109
112
- private ConfigurableStyle style (KtfmtStep .Style style ) {
113
- this .style = style ;
114
- replaceStep (createStep ());
115
- return configurableStyle ;
116
- }
117
-
118
110
public ConfigurableStyle dropboxStyle () {
119
111
return style (KtfmtStep .Style .DROPBOX );
120
112
}
@@ -131,13 +123,18 @@ public void configure(Consumer<KtfmtStep.KtfmtFormattingOptions> optionsConfigur
131
123
this .configurableStyle .configure (optionsConfiguration );
132
124
}
133
125
126
+ private ConfigurableStyle style (KtfmtStep .Style style ) {
127
+ this .style = style ;
128
+ replaceStep (createStep ());
129
+ return configurableStyle ;
130
+ }
131
+
134
132
private FormatterStep createStep () {
135
133
return KtfmtStep .create (version , provisioner (), style , options );
136
134
}
137
135
138
136
public class ConfigurableStyle {
139
-
140
- public void configure (Consumer <KtfmtStep .KtfmtFormattingOptions > optionsConfiguration ) {
137
+ private void configure (Consumer <KtfmtStep .KtfmtFormattingOptions > optionsConfiguration ) {
141
138
KtfmtStep .KtfmtFormattingOptions ktfmtFormattingOptions = new KtfmtStep .KtfmtFormattingOptions ();
142
139
optionsConfiguration .accept (ktfmtFormattingOptions );
143
140
options = ktfmtFormattingOptions ;
@@ -147,26 +144,26 @@ public void configure(Consumer<KtfmtStep.KtfmtFormattingOptions> optionsConfigur
147
144
}
148
145
149
146
public class KtlintConfig {
150
-
151
147
private final String version ;
152
- @ Nullable
153
148
private FileSignature editorConfigPath ;
154
149
private Map <String , String > userData ;
155
150
private Map <String , Object > editorConfigOverride ;
156
151
157
- KtlintConfig (String version , Map <String , String > config ,
152
+ private KtlintConfig (
153
+ String version ,
154
+ Map <String , String > userData ,
158
155
Map <String , Object > editorConfigOverride ) throws IOException {
159
156
Objects .requireNonNull (version );
160
157
File defaultEditorConfig = getProject ().getRootProject ().file (".editorconfig" );
161
158
FileSignature editorConfigPath = defaultEditorConfig .exists () ? FileSignature .signAsList (defaultEditorConfig ) : null ;
162
159
this .version = version ;
163
160
this .editorConfigPath = editorConfigPath ;
164
- this .userData = config ;
161
+ this .userData = userData ;
165
162
this .editorConfigOverride = editorConfigOverride ;
166
163
addStep (createStep ());
167
164
}
168
165
169
- public KtlintConfig setEditorConfigPath (Object editorConfigPath ) throws IOException {
166
+ public KtlintConfig setEditorConfigPath (@ Nullable Object editorConfigPath ) throws IOException {
170
167
if (editorConfigPath == null ) {
171
168
this .editorConfigPath = null ;
172
169
} else {
0 commit comments