/** * @see #isGeneratorSafe() */ public final void setGeneratorSafe(boolean isGeneratorSafe) { putBooleanProp(Prop.IS_GENERATOR_SAFE, isGeneratorSafe); }
/** * Sets whether this node is a variable length argument node. This * method is meaningful only on {@link Token#NAME} nodes * used to define a {@link Token#FUNCTION}'s argument list. */ public void setVarArgs(boolean varArgs) { putBooleanProp(VAR_ARGS_NAME, varArgs); }
/** * Sets whether this is a synthetic block that should not be considered * a real source block. */ public void setIsSyntheticBlock(boolean val) { putBooleanProp(SYNTHETIC_BLOCK_PROP, val); }
/** * Sets whether this node is a static member node. This * method is meaningful only on {@link Token#GETTER_DEF}, * {@link Token#SETTER_DEF} or {@link Token#MEMBER_FUNCTION_DEF} nodes contained * within {@link Token#CLASS}. */ public final void setStaticMember(boolean isStatic) { putBooleanProp(Prop.STATIC_MEMBER, isStatic); }
/** * Sets whether this node subtree contains YIELD nodes. * * <p> It's used in the translation of generators. */ public final void setGeneratorMarker(boolean isGeneratorMarker) { putBooleanProp(Prop.IS_GENERATOR_MARKER, isGeneratorMarker); }
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; }
/** * Copy any annotations that follow a named value. * @param source * @param destination */ static void copyNameAnnotations(Node source, Node destination) { if (source.getBooleanProp(Node.IS_CONSTANT_NAME)) { destination.putBooleanProp(Node.IS_CONSTANT_NAME, true); } }
private static Node fixupFreeCall(Node call) { Preconditions.checkState(call.isCall()); call.putBooleanProp(Node.FREE_CALL, true); return call; }
private static Node fixupFreeCall(Node call) { checkState(call.isCall()); call.putBooleanProp(Node.FREE_CALL, true); return call; }
public static Node dec(Node exp, boolean isPost) { Node op = unaryOp(Token.DEC, exp); op.putBooleanProp(Node.INCRDECR_PROP, isPost); return op; }
Node processOptionalParameter(OptionalParameterTree optionalParam) { maybeWarnTypeSyntax(optionalParam, Feature.OPTIONAL_PARAMETER); Node param = transform(optionalParam.param); param.putBooleanProp(Node.OPT_ES6_TYPED, true); return param; }
/** * Rewrite a single ES6 module file to a global script version. */ private void processFile(Node root) { checkArgument(isEs6ModuleRoot(root), root); clearState(); root.putBooleanProp(Node.TRANSPILED, true); NodeTraversal.traverse(compiler, root, this); }
private static Node newName(AbstractCompiler compiler, String name) { Node nameNode = IR.name(name); nameNode.setLength(name.length()); if (compiler.getCodingConvention().isConstant(name)) { nameNode.putBooleanProp(Node.IS_CONSTANT_NAME, true); } return nameNode; }
/** * @param n String node containing goog.module namespace. * @return A NAMESPACE node with the same name and source info as provided node. */ private static Node createNamespaceNode(Node n) { Node node = Node.newString(n.getString()).useSourceInfoFrom(n); node.putBooleanProp(Node.IS_MODULE_NAME, true); return node; }
Node processMemberVariable(MemberVariableTree tree) { Node member = newStringNode(Token.MEMBER_VARIABLE_DEF, tree.name.value); maybeProcessType(member, tree.declaredType); member.setStaticMember(tree.isStatic); member.putBooleanProp(Node.OPT_ES6_TYPED, tree.isOptional); maybeProcessAccessibilityModifier(member, tree.access); return member; }
Node processComputedPropertyGetter(ComputedPropertyGetterTree tree) { maybeWarnForFeature(tree, Feature.COMPUTED_PROPERTIES); Node key = transform(tree.property); Node body = transform(tree.body); Node function = IR.function(IR.name(""), IR.paramList(), body); function.useSourceInfoIfMissingFromForTree(body); Node n = newNode(Token.COMPUTED_PROP, key, function); n.putBooleanProp(Node.COMPUTED_PROP_GETTER, true); n.putBooleanProp(Node.STATIC_MEMBER, tree.isStatic); return n; }
Node processMemberVariable(MemberVariableTree tree) { Node member = newStringNode(Token.MEMBER_VARIABLE_DEF, tree.name.value); maybeProcessType(member, tree.declaredType); member.setStaticMember(tree.isStatic); member.putBooleanProp(Node.OPT_ES6_TYPED, tree.isOptional); maybeProcessAccessibilityModifier(tree, member, tree.access); return member; }
/** * Creates a property access on the {@code context} tree. */ public static Node newPropertyAccess(AbstractCompiler compiler, Node context, String name) { Node propNode = IR.getprop(context, IR.string(name)); if (compiler.getCodingConvention().isConstantKey(name)) { propNode.putBooleanProp(Node.IS_CONSTANT_NAME, true); } return propNode; }
Node processComputedPropertyMemberVariable(ComputedPropertyMemberVariableTree tree) { maybeWarnForFeature(tree, Feature.COMPUTED_PROPERTIES); maybeWarnTypeSyntax(tree, Feature.MEMBER_VARIABLE_IN_CLASS); Node n = newNode(Token.COMPUTED_PROP, transform(tree.property)); maybeProcessType(n, tree.declaredType); n.putBooleanProp(Node.COMPUTED_PROP_VARIABLE, true); n.putProp(Node.ACCESS_MODIFIER, tree.access); n.setStaticMember(tree.isStatic); maybeProcessAccessibilityModifier(tree, n, tree.access); return n; }