Package org.python.pydev.core.docutils

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


    public void test3() throws Exception {

        doc = new Document("    #---- aa\n" +
                "        #---- b\n" +
                "    #---- c");
        ps = new PySelection(doc, 0, 0, 0);
        PyRemoveBlockComment pyRemoveBlockComment = new PyRemoveBlockComment();
        pyRemoveBlockComment.perform(ps);

        expected = "    aa\n" +
                "        b\n" +
View Full Code Here


        doc = new Document("    #---- aa\n" +
                "        #---- b\n" +
                "    #---- c\n" +
                "\n" +
                "\n");
        ps = new PySelection(doc, 0, 0, 0);
        PyRemoveBlockComment pyRemoveBlockComment = new PyRemoveBlockComment();
        pyRemoveBlockComment.perform(ps);

        expected = "    aa\n" +
                "        b\n" +
View Full Code Here

        doc = new Document("\t#---- aa\n" +
                "\t\t#---- b\n" +
                "\t#---- c\n" +
                "\n" +
                "\n");
        ps = new PySelection(doc, 0, 0, 0);
        PyRemoveBlockComment pyRemoveBlockComment = new PyRemoveBlockComment();
        pyRemoveBlockComment.perform(ps);

        expected = "\taa\n" +
                "\t\tb\n" +
View Full Code Here

        doc = new Document("\t#---- aa\n" +
                "\t\t'--#--' b\n" + //Ignore this line when removing block comments
                "\t#---- c\n" + //This won't be touched as the block broke on the previous line.
                "\n" +
                "\n");
        ps = new PySelection(doc, 0, 0, 0);
        PyRemoveBlockComment pyRemoveBlockComment = new PyRemoveBlockComment();
        pyRemoveBlockComment.perform(ps);

        expected = "\taa\n" +
                "\t\t'--#--' b\n" +
View Full Code Here

    public void test7() throws Exception {

        doc = new Document("\t# aa\n" +
                "\t# aa\n" +
                "\n");
        ps = new PySelection(doc, 0, 0, 0);
        PyRemoveBlockComment pyRemoveBlockComment = new PyRemoveBlockComment();
        pyRemoveBlockComment.perform(ps);

        expected = "\taa\n" +
                "\taa\n" +
View Full Code Here

    public void test8() throws Exception {

        doc = new Document("# aa\n" +
                "# aa\n" +
                "\n");
        ps = new PySelection(doc, 0, 0, 0);
        PyRemoveBlockComment pyRemoveBlockComment = new PyRemoveBlockComment();
        pyRemoveBlockComment.perform(ps);

        expected = "aa\n" +
                "aa\n" +
View Full Code Here

    public void test9() throws Exception {

        doc = new Document("    #  aa\n" +
                "    #  aa\n" +
                "\n");
        ps = new PySelection(doc, 0, 0, 0);
        PyRemoveBlockComment pyRemoveBlockComment = new PyRemoveBlockComment();
        pyRemoveBlockComment.perform(ps);

        expected = "    aa\n" +
                "    aa\n" +
View Full Code Here

                @Override
                public IStatus runInUIThread(IProgressMonitor monitor) {
                    try {
                        ISourceViewer viewer = pyEdit.getPySourceViewer();
                        IDocument document = viewer.getDocument();
                        PySelection ps = new PySelection(pyEdit);
                        LinkedPositionGroup group = new LinkedPositionGroup();

                        if (!fillWithOccurrences(document, group, new NullProgressMonitor(), ps)) {
                            return Status.OK_STATUS;
                        }

                        if (group.isEmpty()) {
                            return Status.OK_STATUS;
                        }

                        LinkedModeModel model = new LinkedModeModel();
                        model.addGroup(group);
                        if (model.tryInstall() && model.getTabStopSequence().size() > 0) {
                            final LinkedModeUI ui = new EditorLinkedModeUI(model, viewer);
                            Tuple<String, Integer> currToken = ps.getCurrToken();
                            ui.setCyclingMode(LinkedModeUI.CYCLE_ALWAYS);
                            ui.setExitPosition(viewer, currToken.o2 + currToken.o1.length(), 0, 0 /*ordered so that 0 is current pos*/);
                            ui.enter();
                        }
                    } catch (BadLocationException e) {
View Full Code Here

    }

    public void testUncomment() throws Exception {
        Document doc = new Document("#a\n" +
                "#b");
        PySelection ps = new PySelection(doc, 0, 0, doc.getLength());
        assertEquals(new Tuple<Integer, Integer>(0, 3), new PyUncomment().perform(ps));

        String expected = "a\n" +
                "b";
        assertEquals(expected, doc.get());
View Full Code Here

    /**
     * Returns a proposal that can be used to generate the code.
     */
    public ICompletionProposal createProposal(RefactoringInfo refactoringInfo, String actTok, int locationStrategy,
            List<String> parametersAfterCall) {
        PySelection pySelection = refactoringInfo.getPySelection();
        ModuleAdapter moduleAdapter = refactoringInfo.getModuleAdapter();
        String decorators = "";

        IClassDefAdapter targetClass = null;
        String body = "${pass}";
        if (createInClass != null) {
            List<IClassDefAdapter> classes = moduleAdapter.getClasses();
            for (IClassDefAdapter iClassDefAdapter : classes) {
                if (createInClass.equals(iClassDefAdapter.getName())) {
                    targetClass = iClassDefAdapter;
                    break;
                }
            }

            if (targetClass != null) {
                switch (createAs) {
                    case BOUND_METHOD:
                        parametersAfterCall = checkFirst(parametersAfterCall, "self");
                        break;

                    case CLASSMETHOD:
                        parametersAfterCall = checkFirst(parametersAfterCall, "cls");
                        decorators = "@classmethod\n";
                        break;

                    case STATICMETHOD:
                        decorators = "@staticmethod\n";
                        break;

                    case CONSTANT:
                        String indent = targetClass.getNodeBodyIndent();
                        Pass replacePassStatement = getLastPassFromNode(targetClass.getASTNode());

                        String constant = com.aptana.shared_core.string.StringUtils.format("\n%s = ${None}${cursor}\n", actTok);
                        Tuple<Integer, String> offsetAndIndent;
                        offsetAndIndent = getLocationOffset(AbstractPyCreateAction.LOCATION_STRATEGY_FIRST_METHOD,
                                pySelection, moduleAdapter, targetClass);

                        return createProposal(pySelection, constant, offsetAndIndent, false, replacePassStatement);

                    case FIELD:

                        parametersAfterCall = checkFirst(parametersAfterCall, "self");
                        FunctionDefAdapter firstInit = targetClass.getFirstInit();
                        if (firstInit != null) {
                            FunctionDef astNode = firstInit.getASTNode();
                            replacePassStatement = getLastPassFromNode(astNode);

                            //Create the field as the last line in the __init__
                            int nodeLastLine = firstInit.getNodeLastLine() - 1;
                            indent = firstInit.getNodeBodyIndent();
                            String pattern;

                            if (replacePassStatement == null) {
                                pattern = com.aptana.shared_core.string.StringUtils.format("\nself.%s = ${None}${cursor}", actTok);
                                try {
                                    IRegion region = pySelection.getDoc().getLineInformation(nodeLastLine);
                                    int offset = region.getOffset() + region.getLength();
                                    offsetAndIndent = new Tuple<Integer, String>(offset, indent);
                                } catch (BadLocationException e) {
                                    Log.log(e);
                                    return null;
View Full Code Here

TOP

Related Classes of org.python.pydev.core.docutils.PySelection$TddPossibleMatches

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.