Package com.aptana.shared_core.utils

Examples of com.aptana.shared_core.utils.DocCmd


            if (fReplacementString.equals("elif")) {
                doc.replace(offset, 0, fReplacementString.substring(dif));

                //check if we should dedent
                PyAutoIndentStrategy strategy = new PyAutoIndentStrategy();
                DocCmd cmd = new DocCmd(offset + fReplacementString.length() - dif, 0, " ");
                Tuple<String, Integer> dedented = PyAutoIndentStrategy.autoDedentElif(doc, cmd,
                        strategy.getIndentPrefs());
                doc.replace(cmd.offset, 0, " :");
                //make up for the ' :' (right before ':')
                if (dedented != null) {
                    changeInCursorPos = -dedented.o2 + 1;
                }
                return;

            } else if (fReplacementString.endsWith(":")) { //else:, finally:, except: ...
                //make the replacement for the 'else'
                String replacementString = fReplacementString.substring(0, fReplacementString.length() - 1);
                doc.replace(offset, 0, replacementString.substring(dif));

                //dedent if needed
                PyAutoIndentStrategy strategy = new PyAutoIndentStrategy();
                DocCmd cmd = new DocCmd(offset + replacementString.length() - dif, 0, ":");
                Tuple<String, Integer> dedented = PyAutoIndentStrategy.autoDedentAfterColon(doc, cmd,
                        strategy.getIndentPrefs());
                doc.replace(cmd.offset, 0, ":");
                //make up for the ':'
                if (dedented != null) {
View Full Code Here


            boolean isDefaultContext = contentType.equals(ParsingUtils.PY_DEFAULT);
            if (!isDefaultContext) {
                //not handled: leave it up to the auto-indent (if we're in link mode already it may delete the selected text and add a ', which is what we want).
                return false;
            }
            DocCmd docCmd = new DocCmd(ps.getAbsoluteCursorOffset(), ps.getSelLength(), "" + c);
            if (literal) {
                if (!handleLiteral(doc, docCmd, ps, isDefaultContext, prefs)) {
                    return false; //not handled
                }
            } else {
View Full Code Here

     * Empty document (should not be written to).
     */
    IDocument EMPTY_DOCUMENT = new Document();

    public String convertTabs(String cmd) {
        DocCmd newStr = new DocCmd(0, 0, cmd);
        getIndentPrefs().convertToStd(EMPTY_DOCUMENT, newStr);
        cmd = newStr.text;
        return cmd;

    }
View Full Code Here

        while (line > 0 && (line2.startsWith("#") || line2.trim().length() == 0)) {
            line--;
            line2 = skippedPs.getLine(line);
        }

        DocumentCommand command = new DocCmd(skippedPs.getEndLineOffset(line), 0, "\n");
        indentStrategy.customizeDocumentCommand(document, command);
        return command.text.substring(1);
    }
View Full Code Here

                "class Class:\n" +
                "\n" +
                "    def Method(self):\n" +
                "        '''docstring'''  " +
                "";
        DocCmd docCmd = new DocCmd(doc.length(), 0, "\n");
        strategy.customizeDocumentCommand(new Document(doc), docCmd);
        String expected = "\n        ";
        assertEquals(expected, docCmd.text);
    }
View Full Code Here

                "\n" +
                "    return [0.5 * ((A / B) ** 2 + \n"
                +
                "                   (C / D) ** 2) for E, F in G]" + //<return> before 'for'
                "";
        DocCmd docCmd = new DocCmd(doc.length() - "for E, F in G]".length(), 0, "\n");
        strategy.customizeDocumentCommand(new Document(doc), docCmd);
        String expected = "\n            ";
        assertEquals(expected, docCmd.text);
    }
View Full Code Here

                "\n" +
                "    return [0.5 * ((A / B) ** 2 + \n"
                +
                "                      (C / D) ** 2) for E, F in G]" + //keep the same level, not the one of the starting parens, as we didn't change the parens level!
                "";
        DocCmd docCmd = new DocCmd(doc.length() - ") for E, F in G]".length(), 0, "\n");
        strategy.customizeDocumentCommand(new Document(doc), docCmd);
        String expected = "\n                      ";
        assertEquals(expected, docCmd.text);
    }
View Full Code Here

                "\n" +
                "    return [0.5 * ((A / B) ** 2 + \n"
                +
                "                      (C / D) ** 2" + //keep the same level, not the one of the starting parens, as we didn't change the parens level!
                "";
        DocCmd docCmd = new DocCmd(doc.length(), 0, "\n");
        strategy.customizeDocumentCommand(new Document(doc), docCmd);
        String expected = "\n                      ";
        assertEquals(expected, docCmd.text);
    }
View Full Code Here

        String doc = "" +
                "newTuple = (\n" +
                "              what()\n" +
                ")" +
                "";
        DocCmd docCmd = new DocCmd(doc.length() - "\n)".length(), 0, "\n");
        strategy.customizeDocumentCommand(new Document(doc), docCmd);
        String expected = "\n              ";
        assertEquals(expected, docCmd.text);
    }
View Full Code Here

                "\n" +
                "    a = [0.5 * ((A / B) ** 2 + \n"
                +
                "        ( C / D) ** 2)]" +
                "";
        DocCmd docCmd = new DocCmd(doc.length() - 1, 0, "\n");
        strategy.customizeDocumentCommand(new Document(doc), docCmd);
        String expected = "\n        ";
        assertEquals(expected, docCmd.text);
    }
View Full Code Here

TOP

Related Classes of com.aptana.shared_core.utils.DocCmd

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.