Package org.python.pydev.editor

Examples of org.python.pydev.editor.PyEdit$MyResources


            launch(new FileOrResource(file), mode);
            return;
        }

        if (editor instanceof PyEdit) {
            PyEdit pyEdit = (PyEdit) editor;
            File editorFile = pyEdit.getEditorFile();
            if (editorFile != null) {
                launch(new FileOrResource(editorFile), mode);
                return;
            }
        }
View Full Code Here


    public static final String PYDEV_COVERAGE_MARKER = "org.python.pydev.debug.pydev_coverage_marker";

    private void openFileWithCoverageMarkers(File realFile) {
        IEditorPart editor = PyOpenEditor.doOpenEditor(realFile);
        if (editor instanceof PyEdit) {
            PyEdit e = (PyEdit) editor;
            IEditorInput input = e.getEditorInput();
            final IFile original = (input instanceof IFileEditorInput) ? ((IFileEditorInput) input).getFile() : null;
            if (original == null)
                return;
            final IDocument document = e.getDocumentProvider().getDocument(e.getEditorInput());
            //When creating it, it'll already start to listen for changes to remove the marker when needed.
            new RemoveCoverageMarkersListener(document, e, original);

            final FileNode cache = (FileNode) PyCoverage.getPyCoverage().cache.getFile(realFile);
            if (cache != null) {
View Full Code Here

                super.apply(viewer, trigger, stateMask, offset);
                if (forceReparseOnApply) {
                    //and after applying it, let's request a reanalysis
                    if (viewer instanceof PySourceViewer) {
                        PySourceViewer sourceViewer = (PySourceViewer) viewer;
                        PyEdit edit = sourceViewer.getEdit();
                        if (edit != null) {
                            edit.getParser().forceReparse(
                                    new Tuple<String, Boolean>(AnalysisParserObserver.ANALYSIS_PARSER_OBSERVER_FORCE,
                                            true));
                        }
                    }
                }
View Full Code Here

    private void getDocstringHover(IRegion hoverRegion, PySourceViewer s, PySelection ps) {
        //Now, aside from the marker, let's check if there's some definition we should show the user about.
        CompletionCache completionCache = new CompletionCache();
        ArrayList<IDefinition> selected = new ArrayList<IDefinition>();

        PyEdit edit = s.getEdit();
        RefactoringRequest request;
        IPythonNature nature = null;
        try {
            nature = edit.getPythonNature();
            request = new RefactoringRequest(edit.getEditorFile(), ps, new NullProgressMonitor(), nature, edit);
        } catch (MisconfigurationException e) {
            return;
        }
        String[] tokenAndQual = null;
        try {
            tokenAndQual = PyRefactoringFindDefinition.findActualDefinition(request, completionCache, selected);
        } catch (CompletionRecursionException e1) {
            Log.log(e1);
            buf.append("Unable to compute hover. Details: " + e1.getMessage());
            return;
        }

        FastStringBuffer temp = new FastStringBuffer();

        if (tokenAndQual != null && selected.size() > 0) {
            for (IDefinition d : selected) {
                Definition def = (Definition) d;

                SimpleNode astToPrint = null;
                if (def.ast != null) {
                    astToPrint = def.ast;
                    if ((astToPrint instanceof Name || astToPrint instanceof NameTok) && def.scope != null) {
                        //There's no real point in just printing the name, let's see if we're able to actually find
                        //the scope where it's in and print that scope.
                        FastStack<SimpleNode> scopeStack = def.scope.getScopeStack();
                        if (scopeStack != null && scopeStack.size() > 0) {
                            SimpleNode peek = scopeStack.peek();
                            if (peek != null) {
                                stmtType stmt = NodeUtils.findStmtForNode(peek, astToPrint);
                                if (stmt != null) {
                                    astToPrint = stmt;
                                }
                            }
                        }
                    }
                    try {
                        astToPrint = astToPrint.createCopy();
                        MakeAstValidForPrettyPrintingVisitor.makeValid(astToPrint);
                    } catch (Exception e) {
                        Log.log(e);
                    }
                }

                temp = temp.clear();
                if (def.value != null) {
                    if (astToPrint instanceof FunctionDef) {
                        temp.append("def ");

                    } else if (astToPrint instanceof ClassDef) {
                        temp.append("class ");

                    }
                    temp.append("<pydev_hint_bold>");
                    temp.append(def.value);
                    temp.append("</pydev_hint_bold>");
                    temp.append(' ');
                }

                if (def.module != null) {
                    temp.append("Found at: ");
                    temp.append("<pydev_hint_bold>");
                    temp.append(def.module.getName());
                    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\">",
                                        StringEscapeUtils.escapeXml(asPortableString)));
                        temp.replaceAll("</pydev_hint_bold>", "</pydev_link>");
                    }
                }

                String str = printAst(edit, astToPrint);

                if (str != null && str.trim().length() > 0) {
                    temp.append(PyInformationPresenter.LINE_DELIM);
                    temp.append(str);

                } else {
                    String docstring = d.getDocstring(nature, completionCache);
                   
                    // Jiawei Zhang Add Begin.
                    if (docstring == null && d.getModule().getName().indexOf("PyQt4") == 0) {
                        // Convert the full method name such as: QApplication.aboutQt -> QApplication, about or Phonon.AudioOutput.method -> Phonon.AudioOutput, method
                        int index = def.value.lastIndexOf(".");
                        if (index != -1) {
                            String className = def.value.substring(0, index);
                            String methodName = def.value.substring(index + 1, def.value.length());
                            String[] argsDoc = PythonShell.getQtArgsDoc(className, methodName);
                            docstring = argsDoc[1];
                        }
                    }
                    // Jiawei Zhang Add End.

                    if (docstring != null && docstring.trim().length() > 0) {
                        IIndentPrefs indentPrefs = edit.getIndentPrefs();
                        temp.append(StringUtils.fixWhitespaceColumnsToLeftFromDocstring(docstring,
                                indentPrefs.getIndentationString()));
                    }
                }
View Full Code Here

     */
    public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
        IDocument document = viewer.getDocument();
        if (viewer instanceof PySourceViewer) {
            PySourceViewer pySourceViewer = (PySourceViewer) viewer;
            PyEdit pyEdit = pySourceViewer.getEdit();
            this.indentString = pyEdit.getIndentPrefs().getIndentationString();
        } else {
            //happens on compare editor
            this.indentString = new DefaultIndentPrefs().getIndentationString();
        }
        //If the completion is applied with shift pressed, do a local import. Note that the user is only actually
View Full Code Here

        if (!(part instanceof PyEdit)) {
            return false;
        }

        PyEdit pyEdit = (PyEdit) part;
        SimpleNode ast = pyEdit.getAST();
        if (ast == null) {
            IDocument doc = pyEdit.getDocument();
            SourceModule sourceModule;
            IPythonNature nature = null;
            try {
                nature = pyEdit.getPythonNature();
            } catch (MisconfigurationException e) {
                // Let's try to find a suitable nature
                File editorFile = pyEdit.getEditorFile();
                if (editorFile == null || !editorFile.exists()) {
                    Log.log(e);
                    return false;
                }
                nature = PydevPlugin.getInfoForFile(editorFile).o1;
View Full Code Here

        }
    }

    public int applyOnDocument(ITextViewer viewer, IDocument document, char trigger, int stateMask, int offset) {
        IGrammarVersionProvider versionProvider = null;
        PyEdit edit = null;
        if (viewer instanceof PySourceViewer) {
            PySourceViewer pySourceViewer = (PySourceViewer) viewer;
            versionProvider = edit = pySourceViewer.getEdit();
        } else {
            versionProvider = new IGrammarVersionProvider() {
View Full Code Here

        if (!(part instanceof PyEdit)) {
            return;
        }

        PyEdit pyEdit = (PyEdit) part;
        SimpleNode ast = pyEdit.getAST();
        if (ast == null) {
            IDocument doc = pyEdit.getDocument();
            SourceModule sourceModule;
            IPythonNature nature = null;
            try {
                nature = pyEdit.getPythonNature();
            } catch (MisconfigurationException e) {
                //Let's try to find a suitable nature
                File editorFile = pyEdit.getEditorFile();
                if (editorFile == null || !editorFile.exists()) {
                    Log.log(e);
                    return;
                }
                nature = PydevPlugin.getInfoForFile(editorFile).o1;
View Full Code Here

    // --------------- All others point to this 2 methods!
    public void toggleBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
        if (part instanceof PyEdit && selection instanceof TextSelection) {
            TextSelection textSelection = (TextSelection) selection;
            PyEdit pyEdit = (PyEdit) part;
            int startLine = textSelection.getStartLine();

            List<IMarker> markersFromCurrentFile = PyBreakpointRulerAction.getMarkersFromCurrentFile(pyEdit, startLine);
            if (markersFromCurrentFile.size() > 0) {
                PyBreakpointRulerAction.removeMarkers(markersFromCurrentFile);
            } else {
                PyBreakpointRulerAction.addBreakpointMarker(pyEdit.getDocument(), startLine + 1, pyEdit);
            }

        }

    }
View Full Code Here

public class RunEditorAsCustomUnitTestAction extends AbstractRunEditorAction {

    public void run(IAction action) {

        PyEdit pyEdit = getPyEdit();
        final Tuple<String, IInterpreterManager> launchConfigurationTypeAndInterpreterManager = this
                .getLaunchConfigurationTypeAndInterpreterManager(pyEdit, true);

        final DialogMemento memento = new DialogMemento(getShell(),
                "org.python.pydev.debug.ui.actions.RunEditorAsCustomUnitTestAction");
        SimpleNode ast = pyEdit.getAST();

        TreeSelectionDialog dialog = new TreeSelectionDialog(getShell(), new SelectTestLabelProvider(),
                new SelectTestTreeContentProvider()) {

            Link configTestRunner;
View Full Code Here

TOP

Related Classes of org.python.pydev.editor.PyEdit$MyResources

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.