Skip to content

Commit cf8bc08

Browse files
committed
rename skipLinesPattern to skipÅLinesMatching
1 parent 50e7cb0 commit cf8bc08

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

lib/src/main/java/com/diffplug/spotless/generic/LicenseHeaderStep.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,56 +60,56 @@ public static LicenseHeaderStep headerDelimiter(ThrowingEx.Supplier<String> head
6060
final String delimiter;
6161
final String yearSeparator;
6262
final Supplier<YearMode> yearMode;
63-
final @Nullable String skipLinesPattern;
63+
final @Nullable String skipLinesMatching;
6464

65-
private LicenseHeaderStep(@Nullable String name, @Nullable String contentPattern, ThrowingEx.Supplier<String> headerLazy, String delimiter, String yearSeparator, Supplier<YearMode> yearMode, @Nullable String skipLinesPattern) {
65+
private LicenseHeaderStep(@Nullable String name, @Nullable String contentPattern, ThrowingEx.Supplier<String> headerLazy, String delimiter, String yearSeparator, Supplier<YearMode> yearMode, @Nullable String skipLinesMatching) {
6666
this.name = sanitizeName(name);
6767
this.contentPattern = sanitizePattern(contentPattern);
6868
this.headerLazy = Objects.requireNonNull(headerLazy);
6969
this.delimiter = Objects.requireNonNull(delimiter);
7070
this.yearSeparator = Objects.requireNonNull(yearSeparator);
7171
this.yearMode = Objects.requireNonNull(yearMode);
72-
this.skipLinesPattern = sanitizePattern(skipLinesPattern);
72+
this.skipLinesMatching = sanitizePattern(skipLinesMatching);
7373
}
7474

7575
public String getName() {
7676
return name;
7777
}
7878

7979
public LicenseHeaderStep withName(String name) {
80-
return new LicenseHeaderStep(name, contentPattern, headerLazy, delimiter, yearSeparator, yearMode, skipLinesPattern);
80+
return new LicenseHeaderStep(name, contentPattern, headerLazy, delimiter, yearSeparator, yearMode, skipLinesMatching);
8181
}
8282

8383
public LicenseHeaderStep withContentPattern(String contentPattern) {
84-
return new LicenseHeaderStep(name, contentPattern, headerLazy, delimiter, yearSeparator, yearMode, skipLinesPattern);
84+
return new LicenseHeaderStep(name, contentPattern, headerLazy, delimiter, yearSeparator, yearMode, skipLinesMatching);
8585
}
8686

8787
public LicenseHeaderStep withHeaderString(String header) {
8888
return withHeaderLazy(() -> header);
8989
}
9090

9191
public LicenseHeaderStep withHeaderLazy(ThrowingEx.Supplier<String> headerLazy) {
92-
return new LicenseHeaderStep(name, contentPattern, headerLazy, delimiter, yearSeparator, yearMode, skipLinesPattern);
92+
return new LicenseHeaderStep(name, contentPattern, headerLazy, delimiter, yearSeparator, yearMode, skipLinesMatching);
9393
}
9494

9595
public LicenseHeaderStep withDelimiter(String delimiter) {
96-
return new LicenseHeaderStep(name, contentPattern, headerLazy, delimiter, yearSeparator, yearMode, skipLinesPattern);
96+
return new LicenseHeaderStep(name, contentPattern, headerLazy, delimiter, yearSeparator, yearMode, skipLinesMatching);
9797
}
9898

9999
public LicenseHeaderStep withYearSeparator(String yearSeparator) {
100-
return new LicenseHeaderStep(name, contentPattern, headerLazy, delimiter, yearSeparator, yearMode, skipLinesPattern);
100+
return new LicenseHeaderStep(name, contentPattern, headerLazy, delimiter, yearSeparator, yearMode, skipLinesMatching);
101101
}
102102

103103
public LicenseHeaderStep withYearMode(YearMode yearMode) {
104104
return withYearModeLazy(() -> yearMode);
105105
}
106106

107107
public LicenseHeaderStep withYearModeLazy(Supplier<YearMode> yearMode) {
108-
return new LicenseHeaderStep(name, contentPattern, headerLazy, delimiter, yearSeparator, yearMode, skipLinesPattern);
108+
return new LicenseHeaderStep(name, contentPattern, headerLazy, delimiter, yearSeparator, yearMode, skipLinesMatching);
109109
}
110110

111-
public LicenseHeaderStep withSkipLinesPattern(String skipLinesPattern) {
112-
return new LicenseHeaderStep(name, contentPattern, headerLazy, delimiter, yearSeparator, yearMode, skipLinesPattern);
111+
public LicenseHeaderStep withSkipLinesMatching(String skipLinesMatching) {
112+
return new LicenseHeaderStep(name, contentPattern, headerLazy, delimiter, yearSeparator, yearMode, skipLinesMatching);
113113
}
114114

115115
public FormatterStep build() {
@@ -118,7 +118,7 @@ public FormatterStep build() {
118118
if (yearMode.get() == YearMode.SET_FROM_GIT) {
119119
formatterStep = FormatterStep.createNeverUpToDateLazy(name, () -> {
120120
boolean updateYear = false; // doesn't matter
121-
Runtime runtime = new Runtime(headerLazy.get(), delimiter, yearSeparator, updateYear, skipLinesPattern);
121+
Runtime runtime = new Runtime(headerLazy.get(), delimiter, yearSeparator, updateYear, skipLinesMatching);
122122
return FormatterFunc.needsFile(runtime::setLicenseHeaderYearsFromGitHistory);
123123
});
124124
} else {
@@ -136,7 +136,7 @@ public FormatterStep build() {
136136
default:
137137
throw new IllegalStateException(yearMode.toString());
138138
}
139-
return new Runtime(headerLazy.get(), delimiter, yearSeparator, updateYear, skipLinesPattern);
139+
return new Runtime(headerLazy.get(), delimiter, yearSeparator, updateYear, skipLinesMatching);
140140
}, step -> step::format);
141141
}
142142

@@ -201,7 +201,7 @@ private static class Runtime implements Serializable {
201201
private static final long serialVersionUID = 1475199492829130965L;
202202

203203
private final Pattern delimiterPattern;
204-
private final @Nullable Pattern skipLinesPattern;
204+
private final @Nullable Pattern skipLinesMatching;
205205
private final String yearSepOrFull;
206206
private final @Nullable String yearToday;
207207
private final @Nullable String beforeYear;
@@ -210,7 +210,7 @@ private static class Runtime implements Serializable {
210210
private final boolean licenseHeaderWithRange;
211211

212212
/** The license that we'd like enforced. */
213-
private Runtime(String licenseHeader, String delimiter, String yearSeparator, boolean updateYearWithLatest, @Nullable String skipLinesPattern) {
213+
private Runtime(String licenseHeader, String delimiter, String yearSeparator, boolean updateYearWithLatest, @Nullable String skipLinesMatching) {
214214
if (delimiter.contains("\n")) {
215215
throw new IllegalArgumentException("The delimiter must not contain any newlines.");
216216
}
@@ -220,7 +220,7 @@ private Runtime(String licenseHeader, String delimiter, String yearSeparator, bo
220220
licenseHeader = licenseHeader + "\n";
221221
}
222222
this.delimiterPattern = Pattern.compile('^' + delimiter, Pattern.UNIX_LINES | Pattern.MULTILINE);
223-
this.skipLinesPattern = skipLinesPattern == null ? null : Pattern.compile(skipLinesPattern);
223+
this.skipLinesMatching = skipLinesMatching == null ? null : Pattern.compile(skipLinesMatching);
224224

225225
Optional<String> yearToken = getYearToken(licenseHeader);
226226
if (yearToken.isPresent()) {
@@ -262,7 +262,7 @@ private static Optional<String> getYearToken(String licenseHeader) {
262262

263263
/** Formats the given string. */
264264
private String format(String raw) {
265-
if (skipLinesPattern == null) {
265+
if (skipLinesMatching == null) {
266266
return addOrUpdateLicenseHeader(raw);
267267
} else {
268268
String[] lines = raw.split("\n");
@@ -271,7 +271,7 @@ private String format(String raw) {
271271
boolean lastMatched = true;
272272
for (String line : lines) {
273273
if (lastMatched) {
274-
Matcher matcher = skipLinesPattern.matcher(line);
274+
Matcher matcher = skipLinesMatching.matcher(line);
275275
if (matcher.find()) {
276276
skippedLinesBuilder.append(line).append('\n');
277277
} else {

plugin-gradle/src/main/java/com/diffplug/gradle/spotless/FormatExtension.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,8 @@ public LicenseHeaderConfig yearSeparator(String yearSeparator) {
462462
return this;
463463
}
464464

465-
public LicenseHeaderConfig skipLinesPattern(String skipLinesPattern) {
466-
builder = builder.withSkipLinesPattern(skipLinesPattern);
465+
public LicenseHeaderConfig skipLinesMatching(String skipLinesMatching) {
466+
builder = builder.withSkipLinesMatching(skipLinesMatching);
467467
replaceStep(createStep());
468468
return this;
469469
}

0 commit comments

Comments
 (0)