Package org.python.pydev.core

Examples of org.python.pydev.core.IModule.findDefinition()


                SimpleNode n = NodeUtils.getNodeFromPath(classDef, "__init__");
                if (n instanceof FunctionDef) {
                    initNode = n;

                } else {
                    IDefinition[] definition = mod.findDefinition(CompletionStateFactory.getEmptyCompletionState(
                            className + ".__init__", this.nature, this.completionCache), -1, -1, this.nature);
                    for (IDefinition iDefinition : definition) {
                        Definition d = (Definition) iDefinition;
                        if (d.ast instanceof FunctionDef) {
                            initNode = d.ast;
View Full Code Here


                        String moduleName = nature.resolveModule(file);
                        if (moduleName != null) {
                            IModule mod = nature.getAstManager().getModule(moduleName, nature, true);
                            if (mod != null) {
                                ICompletionCache completionCache = new CompletionCache();
                                IDefinition[] definitions = mod.findDefinition(CompletionStateFactory
                                        .getEmptyCompletionState(testPath, nature, completionCache), -1, -1, nature);

                                if (definitions != null && definitions.length > 0) {
                                    List<ItemPointer> pointers = new ArrayList<ItemPointer>();
                                    PyRefactoringFindDefinition.getAsPointers(pointers, (Definition[]) definitions);
View Full Code Here

            if (path != null && path.length() > 0) {
                tok = path + ".";
            }
            tok += info.getName();
            try {
                IDefinition[] definitions = mod.findDefinition(
                        CompletionStateFactory.getEmptyCompletionState(tok, nature, completionCache), -1, -1, nature);

                if ((definitions == null || definitions.length == 0) && path != null && path.length() > 0) {
                    //this can happen if we have something as an attribute in the path:
View Full Code Here

                    //        self.xxx = 10
                    //
                    //so, we'de get a find definition for Bar.__init__.xxx which is something we won't find
                    //for now, let's simply return a match in the correct context (although the correct way of doing
                    //it would be analyzing that context to find the match)
                    definitions = mod.findDefinition(
                            CompletionStateFactory.getEmptyCompletionState(path, nature, completionCache), -1, -1,
                            nature);

                }
                PyRefactoringFindDefinition.getAsPointers(pointers, (Definition[]) definitions);
View Full Code Here

                        finalRep = parentPackage.substring(length + 1) + '.';
                    }
                    finalRep += token.getRepresentation();

                    try {
                        IDefinition[] definitions = module.findDefinition(state.getCopyWithActTok(finalRep), -1, -1,
                                nature);
                        if (definitions.length > 0) {
                            return (Definition) definitions[0];
                        }
                    } catch (Exception e) {
View Full Code Here

                //TODO: The nature (and so the grammar to be used) must be defined by the file we'll parse
                //(so, we need to know the system modules manager that actually created it to know the actual nature)
                IModule sourceMod = AbstractModule.createModuleFromDoc(mod.getName(), f,
                        new Document(FileUtils.getPyFileContents(f)), nature, true);
                if (sourceMod instanceof SourceModule) {
                    Definition[] definitions = (Definition[]) sourceMod.findDefinition(
                            state.getCopyWithActTok(foundAs), -1, -1, nature);
                    if (definitions.length > 0) {
                        this.definitionsFoundCache.add(token, definitions);
                        return definitions;
                    }
View Full Code Here

                "        self.c.";

        Document doc = new Document(d);
        IModule module = AbstractModule.createModuleFromDoc("", null, doc, nature, true);
        //self.c is found as an assign
        Definition[] defs = (Definition[]) module.findDefinition(
                CompletionStateFactory.getEmptyCompletionState("self.c", nature, new CompletionCache()), 10, 9, nature);

        assertEquals(1, defs.length);
        assertEquals("self.c", ((AssignDefinition) defs[0]).target);
        assertEquals("C", defs[0].value);
View Full Code Here

        assertEquals(1, defs.length);
        assertEquals("self.c", ((AssignDefinition) defs[0]).target);
        assertEquals("C", defs[0].value);
        assertSame(module, defs[0].module);

        defs = (Definition[]) module.findDefinition(
                CompletionStateFactory.getEmptyCompletionState("C", nature, new CompletionCache()), 7, 18, nature);
        assertEquals(1, defs.length);
        assertEquals("C", defs[0].value);
        assertSame(module, defs[0].module);
    }
View Full Code Here

                "    pass\n";

        Document doc = new Document(d);
        IModule module = AbstractModule.createModuleFromDoc("", null, doc, nature, true);
        //self.c is found as an assign
        Definition[] defs = (Definition[]) module
                .findDefinition(
                        CompletionStateFactory.getEmptyCompletionState("TestIt", nature, new CompletionCache()), -1,
                        -1, nature);

        assertEquals(1, defs.length);
View Full Code Here

                "        c.met1";

        Document doc = new Document(d);
        IModule module = AbstractModule.createModuleFromDoc("", null, doc, nature, true);

        Definition[] defs = (Definition[]) module.findDefinition(
                CompletionStateFactory.getEmptyCompletionState("c.met1", nature, new CompletionCache()), 8, 13, nature);

        assertEquals(1, defs.length);
        assertEquals("met1", defs[0].value);
        assertSame(module, defs[0].module);
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.