Skip to content

Commit b5907dd

Browse files
committed
Allow -> as placeholder separator
1 parent 13688dd commit b5907dd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mug-errorprone/src/main/java/com/google/mu/errorprone/FormatStringUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import static com.google.common.base.CharMatcher.whitespace;
55
import static com.google.common.collect.ImmutableList.toImmutableList;
66
import static com.google.mu.util.Optionals.optionally;
7+
import static com.google.mu.util.Substring.before;
78
import static com.google.mu.util.Substring.consecutive;
89
import static com.google.mu.util.Substring.first;
910
import static com.google.mu.util.Substring.firstOccurrence;
@@ -33,17 +34,16 @@
3334
final class FormatStringUtils {
3435
static final Substring.Pattern PLACEHOLDER_PATTERN =
3536
consecutive(CharMatcher.noneOf("{}")::matches).immediatelyBetween("{", INCLUSIVE, "}", INCLUSIVE);
36-
private static final Substring.Pattern PLACEHOLDER_SEPARATOR =
37+
private static final Substring.Pattern PLACEHOLDER_NAME_END =
3738
Stream.of("=", "->").map(Substring::first).collect(firstOccurrence());
3839
static final Substring.RepeatingPattern PLACEHOLDER_NAMES_PATTERN =
3940
consecutive(CharMatcher.noneOf("{}")::matches).immediatelyBetween("{", "}").repeatedly();
4041

4142
static ImmutableList<String> placeholderVariableNames(String formatString) {
42-
Substring.Pattern beforeSeparator = Substring.before(PLACEHOLDER_SEPARATOR);
4343
return PLACEHOLDER_NAMES_PATTERN
4444
.from(formatString)
4545
// for Cloud resource name syntax
46-
.map(n -> beforeSeparator.from(n).map(whitespace()::trimTrailingFrom).orElse(n))
46+
.map(n -> before(PLACEHOLDER_NAME_END).from(n).map(whitespace()::trimTrailingFrom).orElse(n))
4747
.collect(toImmutableList());
4848
}
4949

0 commit comments

Comments
 (0)