Package org.python.pydev.editor.correctionassist.heuristics

Examples of org.python.pydev.editor.correctionassist.heuristics.AssistAssign


        }

        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();
View Full Code Here


        return new Tuple<Integer, String>(offset, "");
    }

    protected FastStringBuffer createParametersList(List<String> parametersAfterCall) {
        FastStringBuffer params = new FastStringBuffer(parametersAfterCall.size() * 10);
        AssistAssign assistAssign = new AssistAssign();
        for (int i = 0; i < parametersAfterCall.size(); i++) {
            String param = parametersAfterCall.get(i).trim();
            if (params.length() > 0) {
                params.append(", ");
            }
            String tok = null;
            if (param.indexOf('=') != -1) {
                List<String> split = StringUtils.split(param, '=');
                if (split.size() > 0) {
                    String part0 = split.get(0).trim();
                    if (StringUtils.isPythonIdentifier(part0)) {
                        tok = part0;
                    }
                }
            }
            if (tok == null) {
                if (StringUtils.isPythonIdentifier(param)) {
                    tok = param;
                } else {
                    tok = assistAssign.getTokToAssign(param);
                    if (tok == null || tok.length() == 0) {
                        tok = "param" + i;
                    }
                }
            }
View Full Code Here

        List<ICompletionProposal> props = new ArrayList<ICompletionProposal>();
        if (sourceViewer instanceof ScriptConsoleViewer) {
            ScriptConsoleViewer viewer = (ScriptConsoleViewer) sourceViewer;

            //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) {
                                break;
                            }
                            char c = doc.getChar(commandLineOffset);
                            if (Character.isWhitespace(c)) {
                                commandLineOffset++;
                            } else {
                                break;
                            }
                        }
                        props.addAll(assistAssign.getProps(ps, PydevPlugin.getImageCache(), sourceViewer, offset,
                                commandLine, commandLineOffset));

                    } catch (BadLocationException e) {
                        Log.log(e);
                    }
View Full Code Here

        List<ICompletionProposal> props = new ArrayList<ICompletionProposal>();
        if (sourceViewer instanceof ScriptConsoleViewer) {
            ScriptConsoleViewer viewer = (ScriptConsoleViewer) sourceViewer;

            //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) {
                                break;
                            }
                            char c = doc.getChar(commandLineOffset);
                            if (Character.isWhitespace(c)) {
                                commandLineOffset++;
                            } else {
                                break;
                            }
                        }
                        props.addAll(assistAssign.getProps(ps, PydevPlugin.getImageCache(), sourceViewer, offset,
                                commandLine, commandLineOffset));

                    } catch (BadLocationException e) {
                        Log.log(e);
                    }
View Full Code Here

TOP

Related Classes of org.python.pydev.editor.correctionassist.heuristics.AssistAssign

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.