Search in sources :

Example 1 with NominalTypeBuilder

use of com.google.javascript.rhino.NominalTypeBuilder in project closure-compiler by google.

the class TypedScopeCreator method createScopeInternal.

private TypedScope createScopeInternal(Node root, TypedScope typedParent) {
    // Constructing the global scope is very different than constructing
    // inner scopes, because only global scopes can contain named classes that
    // show up in the type registry.
    TypedScope newScope = null;
    AbstractScopeBuilder scopeBuilder = null;
    if (typedParent == null) {
        JSType globalThis = typeRegistry.getNativeObjectType(JSTypeNative.GLOBAL_THIS);
        // Mark the main root, the externs root, and the src root
        // with the global this type.
        root.setJSType(globalThis);
        root.getFirstChild().setJSType(globalThis);
        root.getLastChild().setJSType(globalThis);
        // Run a first-order analysis over the syntax tree.
        new FirstOrderFunctionAnalyzer().process(root.getFirstChild(), root.getLastChild());
        // Find all the classes in the global scope.
        newScope = createInitialScope(root);
        scopeBuilder = new GlobalScopeBuilder(newScope);
    } else {
        newScope = new TypedScope(typedParent, root);
        scopeBuilder = new LocalScopeBuilder(newScope);
    }
    scopeBuilder.build();
    scopeBuilder.resolveStubDeclarations();
    if (typedParent == null) {
        List<NominalTypeBuilder> delegateProxies = new ArrayList<>();
        for (FunctionType delegateProxyCtor : delegateProxyCtors) {
            delegateProxies.add(new NominalTypeBuilderOti(delegateProxyCtor, delegateProxyCtor.getInstanceType()));
        }
        codingConvention.defineDelegateProxyPrototypeProperties(typeRegistry, delegateProxies, delegateCallingConventions);
    }
    newScope.setTypeResolver(scopeBuilder);
    return newScope;
}
Also used : NominalTypeBuilderOti(com.google.javascript.rhino.jstype.NominalTypeBuilderOti) JSType(com.google.javascript.rhino.jstype.JSType) FunctionType(com.google.javascript.rhino.jstype.FunctionType) ArrayList(java.util.ArrayList) NominalTypeBuilder(com.google.javascript.rhino.NominalTypeBuilder)

Aggregations

NominalTypeBuilder (com.google.javascript.rhino.NominalTypeBuilder)1 FunctionType (com.google.javascript.rhino.jstype.FunctionType)1 JSType (com.google.javascript.rhino.jstype.JSType)1 NominalTypeBuilderOti (com.google.javascript.rhino.jstype.NominalTypeBuilderOti)1 ArrayList (java.util.ArrayList)1