Package org.python.pydev.editor.model

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


     * @param pointers: OUT: list where the pointers will be added
     * @param definitions the definitions that will be gotten as pointers
     */
    public static void getAsPointers(List<ItemPointer> pointers, IDefinition[] definitions) {
        for (IDefinition definition : definitions) {
            ItemPointer itemPointer = createItemPointer(definition);
            pointers.add(itemPointer);
        }
    }
View Full Code Here


    public static ItemPointer createItemPointer(IDefinition definition) {
        File file = definition.getModule().getFile();
        int line = definition.getLine();
        int col = definition.getCol();

        ItemPointer itemPointer = new ItemPointer(file, new Location(line - 1, col - 1),
                new Location(line - 1, col - 1), (Definition) definition, definition.getModule().getZipFilePath());
        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

    }

    public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
        //Upon creation, opens the new editor and creates the class.
        PyOpenAction openAction = new PyOpenAction();
        openAction.run(new ItemPointer(module));
        PyEdit pyEdit = (PyEdit) openAction.editor;
        TddRefactorCompletion completion = new TddRefactorCompletion(fReplacementString, fImage, fDisplayString,
                fContextInformation, fAdditionalProposalInfo, 0, pyEdit, locationStrategy, parametersAfterCall,
                pyCreateAction, ps);
        completion.apply(pyEdit.getEditorSourceViewer(), '\n', 0, 0);
View Full Code Here

            return;
        }

        if (where.length > 0) {
            if (where.length == 1) {
                ItemPointer itemPointer = where[0];
                doOpen(itemPointer, pyEdit, shell);
            } else {
                //the user has to choose which is the correct definition...
                final Display disp = shell.getDisplay();
                disp.syncExec(new Runnable() {

                    public void run() {
                        ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, new ILabelProvider() {

                            public Image getImage(Object element) {
                                return PyCodeCompletionImages.getImageForType(IToken.TYPE_PACKAGE);
                            }

                            public String getText(Object element) {
                                ItemPointer pointer = (ItemPointer) element;
                                File f = (File) (pointer).file;
                                int line = pointer.start.line;
                                return f.getName() + "  (" + f.getParent() + ") - line:" + line;
                            }
View Full Code Here

            }
        }

        //Upon creation, opens the new editor and creates the class.
        PyOpenAction openAction = new PyOpenAction();
        openAction.run(new ItemPointer(file));

        PyEdit pyEdit = (PyEdit) openAction.editor;
        TddRefactorCompletion completion = new TddRefactorCompletion(fReplacementString, fImage, fDisplayString,
                fContextInformation, fAdditionalProposalInfo, 0, pyEdit, PyCreateClass.LOCATION_STRATEGY_END,
                parametersAfterCall, pyCreateAction, ps);
View Full Code Here

public class PyUnitTestResultTest extends TestCase {

    public void testOpen() throws Exception {
        String contents = getContents();
        ItemPointer itemPointer = PyUnitTestResult.getItemPointer(null, contents, "Test.test_Create");
        assertEquals(7, itemPointer.start.line);
        itemPointer = PyUnitTestResult.getItemPointer(null, contents, "Test.test_Rename");
        assertEquals(44, itemPointer.start.line);
    }
View Full Code Here

        treeMembers.addMouseListener(new MouseAdapter() {
            public void mouseDoubleClick(MouseEvent e) {
                TreeItem[] selection = treeMembers.getSelection();
                if (selection.length > 0) {
                    Object data = selection[0].getData();
                    ItemPointer p = (ItemPointer) data;
                    if (p != null) {
                        new PyOpenAction().run(p);
                    }
                }
            }
View Full Code Here

    private void onClick(final HierarchyNodeModel model, int clickCount) {
        if (clickCount == 2) {
            if (model != null) {
                IModule m = model.module;
                if (m != null && model.ast != null) {
                    ItemPointer pointer = new ItemPointer(m.getFile(), model.ast.name);
                    new PyOpenAction().run(pointer);
                }
            }
        } else {

            Runnable r = new Runnable() {

                public void run() {
                    synchronized (lock) {
                        if (treeMembers.getItemCount() > 0) {
                            treeMembers.removeAll();
                        }
                        if (model == null) {
                            return;
                        }
                        ClassDef ast = model.ast;
                        if (ast != null && treeMembers != null) {
                            DefinitionsASTIteratorVisitor visitor = DefinitionsASTIteratorVisitor.create(ast);
                            Iterator<ASTEntry> outline = visitor.getOutline();

                            HashMap<SimpleNode, TreeItem> c = new HashMap<SimpleNode, TreeItem>();

                            boolean first = true;
                            while (outline.hasNext()) {
                                ASTEntry entry = outline.next();

                                if (first) {
                                    //Don't add the class itself.
                                    first = false;
                                    continue;
                                }

                                TreeItem item = null;
                                if (entry.node instanceof FunctionDef) {
                                    item = createTreeItem(c, entry);
                                    item.setImage(PydevPlugin.getImageCache().get(UIConstants.METHOD_ICON));
                                    if (model.module != null) {
                                        item.setData(new ItemPointer(model.module.getFile(),
                                                ((FunctionDef) entry.node).name));
                                    }

                                } else if (entry.node instanceof ClassDef) {
                                    item = createTreeItem(c, entry);
                                    item.setImage(PydevPlugin.getImageCache().get(UIConstants.CLASS_ICON));
                                    if (model.module != null) {
                                        item.setData(new ItemPointer(model.module.getFile(),
                                                ((ClassDef) entry.node).name));
                                    }

                                } else {
                                    item = createTreeItem(c, entry);
                                    item.setImage(PydevPlugin.getImageCache().get(UIConstants.PUBLIC_ATTR_ICON));
                                    if (model.module != null) {
                                        item.setData(new ItemPointer(model.module.getFile(), entry.node));
                                    }
                                }
                                item.setText(entry.getName());
                                item.setExpanded(true);
                            }
View Full Code Here

                    IModule m = outlineEntry.model.module;
                    if (m instanceof SourceModule) {
                        SourceModule sourceModule = (SourceModule) m;
                        File file = sourceModule.getFile();
                        if (file != null) {
                            ItemPointer p = new ItemPointer(file, outlineEntry.node);
                            pyOpenAction.run(p);
                        }
                    }
                }
            }
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.