Skip to content

Commit 68b2e3a

Browse files
lauraharkercopybara-github
authored andcommitted
Delete unused support for @hidden JSDoc tag & JSMessage.isHidden()
PiperOrigin-RevId: 698031670
1 parent 1584a80 commit 68b2e3a

File tree

12 files changed

+19
-110
lines changed

12 files changed

+19
-110
lines changed

src/com/google/javascript/jscomp/CheckJSDoc.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,7 @@ private void validateMsgJsDoc(Node n, JSDocInfo info) {
533533
return;
534534
}
535535

536-
boolean hasNonDescMsgTag =
537-
info.isHidden() || info.getMeaning() != null || info.getAlternateMessageId() != null;
536+
boolean hasNonDescMsgTag = info.getMeaning() != null || info.getAlternateMessageId() != null;
538537

539538
if (hasNonDescMsgTag
540539
// Don't error on TS gencode using @desc on a non-message. There's a lot of code that

src/com/google/javascript/jscomp/JsMessage.java

-15
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,6 @@ public PlaceholderFormatException(String msg) {
101101
/** Gets the meaning annotated to the message, intended to force different translations. */
102102
public abstract @Nullable String getMeaning();
103103

104-
/**
105-
* Gets whether this message should be hidden from volunteer translators (to reduce the chances of
106-
* a new feature leak).
107-
*/
108-
public abstract boolean isHidden();
109-
110104
public abstract ImmutableMap<String, String> getPlaceholderNameToExampleMap();
111105

112106
public abstract ImmutableMap<String, String> getPlaceholderNameToOriginalCodeMap();
@@ -371,7 +365,6 @@ public static final class Builder {
371365
private String meaning;
372366

373367
private String desc;
374-
private boolean hidden;
375368
private boolean isAnonymous = false;
376369
private boolean isExternal = false;
377370

@@ -499,13 +492,6 @@ public Builder setAlternateId(@Nullable String alternateId) {
499492
return this;
500493
}
501494

502-
/** Sets whether the message should be hidden from volunteer translators. */
503-
@CanIgnoreReturnValue
504-
public Builder setIsHidden(boolean hidden) {
505-
this.hidden = hidden;
506-
return this;
507-
}
508-
509495
@CanIgnoreReturnValue
510496
public Builder setIsAnonymous(boolean isAnonymous) {
511497
this.isAnonymous = isAnonymous;
@@ -554,7 +540,6 @@ public JsMessage build() {
554540
alternateId,
555541
desc,
556542
meaning,
557-
hidden,
558543
placeholderNameToExampleMap,
559544
placeholderNameToOriginalCodeMap,
560545
ImmutableSet.copyOf(jsPlaceholderNames));

src/com/google/javascript/jscomp/parsing/Annotation.java

-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ enum Annotation {
4141
EXPORT,
4242
FILE_OVERVIEW,
4343
FINAL,
44-
HIDDEN,
4544
IDGENERATOR,
4645
IMPLEMENTS,
4746
IMPLICIT_CAST,
@@ -133,7 +132,6 @@ enum Annotation {
133132
.put("externs", Annotation.EXTERNS)
134133
.put("fileoverview", Annotation.FILE_OVERVIEW)
135134
.put("final", Annotation.FINAL)
136-
.put("hidden", Annotation.HIDDEN)
137135
.put("idGenerator", Annotation.IDGENERATOR)
138136
.put("implements", Annotation.IMPLEMENTS)
139137
.put("implicitCast", Annotation.IMPLICIT_CAST)

src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java

-6
Original file line numberDiff line numberDiff line change
@@ -674,12 +674,6 @@ private JsDocToken parseAnnotation(JsDocToken token, List<ExtendedTypeInfo> exte
674674
token = eatUntilEOLIfNotAnnotation(token);
675675
return token;
676676

677-
case HIDDEN:
678-
if (!jsdocBuilder.recordHiddenness()) {
679-
addParserWarning(Msg.JSDOC_HIDDEN);
680-
}
681-
return eatUntilEOLIfNotAnnotation();
682-
683677
case LENDS:
684678
skipEOLs();
685679

src/com/google/javascript/jscomp/serialization/JSDocSerializer.java

-7
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,6 @@ public static JSDocInfo convertJSDocInfoForOptimizations(JSDocInfo jsdoc) {
155155
}
156156

157157
// Used by ReplaceMessages
158-
if (jsdoc.isHidden()) {
159-
builder.addKind(JsdocTag.JSDOC_HIDDEN);
160-
}
161158
if (jsdoc.getDescription() != null) {
162159
builder.setDescriptionPointer(stringPool.put(jsdoc.getDescription()));
163160
}
@@ -325,10 +322,6 @@ private static JSTypeExpression createPlaceholderType() {
325322
builder.recordAbstract();
326323
continue;
327324

328-
case JSDOC_HIDDEN:
329-
builder.recordHiddenness();
330-
continue;
331-
332325
// TODO(lharker): stage 2 passes ideally shouldn't report diagnostics, so this could be
333326
// moved to stage 1.
334327
case JSDOC_SUPPRESS_MESSAGE_CONVENTION:

src/com/google/javascript/rhino/JSDocInfo.java

-17
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ private static enum Bit {
309309
CONST,
310310
CONSTRUCTOR,
311311
DEFINE,
312-
HIDDEN,
313312
TYPE_SUMMARY,
314313
FINAL,
315314
OVERRIDE,
@@ -793,11 +792,6 @@ public boolean isDefine() {
793792
return checkBit(Bit.DEFINE);
794793
}
795794

796-
/** Returns whether the {@code @hidden} annotation is present on this {@link JSDocInfo}. */
797-
public boolean isHidden() {
798-
return checkBit(Bit.HIDDEN);
799-
}
800-
801795
/** Returns whether the {@code @override} annotation is present on this {@link JSDocInfo}. */
802796
public boolean isOverride() {
803797
return checkBit(Bit.OVERRIDE);
@@ -2296,17 +2290,6 @@ public boolean addLicense(String license) {
22962290
return recordLicense(RhinoStringPool.addOrGet(nullToEmpty(txt) + license));
22972291
}
22982292

2299-
/**
2300-
* Records that the {@link JSDocInfo} being built should have its {@link JSDocInfo#isHidden()}
2301-
* flag set to {@code true}.
2302-
*
2303-
* @return {@code true} if the hiddenness was recorded and {@code false} if it was already
2304-
* defined
2305-
*/
2306-
public boolean recordHiddenness() {
2307-
return populateBit(Bit.HIDDEN, true);
2308-
}
2309-
23102293
/**
23112294
* Records that the {@link JSDocInfo} being built should have its {@link
23122295
* JSDocInfo#isNoCompile()} flag set to {@code true}.

src/com/google/javascript/rhino/Msg.java

-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ public enum Msg {
7272
JSDOC_FINAL("extra @final tag."),
7373
JSDOC_FUNCTION_NEWNOTOBJECT("constructed type must be an object type"),
7474
JSDOC_FUNCTION_VARARGS("variable length argument must be last."),
75-
JSDOC_HIDDEN("extra @hidden tag"),
7675
JSDOC_IDGEN_BAD("malformed @idGenerator tag"),
7776
JSDOC_IDGEN_DUPLICATE("extra @idGenerator tag"),
7877
JSDOC_IDGEN_UNKNOWN("unknown @idGenerator parameter: {0}"),

src/com/google/javascript/rhino/typed_ast/optimization_jsdoc.proto

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ enum JsdocTag {
4848
JSDOC_ABSTRACT = 19;
4949

5050
// Used by ReplaceMessage i18n
51-
JSDOC_HIDDEN = 21;
5251
JSDOC_SUPPRESS_MESSAGE_CONVENTION = 22;
5352

5453
// Used by CollapseProperties

test/com/google/javascript/jscomp/JsMessageVisitorTest.java

-1
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,6 @@ public void testExtractPropertyMessageInFunction() {
903903
+ "function f() {\n"
904904
+ " /**\n"
905905
+ " * @desc A message that demonstrates placeholders\n"
906-
+ " * @hidden\n"
907906
+ " */\n"
908907
+ " a.b.MSG_SILLY = goog.getMsg(\n"
909908
+ " '{$adjective} ' + '{$someNoun}',\n"

test/com/google/javascript/jscomp/parsing/JsDocInfoParserTest.java

+2-20
Original file line numberDiff line numberDiff line change
@@ -2421,13 +2421,13 @@ public void testRegression3() {
24212421

24222422
@Test
24232423
public void testRegression4() {
2424-
String comment = " * @const\n" + " * @hidden\n" + " * @constructor\n" + " */";
2424+
String comment = " * @const\n" + " * @private\n" + " * @constructor\n" + " */";
24252425

24262426
JSDocInfo info = parse(comment);
24272427
assertThat(info.isConstant()).isTrue();
24282428
assertThat(info.isDefine()).isFalse();
24292429
assertThat(info.isConstructor()).isTrue();
2430-
assertThat(info.isHidden()).isTrue();
2430+
assertThat(info.getVisibility()).isEqualTo(Visibility.PRIVATE);
24312431
}
24322432

24332433
@Test
@@ -2441,16 +2441,6 @@ public void testRegression5() {
24412441
assertThat(info.getVisibility()).isEqualTo(Visibility.PUBLIC);
24422442
}
24432443

2444-
@Test
2445-
public void testRegression6() {
2446-
String comment = "@hidden\n@enum\n@public*/";
2447-
2448-
JSDocInfo info = parse(comment);
2449-
assertThat(info.isHidden()).isTrue();
2450-
assertTypeEquals(NUMBER_TYPE, info.getEnumParameterType());
2451-
assertThat(info.getVisibility()).isEqualTo(Visibility.PUBLIC);
2452-
}
2453-
24542444
@Test
24552445
public void testRegression7() {
24562446
String comment =
@@ -2490,7 +2480,6 @@ public void testRegression9() {
24902480
assertThat(jsdoc.isConstant()).isFalse();
24912481
assertThat(jsdoc.getDescription()).isNull();
24922482
assertThat(jsdoc.getEnumParameterType()).isNull();
2493-
assertThat(jsdoc.isHidden()).isFalse();
24942483
assertThat(jsdoc.getParameterCount()).isEqualTo(1);
24952484
assertTypeEquals(STRING_TYPE, jsdoc.getParameterType("p0"));
24962485
assertThat(jsdoc.getReturnType()).isNull();
@@ -2511,7 +2500,6 @@ public void testRegression10() {
25112500
assertThat(jsdoc.isConstant()).isFalse();
25122501
assertThat(jsdoc.getDescription()).isNull();
25132502
assertThat(jsdoc.getEnumParameterType()).isNull();
2514-
assertThat(jsdoc.isHidden()).isFalse();
25152503
assertThat(jsdoc.getParameterCount()).isEqualTo(2);
25162504
assertTypeEquals(STRING_OBJECT_TYPE, jsdoc.getParameterType("p0"));
25172505
assertTypeEquals(BOOLEAN_TYPE, jsdoc.getParameterType("p1"));
@@ -2528,7 +2516,6 @@ public void testRegression11() {
25282516
assertThat(jsdoc.isConstant()).isFalse();
25292517
assertThat(jsdoc.getDescription()).isNull();
25302518
assertThat(jsdoc.getEnumParameterType()).isNull();
2531-
assertThat(jsdoc.isHidden()).isFalse();
25322519
assertThat(jsdoc.getParameterCount()).isEqualTo(0);
25332520
assertThat(jsdoc.getReturnType()).isNull();
25342521
assertThat(jsdoc.getType()).isNull();
@@ -2543,7 +2530,6 @@ public void testRegression12() {
25432530
assertThat(jsdoc.isConstant()).isFalse();
25442531
assertThat(jsdoc.getDescription()).isNull();
25452532
assertThat(jsdoc.getEnumParameterType()).isNull();
2546-
assertThat(jsdoc.isHidden()).isFalse();
25472533
assertThat(jsdoc.getParameterCount()).isEqualTo(0);
25482534
assertThat(jsdoc.getReturnType()).isNull();
25492535
assertThat(jsdoc.getType()).isNull();
@@ -2558,7 +2544,6 @@ public void testRegression13() {
25582544
assertThat(jsdoc.isConstant()).isFalse();
25592545
assertThat(jsdoc.getDescription()).isNull();
25602546
assertThat(jsdoc.getEnumParameterType()).isNull();
2561-
assertThat(jsdoc.isHidden()).isFalse();
25622547
assertThat(jsdoc.getParameterCount()).isEqualTo(0);
25632548
assertThat(jsdoc.getReturnType()).isNull();
25642549
assertTypeEquals(REGEXP_TYPE, jsdoc.getType());
@@ -2573,7 +2558,6 @@ public void testRegression14() {
25732558
assertThat(jsdoc.isConstant()).isTrue();
25742559
assertThat(jsdoc.getDescription()).isNull();
25752560
assertThat(jsdoc.getEnumParameterType()).isNull();
2576-
assertThat(jsdoc.isHidden()).isFalse();
25772561
assertThat(jsdoc.getParameterCount()).isEqualTo(0);
25782562
assertThat(jsdoc.getReturnType()).isNull();
25792563
assertThat(jsdoc.getType()).isNull();
@@ -2588,7 +2572,6 @@ public void testRegression15() {
25882572
assertThat(jsdoc.isConstant()).isTrue();
25892573
assertThat(jsdoc.getDescription()).isEqualTo("Hello, World!");
25902574
assertThat(jsdoc.getEnumParameterType()).isNull();
2591-
assertThat(jsdoc.isHidden()).isFalse();
25922575
assertThat(jsdoc.getParameterCount()).isEqualTo(0);
25932576
assertThat(jsdoc.getReturnType()).isNull();
25942577
assertThat(jsdoc.getType()).isNull();
@@ -2603,7 +2586,6 @@ public void testRegression16() {
26032586
assertThat(jsdoc.getBaseType()).isNull();
26042587
assertThat(jsdoc.isConstant()).isFalse();
26052588
assertTypeEquals(STRING_TYPE, jsdoc.getType());
2606-
assertThat(jsdoc.isHidden()).isFalse();
26072589
assertThat(jsdoc.getParameterCount()).isEqualTo(0);
26082590
assertThat(jsdoc.getReturnType()).isNull();
26092591
assertThat(jsdoc.getVisibility()).isEqualTo(Visibility.INHERITED);

test/com/google/javascript/jscomp/parsing/JsDocTokenStreamTest.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,15 @@ public void testJsDocTokenization5() {
127127
public void testJsDocTokenization6() {
128128
ImmutableList<JsDocToken> tokens =
129129
ImmutableList.of(ANNOTATION, EOL, ANNOTATION, EOL, ANNOTATION, EOC);
130-
ImmutableList<String> strings = ImmutableList.of("hidden", "static", "desc");
131-
testJSDocTokenStream("@hidden\n@static\n@desc*/", tokens, strings);
132-
testJSDocTokenStream("@hidden\n @static\n@desc*/", tokens, strings);
133-
testJSDocTokenStream("@hidden\n@static\n @desc*/", tokens, strings);
134-
testJSDocTokenStream("@hidden\n@static\n@desc */", tokens, strings);
135-
testJSDocTokenStream(" @hidden \n@static\n @desc*/", tokens, strings);
136-
testJSDocTokenStream("@hidden\n@static \n @desc */", tokens, strings);
137-
testJSDocTokenStream("@hidden\n@static\n@desc*/", tokens, strings);
138-
testJSDocTokenStream("@hidden \n@static \n @desc*/", tokens, strings);
130+
ImmutableList<String> strings = ImmutableList.of("private", "static", "desc");
131+
testJSDocTokenStream("@private\n@static\n@desc*/", tokens, strings);
132+
testJSDocTokenStream("@private\n @static\n@desc*/", tokens, strings);
133+
testJSDocTokenStream("@private\n@static\n @desc*/", tokens, strings);
134+
testJSDocTokenStream("@private\n@static\n@desc */", tokens, strings);
135+
testJSDocTokenStream(" @private \n@static\n @desc*/", tokens, strings);
136+
testJSDocTokenStream("@private\n@static \n @desc */", tokens, strings);
137+
testJSDocTokenStream("@private\n@static\n@desc*/", tokens, strings);
138+
testJSDocTokenStream("@private \n@static \n @desc*/", tokens, strings);
139139
}
140140

141141
@Test

0 commit comments

Comments
 (0)