public JSType evaluateTypeExpressionInGlobalScope(JSTypeExpression expr) { return expr.evaluate(null, this); }
sb.append(paramName); else if (parameterType.isVarArgs()) if (outputJS && parameterType.isOptionalArg()) if (parameterType.isOptionalArg())
/** * Make the given type expression into an optional type expression, * if possible. */ public static JSTypeExpression makeOptionalArg(JSTypeExpression expr) { if (expr.isOptionalArg() || expr.isVarArgs()) { return expr; } else { return new JSTypeExpression( new Node(Token.EQUALS, expr.root), expr.sourceName); } }
private JSType evalNativeTypeExpr(Node ttlAst) { return new JSTypeExpression( getCallArgument(ttlAst, 0), "").evaluate(scope, typeRegistry); }
public JSType evaluateTypeExpression(JSTypeExpression expr, StaticTypedScope scope) { return createTypeFromCommentNode(expr.getRoot(), expr.getSourceName(), scope); }
if (info != null && info.hasParameterType(paramName)) { JSTypeExpression parameterTypeExpression = info.getParameterType(paramName); parameterType = parameterTypeExpression.evaluate(templateScope, typeRegistry); isOptionalParam = isOptionalParam || parameterTypeExpression.isOptionalArg(); isVarArgs = isVarArgs || parameterTypeExpression.isVarArgs(); } else if (param.getJSDocInfo() != null && param.getJSDocInfo().hasType()) { JSTypeExpression parameterTypeExpression = param.getJSDocInfo().getType(); parameterType = parameterTypeExpression.evaluate(templateScope, typeRegistry); isOptionalParam = parameterTypeExpression.isOptionalArg(); isVarArgs = parameterTypeExpression.isVarArgs(); } else if (oldParameterType != null && oldParameterType.getJSType() != null) {
@Override public boolean apply(Node n) { return n == expr.getRoot(); } };
/** * Constructs a new {@code JSTypeExpression}. * @param n A node. May be null. */ JSTypeExpression createJSTypeExpression(Node n) { return n == null ? null : new JSTypeExpression(n, getSourceName()); }
/** * @return Whether the given param is an optional param. */ private boolean isOptionalParameter( Node param, @Nullable JSDocInfo info) { if (codingConvention.isOptionalParameter(param)) { return true; } String paramName = param.getString(); return info != null && info.hasParameterType(paramName) && info.getParameterType(paramName).isOptionalArg(); }
if (param.isDefaultValue() && Token.EQUALS.equals(paramType.getRoot().getToken())) { paramType = new JSTypeExpression( paramType.getRoot().getFirstChild(), paramType.getSourceName()); && (declarationType == null || declarationType.equals(paramType))) {
JSTypeExpression existingType = existingProperty == null ? null : existingProperty.jsDocInfo().getType(); if (existingProperty != null && typeExpr != null && !existingType.equals(typeExpr)) { compiler.report(JSError.make(member, CONFLICTING_GETTER_SETTER_TYPE, memberName)); } else { jsDoc.recordOverride(); } else if (typeExpr == null) { typeExpr = new JSTypeExpression(new Node(Token.QMARK), member.getSourceFileName()); jsDoc.recordType(typeExpr.copy());
/** * Determine whether this is a var args parameter. * @return Whether the given param is a var args param. */ private boolean isVarArgsParameter( Node param, @Nullable JSDocInfo info) { if (codingConvention.isVarArgsParameter(param)) { return true; } String paramName = param.getString(); return info != null && info.hasParameterType(paramName) && info.getParameterType(paramName).isVarArgs(); }
type = JSTypeExpression.makeOptionalArg(type);
@Override public boolean apply(Node n) { return n == expr.getRoot(); } };
/** * Constructs a new {@code JSTypeExpression}. * @param n A node. May be null. */ JSTypeExpression createJSTypeExpression(Node n) { return n == null ? null : new JSTypeExpression(n, getSourceName()); }
static JSType evaluateTypeString( AbstractCompiler compiler, String expression) throws InvalidRequirementSpec { Node typeNodes = JsDocInfoParser.parseTypeString(expression); if (typeNodes == null) { throw new InvalidRequirementSpec("bad type expression"); } JSTypeExpression typeExpr = new JSTypeExpression( typeNodes, "conformance"); return typeExpr.evaluate(null, compiler.getTypeIRegistry()); }
sb.append(" * @param "); boolean optional = parameterType != null && parameterType.isOptionalArg(); if (outputJS && parameterType != null)
type = JSTypeExpression.makeOptionalArg(type);
public TypeI evaluateInEmptyScope(TypeIRegistry registry) { return evaluate(null, registry); }