Examples of NBinding


Examples of org.python.indexer.NBinding

        assertMethodBinding("__builtin__.list.count");
    }

    public void testBuiltinNum() throws Exception {
        assertClassBinding("__builtin__.float");
        NBinding b = assertMethodBinding("__builtin__.float.fromhex");
        assertTrue(b.isBuiltin());
    }
View Full Code Here

Examples of org.python.indexer.NBinding

    public void testBuiltinSys() throws Exception {
        idx.loadModule("sys");
        assertModuleBinding("sys");
        assertAttributeBinding("sys.__stderr__");
        NBinding b = assertFunctionBinding("sys.exit");
        assertTrue(b.isBuiltin());
        assertFunctionBinding("sys.getprofile");
        assertFunctionBinding("sys.getdefaultencoding");
        assertAttributeBinding("sys.api_version");
        assertNumType("sys.api_version");
        assertAttributeBinding("sys.argv");
View Full Code Here

Examples of org.python.indexer.NBinding

    public void testMethodBuiltinAttrs() throws Exception {
        String file = "classtype_builtins.py";
        buildIndex(file);

        Scope mtable = idx.moduleTable.lookupType(abspath(file)).getTable();
        NBinding method = mtable.lookupType("MyClass").getTable().lookup("__init__");
        assertNotNull(method);
        assertEquals(NBinding.Kind.CONSTRUCTOR, method.getKind());
        assertEquals("classtype_builtins.MyClass.__init__", method.getQname());

        NType ftype = mtable.lookupType("MyClass").getTable().lookupType("__init__");
        assertTrue(ftype.isFuncType());

        NBinding c = mtable.lookup("MyClass");
        for (String special : new String[]{"im_class", "__class__", "im_self", "__self__"}) {
            NBinding attr = ftype.getTable().lookup(special);
            assertNotNull("missing binding for " + special, attr);
            assertEquals(c.getType(), attr.getType());
        }
    }
View Full Code Here

Examples of org.python.indexer.NBinding

        idx.loadModule("class1");
        idx.ready();
        assertModuleBinding("class1");
        assertClassBinding("class1.A");

        NBinding b = assertAttributeBinding("class1.A.__bases__");
        assertStaticSynthetic(b);
        assertTrue(b.getType().isTupleType());
        assertTrue(((NTupleType)b.getType()).getElementTypes().isEmpty());

        b = assertAttributeBinding("class1.A.__name__");
        assertStaticSynthetic(b);
        assertEquals(b.getType(), idx.builtins.BaseStr);

        b = assertAttributeBinding("class1.A.__module__");
        assertStaticSynthetic(b);
        assertEquals(b.getType(), idx.builtins.BaseStr);

        b = assertAttributeBinding("class1.A.__doc__");
        assertStaticSynthetic(b);
        assertEquals(b.getType(), idx.builtins.BaseStr);

        b = assertAttributeBinding("class1.A.__dict__");
        assertStaticSynthetic(b);
        assertTrue(b.getType().isDictType());
        assertEquals(((NDictType)b.getType()).getKeyType(), idx.builtins.BaseStr);
        assertTrue(((NDictType)b.getType()).getValueType().isUnknownType());
    }
View Full Code Here

Examples of org.python.indexer.NBinding

        String src = index(
            "reassign.py",
            "app.foo = 'hello'",
            "app.foo = 2");
        assertScopeBinding("reassign.app");
        NBinding nb = assertAttributeBinding("reassign.app.foo");
        NType type = nb.getType();
        assertTrue(type.isUnionType());
        Set<NType> types = ((NUnionType)type).getTypes();
        assertEquals(2, types.size());
        assertTrue(types.contains(idx.builtins.BaseStr));
        assertTrue(types.contains(idx.builtins.BaseNum));
View Full Code Here

Examples of org.python.indexer.NBinding

            "  def __init__(self):",
            "    self.__random = random.Random()",
            "  def set_seed(self, seed):",
            "    self.__random.seed(seed)");
        assertModuleBinding("random");
        NBinding r = assertClassBinding("random.Random");
        assertFalse(r.isBuiltin());

        assertReference("random", nthIndexOf(src, "random", 3));
        assertConstructed("random.Random", src.indexOf("Random"));

        assertClassBinding("dice.Dice");
View Full Code Here

Examples of org.python.indexer.NBinding

        targetType = targetType.follow();
        if (targetType == Indexer.idx.builtins.None) {
            return;
        }
        NBinding b = targetType.getTable().putAttr(attr.id, attr, v, ATTRIBUTE);
        if (b != null) {
            setType(attr.setType(b.followType()));
        }
    }
View Full Code Here

Examples of org.python.indexer.NBinding

        return getType();
    }

    private void resolveAttributeOnType(NType targetType) {
        NType ttype = targetType.follow();
        NBinding b = ttype.getTable().lookupAttr(attr.id);
        if (b == null) {
            b = makeProvisionalBinding(ttype);
        }
        if (b != null) {
            Indexer.idx.putLocation(attr, b);
            setType(attr.setType(b.getType()));
        }
    }
View Full Code Here

Examples of org.python.indexer.NBinding

        if ("".equals(targetScope.getPath())) {
            return null;
        }

        NType utype = new NUnknownType();
        NBinding b = targetScope.putAttr(attr.id, null, utype, ATTRIBUTE);
        if (b != null) {
            b.setProvisional(true);
            utype.getTable().setPath(b.getQname());
        }
        return b;
    }
View Full Code Here

Examples of org.python.indexer.NBinding

    /**
     * Look for the name in the current scope.  If found, and its
     * qname is a valid binding in the graph, record a reference.
     */
    private void checkForReference(int offset, String qname) {
        NBinding nb;
        if (qname.indexOf('.') == -1) {
            nb = scope.lookup(qname);
            if (nb == null) {
                nb = Indexer.idx.globaltable.lookup(qname);
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.