Examples of PySelection


Examples of org.python.pydev.core.docutils.PySelection

        return new FastParser(doc, currentLine, forward, stopOnFirstMatch).parse();
    }

    private List<stmtType> parse() {
        List<stmtType> body = new ArrayList<stmtType>();
        PySelection ps = new PySelection(doc);
        DocIterator it = new PySelection.DocIterator(forward, ps, currentLine, false);

        Matcher functionMatcher = FUNCTION_PATTERN.matcher("");
        List<Matcher> cythonMatchers = null;
        if (this.cythonParse) {
View Full Code Here

Examples of org.python.pydev.core.docutils.PySelection

        try {
            if (!canModifyEditor()) {
                return;
            }
            // Select from text editor
            PySelection ps = new PySelection(getTextEditor());
            // Perform the action
            int toSelect = perform(ps);
            if (toSelect != -1) {
                getTextEditor().selectAndReveal(toSelect, 0);
            } else {
View Full Code Here

Examples of org.python.pydev.core.docutils.PySelection

     * (non-Javadoc)
     *
     * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
     */
    public void run(IAction action) {
        PySelection ps = new PySelection(getTextEditor());

        ProjectionAnnotationModel model = (ProjectionAnnotationModel) getTextEditor().getAdapter(
                ProjectionAnnotationModel.class);
        try {
            if (model != null) {
                //put annotations in array list.
                Iterator iter = model.getAnnotationIterator();
                while (iter != null && iter.hasNext()) {
                    PyProjectionAnnotation element = (PyProjectionAnnotation) iter.next();
                    Position position = model.getPosition(element);

                    int line = ps.getDoc().getLineOfOffset(position.offset);

                    int start = ps.getStartLineIndex();
                    int end = ps.getEndLineIndex();

                    for (int i = start; i <= end; i++) {
                        if (i == line) {
                            model.collapse(element);
                            break;
View Full Code Here

Examples of org.python.pydev.core.docutils.PySelection

        buf.clear();

        if (!pythonCommentOrMultiline) {
            if (textViewer instanceof PySourceViewer) {
                PySourceViewer s = (PySourceViewer) textViewer;
                PySelection ps = new PySelection(s.getDocument(), hoverRegion.getOffset() + hoverRegion.getLength());

                List<IPyHoverParticipant> participants = ExtensionHelper.getParticipants(ExtensionHelper.PYDEV_HOVER);
                for (IPyHoverParticipant pyHoverParticipant : participants) {
                    try {
                        String hoverText = pyHoverParticipant.getHoverText(hoverRegion, s, ps, textSelection);
View Full Code Here

Examples of org.python.pydev.core.docutils.PySelection

     * (non-Javadoc)
     *
     * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
     */
    public void run(IAction action) {
        PySelection ps = new PySelection(getTextEditor());

        ProjectionAnnotationModel model = (ProjectionAnnotationModel) getTextEditor().getAdapter(
                ProjectionAnnotationModel.class);

        if (model != null) {
            model.expandAll(ps.getAbsoluteCursorOffset(), ps.getSelLength());
        }

    }
View Full Code Here

Examples of org.python.pydev.core.docutils.PySelection

            }

            public PySelection createPySelection() {
                ISelection selection = sourceViewer.getSelection();
                if (selection instanceof ITextSelection) {
                    return new PySelection(sourceViewer.getDocument(), (ITextSelection) selection);
                } else {
                    return null;
                }
            }
View Full Code Here

Examples of org.python.pydev.core.docutils.PySelection

            if (!canModifyEditor()) {
                return;
            }

            // Select from text editor
            ps = new PySelection(getTextEditor());
            ps.selectAll(false);
            // Perform the action
            perform(ps);

            // Put cursor at the first area of the selection
View Full Code Here

Examples of org.python.pydev.core.docutils.PySelection

        }
        l.add(new PyCompletionProposal(comp, offsetPosToAdd, 0, newOffset, image, "Make docstring", null, null,
                IPyCompletionProposal.PRIORITY_DEFAULT) {
            public void apply(IDocument document) {
                //remove the next line if it is a pass...
                PySelection ps = new PySelection(document, fReplacementOffset);
                int iNextLine = ps.getCursorLine() + 1;
                String nextLine = ps.getLine(iNextLine);
                if (nextLine.trim().equals("pass")) {
                    ps.deleteLine(iNextLine);
                }
                super.apply(document);
            }
        });
        return l;
View Full Code Here

Examples of org.python.pydev.core.docutils.PySelection

            // if either the skipped line or the moving lines are outside the widget's
            // visible area, bail out
            if (!containedByVisibleRegion(movingArea, viewer) || !containedByVisibleRegion(skippedLine, viewer))
                return;

            PySelection skippedPs = new PySelection(document, skippedLine);

            // get the content to be moved around: the moving (selected) area and the skipped line
            String moving = movingArea.getText();
            String skipped = skippedLine.getText();
            if (moving == null || skipped == null || document.getLength() == 0)
                return;

            String delim;
            String insertion;
            int offset;
            int length;
            ILineRange selectionBefore = getLineRange(document, movingArea);
            IRewriteTarget target = null;
            if (pyEdit != null) {
                target = (IRewriteTarget) pyEdit.getAdapter(IRewriteTarget.class);
                if (target != null) {
                    target.beginCompoundChange();
                    if (!getMoveUp()) {
                        //When going up we'll just do a single document change, so, there's
                        //no need to set the redraw.
                        target.setRedraw(false);
                    }
                }
            }
            ILineRange selectionAfter;
            boolean isStringPartition;
            try {
                if (getMoveUp()) {
                    //check partition in the start of the skipped line
                    isStringPartition = ParsingUtils.isStringPartition(document, skippedLine.getOffset());
                    delim = document.getLineDelimiter(skippedLine.getEndLine());
                    Assert.isNotNull(delim);
                    offset = skippedLine.getOffset();
                    length = moving.length() + delim.length() + skipped.length();
                } else {
                    //check partition in the start of the line after the skipped line
                    int offsetToCheckPartition;
                    if (skippedLine.getEndLine() == document.getNumberOfLines() - 1) {
                        offsetToCheckPartition = document.getLength() - 1; //check the last document char
                    } else {
                        offsetToCheckPartition = skippedLine.getOffset() + skippedLine.getLength(); //that's always the '\n' of the line
                    }

                    isStringPartition = ParsingUtils.isStringPartition(document, offsetToCheckPartition);

                    delim = document.getLineDelimiter(movingArea.getEndLine());
                    Assert.isNotNull(delim);
                    offset = movingArea.getOffset();

                    //When going down, we need to remove the movingArea to compute the new indentation
                    //properly (otherwise we'd use that text being moved on the compute algorithm)
                    document.replace(movingArea.getOffset(), movingArea.getLength() + delim.length(), "");
                    length = skipped.length();
                    int pos = skippedPs.getAbsoluteCursorOffset() - (movingArea.getLength() + delim.length());
                    skippedPs.setSelection(pos, pos);
                }

                PyAutoIndentStrategy indentStrategy = null;
                if (pyEdit != null) {
                    indentStrategy = pyEdit.getAutoEditStrategy();
View Full Code Here

Examples of org.python.pydev.core.docutils.PySelection

            if (!canModifyEditor()) {
                return;
            }

            // Select from text editor
            ps = new PySelection(getTextEditor());
            ps.selectAll(false);
            // Perform the action
            perform();

            // Put cursor at the first area of the selection
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.