|
15 | 15 | */ |
16 | 16 | package com.diffplug.gradle.spotless; |
17 | 17 |
|
| 18 | +import javax.inject.Inject; |
| 19 | + |
18 | 20 | import com.diffplug.spotless.FormatterStep; |
19 | 21 | import com.diffplug.spotless.go.GofmtFormatStep; |
20 | 22 |
|
21 | | -import javax.inject.Inject; |
22 | | - |
23 | 23 | public class GoExtension extends FormatExtension { |
24 | | - public static final String NAME = "go"; |
25 | | - |
26 | | - @Inject |
27 | | - public GoExtension(SpotlessExtension spotless) { |
28 | | - super(spotless); |
29 | | - } |
30 | | - |
31 | | - public GofmtConfig gofmt() { |
32 | | - return new GofmtConfig(GofmtFormatStep.defaultVersion()); |
33 | | - } |
34 | | - |
35 | | - public GofmtConfig gofmt(String version) { |
36 | | - return new GofmtConfig(version); |
37 | | - } |
38 | | - |
39 | | - public class GofmtConfig { |
40 | | - GofmtFormatStep stepCfg; |
41 | | - |
42 | | - public GofmtConfig(String version) { |
43 | | - stepCfg = GofmtFormatStep.withVersion(version); |
44 | | - addStep(createStep()); |
45 | | - } |
46 | | - |
47 | | - public GofmtConfig withGoExecutable(String pathToGo) { |
48 | | - stepCfg = stepCfg.withGoExecutable(pathToGo); |
49 | | - replaceStep(createStep()); |
50 | | - return this; |
51 | | - } |
52 | | - |
53 | | - private FormatterStep createStep() { |
54 | | - return stepCfg.create(); |
55 | | - } |
56 | | - } |
| 24 | + public static final String NAME = "go"; |
| 25 | + |
| 26 | + @Inject |
| 27 | + public GoExtension(SpotlessExtension spotless) { |
| 28 | + super(spotless); |
| 29 | + } |
| 30 | + |
| 31 | + public GofmtConfig gofmt() { |
| 32 | + return new GofmtConfig(GofmtFormatStep.defaultVersion()); |
| 33 | + } |
| 34 | + |
| 35 | + public GofmtConfig gofmt(String version) { |
| 36 | + return new GofmtConfig(version); |
| 37 | + } |
| 38 | + |
| 39 | + public class GofmtConfig { |
| 40 | + GofmtFormatStep stepCfg; |
| 41 | + |
| 42 | + public GofmtConfig(String version) { |
| 43 | + stepCfg = GofmtFormatStep.withVersion(version); |
| 44 | + addStep(createStep()); |
| 45 | + } |
| 46 | + |
| 47 | + public GofmtConfig withGoExecutable(String pathToGo) { |
| 48 | + stepCfg = stepCfg.withGoExecutable(pathToGo); |
| 49 | + replaceStep(createStep()); |
| 50 | + return this; |
| 51 | + } |
| 52 | + |
| 53 | + private FormatterStep createStep() { |
| 54 | + return stepCfg.create(); |
| 55 | + } |
| 56 | + } |
57 | 57 | } |
0 commit comments