public final class JSTypeCreatorFromJSDoc
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
JSTypeCreatorFromJSDoc.FunctionAndSlotType |
private static class |
JSTypeCreatorFromJSDoc.ParameterKind |
private static class |
JSTypeCreatorFromJSDoc.ParameterType |
private static class |
JSTypeCreatorFromJSDoc.ParamIterator |
static class |
JSTypeCreatorFromJSDoc.UnknownTypeException
Exception for when unrecognized type names are encountered
|
Constructor and Description |
---|
JSTypeCreatorFromJSDoc(CodingConvention convention,
UniqueNameGenerator nameGen) |
Modifier and Type | Method and Description |
---|---|
private void |
checkInvalidGenericsInstantiation(Node n) |
private void |
fillInFormalParameterTypes(JSDocInfo jsdoc,
Node funNode,
com.google.common.collect.ImmutableList<java.lang.String> typeParameters,
DeclaredTypeRegistry registry,
FunctionTypeBuilder builder,
boolean ignoreJsdoc) |
private void |
fillInFunTypeBuilder(Node jsdocNode,
RawNominalType ownerType,
DeclaredTypeRegistry registry,
com.google.common.collect.ImmutableList<java.lang.String> typeParameters,
FunctionTypeBuilder builder) |
private void |
fillInReturnType(JSDocInfo jsdoc,
Node funNode,
Node parent,
com.google.common.collect.ImmutableList<java.lang.String> typeParameters,
DeclaredTypeRegistry registry,
FunctionTypeBuilder builder,
boolean ignoreJsdoc) |
private static java.util.List<JSType> |
fixLengthOfTypeList(int desiredLength,
java.util.List<JSType> typeList) |
private JSType |
getDeclaredTypeOfNode(JSDocInfo jsdoc,
DeclaredTypeRegistry registry,
com.google.common.collect.ImmutableList<java.lang.String> typeParameters) |
JSType |
getDeclaredTypeOfNode(JSDocInfo jsdoc,
RawNominalType ownerType,
DeclaredTypeRegistry registry) |
private JSType |
getEnumPropType(EnumType e,
DeclaredTypeRegistry registry) |
private com.google.common.collect.ImmutableSet<NominalType> |
getExtendedInterfaces(JSDocInfo jsdoc,
DeclaredTypeRegistry registry,
com.google.common.collect.ImmutableList<java.lang.String> typeParameters) |
JSTypeCreatorFromJSDoc.FunctionAndSlotType |
getFunctionType(JSDocInfo jsdoc,
java.lang.String functionName,
Node declNode,
RawNominalType constructorType,
RawNominalType ownerType,
DeclaredTypeRegistry registry)
Consumes either a "classic" function jsdoc with @param, @return, etc,
or a jsdoc with @type {function ...} and finds the types of the formal
parameters and the return value.
|
private DeclaredFunctionType |
getFunTypeFromTypicalFunctionJsdoc(JSDocInfo jsdoc,
java.lang.String functionName,
Node funNode,
RawNominalType constructorType,
RawNominalType ownerType,
DeclaredTypeRegistry registry,
FunctionTypeBuilder builder) |
private JSType |
getFunTypeHelper(Node jsdocNode,
DeclaredTypeRegistry registry,
com.google.common.collect.ImmutableList<java.lang.String> typeParameters) |
private com.google.common.collect.ImmutableSet<NominalType> |
getImplementedInterfaces(JSDocInfo jsdoc,
DeclaredTypeRegistry registry,
com.google.common.collect.ImmutableList<java.lang.String> typeParameters) |
private com.google.common.collect.ImmutableSet<NominalType> |
getInterfacesHelper(JSDocInfo jsdoc,
DeclaredTypeRegistry registry,
com.google.common.collect.ImmutableList<java.lang.String> typeParameters,
boolean implementedIntfs) |
private NominalType |
getMaybeParentClass(JSDocInfo jsdoc,
java.lang.String functionName,
Node funNode,
com.google.common.collect.ImmutableList<java.lang.String> typeParameters,
DeclaredTypeRegistry registry) |
private JSType |
getMaybeTypeFromComment(Node n,
DeclaredTypeRegistry registry,
com.google.common.collect.ImmutableList<java.lang.String> typeParameters) |
private JSType |
getNamedTypeHelper(Node n,
DeclaredTypeRegistry registry,
com.google.common.collect.ImmutableList<java.lang.String> outerTypeParameters) |
private JSType |
getNominalTypeHelper(RawNominalType rawType,
Node n,
DeclaredTypeRegistry registry,
com.google.common.collect.ImmutableList<java.lang.String> outerTypeParameters) |
private JSType |
getRecordTypeHelper(Node n,
DeclaredTypeRegistry registry,
com.google.common.collect.ImmutableList<java.lang.String> typeParameters) |
private JSType |
getThisOrNewType(Node n,
DeclaredTypeRegistry registry,
com.google.common.collect.ImmutableList<java.lang.String> typeParameters) |
private JSType |
getTypedefType(Typedef td,
DeclaredTypeRegistry registry) |
private JSType |
getTypeFromComment(Node n,
DeclaredTypeRegistry registry,
com.google.common.collect.ImmutableList<java.lang.String> typeParameters) |
private JSType |
getTypeFromCommentHelper(Node n,
DeclaredTypeRegistry registry,
com.google.common.collect.ImmutableList<java.lang.String> typeParameters) |
private JSType |
getTypeFromJSTypeExpression(JSTypeExpression expr,
DeclaredTypeRegistry registry,
com.google.common.collect.ImmutableList<java.lang.String> typeParameters) |
java.util.Map<Node,java.lang.String> |
getUnknownTypesMap() |
java.util.Set<JSError> |
getWarnings() |
private void |
handleConstructorAnnotation(java.lang.String functionName,
Node funNode,
RawNominalType constructorType,
NominalType parentClass,
com.google.common.collect.ImmutableSet<NominalType> implementedIntfs,
DeclaredTypeRegistry registry,
FunctionTypeBuilder builder) |
private void |
handleInterfaceAnnotation(JSDocInfo jsdoc,
java.lang.String functionName,
Node funNode,
RawNominalType constructorType,
com.google.common.collect.ImmutableSet<NominalType> implementedIntfs,
com.google.common.collect.ImmutableList<java.lang.String> typeParameters,
DeclaredTypeRegistry registry,
FunctionTypeBuilder builder) |
static boolean |
isRestArg(JSDocInfo funJsdoc,
java.lang.String formalParamName) |
private boolean |
isUnionWithUndefined(Node n) |
private JSType |
lookupTypeByName(java.lang.String name,
Node n,
DeclaredTypeRegistry registry,
com.google.common.collect.ImmutableList<java.lang.String> outerTypeParameters) |
JSType |
maybeMakeNullable(JSType t) |
private JSTypeCreatorFromJSDoc.ParameterType |
parseParameter(JSTypeExpression jsdoc,
JSTypeCreatorFromJSDoc.ParameterKind p,
DeclaredTypeRegistry registry,
com.google.common.collect.ImmutableList<java.lang.String> typeParameters) |
private JSTypeCreatorFromJSDoc.ParameterType |
parseParameter(Node jsdoc,
JSTypeCreatorFromJSDoc.ParameterKind p,
DeclaredTypeRegistry registry,
com.google.common.collect.ImmutableList<java.lang.String> typeParameters) |
void |
resolveEnum(EnumType e,
DeclaredTypeRegistry registry) |
void |
resolveTypedef(Typedef td,
DeclaredTypeRegistry registry) |
public static final DiagnosticType INVALID_GENERICS_INSTANTIATION
public static final DiagnosticType EXTENDS_NON_OBJECT
public static final DiagnosticType EXTENDS_NOT_ON_CTOR_OR_INTERF
public static final DiagnosticType INHERITANCE_CYCLE
public static final DiagnosticType DICT_IMPLEMENTS_INTERF
public static final DiagnosticType IMPLEMENTS_WITHOUT_CONSTRUCTOR
public static final DiagnosticType CONFLICTING_SHAPE_TYPE
public static final DiagnosticType CONFLICTING_EXTENDED_TYPE
public static final DiagnosticType CONFLICTING_IMPLEMENTED_TYPE
public static final DiagnosticType UNION_IS_UNINHABITABLE
public static final DiagnosticType NEW_EXPECTS_OBJECT_OR_TYPEVAR
public static final DiagnosticType BAD_ARRAY_TYPE_SYNTAX
public static final DiagnosticType CANNOT_MAKE_TYPEVAR_NON_NULL
public static final DiagnosticType CIRCULAR_TYPEDEF_ENUM
public static final DiagnosticType ENUM_WITH_TYPEVARS
public static final DiagnosticType ENUM_IS_TOP
public static final DiagnosticType ENUM_IS_UNION
public static final DiagnosticType WRONG_PARAMETER_ORDER
public static final DiagnosticType IMPLEMENTS_NON_INTERFACE
public static final DiagnosticType EXTENDS_NON_INTERFACE
public static final DiagnosticType FUNCTION_WITH_NONFUNC_JSDOC
public static final DiagnosticType TEMPLATED_GETTER_SETTER
public static final DiagnosticType TWO_JSDOCS
public static final DiagnosticGroup ALL_DIAGNOSTICS
private final CodingConvention convention
private final UniqueNameGenerator nameGen
private int howmanyTypeVars
private java.util.Set<JSError> warnings
private java.util.Map<Node,java.lang.String> unknownTypeNames
private JSTypeCreatorFromJSDoc.FunctionAndSlotType qmarkFunctionDeclared
private static final boolean NULLABLE_TYPES_BY_DEFAULT
public JSTypeCreatorFromJSDoc(CodingConvention convention, UniqueNameGenerator nameGen)
public JSType getDeclaredTypeOfNode(JSDocInfo jsdoc, RawNominalType ownerType, DeclaredTypeRegistry registry)
private JSType getDeclaredTypeOfNode(JSDocInfo jsdoc, DeclaredTypeRegistry registry, com.google.common.collect.ImmutableList<java.lang.String> typeParameters)
public java.util.Set<JSError> getWarnings()
public java.util.Map<Node,java.lang.String> getUnknownTypesMap()
private JSType getTypeFromJSTypeExpression(JSTypeExpression expr, DeclaredTypeRegistry registry, com.google.common.collect.ImmutableList<java.lang.String> typeParameters)
private JSType getTypeFromComment(Node n, DeclaredTypeRegistry registry, com.google.common.collect.ImmutableList<java.lang.String> typeParameters)
private JSType getMaybeTypeFromComment(Node n, DeclaredTypeRegistry registry, com.google.common.collect.ImmutableList<java.lang.String> typeParameters)
private JSType getTypeFromCommentHelper(Node n, DeclaredTypeRegistry registry, com.google.common.collect.ImmutableList<java.lang.String> typeParameters) throws JSTypeCreatorFromJSDoc.UnknownTypeException
private boolean isUnionWithUndefined(Node n)
private JSType getRecordTypeHelper(Node n, DeclaredTypeRegistry registry, com.google.common.collect.ImmutableList<java.lang.String> typeParameters) throws JSTypeCreatorFromJSDoc.UnknownTypeException
private JSType getNamedTypeHelper(Node n, DeclaredTypeRegistry registry, com.google.common.collect.ImmutableList<java.lang.String> outerTypeParameters) throws JSTypeCreatorFromJSDoc.UnknownTypeException
private JSType lookupTypeByName(java.lang.String name, Node n, DeclaredTypeRegistry registry, com.google.common.collect.ImmutableList<java.lang.String> outerTypeParameters) throws JSTypeCreatorFromJSDoc.UnknownTypeException
private JSType getTypedefType(Typedef td, DeclaredTypeRegistry registry)
public void resolveTypedef(Typedef td, DeclaredTypeRegistry registry)
private JSType getEnumPropType(EnumType e, DeclaredTypeRegistry registry)
public void resolveEnum(EnumType e, DeclaredTypeRegistry registry)
private void checkInvalidGenericsInstantiation(Node n)
private JSType getNominalTypeHelper(RawNominalType rawType, Node n, DeclaredTypeRegistry registry, com.google.common.collect.ImmutableList<java.lang.String> outerTypeParameters) throws JSTypeCreatorFromJSDoc.UnknownTypeException
private static java.util.List<JSType> fixLengthOfTypeList(int desiredLength, java.util.List<JSType> typeList)
private JSType getFunTypeHelper(Node jsdocNode, DeclaredTypeRegistry registry, com.google.common.collect.ImmutableList<java.lang.String> typeParameters) throws JSTypeCreatorFromJSDoc.UnknownTypeException
private void fillInFunTypeBuilder(Node jsdocNode, RawNominalType ownerType, DeclaredTypeRegistry registry, com.google.common.collect.ImmutableList<java.lang.String> typeParameters, FunctionTypeBuilder builder) throws JSTypeCreatorFromJSDoc.UnknownTypeException
private JSType getThisOrNewType(Node n, DeclaredTypeRegistry registry, com.google.common.collect.ImmutableList<java.lang.String> typeParameters)
private com.google.common.collect.ImmutableSet<NominalType> getImplementedInterfaces(JSDocInfo jsdoc, DeclaredTypeRegistry registry, com.google.common.collect.ImmutableList<java.lang.String> typeParameters)
private com.google.common.collect.ImmutableSet<NominalType> getExtendedInterfaces(JSDocInfo jsdoc, DeclaredTypeRegistry registry, com.google.common.collect.ImmutableList<java.lang.String> typeParameters)
private com.google.common.collect.ImmutableSet<NominalType> getInterfacesHelper(JSDocInfo jsdoc, DeclaredTypeRegistry registry, com.google.common.collect.ImmutableList<java.lang.String> typeParameters, boolean implementedIntfs)
public JSTypeCreatorFromJSDoc.FunctionAndSlotType getFunctionType(JSDocInfo jsdoc, java.lang.String functionName, Node declNode, RawNominalType constructorType, RawNominalType ownerType, DeclaredTypeRegistry registry)
private DeclaredFunctionType getFunTypeFromTypicalFunctionJsdoc(JSDocInfo jsdoc, java.lang.String functionName, Node funNode, RawNominalType constructorType, RawNominalType ownerType, DeclaredTypeRegistry registry, FunctionTypeBuilder builder)
private void fillInFormalParameterTypes(JSDocInfo jsdoc, Node funNode, com.google.common.collect.ImmutableList<java.lang.String> typeParameters, DeclaredTypeRegistry registry, FunctionTypeBuilder builder, boolean ignoreJsdoc)
private void fillInReturnType(JSDocInfo jsdoc, Node funNode, Node parent, com.google.common.collect.ImmutableList<java.lang.String> typeParameters, DeclaredTypeRegistry registry, FunctionTypeBuilder builder, boolean ignoreJsdoc)
private NominalType getMaybeParentClass(JSDocInfo jsdoc, java.lang.String functionName, Node funNode, com.google.common.collect.ImmutableList<java.lang.String> typeParameters, DeclaredTypeRegistry registry)
private void handleConstructorAnnotation(java.lang.String functionName, Node funNode, RawNominalType constructorType, NominalType parentClass, com.google.common.collect.ImmutableSet<NominalType> implementedIntfs, DeclaredTypeRegistry registry, FunctionTypeBuilder builder)
private void handleInterfaceAnnotation(JSDocInfo jsdoc, java.lang.String functionName, Node funNode, RawNominalType constructorType, com.google.common.collect.ImmutableSet<NominalType> implementedIntfs, com.google.common.collect.ImmutableList<java.lang.String> typeParameters, DeclaredTypeRegistry registry, FunctionTypeBuilder builder)
public static boolean isRestArg(JSDocInfo funJsdoc, java.lang.String formalParamName)
private JSTypeCreatorFromJSDoc.ParameterType parseParameter(JSTypeExpression jsdoc, JSTypeCreatorFromJSDoc.ParameterKind p, DeclaredTypeRegistry registry, com.google.common.collect.ImmutableList<java.lang.String> typeParameters)
private JSTypeCreatorFromJSDoc.ParameterType parseParameter(Node jsdoc, JSTypeCreatorFromJSDoc.ParameterKind p, DeclaredTypeRegistry registry, com.google.common.collect.ImmutableList<java.lang.String> typeParameters)