private String formatTypeVar(JSType var) { return var.toAnnotationString(Nullability.IMPLICIT); }
private String getTypeAnnotationString(@Nullable JSType typeI) { if (typeI == null) { return "NO TYPE INFORMATION"; } else { return "{" + typeI.toAnnotationString(Nullability.EXPLICIT) + "}"; } }
/** Creates a JSDoc-suitable String representation of the type of a parameter. */ private String getParameterJSDocType(List<JSType> types, int index, int minArgs, int maxArgs) { JSType type = types.get(index); if (index < minArgs) { return type.toAnnotationString(Nullability.EXPLICIT); } boolean isRestArgument = maxArgs == Integer.MAX_VALUE && index == types.size() - 1; if (isRestArgument) { return "..." + restrictByUndefined(type).toAnnotationString(Nullability.EXPLICIT); } return restrictByUndefined(type).toAnnotationString(Nullability.EXPLICIT) + "="; }
/** * Formats a found/required error message. */ private static String formatFoundRequired(String description, JSType found, JSType required) { String foundStr = found.toString(); String requiredStr = required.toString(); if (foundStr.equals(requiredStr)) { foundStr = found.toAnnotationString(); requiredStr = required.toAnnotationString(); } return MessageFormat.format(FOUND_REQUIRED, description, foundStr, requiredStr); }
public final String toNonNullAnnotationString() { return !isUnknownType() && !isTemplateType() && !isRecordType() && isObject() ? "!" + toAnnotationString() : toAnnotationString(); }
private void emitInterface(StringBuilder sb) { sb.append("public interface "); sb.append(getBaseName()).append(" "); List<JSTypeExpression> extendedInterfaces = getComment().getExtendedInterfaces(); int len = extendedInterfaces.size(); if (len > 0) { sb.append("extends "); for (JSTypeExpression jsTypeExpression : extendedInterfaces) { String value = getModel().evaluate(jsTypeExpression).toAnnotationString(); sb.append(value); if (--len > 0) sb.append(", "); } sb.append(" "); } }
public List<ClassReference> getImplementedInterfaces() { ArrayList<ClassReference> result = new ArrayList<ClassReference>(); for (JSTypeExpression jsTypeExpression : getComment().getImplementedInterfaces()) { String interfaceName = getModel().evaluate(jsTypeExpression).toAnnotationString(); ClassReference reference = getModel().getClassReference(interfaceName); if (reference != null) result.add(reference); } return result; }
public List<ClassReference> getExtendedInterfaces() { ArrayList<ClassReference> result = new ArrayList<ClassReference>(); for (JSTypeExpression jsTypeExpression : getComment().getExtendedInterfaces()) { String interfaceName = getModel().evaluate(jsTypeExpression).toAnnotationString(); ClassReference reference = getModel().getClassReference(interfaceName); if (reference != null) result.add(reference); } return result; }
public List<ClassReference> getExtendedInterfaces() { ArrayList<ClassReference> result = new ArrayList<ClassReference>(); for (JSTypeExpression jsTypeExpression : getComment().getExtendedInterfaces()) { String interfaceName = getModel().evaluate(jsTypeExpression).toAnnotationString(); ClassReference reference = getModel().getClassReference(interfaceName); if (reference != null) result.add(reference); } return result; }
public List<ClassReference> getImplementedInterfaces() { ArrayList<ClassReference> result = new ArrayList<ClassReference>(); for (JSTypeExpression jsTypeExpression : getComment().getImplementedInterfaces()) { String interfaceName = getModel().evaluate(jsTypeExpression).toAnnotationString(); ClassReference reference = getModel().getClassReference(interfaceName); if (reference != null) result.add(reference); } return result; }
public String toReturnTypeAnnotationString() { JSType jsType = getModel().evaluate(getComment().getReturnType()); return jsType.toAnnotationString(); }
public String toReturnTypeAnnotationString() { JSType jsType = getModel().evaluate(getComment().getReturnType()); return jsType.toAnnotationString(); }
public String toReturnTypeAnnotationString() { JSType jsType = getModel().evaluate(getComment().getReturnType()); return jsType.toAnnotationString(Nullability.EXPLICIT); }
public static String toEnumTypeString(BaseReference reference) { JSTypeExpression enumParameterType = reference.getComment().getEnumParameterType(); String overrideStringType = transformType(reference.getModel().evaluate(enumParameterType).toAnnotationString(Nullability.EXPLICIT)); return overrideStringType; }
public static String toEnumTypeString(BaseReference reference) { JSTypeExpression enumParameterType = reference.getComment().getEnumParameterType(); String overrideStringType = transformType(reference.getModel().evaluate(enumParameterType).toAnnotationString()); return overrideStringType; }
public static String toEnumTypeString(BaseReference reference) { JSTypeExpression enumParameterType = reference.getComment().getEnumParameterType(); String overrideStringType = transformType(reference.getModel().evaluate(enumParameterType).toAnnotationString()); return overrideStringType; }
public String toTypeAnnotationString() { JSType jsType = null; if (getComment() != null && getComment().getType() != null) { jsType = getModel().evaluate(getComment().getType()); } return jsType != null ? jsType.toAnnotationString() : "Object"; }
public String toTypeAnnotationString() { JSType jsType = null; if (getComment() != null && getComment().getType() != null) { jsType = getModel().evaluate(getComment().getType()); } return jsType != null ? jsType.toAnnotationString() : "Object"; }
public String toTypeAnnotationString() { JSType jsType = null; if (getComment() != null && getComment().getType() != null) { jsType = getModel().evaluate(getComment().getType()); } return jsType != null ? jsType.toAnnotationString(Nullability.EXPLICIT) : "Object"; }
private static void maybeWarnForConstWithoutExplicitType( AbstractCompiler compiler, PotentialDeclaration decl) { if (decl.isConstToBeInferred() && !decl.getLhs().isFromExterns() && !JsdocUtil.isPrivate(decl.getJsDoc())) { Node nameNode = decl.getLhs(); if (nameNode.getJSType() == null) { compiler.report(JSError.make(nameNode, CONSTANT_WITHOUT_EXPLICIT_TYPE)); } else { compiler.report( JSError.make( nameNode, CONSTANT_WITH_SUGGESTED_TYPE, nameNode.getJSType().toAnnotationString(Nullability.EXPLICIT))); } } }