@Override public void visit(NodeTraversal t, Node n, Node parent) { maybeAddJsDocUsages(t, n); switch (n.getType()) { case Token.ASSIGN: case Token.VAR: case Token.LET: case Token.CONST: maybeAddProvidedName(n); break; case Token.FUNCTION: // Exclude function expressions. if (NodeUtil.isStatement(n)) { maybeAddProvidedName(n); } break; case Token.NAME: if (!NodeUtil.isLValue(n)) { visitQualifiedName(n); } break; case Token.GETPROP: visitQualifiedName(n); break; case Token.CALL: visitCallNode(t, n, parent); break; case Token.SCRIPT: visitScriptNode(t); reset(); break; case Token.NEW: visitNewNode(t, n); break; case Token.CLASS: visitClassNode(t, n); break; case Token.IMPORT: visitImportNode(n); break; } }
private void maybeReplaceJqueryPrototypeAlias(Node n) { // Check to see if this is the assignment of the original alias. // If so, leave it intact. if (NodeUtil.isLValue(n)) { Node maybeAssign = n.getParent(); while (!NodeUtil.isStatement(maybeAssign) && !maybeAssign.isAssign()) { maybeAssign = maybeAssign.getParent(); } if (maybeAssign.isAssign()) { maybeAssign = maybeAssign.getParent(); if (maybeAssign.isBlock() || maybeAssign.isScript() || NodeUtil.isStatement(maybeAssign)) { return; } } } Node fn = n.getLastChild(); if (fn != null) { n.replaceChild(fn, IR.string("prototype").srcref(fn)); compiler.reportCodeChange(); } }