private static JSDocInfoBuilder makeBuilderWithType(@Nullable JSDocInfo oldJSDoc, Node typeAst) { JSDocInfoBuilder builder = JSDocInfoBuilder.maybeCopyFrom(oldJSDoc); builder.recordType(new JSTypeExpression(typeAst, "<synthetic>")); return builder; }
static JSDocInfo mergeJsdocs(@Nullable JSDocInfo classicJsdoc, @Nullable JSDocInfo inlineJsdoc) { if (inlineJsdoc == null || !inlineJsdoc.hasType()) { return classicJsdoc; } JSDocInfoBuilder builder = JSDocInfoBuilder.maybeCopyFrom(classicJsdoc); builder.recordType(inlineJsdoc.getType()); return builder.build(); }
/** * Records the type of a define. * * 'Define' values are special constants that may be manipulated by * the compiler. They are designed to mimic the #define command in * the C preprocessor. */ public boolean recordDefineType(JSTypeExpression type) { if (type != null && !currentInfo.isConstant() && !currentInfo.isDefine() && recordType(type)) { currentInfo.setDefine(true); populated = true; return true; } else { return false; } }
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 JSDocInfo createUnknownTypeJsDocInfo() { JSDocInfoBuilder castToUnknownBuilder = new JSDocInfoBuilder(true); castToUnknownBuilder.recordType( new JSTypeExpression( JsDocInfoParser.parseTypeString("?"), "<ProcessClosurePrimitives.java>")); return castToUnknownBuilder.build(); }
/** * Records the type of a define. * * 'Define' values are special constants that may be manipulated by * the compiler. They are designed to mimic the #define command in * the C preprocessor. */ public boolean recordDefineType(JSTypeExpression type) { if (type != null && !currentInfo.isConstant() && !currentInfo.isDefine() && recordType(type)) { currentInfo.setDefine(true); populated = true; return true; } else { return false; } }
/** * Parse a description as a {@code @type}. */ public JSDocInfo parseInlineTypeDoc() { skipEOLs(); JsDocToken token = next(); int lineno = stream.getLineno(); int startCharno = stream.getCharno(); Node typeAst = parseParamTypeExpression(token); recordTypeNode(lineno, startCharno, typeAst, token == JsDocToken.LEFT_CURLY); JSTypeExpression expr = createJSTypeExpression(typeAst); if (expr != null) { jsdocBuilder.recordType(expr); jsdocBuilder.recordInlineType(); return retrieveAndResetParsedJSDocInfo(); } return null; }
/** * Parse a description as a {@code @type}. */ public JSDocInfo parseInlineTypeDoc() { skipEOLs(); JsDocToken token = next(); int lineno = stream.getLineno(); int startCharno = stream.getCharno(); Node typeAst = parseParamTypeExpression(token); recordTypeNode(lineno, startCharno, typeAst, token == JsDocToken.LEFT_CURLY); JSTypeExpression expr = createJSTypeExpression(typeAst); if (expr != null) { jsdocBuilder.recordType(expr); jsdocBuilder.recordInlineType(); return retrieveAndResetParsedJSDocInfo(); } return null; }
/** * Appends all properties in the ClassDefinition to the prototype of the custom element. */ private void appendPropertiesToBlock( final PolymerClassDefinition cls, Node block, String basePath) { for (MemberDefinition prop : cls.props) { Node propertyNode = IR.exprResult( NodeUtil.newQName(compiler, basePath + prop.name.getString())); JSDocInfoBuilder info = JSDocInfoBuilder.maybeCopyFrom(prop.info); JSTypeExpression propType = PolymerPassStaticUtils.getTypeFromProperty(prop, compiler); if (propType == null) { return; } info.recordType(propType); propertyNode.getFirstChild().setJSDocInfo(info.build()); block.addChildToBack(propertyNode); } }
JSDocInfoBuilder info = JSDocInfoBuilder.maybeCopyFrom(staticGetProp.getJSDocInfo()); JSTypeExpression unknown = new JSTypeExpression(new Node(Token.QMARK), "<synthetic>"); info.recordType(unknown); // In case there wasn't a type specified on the base class. info.addSuppression("visibility"); getprop.setJSDocInfo(info.build());
? originalParent : original; JSDocInfoBuilder builder = new JSDocInfoBuilder(false); builder.recordType(new JSTypeExpression( convertWithLocation(TypeDeclarationsIR.namedType("Function")), n.getSourceFileName())); originalJsDocNode.setJSDocInfo(builder.build());
JSDocInfoBuilder info = JSDocInfoBuilder.maybeCopyFrom(staticGetProp.getJSDocInfo()); JSTypeExpression unknown = new JSTypeExpression(new Node(Token.QMARK), "<synthetic>"); info.recordType(unknown); // In case there wasn't a type specified on the base class. info.addSuppression("visibility"); getprop.setJSDocInfo(info.build());
if (nameNode.getJSDocInfo() != null || n.getJSDocInfo() != null) { JSDocInfoBuilder jsDoc = new JSDocInfoBuilder(false); jsDoc.recordType(new JSTypeExpression(new Node(Token.QMARK), n.getSourceFileName())); undefined = IR.cast(undefined, jsDoc.build());
? originalParent : original; JSDocInfoBuilder builder = new JSDocInfoBuilder(false); builder.recordType(new JSTypeExpression( convertWithLocation(TypeDeclarationsIR.namedType("Function")), n.getSourceFileName())); originalJsDocNode.setJSDocInfo(builder.build());
/** Appends all of the given properties to the given block. */ private void appendPropertiesToBlock(List<MemberDefinition> props, Node block, String basePath) { for (MemberDefinition prop : props) { Node propertyNode = IR.exprResult(NodeUtil.newQName(compiler, basePath + prop.name.getString())); // If a property string is quoted, make sure the added prototype properties are also quoted if (prop.name.isQuotedString()) { continue; } propertyNode.useSourceInfoIfMissingFromForTree(prop.name); JSDocInfoBuilder info = JSDocInfoBuilder.maybeCopyFrom(prop.info); JSTypeExpression propType = PolymerPassStaticUtils.getTypeFromProperty(prop, compiler); if (propType == null) { return; } info.recordType(propType); propertyNode.getFirstChild().setJSDocInfo(info.build()); block.addChildToBack(propertyNode); } }
break; case MEMBER_VARIABLE_DEF: builder.recordType(typeExpression); break; default: builder.recordType(typeExpression); builder.recordInlineType();
break; case Token.MEMBER_VARIABLE_DEF: builder.recordType(typeExpression); break; default: builder.recordType(typeExpression); builder.recordInlineType();
} else { JSDocInfoBuilder jsDoc = new JSDocInfoBuilder(false); jsDoc.recordType(typeExpr); if (member.getJSDocInfo() != null && member.getJSDocInfo().isExport()) { jsDoc.recordExport();
Node argumentsVar = IR.constNode(name, IR.name("arguments")); JSDocInfoBuilder jsdoc = new JSDocInfoBuilder(false); jsdoc.recordType( new JSTypeExpression( new Node(Token.BANG, IR.string("Arguments")), "<Es6RewriteArrowFunction>"));
jsdoc.recordType( new JSTypeExpression( new Node(Token.BANG, IR.string("Arguments")), "<Es6RewriteArrowFunction>"));