Search in sources :

Example 11 with Namespace

use of com.google.javascript.jscomp.newtypes.Namespace in project closure-compiler by google.

the class NTIScope method getNamespaceOrTypedefType.

@Override
public JSType getNamespaceOrTypedefType(String typeName) {
    Namespace ns = getNamespaceAfterFreezing(typeName);
    if (ns != null) {
        return ns.toJSType();
    }
    Typedef td = getTypedef(typeName);
    return td == null ? null : td.getType();
}
Also used : Typedef(com.google.javascript.jscomp.newtypes.Typedef) Namespace(com.google.javascript.jscomp.newtypes.Namespace) FunctionNamespace(com.google.javascript.jscomp.newtypes.FunctionNamespace)

Example 12 with Namespace

use of com.google.javascript.jscomp.newtypes.Namespace in project closure-compiler by google.

the class SimpleInference method inferPrototypeProperty.

private JSType inferPrototypeProperty(Node recv, String pname, NTIScope scope) {
    QualifiedName recvQname = QualifiedName.fromNode(recv);
    Declaration decl = scope.getDeclaration(recvQname, false);
    if (decl != null) {
        Namespace ns = decl.getNamespace();
        if (ns instanceof RawNominalType) {
            return ((RawNominalType) ns).getProtoPropDeclaredType(pname);
        }
    }
    return null;
}
Also used : QualifiedName(com.google.javascript.jscomp.newtypes.QualifiedName) RawNominalType(com.google.javascript.jscomp.newtypes.RawNominalType) Declaration(com.google.javascript.jscomp.newtypes.Declaration) FunctionNamespace(com.google.javascript.jscomp.newtypes.FunctionNamespace) Namespace(com.google.javascript.jscomp.newtypes.Namespace)

Aggregations

FunctionNamespace (com.google.javascript.jscomp.newtypes.FunctionNamespace)12 Namespace (com.google.javascript.jscomp.newtypes.Namespace)12 Declaration (com.google.javascript.jscomp.newtypes.Declaration)6 QualifiedName (com.google.javascript.jscomp.newtypes.QualifiedName)5 JSType (com.google.javascript.jscomp.newtypes.JSType)4 DeclaredFunctionType (com.google.javascript.jscomp.newtypes.DeclaredFunctionType)2 EnumType (com.google.javascript.jscomp.newtypes.EnumType)2 NamespaceLit (com.google.javascript.jscomp.newtypes.NamespaceLit)2 RawNominalType (com.google.javascript.jscomp.newtypes.RawNominalType)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 AbstractShallowCallback (com.google.javascript.jscomp.NodeTraversal.AbstractShallowCallback)1 FunctionType (com.google.javascript.jscomp.newtypes.FunctionType)1 FunctionTypeBuilder (com.google.javascript.jscomp.newtypes.FunctionTypeBuilder)1 Typedef (com.google.javascript.jscomp.newtypes.Typedef)1 Node (com.google.javascript.rhino.Node)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1