public static Node cast(Node expr1, JSDocInfo jsdoc) { Node op = unaryOp(Token.CAST, expr1); op.setJSDocInfo(jsdoc); return op; }
public static Node cast(Node expr1, JSDocInfo jsdoc) { Node op = unaryOp(Token.CAST, expr1); op.setJSDocInfo(jsdoc); return op; }
private void deleteInlineJsdocs(Node fn) { Preconditions.checkArgument(fn.isFunction()); for (Node param : NodeUtil.getFunctionParameters(fn).children()) { param.setJSDocInfo(null); } // Delete the inline return as well, if any fn.getFirstChild().setJSDocInfo(null); }
private void deleteInlineJsdocs(Node fn) { checkArgument(fn.isFunction()); for (Node param : NodeUtil.getFunctionParameters(fn).children()) { param.setJSDocInfo(null); } // Delete the inline return as well, if any fn.getFirstChild().setJSDocInfo(null); }
private static void extractInlineJSDoc(Node srcDeclaration, Node srcName, Node destDeclaration) { JSDocInfo existingInfo = srcDeclaration.getJSDocInfo(); if (existingInfo == null) { // Extract inline JSDoc from "src" and add it to the "dest" node. existingInfo = srcName.getJSDocInfo(); srcName.setJSDocInfo(null); } JSDocInfoBuilder builder = JSDocInfoBuilder.maybeCopyFrom(existingInfo); destDeclaration.setJSDocInfo(builder.build()); }
private void markConst(Node n) { JSDocInfoBuilder builder = JSDocInfoBuilder.maybeCopyFrom(n.getJSDocInfo()); builder.recordConstancy(); n.setJSDocInfo(builder.build()); }
private static void markConstAndCopyJsDoc(Node from, Node target) { JSDocInfo info = from.getJSDocInfo(); JSDocInfoBuilder builder = JSDocInfoBuilder.maybeCopyFrom(info); builder.recordConstancy(); target.setJSDocInfo(builder.build()); }
Node processNameWithInlineJSDoc(IdentifierToken identifierToken) { JSDocInfo info = handleInlineJsDoc(identifierToken); maybeWarnReservedKeyword(identifierToken); Node node = newStringNode(Token.NAME, identifierToken.value); if (info != null) { node.setJSDocInfo(info); } setSourceInfo(node, identifierToken); return node; }
/** * Add at-constructor to the JSDoc of the given node. * * @param node */ private void addAtConstructor(Node node) { JSDocInfoBuilder builder = JSDocInfoBuilder.maybeCopyFrom(node.getJSDocInfo()); builder.recordConstructor(); node.setJSDocInfo(builder.build()); } }
private static void setJsDocWithType(Node target, Node type) { JSDocInfoBuilder builder = new JSDocInfoBuilder(false); builder.recordType(new JSTypeExpression(type, "<ChromePass.java>")); target.setJSDocInfo(builder.build()); }
private void markConst(Node n) { JSDocInfoBuilder builder = JSDocInfoBuilder.maybeCopyFrom(n.getJSDocInfo()); builder.recordConstancy(); n.setJSDocInfo(builder.build()); }
Node transform(ParseTree tree) { JSDocInfo info = handleJsDoc(tree); Node node = transformDispatcher.process(tree); if (info != null) { node = maybeInjectCastNode(tree, info, node); node.setJSDocInfo(info); } setSourceInfo(node, tree); return node; }
Node transform(ParseTree tree) { JSDocInfo info = handleJsDoc(tree); Node node = transformDispatcher.process(tree); if (info != null) { node = maybeInjectCastNode(tree, info, node); node.setJSDocInfo(info); } setSourceInfo(node, tree); return node; }
Node transformNumberAsString(LiteralToken token) { double value = normalizeNumber(token); Node irNode = newStringNode(DToA.numberToString(value)); JSDocInfo jsDocInfo = handleJsDoc(token); if (jsDocInfo != null) { irNode.setJSDocInfo(jsDocInfo); } setSourceInfo(irNode, token); return irNode; }
Node processNameWithInlineJSDoc(IdentifierToken identifierToken) { JSDocInfo info = handleInlineJsDoc(identifierToken); maybeWarnReservedKeyword(identifierToken); Node node = newStringNode(Token.NAME, identifierToken.toString()); if (info != null) { node.setJSDocInfo(info); } setSourceInfo(node, identifierToken); return node; }
/** * Converts a member definition in an object literal to an ES3 key/value pair. * Member definitions in classes are handled in {@link #visitClass}. */ private void visitMemberFunctionDefInObjectLit(Node n, Node parent) { String name = n.getString(); Node stringKey = IR.stringKey(name, n.getFirstChild().detachFromParent()); stringKey.setJSDocInfo(n.getJSDocInfo()); parent.replaceChild(n, stringKey); compiler.reportCodeChange(); }
private static void maybeAddConstJSDoc(Node srcDeclaration, Node srcParent, Node srcName, Node destDeclaration) { if (srcDeclaration.isConst() // Don't add @const for the left side of a for/in. If we do we get warnings from the NTI. // TODO(lharker): Check if this condition is still necessary, since NTI is deleted && !(srcParent.isForIn() && srcDeclaration == srcParent.getFirstChild())) { extractInlineJSDoc(srcDeclaration, srcName, destDeclaration); JSDocInfoBuilder builder = JSDocInfoBuilder.maybeCopyFrom(destDeclaration.getJSDocInfo()); builder.recordConstancy(); destDeclaration.setJSDocInfo(builder.build()); } }
/** Converts a member function into a quoted string key to avoid property renaming */ private void rewriteMemberDefInObjLit(Node memberDef, Node objLit) { String name = memberDef.getString(); Node stringKey = IR.stringKey(name, memberDef.getFirstChild().detach()); objLit.replaceChild(memberDef, stringKey); stringKey.setQuotedString(); stringKey.setJSDocInfo(memberDef.getJSDocInfo()); compiler.reportChangeToEnclosingScope(objLit); }
private static void maybeAddConstJSDoc(Node srcDeclaration, Node srcParent, Node srcName, Node destDeclaration) { if (srcDeclaration.isConst() // Don't add @const for the left side of a for/in. If we do we get warnings from the NTI. && !(NodeUtil.isForIn(srcParent) && srcDeclaration == srcParent.getFirstChild())) { extractInlineJSDoc(srcDeclaration, srcName, destDeclaration); JSDocInfoBuilder builder = JSDocInfoBuilder.maybeCopyFrom(destDeclaration.getJSDocInfo()); builder.recordConstancy(); destDeclaration.setJSDocInfo(builder.build()); } }
private void maybeAddVisibility(Node n) { Visibility access = (Visibility) n.getProp(Node.ACCESS_MODIFIER); if (access != null) { if (n.isComputedProp()) { compiler.report(JSError.make(n, COMPUTED_PROP_ACCESS_MODIFIER)); } JSDocInfoBuilder memberDoc = JSDocInfoBuilder.maybeCopyFrom(n.getJSDocInfo()); memberDoc.recordVisibility(access); n.setJSDocInfo(memberDoc.build()); n.removeProp(Node.ACCESS_MODIFIER); } }