Examples of PyEdit


Examples of org.python.pydev.editor.PyEdit

public class RunEditorBasedOnNatureTypeAction extends AbstractRunEditorAction {

    public void run(IAction action) {

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

        AbstractLaunchShortcut shortcut = new AbstractLaunchShortcut() {
View Full Code Here

Examples of org.python.pydev.editor.PyEdit

                IEditorReference[] editorReferences = activePage.getEditorReferences();
                for (IEditorReference editorReference : editorReferences) {
                    IEditorPart editor = editorReference.getEditor(false);
                    if (editor != null) {
                        if (editor instanceof PyEdit) {
                            PyEdit pyEdit = (PyEdit) editor;
                            IEditorInput editorInput = pyEdit.getEditorInput();
                            if (editorInput instanceof IPathEditorInput) {
                                IPathEditorInput pathEditorInput = (IPathEditorInput) editorInput;
                                IPath localPath = pathEditorInput.getPath();
                                if (localPath != null) {
                                    String considerName = localPath.segment(localPath.segmentCount() - 1);
                                    if (matchName.equals(considerName)) {
                                        workbenchAndReturn.o2 = editorInput;
                                        return;
                                    }
                                }
                            } else {
                                File editorFile = pyEdit.getEditorFile();
                                if (editorFile != null) {
                                    if (editorFile.getName().equals(matchName)) {
                                        workbenchAndReturn.o2 = editorInput;
                                        return;
                                    }
View Full Code Here

Examples of org.python.pydev.editor.PyEdit

    public String getModuleName() {
        if (this.viewer instanceof PySourceViewer) {
            try {
                PySourceViewer pyViewer = (PySourceViewer) this.viewer;
                PyEdit edit = pyViewer.getEdit();
                IPythonNature nature = edit.getPythonNature();
                if (nature != null) {
                    return nature.resolveModule(edit.getEditorFile());
                }
            } catch (MisconfigurationException e) {
            }
        }
        return "";
View Full Code Here

Examples of org.python.pydev.editor.PyEdit

public class PyToggleForceTabs extends PyAction {

    public void run(IAction action) {
        if (targetEditor instanceof PyEdit) {
            PyEdit pyEdit = (PyEdit) targetEditor;
            IIndentPrefs indentPrefs = pyEdit.getIndentPrefs();
            indentPrefs.setForceTabs(!indentPrefs.getForceTabs());
            updateActionState(indentPrefs);
        }
    }
View Full Code Here

Examples of org.python.pydev.editor.PyEdit

    private void updateActionState(IIndentPrefs indentPrefs) {
        //This doesn't work! (setChecked and setImageDescriptor don't seem to update the action in the pop up menu).
        //    setChecked(forceTabs);
        //    setImageDescriptor(desc);

        PyEdit pyEdit = getPyEdit();
        pyEdit.updateForceTabsMessage();
    }
View Full Code Here

Examples of org.python.pydev.editor.PyEdit

        try {
            if (!canModifyEditor()) {
                return;
            }

            PyEdit pyEdit = (PyEdit) getTextEditor();
            IIndentPrefs indentPrefs = pyEdit.getIndentPrefs();
            PySelection ps = new PySelection(pyEdit);
            perform(ps, indentPrefs);
        } catch (Exception e) {
            beep(e);
        }
View Full Code Here

Examples of org.python.pydev.editor.PyEdit

        int offset = invocationContext.getOffset();
        PySelection base = edit.createPySelection();
        if (!(this.edit instanceof PyEdit) || base == null) {
            return new ICompletionProposal[0];
        }
        PyEdit editor = (PyEdit) this.edit;

        List<ICompletionProposal> results = new ArrayList<ICompletionProposal>();
        String sel = PyAction.getLineWithoutComments(base);

        List<IAssistProps> assists = new ArrayList<IAssistProps>();
        synchronized (PythonCorrectionProcessor.additionalAssists) {
            for (IAssistProps prop : additionalAssists.values()) {
                assists.add(prop);
            }
        }

        assists.add(new AssistSurroundWith());
        assists.add(new AssistImport());
        assists.add(new AssistDocString());
        assists.add(new AssistAssign());
        assists.add(new AssistPercentToFormat());

        assists.addAll(ExtensionHelper.getParticipants(ExtensionHelper.PYDEV_CTRL_1));
        ImageCache imageCache = PydevPlugin.getImageCache();
        File editorFile = edit.getEditorFile();
        IPythonNature pythonNature = null;
        try {
            pythonNature = edit.getPythonNature();
        } catch (MisconfigurationException e1) {
            Log.log(e1);
        }

        for (IAssistProps assist : assists) {
            //Always create a new for each assist, as any given assist may change it.
            PySelection ps = new PySelection(base);
            try {
                if (assist.isValid(ps, sel, editor, offset)) {
                    try {
                        results.addAll(assist.getProps(ps, imageCache, editorFile, pythonNature, editor, offset));
                    } catch (Exception e) {
                        Log.log(e);
                    }
                }
            } catch (Exception e) {
                Log.log(e);
            }
        }

        Collections.sort(results, IPyCodeCompletion.PROPOSAL_COMPARATOR);

        try {
            //handling spelling... (we only want to show spelling fixes if a spell problem annotation is found at the current location).
            //we'll only show some spelling proposal if there's some spelling problem (so, we don't have to check the preferences at this place,
            //as no annotations on spelling will be here if the spelling is not enabled).
            ICompletionProposal[] spellProps = null;

            IAnnotationModel annotationModel = editor.getPySourceViewer().getAnnotationModel();
            Iterator<Object> it = annotationModel.getAnnotationIterator();
            while (it.hasNext()) {
                Object annotation = it.next();
                if (annotation instanceof SpellingAnnotation) {
                    SpellingAnnotation spellingAnnotation = (SpellingAnnotation) annotation;
View Full Code Here

Examples of org.python.pydev.editor.PyEdit

            Log.log(e);
        }
    }

    public void perform(IDocument doc, ITextSelection selection) {
        PyEdit pyEdit = getPyEdit();
        FastStack<IRegion> cache = getCache(pyEdit);
        Region initialRegion = new Region(selection.getOffset(), selection.getLength());
        if (cache.size() > 0) {
            IRegion peek = cache.peek();
            if (!peek.equals(initialRegion)) {
                cache.clear();
            }
        }
        if (cache.size() == 0) {
            cache.push(initialRegion);
        }
        ITextSelection newSelection = getNewSelection(doc, selection);
        if (initialRegion.equals(new Region(newSelection.getOffset(), newSelection.getLength()))) {
            return;
        }

        pyEdit.setSelection(newSelection.getOffset(), newSelection.getLength());
        cache.push(new Region(newSelection.getOffset(), newSelection.getLength()));
    }
View Full Code Here

Examples of org.python.pydev.editor.PyEdit

            return; //no template selected, nothing to apply!
        }

        Template template = selectedTemplate.getTemplate();

        PyEdit pyEdit = (PyEdit) openEditor;
        Region region = new Region(0, 0);
        PyDocumentTemplateContext context = PyTemplateCompletionProcessor.createContext(new PyContextType(),
                pyEdit.getPySourceViewer(), region);

        TemplateProposal templateProposal = new TemplateProposal(template, context, region, null);
        templateProposal.apply(pyEdit.getPySourceViewer(), '\n', 0, 0);
    }
View Full Code Here

Examples of org.python.pydev.editor.PyEdit

public class PyCopyQualifiedName extends PyAction {

    public void run(IAction action) {
        FastStringBuffer buf = new FastStringBuffer();
        try {
            PyEdit pyEdit = getPyEdit();

            PySelection pySelection = new PySelection(pyEdit);

            IPythonNature nature = pyEdit.getPythonNature();
            File editorFile = pyEdit.getEditorFile();
            buf.append(nature.resolveModule(editorFile));

            List<stmtType> path = FastParser.parseToKnowGloballyAccessiblePath(pySelection.getDoc(),
                    pySelection.getStartLineIndex());
            for (stmtType stmtType : path) {
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.