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 addNewWarning(String messageId, String messageArg, Node nodeWarning) { // TODO(lpino): Use the exact lineno and charno, it is currently using // the lineno and charno of the parent @template // TODO(lpino): Use only constants as parameters of this method errorReporter.warning( "Bad type annotation. " + SimpleErrorReporter.getMessage1(messageId, messageArg), sourceFile.getName(), templateLineno, templateCharno); }
/** * @return Whether there is a declaration of a callable type. */ public boolean containsFunctionDeclaration() { boolean hasFunctionType = hasType() && getType().getRoot().isFunction(); return hasFunctionType || hasReturnType() || hasThisType() || getParameterCount() > 0 || getFlag(MASK_CONSTRUCTOR) || (getFlag(MASK_NOSIDEEFFECTS) && !hasType()); }
private void maybeSplitMultiVar(Node rhsNode) { Node statementNode = rhsNode.getGrandparent(); if (!statementNode.isVar() || !statementNode.hasMoreThanOneChild()) { return; } Node nameNode = rhsNode.getParent(); nameNode.detach(); rhsNode.detach(); statementNode.getParent().addChildBefore(IR.var(nameNode, rhsNode), statementNode); }
/** Returns an assign replacing the equivalent var or let declaration. */ private static Node varToAssign(Node var) { Node assign = IR.assign(var.getFirstChild().cloneNode(), var.getFirstChild().removeFirstChild()); return IR.exprResult(assign).useSourceInfoIfMissingFromForTree(var); } }
private void markConst(Node n) { JSDocInfoBuilder builder = JSDocInfoBuilder.maybeCopyFrom(n.getJSDocInfo()); builder.recordConstancy(); n.setJSDocInfo(builder.build()); }
public static boolean isRestArg(JSDocInfo funJsdoc, String formalParamName) { if (funJsdoc == null) { return false; } JSTypeExpression texp = funJsdoc.getParameterType(formalParamName); Node jsdocNode = texp == null ? null : texp.getRoot(); return jsdocNode != null && jsdocNode.getType() == Token.ELLIPSIS; }
/** Moves the access modifier from the original declaration to the constructor parameter */ void moveAccessModifier(ClassMemberDeclaration declaration, Node param) { if (Visibility.PRIVATE.equals(declaration.jsDoc.getVisibility())) { param.putProp(Node.ACCESS_MODIFIER, Visibility.PRIVATE); } else if (Visibility.PROTECTED.equals(declaration.jsDoc.getVisibility())) { param.putProp(Node.ACCESS_MODIFIER, Visibility.PROTECTED); } else { param.putProp(Node.ACCESS_MODIFIER, Visibility.PUBLIC); } }
private static boolean areEquivalent(Marker m1, Marker m2) { if (m1 == null && m2 == null) { return true; } if ((m1 == null && m2 != null) || (m1 != null && m2 == null)) { return false; } return TrimmedStringPosition.areEquivalent(m1.annotation, m2.annotation) && NamePosition.areEquivalent(m1.nameNode, m2.nameNode) && StringPosition.areEquivalent(m1.description, m2.description) && TypePosition.areEquivalent(m1.type, m2.type); } }
@Override protected ConformanceResult checkConformance(NodeTraversal t, Node n) { JSDocInfo info = n.getJSDocInfo(); if (info != null && info.isExpose()) { return ConformanceResult.VIOLATION; } return ConformanceResult.CONFORMANCE; } }
/** * Get the value of the @nosideeffects annotation stored in the * doc info. */ private static boolean hasNoSideEffectsAnnotation(Node node) { JSDocInfo docInfo = node.getJSDocInfo(); return docInfo != null && docInfo.isNoSideEffects(); }
@Override public void clearAst() { root = IR.script(); root.setInputId(inputId); root.setStaticSourceFile(sourceFile); }
public JSDocInfo clone(boolean cloneTypeNodes) { JSDocInfo other = new JSDocInfo(); other.info = this.info == null ? null : this.info.clone(cloneTypeNodes); other.documentation = this.documentation; other.visibility = this.visibility; other.bitset = this.bitset; other.type = cloneType(this.type, cloneTypeNodes); other.thisType = cloneType(this.thisType, cloneTypeNodes); other.includeDocumentation = this.includeDocumentation; other.originalCommentPosition = this.originalCommentPosition; return other; }
public static Node inc(Node exp, boolean isPost) { Node op = unaryOp(Token.INC, exp); op.putBooleanProp(Node.INCRDECR_PROP, isPost); return op; }
public static Node quotedStringKey(String s, Node value) { Node k = stringKey(s, value); k.putBooleanProp(Node.QUOTED_PROP, true); return k; }
public final void removeProp(Prop propType) { PropListItem result = removeProp(propListHead, (byte) propType.ordinal()); if (result != propListHead) { propListHead = result; } }
/** Records that this method is to be exposed as a mixinClass. */ public boolean recordMixinClass() { if (!isMixinClassRecorded()) { currentInfo.setMixinClass(true); populated = true; return true; } else { return false; } }
private static void markConstAndCopyJsDoc(Node from, Node target) { JSDocInfo info = from.getJSDocInfo(); JSDocInfoBuilder builder = JSDocInfoBuilder.maybeCopyFrom(info); builder.recordConstancy(); target.setJSDocInfo(builder.build()); }
private void addNewWarning(String messageId, String messageArg, Node nodeWarning) { // TODO(lpino): Use the exact lineno and charno, it is currently using // the lineno and charno of the parent @template // TODO(lpino): Use only constants as parameters of this method errorReporter.warning( "Bad type annotation. " + SimpleErrorReporter.getMessage1(messageId, messageArg), sourceFile.getName(), templateLineno, templateCharno); }