Skip to content

Commit

Permalink
Delete unused support for @hidden JSDoc tag & JSMessage.isHidden()
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 698031670
  • Loading branch information
lauraharker authored and copybara-github committed Nov 19, 2024
1 parent 1584a80 commit 68b2e3a
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 110 deletions.
3 changes: 1 addition & 2 deletions src/com/google/javascript/jscomp/CheckJSDoc.java
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,7 @@ private void validateMsgJsDoc(Node n, JSDocInfo info) {
return;
}

boolean hasNonDescMsgTag =
info.isHidden() || info.getMeaning() != null || info.getAlternateMessageId() != null;
boolean hasNonDescMsgTag = info.getMeaning() != null || info.getAlternateMessageId() != null;

if (hasNonDescMsgTag
// Don't error on TS gencode using @desc on a non-message. There's a lot of code that
Expand Down
15 changes: 0 additions & 15 deletions src/com/google/javascript/jscomp/JsMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,6 @@ public PlaceholderFormatException(String msg) {
/** Gets the meaning annotated to the message, intended to force different translations. */
public abstract @Nullable String getMeaning();

/**
* Gets whether this message should be hidden from volunteer translators (to reduce the chances of
* a new feature leak).
*/
public abstract boolean isHidden();

public abstract ImmutableMap<String, String> getPlaceholderNameToExampleMap();

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

private String desc;
private boolean hidden;
private boolean isAnonymous = false;
private boolean isExternal = false;

Expand Down Expand Up @@ -499,13 +492,6 @@ public Builder setAlternateId(@Nullable String alternateId) {
return this;
}

/** Sets whether the message should be hidden from volunteer translators. */
@CanIgnoreReturnValue
public Builder setIsHidden(boolean hidden) {
this.hidden = hidden;
return this;
}

@CanIgnoreReturnValue
public Builder setIsAnonymous(boolean isAnonymous) {
this.isAnonymous = isAnonymous;
Expand Down Expand Up @@ -554,7 +540,6 @@ public JsMessage build() {
alternateId,
desc,
meaning,
hidden,
placeholderNameToExampleMap,
placeholderNameToOriginalCodeMap,
ImmutableSet.copyOf(jsPlaceholderNames));
Expand Down
2 changes: 0 additions & 2 deletions src/com/google/javascript/jscomp/parsing/Annotation.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ enum Annotation {
EXPORT,
FILE_OVERVIEW,
FINAL,
HIDDEN,
IDGENERATOR,
IMPLEMENTS,
IMPLICIT_CAST,
Expand Down Expand Up @@ -133,7 +132,6 @@ enum Annotation {
.put("externs", Annotation.EXTERNS)
.put("fileoverview", Annotation.FILE_OVERVIEW)
.put("final", Annotation.FINAL)
.put("hidden", Annotation.HIDDEN)
.put("idGenerator", Annotation.IDGENERATOR)
.put("implements", Annotation.IMPLEMENTS)
.put("implicitCast", Annotation.IMPLICIT_CAST)
Expand Down
6 changes: 0 additions & 6 deletions src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -674,12 +674,6 @@ private JsDocToken parseAnnotation(JsDocToken token, List<ExtendedTypeInfo> exte
token = eatUntilEOLIfNotAnnotation(token);
return token;

case HIDDEN:
if (!jsdocBuilder.recordHiddenness()) {
addParserWarning(Msg.JSDOC_HIDDEN);
}
return eatUntilEOLIfNotAnnotation();

case LENDS:
skipEOLs();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,6 @@ public static JSDocInfo convertJSDocInfoForOptimizations(JSDocInfo jsdoc) {
}

// Used by ReplaceMessages
if (jsdoc.isHidden()) {
builder.addKind(JsdocTag.JSDOC_HIDDEN);
}
if (jsdoc.getDescription() != null) {
builder.setDescriptionPointer(stringPool.put(jsdoc.getDescription()));
}
Expand Down Expand Up @@ -325,10 +322,6 @@ private static JSTypeExpression createPlaceholderType() {
builder.recordAbstract();
continue;

case JSDOC_HIDDEN:
builder.recordHiddenness();
continue;

// TODO(lharker): stage 2 passes ideally shouldn't report diagnostics, so this could be
// moved to stage 1.
case JSDOC_SUPPRESS_MESSAGE_CONVENTION:
Expand Down
17 changes: 0 additions & 17 deletions src/com/google/javascript/rhino/JSDocInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ private static enum Bit {
CONST,
CONSTRUCTOR,
DEFINE,
HIDDEN,
TYPE_SUMMARY,
FINAL,
OVERRIDE,
Expand Down Expand Up @@ -793,11 +792,6 @@ public boolean isDefine() {
return checkBit(Bit.DEFINE);
}

/** Returns whether the {@code @hidden} annotation is present on this {@link JSDocInfo}. */
public boolean isHidden() {
return checkBit(Bit.HIDDEN);
}

/** Returns whether the {@code @override} annotation is present on this {@link JSDocInfo}. */
public boolean isOverride() {
return checkBit(Bit.OVERRIDE);
Expand Down Expand Up @@ -2296,17 +2290,6 @@ public boolean addLicense(String license) {
return recordLicense(RhinoStringPool.addOrGet(nullToEmpty(txt) + license));
}

/**
* Records that the {@link JSDocInfo} being built should have its {@link JSDocInfo#isHidden()}
* flag set to {@code true}.
*
* @return {@code true} if the hiddenness was recorded and {@code false} if it was already
* defined
*/
public boolean recordHiddenness() {
return populateBit(Bit.HIDDEN, true);
}

/**
* Records that the {@link JSDocInfo} being built should have its {@link
* JSDocInfo#isNoCompile()} flag set to {@code true}.
Expand Down
1 change: 0 additions & 1 deletion src/com/google/javascript/rhino/Msg.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public enum Msg {
JSDOC_FINAL("extra @final tag."),
JSDOC_FUNCTION_NEWNOTOBJECT("constructed type must be an object type"),
JSDOC_FUNCTION_VARARGS("variable length argument must be last."),
JSDOC_HIDDEN("extra @hidden tag"),
JSDOC_IDGEN_BAD("malformed @idGenerator tag"),
JSDOC_IDGEN_DUPLICATE("extra @idGenerator tag"),
JSDOC_IDGEN_UNKNOWN("unknown @idGenerator parameter: {0}"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ enum JsdocTag {
JSDOC_ABSTRACT = 19;

// Used by ReplaceMessage i18n
JSDOC_HIDDEN = 21;
JSDOC_SUPPRESS_MESSAGE_CONVENTION = 22;

// Used by CollapseProperties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,6 @@ public void testExtractPropertyMessageInFunction() {
+ "function f() {\n"
+ " /**\n"
+ " * @desc A message that demonstrates placeholders\n"
+ " * @hidden\n"
+ " */\n"
+ " a.b.MSG_SILLY = goog.getMsg(\n"
+ " '{$adjective} ' + '{$someNoun}',\n"
Expand Down
22 changes: 2 additions & 20 deletions test/com/google/javascript/jscomp/parsing/JsDocInfoParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2421,13 +2421,13 @@ public void testRegression3() {

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

JSDocInfo info = parse(comment);
assertThat(info.isConstant()).isTrue();
assertThat(info.isDefine()).isFalse();
assertThat(info.isConstructor()).isTrue();
assertThat(info.isHidden()).isTrue();
assertThat(info.getVisibility()).isEqualTo(Visibility.PRIVATE);
}

@Test
Expand All @@ -2441,16 +2441,6 @@ public void testRegression5() {
assertThat(info.getVisibility()).isEqualTo(Visibility.PUBLIC);
}

@Test
public void testRegression6() {
String comment = "@hidden\n@enum\n@public*/";

JSDocInfo info = parse(comment);
assertThat(info.isHidden()).isTrue();
assertTypeEquals(NUMBER_TYPE, info.getEnumParameterType());
assertThat(info.getVisibility()).isEqualTo(Visibility.PUBLIC);
}

@Test
public void testRegression7() {
String comment =
Expand Down Expand Up @@ -2490,7 +2480,6 @@ public void testRegression9() {
assertThat(jsdoc.isConstant()).isFalse();
assertThat(jsdoc.getDescription()).isNull();
assertThat(jsdoc.getEnumParameterType()).isNull();
assertThat(jsdoc.isHidden()).isFalse();
assertThat(jsdoc.getParameterCount()).isEqualTo(1);
assertTypeEquals(STRING_TYPE, jsdoc.getParameterType("p0"));
assertThat(jsdoc.getReturnType()).isNull();
Expand All @@ -2511,7 +2500,6 @@ public void testRegression10() {
assertThat(jsdoc.isConstant()).isFalse();
assertThat(jsdoc.getDescription()).isNull();
assertThat(jsdoc.getEnumParameterType()).isNull();
assertThat(jsdoc.isHidden()).isFalse();
assertThat(jsdoc.getParameterCount()).isEqualTo(2);
assertTypeEquals(STRING_OBJECT_TYPE, jsdoc.getParameterType("p0"));
assertTypeEquals(BOOLEAN_TYPE, jsdoc.getParameterType("p1"));
Expand All @@ -2528,7 +2516,6 @@ public void testRegression11() {
assertThat(jsdoc.isConstant()).isFalse();
assertThat(jsdoc.getDescription()).isNull();
assertThat(jsdoc.getEnumParameterType()).isNull();
assertThat(jsdoc.isHidden()).isFalse();
assertThat(jsdoc.getParameterCount()).isEqualTo(0);
assertThat(jsdoc.getReturnType()).isNull();
assertThat(jsdoc.getType()).isNull();
Expand All @@ -2543,7 +2530,6 @@ public void testRegression12() {
assertThat(jsdoc.isConstant()).isFalse();
assertThat(jsdoc.getDescription()).isNull();
assertThat(jsdoc.getEnumParameterType()).isNull();
assertThat(jsdoc.isHidden()).isFalse();
assertThat(jsdoc.getParameterCount()).isEqualTo(0);
assertThat(jsdoc.getReturnType()).isNull();
assertThat(jsdoc.getType()).isNull();
Expand All @@ -2558,7 +2544,6 @@ public void testRegression13() {
assertThat(jsdoc.isConstant()).isFalse();
assertThat(jsdoc.getDescription()).isNull();
assertThat(jsdoc.getEnumParameterType()).isNull();
assertThat(jsdoc.isHidden()).isFalse();
assertThat(jsdoc.getParameterCount()).isEqualTo(0);
assertThat(jsdoc.getReturnType()).isNull();
assertTypeEquals(REGEXP_TYPE, jsdoc.getType());
Expand All @@ -2573,7 +2558,6 @@ public void testRegression14() {
assertThat(jsdoc.isConstant()).isTrue();
assertThat(jsdoc.getDescription()).isNull();
assertThat(jsdoc.getEnumParameterType()).isNull();
assertThat(jsdoc.isHidden()).isFalse();
assertThat(jsdoc.getParameterCount()).isEqualTo(0);
assertThat(jsdoc.getReturnType()).isNull();
assertThat(jsdoc.getType()).isNull();
Expand All @@ -2588,7 +2572,6 @@ public void testRegression15() {
assertThat(jsdoc.isConstant()).isTrue();
assertThat(jsdoc.getDescription()).isEqualTo("Hello, World!");
assertThat(jsdoc.getEnumParameterType()).isNull();
assertThat(jsdoc.isHidden()).isFalse();
assertThat(jsdoc.getParameterCount()).isEqualTo(0);
assertThat(jsdoc.getReturnType()).isNull();
assertThat(jsdoc.getType()).isNull();
Expand All @@ -2603,7 +2586,6 @@ public void testRegression16() {
assertThat(jsdoc.getBaseType()).isNull();
assertThat(jsdoc.isConstant()).isFalse();
assertTypeEquals(STRING_TYPE, jsdoc.getType());
assertThat(jsdoc.isHidden()).isFalse();
assertThat(jsdoc.getParameterCount()).isEqualTo(0);
assertThat(jsdoc.getReturnType()).isNull();
assertThat(jsdoc.getVisibility()).isEqualTo(Visibility.INHERITED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ public void testJsDocTokenization5() {
public void testJsDocTokenization6() {
ImmutableList<JsDocToken> tokens =
ImmutableList.of(ANNOTATION, EOL, ANNOTATION, EOL, ANNOTATION, EOC);
ImmutableList<String> strings = ImmutableList.of("hidden", "static", "desc");
testJSDocTokenStream("@hidden\n@static\n@desc*/", tokens, strings);
testJSDocTokenStream("@hidden\n @static\n@desc*/", tokens, strings);
testJSDocTokenStream("@hidden\n@static\n @desc*/", tokens, strings);
testJSDocTokenStream("@hidden\n@static\n@desc */", tokens, strings);
testJSDocTokenStream(" @hidden \n@static\n @desc*/", tokens, strings);
testJSDocTokenStream("@hidden\n@static \n @desc */", tokens, strings);
testJSDocTokenStream("@hidden\n@static\n@desc*/", tokens, strings);
testJSDocTokenStream("@hidden \n@static \n @desc*/", tokens, strings);
ImmutableList<String> strings = ImmutableList.of("private", "static", "desc");
testJSDocTokenStream("@private\n@static\n@desc*/", tokens, strings);
testJSDocTokenStream("@private\n @static\n@desc*/", tokens, strings);
testJSDocTokenStream("@private\n@static\n @desc*/", tokens, strings);
testJSDocTokenStream("@private\n@static\n@desc */", tokens, strings);
testJSDocTokenStream(" @private \n@static\n @desc*/", tokens, strings);
testJSDocTokenStream("@private\n@static \n @desc */", tokens, strings);
testJSDocTokenStream("@private\n@static\n@desc*/", tokens, strings);
testJSDocTokenStream("@private \n@static \n @desc*/", tokens, strings);
}

@Test
Expand Down
Loading

0 comments on commit 68b2e3a

Please sign in to comment.