Skip to content

Commit

Permalink
Deletes linter check for visibility annotations on class constructors…
Browse files Browse the repository at this point in the history
… now that they're supported.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=216720684
  • Loading branch information
nreid260 authored and brad4d committed Oct 12, 2018
1 parent 5e995c8 commit 3b7c29d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 24 deletions.
18 changes: 3 additions & 15 deletions src/com/google/javascript/jscomp/lint/CheckJSDocStyle.java
Expand Up @@ -40,10 +40,6 @@
* with no corresponding {@code @param} annotation, coding conventions not being respected, etc.
*/
public final class CheckJSDocStyle extends AbstractPostOrderCallback implements CompilerPass {
public static final DiagnosticType CONSTRUCTOR_DISALLOWED_JSDOC =
DiagnosticType.disabled("JSC_CONSTRUCTOR_DISALLOWED_JSDOC",
"Setting visibility on constructors is not yet supported.\n"
+ "See https://github.com/google/closure-compiler/issues/2761\n");

public static final DiagnosticType CLASS_DISALLOWED_JSDOC =
DiagnosticType.disabled("JSC_CLASS_DISALLOWED_JSDOC",
Expand Down Expand Up @@ -94,7 +90,6 @@ public final class CheckJSDocStyle extends AbstractPostOrderCallback implements
public static final DiagnosticGroup ALL_DIAGNOSTICS =
new DiagnosticGroup(
CLASS_DISALLOWED_JSDOC,
CONSTRUCTOR_DISALLOWED_JSDOC,
MISSING_JSDOC,
MISSING_PARAMETER_JSDOC,
MIXED_PARAM_JSDOC_STYLES,
Expand All @@ -120,10 +115,10 @@ public void process(Node externs, Node root) {
}

@Override
public void visit(NodeTraversal t, Node n, Node parent) {
public void visit(NodeTraversal t, Node n, Node unused) {
switch (n.getToken()) {
case FUNCTION:
visitFunction(t, n, parent);
visitFunction(t, n);
break;
case CLASS:
visitClass(t, n);
Expand Down Expand Up @@ -198,7 +193,7 @@ private void checkStyleForPrivateProperties(NodeTraversal t, Node n) {
}
}

private void visitFunction(NodeTraversal t, Node function, Node parent) {
private void visitFunction(NodeTraversal t, Node function) {
JSDocInfo jsDoc = NodeUtil.getBestJSDocInfo(function);

checkForAtSignCodePresence(t, function, jsDoc);
Expand All @@ -214,13 +209,6 @@ private void visitFunction(NodeTraversal t, Node function, Node parent) {
}
checkReturn(t, function, jsDoc);
}

if (parent.isMemberFunctionDef()
&& "constructor".equals(parent.getString())
&& jsDoc != null
&& !jsDoc.getVisibility().equals(Visibility.INHERITED)) {
t.report(function, CONSTRUCTOR_DISALLOWED_JSDOC);
}
}

private void visitClass(NodeTraversal t, Node cls) {
Expand Down
Expand Up @@ -16,7 +16,6 @@
package com.google.javascript.jscomp.lint;

import static com.google.javascript.jscomp.lint.CheckJSDocStyle.CLASS_DISALLOWED_JSDOC;
import static com.google.javascript.jscomp.lint.CheckJSDocStyle.CONSTRUCTOR_DISALLOWED_JSDOC;
import static com.google.javascript.jscomp.lint.CheckJSDocStyle.EXTERNS_FILES_SHOULD_BE_ANNOTATED;
import static com.google.javascript.jscomp.lint.CheckJSDocStyle.INCORRECT_PARAM_NAME;
import static com.google.javascript.jscomp.lint.CheckJSDocStyle.MISSING_JSDOC;
Expand Down Expand Up @@ -1147,14 +1146,6 @@ public void testValidExternsAnnotation_withES6Modules() {
srcs(""));
}

@Test
public void testConstructorsDontHaveVisibility() {
testSame(inIIFE("/** @private */ class Foo { constructor() {} }"));

testWarning(
inIIFE("class Foo { /** @private */ constructor() {} }"), CONSTRUCTOR_DISALLOWED_JSDOC);
}

@Test
public void testAtSignCodeDetectedWhenPresent() {
testWarning(
Expand Down

0 comments on commit 3b7c29d

Please sign in to comment.