Skip to content

Commit 6d2f6fc

Browse files
Internal change
PiperOrigin-RevId: 720446465
1 parent 5f9fc54 commit 6d2f6fc

File tree

1 file changed

+8
-46
lines changed

1 file changed

+8
-46
lines changed

java/core/src/main/java/com/google/protobuf/TextFormat.java

+8-46
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ private TextFormat() {}
3838

3939
private static final Logger logger = Logger.getLogger(TextFormat.class.getName());
4040

41-
private static final String DEBUG_STRING_SILENT_MARKER = " \t ";
42-
4341
private static final String REDACTED_MARKER = "[REDACTED]";
4442

4543
/**
@@ -997,15 +995,6 @@ private static final class Tokenizer {
997995
private int previousLine = 0;
998996
private int previousColumn = 0;
999997

1000-
/**
1001-
* {@link containsSilentMarkerAfterCurrentToken} indicates if there is a silent marker after the
1002-
* current token. This value is moved to {@link containsSilentMarkerAfterPrevToken} every time
1003-
* the next token is parsed.
1004-
*/
1005-
private boolean containsSilentMarkerAfterCurrentToken = false;
1006-
1007-
private boolean containsSilentMarkerAfterPrevToken = false;
1008-
1009998
/** Construct a tokenizer that parses tokens from the given text. */
1010999
private Tokenizer(final CharSequence text) {
10111000
this.text = text;
@@ -1029,14 +1018,6 @@ int getColumn() {
10291018
return column;
10301019
}
10311020

1032-
boolean getContainsSilentMarkerAfterCurrentToken() {
1033-
return containsSilentMarkerAfterCurrentToken;
1034-
}
1035-
1036-
boolean getContainsSilentMarkerAfterPrevToken() {
1037-
return containsSilentMarkerAfterPrevToken;
1038-
}
1039-
10401021
/** Are we at the end of the input? */
10411022
boolean atEnd() {
10421023
return currentToken.length() == 0;
@@ -1725,19 +1706,6 @@ public static <T extends Message> T parse(
17251706
* control the parser behavior.
17261707
*/
17271708
public static class Parser {
1728-
1729-
/**
1730-
* A valid silent marker appears between a field name and its value. If there is a ":" in
1731-
* between, the silent marker will only appear after the colon. This is called after a field
1732-
* name is parsed, and before the ":" if it exists. If the current token is ":", then
1733-
* containsSilentMarkerAfterCurrentToken indicates if there is a valid silent marker. Otherwise,
1734-
* the current token is part of the field value, so the silent marker is indicated by
1735-
* containsSilentMarkerAfterPrevToken.
1736-
*/
1737-
private void detectSilentMarker(
1738-
Tokenizer tokenizer, Descriptor immediateMessageType, String fieldName) {
1739-
}
1740-
17411709
/**
17421710
* Determines if repeated values for non-repeated fields and oneofs are permitted. For example,
17431711
* given required/optional field "foo" and a oneof containing "baz" and "moo":
@@ -2110,14 +2078,12 @@ private void mergeField(
21102078

21112079
// Skips unknown fields.
21122080
if (field == null) {
2113-
detectSilentMarker(tokenizer, type, name);
21142081
guessFieldTypeAndSkip(tokenizer, type, recursionLimit);
21152082
return;
21162083
}
21172084

21182085
// Handle potential ':'.
21192086
if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
2120-
detectSilentMarker(tokenizer, type, field.getFullName());
21212087
tokenizer.tryConsume(":"); // optional
21222088
if (parseTreeBuilder != null) {
21232089
TextFormatParseInfoTree.Builder childParseTreeBuilder =
@@ -2143,7 +2109,6 @@ private void mergeField(
21432109
recursionLimit);
21442110
}
21452111
} else {
2146-
detectSilentMarker(tokenizer, type, field.getFullName());
21472112
tokenizer.consume(":"); // required
21482113
consumeFieldValues(
21492114
tokenizer,
@@ -2167,27 +2132,26 @@ private void mergeField(
21672132
}
21682133
}
21692134

2170-
private String consumeFullTypeName(Tokenizer tokenizer) throws ParseException {
2135+
private void consumeFullTypeName(Tokenizer tokenizer) throws ParseException {
21712136
// If there is not a leading `[`, this is just a type name.
21722137
if (!tokenizer.tryConsume("[")) {
2173-
return tokenizer.consumeIdentifier();
2138+
tokenizer.consumeIdentifier();
2139+
return;
21742140
}
21752141

21762142
// Otherwise, this is an extension or google.protobuf.Any type URL: we consume proto path
21772143
// elements until we've addressed the type.
2178-
String name = tokenizer.consumeIdentifier();
2144+
tokenizer.consumeIdentifier();
21792145
while (tokenizer.tryConsume(".")) {
2180-
name += "." + tokenizer.consumeIdentifier();
2146+
tokenizer.consumeIdentifier();
21812147
}
21822148
if (tokenizer.tryConsume("/")) {
2183-
name += "/" + tokenizer.consumeIdentifier();
2149+
tokenizer.consumeIdentifier();
21842150
while (tokenizer.tryConsume(".")) {
2185-
name += "." + tokenizer.consumeIdentifier();
2151+
tokenizer.consumeIdentifier();
21862152
}
21872153
}
21882154
tokenizer.consume("]");
2189-
2190-
return name;
21912155
}
21922156

21932157
/**
@@ -2433,7 +2397,6 @@ private void mergeAnyFieldValue(
24332397
throw tokenizer.parseExceptionPreviousToken("Expected a valid type URL.");
24342398
}
24352399
}
2436-
detectSilentMarker(tokenizer, anyDescriptor, typeUrlBuilder.toString());
24372400
tokenizer.tryConsume(":");
24382401
final String anyEndToken;
24392402
if (tokenizer.tryConsume("<")) {
@@ -2478,8 +2441,7 @@ private void mergeAnyFieldValue(
24782441
/** Skips the next field including the field's name and value. */
24792442
private void skipField(Tokenizer tokenizer, Descriptor type, int recursionLimit)
24802443
throws ParseException {
2481-
String name = consumeFullTypeName(tokenizer);
2482-
detectSilentMarker(tokenizer, type, name);
2444+
consumeFullTypeName(tokenizer);
24832445
guessFieldTypeAndSkip(tokenizer, type, recursionLimit);
24842446

24852447
// For historical reasons, fields may optionally be separated by commas or

0 commit comments

Comments
 (0)