Package org.python.pydev.editor.model

Examples of org.python.pydev.editor.model.ItemPointer


    public void open() {
        File file = new File(this.location);
        if (file.exists()) {
            PyOpenAction openAction = new PyOpenAction();
            String fileContents = FileUtils.getFileContents(file);
            ItemPointer itemPointer = getItemPointer(file, fileContents, this.test);
            openAction.run(itemPointer);
        }
    }
View Full Code Here


            if (testPath != null && testPath.length() > 0) {
                testNode = NodeUtils.getNodeFromPath(node, testPath);
            }
        }

        ItemPointer itemPointer;
        if (testNode != null) {
            itemPointer = new ItemPointer(file, testNode);
        } else {
            //Ok, it's not defined directly here (it's probably in a superclass), so, let's go on and
            //do an actual (more costly) find definition.
            try {
                PySourceLocatorBase locator = new PySourceLocatorBase();
                IFile workspaceFile = locator.getWorkspaceFile(file);
                if (workspaceFile != null && workspaceFile.exists()) {
                    IProject project = workspaceFile.getProject();
                    if (project != null && project.exists()) {
                        PythonNature nature = PythonNature.getPythonNature(project);
                        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);
                                    if (pointers.size() > 0) {
                                        return pointers.get(0);
                                    }
                                }
                            }
                        }
                    }
                }
            } catch (Exception e) {
                Log.log(e);
            }
            //if we couldn't actually get the definition line, at least open the file we had (although that may not really
            //be the place where it's defined if it's a test in a superclass).
            itemPointer = new ItemPointer(file);
        }
        return itemPointer;
    }
View Full Code Here

                    temp.append("</pydev_hint_bold>");
                    temp.append(PyInformationPresenter.LINE_DELIM);
                }

                if (def.module != null && def.value != null) {
                    ItemPointer pointer = PyRefactoringFindDefinition.createItemPointer(def);
                    String asPortableString = pointer.asPortableString();
                    if (asPortableString != null) {
                        //may happen if file is not in the pythonpath
                        temp.replaceAll(
                                "<pydev_hint_bold>",
                                com.aptana.shared_core.string.StringUtils.format("<pydev_link pointer=\"%s\">",
View Full Code Here

                link = new FileLink(files[0], null, -1, -1, num);
            else {
                // files outside of the workspace
                File realFile = new File(fileName);
                if (!onlyCreateLinksForExistingFiles || realFile.exists()) {
                    ItemPointer p = new ItemPointer(realFile, new Location(num - 1, 0), null);
                    link = new ConsoleLink(p);
                }
            }
            if (link != null) {
                linkContainer.addLink(link, lineOffset + fileStart, lineLength - fileStart);
View Full Code Here

    @Override
    protected void openFiles(PythonpathTreeNode[] pythonPathFilesSelected) {
        for (PythonpathTreeNode n : pythonPathFilesSelected) {
            try {
                if (PythonPathHelper.isValidSourceFile(n.file.getName())) {
                    new PyOpenAction().run(new ItemPointer(n.file));
                } else {
                    IEditorRegistry editorReg = PlatformUI.getWorkbench().getEditorRegistry();
                    IEditorDescriptor defaultEditor = editorReg.getDefaultEditor(n.file.getName());
                    if (defaultEditor != null) {
                        IDE.openEditor(page, PydevFileEditorInput.create(n.file, false), defaultEditor.getId());
View Full Code Here

    @Override
    protected void openFiles(PythonpathZipChildTreeNode[] pythonPathFilesSelected) {
        for (PythonpathZipChildTreeNode n : pythonPathFilesSelected) {
            try {
                if (PythonPathHelper.isValidSourceFile(n.zipPath)) {
                    new PyOpenAction().run(new ItemPointer(n.zipStructure.file, new Location(), new Location(), null,
                            n.zipPath));
                } else {
                    IEditorRegistry editorReg = PlatformUI.getWorkbench().getEditorRegistry();
                    IEditorDescriptor defaultEditor = editorReg.getDefaultEditor(n.zipPath);
                    PydevZipFileStorage storage = new PydevZipFileStorage(n.zipStructure.file, n.zipPath);
View Full Code Here

        } else if (nodesSelected.size() > 0) {
            PythonNode node = nodesSelected.iterator().next();
            ParsedItem actualObject = node.getActualObject();
            ASTEntryWithChildren astThis = actualObject.getAstThis();
            if (astThis != null) {
                new PyOpenAction().run(new ItemPointer(node.getPythonFile().getActualObject(), NodeUtils
                        .getNameTokFromNode(astThis.node)));
            }

        } else if (pythonPathZipFilesSelected.size() > 0) {
            openFiles(pythonPathZipFilesSelected.toArray(new PythonpathZipChildTreeNode[pythonPathZipFilesSelected
View Full Code Here

    }

    protected void openFiles(PythonpathZipChildTreeNode[] pythonPathZipFilesSelected) {
        PyOpenAction pyOpenAction = new PyOpenAction();
        for (PythonpathZipChildTreeNode n : pythonPathZipFilesSelected) {
            pyOpenAction.run(new ItemPointer(n.zipStructure.file, new Location(), new Location(), null, n.zipPath));
        }
    }
View Full Code Here

    }

    protected void openFiles(PythonpathTreeNode[] pythonPathFilesSelected) {
        PyOpenAction pyOpenAction = new PyOpenAction();
        for (PythonpathTreeNode n : pythonPathFilesSelected) {
            pyOpenAction.run(new ItemPointer(n.file));
        }
    }
View Full Code Here

     */
    protected void openFiles(List<IFile> filesSelected) {
        for (IFile f : filesSelected) {
            //If a file is opened here, set it as having the Pydev editor as the default editor.
            IDE.setDefaultEditor(f, PyEdit.EDITOR_ID);
            new PyOpenAction().run(new ItemPointer(f));
        }
    }
View Full Code Here

TOP

Related Classes of org.python.pydev.editor.model.ItemPointer

Copyright © 2018 www.massapicom. 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.