Package org.python.pydev.core.docutils

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


    }

    public ItemPointer[] findDefinitionsAndOpen(boolean doOpenDefinition) {
        request = null;

        ps = new PySelection(getTextEditor());
        final PyEdit pyEdit = getPyEdit();
        RefactoringRequest refactoringRequest;
        try {
            refactoringRequest = getRefactoringRequest();
        } catch (MisconfigurationException e1) {
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 source;
        if (parametersAfterCall == null || parametersAfterCall.size() == 0) {
            source = com.aptana.shared_core.string.StringUtils.format(baseClassStr, actTok);
View Full Code Here

    public FindDuplicatesVisitor(ITextSelection selection, exprType expression, IDocument doc) {
        this.selection = selection;
        this.expression = expression;
        this.doc = doc;
        this.ps = new PySelection(this.doc, selection);
        FastStringBuffer buf = new FastStringBuffer(ps.getSelectedText(), 0);
        ParsingUtils.removeCommentsAndWhitespaces(buf);
        buf.replaceAll("\\", ""); //Remove all the \\
        selectedText = buf.toCharArray();
        parsingUtils = ParsingUtils.create(this.doc);
View Full Code Here

                "a  =  10  \n" +
                "";
        Document doc = new Document(s);

        int[] regionsForSave = new int[] { 0 };
        pyFormatStd.formatSelection(doc, regionsForSave, null, new PySelection(doc), std);
        assertEquals(expected, doc.get());
    }
View Full Code Here

                "a  =  10  \n" +
                "";
        Document doc = new Document(s);

        int[] regionsForSave = new int[] { 0 };
        pyFormatStd.formatSelection(doc, regionsForSave, null, new PySelection(doc), std);
        assertEquals(expected, doc.get());
    }
View Full Code Here

                "a  =  10\n" +
                "";
        Document doc = new Document(s);

        int[] regionsForSave = new int[] { 0 };
        pyFormatStd.formatSelection(doc, regionsForSave, null, new PySelection(doc), std);
        assertEquals(s, doc.get());
    }
View Full Code Here

    public void execute(RefactoringInfo refactoringInfo, int locationStrategy) {
        try {
            String creationStr = this.getCreationStr();
            final String asTitle = StringUtils.getWithFirstUpper(creationStr);

            PySelection pySelection = refactoringInfo.getPySelection();
            Tuple<String, Integer> currToken = pySelection.getCurrToken();
            String actTok = currToken.o1;
            List<String> parametersAfterCall = null;
            if (actTok.length() == 0) {
                InputDialog dialog = new InputDialog(PyAction.getShell(), asTitle + " name",
                        "Please enter the name of the " + asTitle + " to be created.", "", new IInputValidator() {

                            public String isValid(String newText) {
                                if (newText.length() == 0) {
                                    return "The " + asTitle + " name may not be empty";
                                }
                                if (StringUtils.containsWhitespace(newText)) {
                                    return "The " + asTitle + " name may not contain whitespaces.";
                                }
                                return null;
                            }
                        });
                if (dialog.open() != InputDialog.OK) {
                    return;
                }
                actTok = dialog.getValue();
            } else {
                parametersAfterCall = pySelection.getParametersAfterCall(currToken.o2 + actTok.length());

            }

            execute(refactoringInfo, actTok, parametersAfterCall, locationStrategy);
        } catch (BadLocationException e) {
View Full Code Here

            //currently, only the assign quick assist is used
            AssistAssign assistAssign = new AssistAssign();

            ISelection selection = sourceViewer.getSelectionProvider().getSelection();
            if (selection instanceof ITextSelection) {
                PySelection ps = new PySelection(sourceViewer.getDocument(), (ITextSelection) selection);
                int offset = viewer.getCaretOffset();
                String commandLine = viewer.getCommandLine();

                //let's calculate the 1st line that is not a whitespace.
                if (assistAssign.isValid(ps.getSelLength(), commandLine, offset)) {
                    int commandLineOffset = viewer.getCommandLineOffset();
                    try {
                        IDocument doc = sourceViewer.getDocument();
                        while (true) {
                            if (commandLineOffset == doc.getLength() - 1) {
View Full Code Here

    private ArrayList<IDefinition> findDefinitions(IPythonNature nature, PyEdit edit, int start, IDocument doc) {
        CompletionCache completionCache = new CompletionCache();
        ArrayList<IDefinition> selected = new ArrayList<IDefinition>();

        RefactoringRequest request = new RefactoringRequest(edit.getEditorFile(), new PySelection(doc,
                new TextSelection(doc, start, 0)), new NullProgressMonitor(), nature, edit);

        try {
            PyRefactoringFindDefinition.findActualDefinition(request, completionCache, selected);
        } catch (CompletionRecursionException e1) {
View Full Code Here

                        if (!foundOffsets.contains(offset)) {
                            foundOffsets.add(offset);
                            if (PyFindAllOccurrences.DEBUG_FIND_REFERENCES) {
                                System.out.println("Adding match:" + workspaceFile);
                            }
                            PySelection ps = new PySelection(doc, offset);
                            int lineNumber = ps.getLineOfOffset();
                            String lineContents = ps.getLine(lineNumber);
                            int lineStartOffset = ps.getLineOffset(lineNumber);

                            LineElement element = new LineElement(workspaceFile, lineNumber, lineStartOffset,
                                    lineContents);
                            findOccurrencesSearchResult.addMatch(new FileMatch(workspaceFile, offset, length, element));
                        }
View Full Code Here

TOP

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

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.