Package org.python.pydev.core.docutils.PySelection

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


            ImportHandleInfo groupInto = null;
            ImportHandleInfo realImportHandleInfo = null;

            boolean groupImports = ImportsPreferencesPage.getGroupImports();

            LineStartingScope previousLineThatStartsScope = null;
            PySelection ps = null;
            if (this.addLocalImport) {
                ps = new PySelection(document, offset);
                int startLineIndex = ps.getStartLineIndex();
                if (startLineIndex == 0) {
View Full Code Here


        int lineCtx = ps.isInDeclarationLine();
        if (lineCtx != PySelection.DECLARATION_NONE) {
            if (lineCtx == PySelection.DECLARATION_METHOD) {
                Image imageOverride = PydevPlugin.getImageCache().get(UIConstants.METHOD_ICON);
                String lineContentsToCursor = ps.getLineContentsToCursor();
                LineStartingScope scopeStart = ps.getPreviousLineThatStartsScope(PySelection.CLASS_TOKEN, false,
                        PySelection.getFirstCharPosition(lineContentsToCursor));

                String className = null;
                if (scopeStart != null) {
                    className = PySelection.getClassNameInLine(scopeStart.lineStartingScope);
View Full Code Here

    /**
     * @return the text for the indent
     */
    private String indentBasedOnStartingScope(String text, PySelection selection, boolean checkForLowestBeforeNewScope) {
        LineStartingScope previousIfLine = selection.getPreviousLineThatStartsScope();
        if (previousIfLine != null) {
            String initial = getCharsBeforeNewLine(text);

            if (previousIfLine.lineWithDedentWhileLookingScope == null) { //no dedent was found
                String indent = PySelection.getIndentationFromLine(previousIfLine.lineStartingScope);
View Full Code Here

                            if (!considerOnlyCurrentLine) {
                                //ok, also analyze the scope we're in (otherwise, if we only have the current line
                                //that's the best guess we can give).
                                int firstCharPosition = PySelection.getFirstCharPosition(line);

                                LineStartingScope scopeStart = ps.getPreviousLineThatStartsScope(
                                        PySelection.CLASS_AND_FUNC_TOKENS, false, firstCharPosition);

                                if (scopeStart != null) {
                                    if (scopeStart.lineStartingScope != null
                                            && scopeStart.lineStartingScope.indexOf("def ") != -1) {
View Full Code Here

            }
        }

        //Ok, we have to analyze the current context and see if each closing peer
        //in this context has a match. If one doesn't, we won't close it.
        LineStartingScope nextLineThatStartsScope = ps.getNextLineThatStartsScope();
        int lineStartingNextScope;
        if (nextLineThatStartsScope == null) {
            lineStartingNextScope = Integer.MAX_VALUE;
        } else {
            lineStartingNextScope = nextLineThatStartsScope.iLineStartingScope;
View Full Code Here

            String methodToCreate = headAndTail[1];
            if (headAndTail[0].equals("self")) {
                //creating something in the current class -- note that if it was self.bar here, we'd treat it as regular
                //(i.e.: no special support for self), so, we wouldn't enter here!
                int firstCharPosition = PySelection.getFirstCharPosition(lineContents);
                LineStartingScope scopeStart = callPs.getPreviousLineThatStartsScope(PySelection.CLASS_TOKEN, false,
                        firstCharPosition);
                String classNameInLine = null;
                if (scopeStart != null) {
                    for (Boolean isCall : new Boolean[] { true, false }) {
                        PyCreateMethodOrField pyCreateMethod = new PyCreateMethodOrField();
View Full Code Here

            switch (locationStrategy) {
                case LOCATION_STRATEGY_BEFORE_CURRENT:
                    String currentLine = pySelection.getLine();
                    int firstCharPosition = PySelection.getFirstCharPosition(currentLine);

                    LineStartingScope scopeStart = pySelection.getPreviousLineThatStartsScope(
                            PySelection.CLASS_AND_FUNC_TOKENS, false, firstCharPosition);

                    if (scopeStart == null) {
                        Log.log("Could not get proper scope to create code inside class.");
                        ClassDef astNode = targetClass.getASTNode();
View Full Code Here

                "    def m1(self):\n" +
                "        pass\n" +
                "";
        doc = new Document(str);
        PySelection ps = new PySelection(doc, 0);
        LineStartingScope nextLineThatStartsScope = ps.getNextLineThatStartsScope();
        assertEquals(0, nextLineThatStartsScope.iLineStartingScope);

        ps = new PySelection(doc, 12);
        nextLineThatStartsScope = ps.getNextLineThatStartsScope();
        assertEquals(2, nextLineThatStartsScope.iLineStartingScope);
View Full Code Here

TOP

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

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.