Skip to content

Commit 98c8525

Browse files
cpovirkgoogle-java-format Team
authored andcommitted
Split up the string "M" + "OE:(begin|end)_intracomment_stripping," as the full string will trigger stripping under Copybara.
Also, avoid reference to an internal link shortener, as we are making references to it an error. Looking to the future: When we migrate to use proper Copybara stripping directives, we could consider removing support for the old directives. Then the problem would mostly go away. However, we might end up having the same problem with Copybara directives when google-java-format's strings and method names start mentioning *them*. PiperOrigin-RevId: 311344956
1 parent f5a9280 commit 98c8525

2 files changed

Lines changed: 27 additions & 27 deletions

File tree

core/src/main/java/com/google/googlejavaformat/java/javadoc/JavadocLexer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,9 +507,9 @@ private static boolean hasMultipleNewlines(String s) {
507507
// Match "@param <T>" specially in case the <T> is a <P> or other HTML tag we treat specially.
508508
private static final Pattern FOOTER_TAG_PATTERN = compile("^@(param\\s+<\\w+>|[a-z]\\w*)");
509509
private static final Pattern MOE_BEGIN_STRIP_COMMENT_PATTERN =
510-
compile("^<!--\\s*MOE:begin_intracomment_strip\\s*-->");
510+
compile("^<!--\\s*M" + "OE:begin_intracomment_strip\\s*-->");
511511
private static final Pattern MOE_END_STRIP_COMMENT_PATTERN =
512-
compile("^<!--\\s*MOE:end_intracomment_strip\\s*-->");
512+
compile("^<!--\\s*M" + "OE:end_intracomment_strip\\s*-->");
513513
private static final Pattern HTML_COMMENT_PATTERN = fullCommentPattern();
514514
private static final Pattern PRE_OPEN_PATTERN = openTagPattern("pre");
515515
private static final Pattern PRE_CLOSE_PATTERN = closeTagPattern("pre");

core/src/test/java/com/google/googlejavaformat/java/JavadocFormattingTest.java

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -115,48 +115,48 @@ public void moeComments() {
115115
String[] input = {
116116
"/**",
117117
" * Deatomizes the given user.",
118-
" * <!-- MOE:begin_intracomment_strip -->",
119-
" * See go/deatomizer-v5 for the design doc.",
120-
" * <!-- MOE:end_intracomment_strip -->",
118+
" * <!-- M" + "OE:begin_intracomment_strip -->",
119+
" * See deatomizer-v5 for the design doc.",
120+
" * <!-- M" + "OE:end_intracomment_strip -->",
121121
" * To reatomize, call {@link reatomize}.",
122122
" *",
123-
" * <!-- MOE:begin_intracomment_strip -->",
123+
" * <!-- M" + "OE:begin_intracomment_strip -->",
124124
" * <p>This method is used in the Google teleporter.",
125125
" *",
126126
" * <p>Yes, we have a teleporter.",
127-
" * <!-- MOE:end_intracomment_strip -->",
127+
" * <!-- M" + "OE:end_intracomment_strip -->",
128128
" *",
129129
" * @param user the person to teleport.",
130-
" * <!-- MOE:begin_intracomment_strip -->",
131-
" * Users must sign go/deatomize-waiver ahead of time.",
132-
" * <!-- MOE:end_intracomment_strip -->",
133-
" * <!-- MOE:begin_intracomment_strip -->",
130+
" * <!-- M" + "OE:begin_intracomment_strip -->",
131+
" * Users must sign deatomize-waiver ahead of time.",
132+
" * <!-- M" + "OE:end_intracomment_strip -->",
133+
" * <!-- M" + "OE:begin_intracomment_strip -->",
134134
" * @deprecated Sometimes turns the user into a goat.",
135-
" * <!-- MOE:end_intracomment_strip -->",
135+
" * <!-- M" + "OE:end_intracomment_strip -->",
136136
" */",
137137
"class Test {}",
138138
};
139139
String[] expected = {
140140
"/**",
141141
" * Deatomizes the given user.",
142-
" * <!-- MOE:begin_intracomment_strip -->",
143-
" * See go/deatomizer-v5 for the design doc.",
144-
" * <!-- MOE:end_intracomment_strip -->",
142+
" * <!-- M" + "OE:begin_intracomment_strip -->",
143+
" * See deatomizer-v5 for the design doc.",
144+
" * <!-- M" + "OE:end_intracomment_strip -->",
145145
" * To reatomize, call {@link reatomize}.",
146146
" *",
147-
" * <!-- MOE:begin_intracomment_strip -->",
147+
" * <!-- M" + "OE:begin_intracomment_strip -->",
148148
" * <p>This method is used in the Google teleporter.",
149149
" *",
150150
" * <p>Yes, we have a teleporter.",
151-
" * <!-- MOE:end_intracomment_strip -->",
151+
" * <!-- M" + "OE:end_intracomment_strip -->",
152152
" *",
153153
" * @param user the person to teleport.",
154-
" * <!-- MOE:begin_intracomment_strip -->",
155-
" * Users must sign go/deatomize-waiver ahead of time.",
156-
" * <!-- MOE:end_intracomment_strip -->",
157-
" * <!-- MOE:begin_intracomment_strip -->",
154+
" * <!-- M" + "OE:begin_intracomment_strip -->",
155+
" * Users must sign deatomize-waiver ahead of time.",
156+
" * <!-- M" + "OE:end_intracomment_strip -->",
157+
" * <!-- M" + "OE:begin_intracomment_strip -->",
158158
" * @deprecated Sometimes turns the user into a goat.",
159-
" * <!-- MOE:end_intracomment_strip -->",
159+
" * <!-- M" + "OE:end_intracomment_strip -->",
160160
" */",
161161
"class Test {}",
162162
};
@@ -169,15 +169,15 @@ public void moeCommentBeginOnlyInMiddleOfDoc() {
169169
String[] input = {
170170
"/**", //
171171
" * Foo.",
172-
" * <!-- MOE:begin_intracomment_strip -->",
172+
" * <!-- M" + "OE:begin_intracomment_strip -->",
173173
" * Bar.",
174174
" */",
175175
"class Test {}",
176176
};
177177
String[] expected = {
178178
"/**", //
179179
" * Foo.",
180-
" * <!-- MOE:begin_intracomment_strip -->",
180+
" * <!-- M" + "OE:begin_intracomment_strip -->",
181181
" * Bar.",
182182
" */",
183183
"class Test {}",
@@ -192,7 +192,7 @@ public void moeCommentBeginOnlyAtEndOfDoc() {
192192
String[] input = {
193193
"/**", //
194194
" * Foo.",
195-
" * <!-- MOE:begin_intracomment_strip -->",
195+
" * <!-- M" + "OE:begin_intracomment_strip -->",
196196
" */",
197197
"class Test {}",
198198
};
@@ -209,14 +209,14 @@ public void moeCommentEndOnly() {
209209
String[] input = {
210210
"/**", //
211211
" * Foo.",
212-
" * <!-- MOE:end_intracomment_strip -->",
212+
" * <!-- M" + "OE:end_intracomment_strip -->",
213213
" */",
214214
"class Test {}",
215215
};
216216
String[] expected = {
217217
"/**", //
218218
" * Foo.",
219-
" * <!-- MOE:end_intracomment_strip -->",
219+
" * <!-- M" + "OE:end_intracomment_strip -->",
220220
" */",
221221
"class Test {}",
222222
};

0 commit comments

Comments
 (0)