src/eric7/QScintilla/TypingCompleters/CompleterPython.py

Sun, 10 Sep 2023 18:04:28 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 10 Sep 2023 18:04:28 +0200
branch
eric7
changeset 10201
5beaa25bdfbe
parent 10126
32e6b6cb3cd1
child 10431
64157aeb0312
permissions
-rw-r--r--

Editor
- Added a typing completer for TOML files.
- Enhanced the existing completers slightly.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
9653
e67609152c5e Updated copyright for 2023.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9493
diff changeset
3 # Copyright (c) 2007 - 2023 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a typing completer for Python.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import re
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
12 from PyQt6.Qsci import QsciLexerPython, QsciScintilla
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
14 from eric7 import Preferences
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
15 from eric7.Utilities import rxIndex
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
17 from .CompleterBase import CompleterBase
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
18
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
19
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 class CompleterPython(CompleterBase):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 Class implementing typing completer for Python.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
24
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
25 def __init__(self, editor, parent=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 Constructor
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
28
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 @param editor reference to the editor object (QScintilla.Editor)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @param parent reference to the parent object (QObject)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8131
diff changeset
32 super().__init__(editor, parent)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
33
10126
32e6b6cb3cd1 Fixed the handling of 'async' in the Python typing completer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10115
diff changeset
34 self.__defRX = re.compile(r"^[ \t]*(async[ \t]+)?(def|cdef|cpdef) \w+\(")
8131
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
35 self.__defSelfRX = re.compile(
10126
32e6b6cb3cd1 Fixed the handling of 'async' in the Python typing completer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10115
diff changeset
36 r"^[ \t]*(async[ \t]+)?(def|cdef|cpdef) \w+\([ \t]*self[ \t]*[,)]"
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
37 )
8131
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
38 self.__defClsRX = re.compile(
10126
32e6b6cb3cd1 Fixed the handling of 'async' in the Python typing completer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10115
diff changeset
39 r"^[ \t]*(async[ \t]+)?(def|cdef|cpdef) \w+\([ \t]*cls[ \t]*[,)]"
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
40 )
9991
814552ada1fb CompleterPython: fixed an inaccuracy causing plain classes (i.e. class foo:) not to be detected.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
41 self.__classRX = re.compile(r"^[ \t]*(cdef[ \t]+)?class \w+[(:]")
7775
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
42 self.__importRX = re.compile(r"^[ \t]*from [\w.]+ ")
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
43 self.__classmethodRX = re.compile(r"^[ \t]*@classmethod")
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
44 self.__staticmethodRX = re.compile(r"^[ \t]*@staticmethod")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
45
7775
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
46 self.__defOnlyRX = re.compile(r"^[ \t]*def ")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
47
7775
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
48 self.__ifRX = re.compile(r"^[ \t]*if ")
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
49 self.__elifRX = re.compile(r"^[ \t]*elif ")
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
50 self.__elseRX = re.compile(r"^[ \t]*else:")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
51
7775
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
52 self.__tryRX = re.compile(r"^[ \t]*try:")
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
53 self.__finallyRX = re.compile(r"^[ \t]*finally:")
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
54 self.__exceptRX = re.compile(r"^[ \t]*except ")
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
55 self.__exceptcRX = re.compile(r"^[ \t]*except:")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
56
7775
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
57 self.__whileRX = re.compile(r"^[ \t]*while ")
10126
32e6b6cb3cd1 Fixed the handling of 'async' in the Python typing completer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10115
diff changeset
58 self.__forRX = re.compile(r"^[ \t]*(async[ \t]+)?for ")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
59
10201
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10126
diff changeset
60 self.__trailingBlankRe = re.compile(r"(?:,)(\s*)\r?\n")
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10126
diff changeset
61
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 self.readSettings()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
63
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 def readSettings(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 Public slot called to reread the configuration parameters.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
68 self.setEnabled(Preferences.getEditorTyping("Python/EnabledTypingAids"))
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
69 self.__insertClosingBrace = Preferences.getEditorTyping(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
70 "Python/InsertClosingBrace"
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
71 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
72 self.__indentBrace = Preferences.getEditorTyping("Python/IndentBrace")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
73 self.__skipBrace = Preferences.getEditorTyping("Python/SkipBrace")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
74 self.__insertQuote = Preferences.getEditorTyping("Python/InsertQuote")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
75 self.__dedentElse = Preferences.getEditorTyping("Python/DedentElse")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
76 self.__dedentExcept = Preferences.getEditorTyping("Python/DedentExcept")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
77 self.__insertImport = Preferences.getEditorTyping("Python/InsertImport")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
78 self.__importBraceType = Preferences.getEditorTyping("Python/ImportBraceType")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
79 self.__insertSelf = Preferences.getEditorTyping("Python/InsertSelf")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
80 self.__insertBlank = Preferences.getEditorTyping("Python/InsertBlank")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
81 self.__colonDetection = Preferences.getEditorTyping("Python/ColonDetection")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
82 self.__dedentDef = Preferences.getEditorTyping("Python/DedentDef")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 def charAdded(self, charNumber):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 Public slot called to handle the user entering a character.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
87
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 @param charNumber value of the character entered (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 """
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
90 char = chr(charNumber)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
91 if char not in ["(", ")", "{", "}", "[", "]", " ", ",", "'", '"', "\n", ":"]:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 return # take the short route
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
93
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 line, col = self.editor.getCursorPosition()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
95
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
96 if (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
97 self.__inComment(line, col)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
98 or (char != '"' and self.__inDoubleQuotedString())
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
99 or (char != '"' and self.__inTripleDoubleQuotedString())
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
100 or (char != "'" and self.__inSingleQuotedString())
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
101 or (char != "'" and self.__inTripleSingleQuotedString())
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
102 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 return
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
104
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 # open parenthesis
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 # insert closing parenthesis and self
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
107 if char == "(":
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 txt = self.editor.text(line)[:col]
7811
31d56b9bc7bd CompleterPython: optimized the handling of chained insertions into one undo group.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7775
diff changeset
109 self.editor.beginUndoAction()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
110 if self.__insertSelf and self.__defRX.fullmatch(txt) is not None:
1222
161e4514253b Fixed an issue in the Python typing completer not recognizing static methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
111 if self.__isClassMethodDef():
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
112 self.editor.insert("cls")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 self.editor.setCursorPosition(line, col + 3)
1222
161e4514253b Fixed an issue in the Python typing completer not recognizing static methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
114 elif self.__isStaticMethodDef():
161e4514253b Fixed an issue in the Python typing completer not recognizing static methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
115 # nothing to insert
161e4514253b Fixed an issue in the Python typing completer not recognizing static methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
116 pass
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 elif self.__isClassMethod():
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
118 self.editor.insert("self")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 self.editor.setCursorPosition(line, col + 4)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 if self.__insertClosingBrace:
9995
00eb2b418f8e Corrected some code formatting issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9992
diff changeset
121 if self.__defRX.fullmatch(txt) is not None or (
00eb2b418f8e Corrected some code formatting issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9992
diff changeset
122 self.__classRX.fullmatch(txt) is not None and txt.endswith("(")
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
123 ):
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
124 self.editor.insert("):")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 else:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
126 self.editor.insert(")")
7811
31d56b9bc7bd CompleterPython: optimized the handling of chained insertions into one undo group.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7775
diff changeset
127 self.editor.endUndoAction()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
128
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 # closing parenthesis
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 # skip matching closing parenthesis
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
131 elif char in [")", "}", "]"]:
431
96cc7d322f89 Fixed an issue in the typing completers causing a stacktrace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
132 txt = self.editor.text(line)
8222
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
133 if col < len(txt) and char == txt[col] and self.__skipBrace:
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
134 self.editor.setSelection(line, col, line, col + 1)
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
135 self.editor.removeSelectedText()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
136
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 # space
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
138 # insert import, dedent to if for elif, dedent to try for except,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
139 # dedent def
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
140 elif char == " ":
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 txt = self.editor.text(line)[:col]
7775
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
142 if self.__insertImport and self.__importRX.fullmatch(txt):
7811
31d56b9bc7bd CompleterPython: optimized the handling of chained insertions into one undo group.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7775
diff changeset
143 self.editor.beginUndoAction()
6997
24eabcea4c59 Python and Ruby Typing: added support for 'from ... import (...)' and changed the indentation when the previous line ends with '(', '[' or '{'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
144 if self.__importBraceType:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
145 self.editor.insert("import ()")
6997
24eabcea4c59 Python and Ruby Typing: added support for 'from ... import (...)' and changed the indentation when the previous line ends with '(', '[' or '{'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
146 self.editor.setCursorPosition(line, col + 8)
24eabcea4c59 Python and Ruby Typing: added support for 'from ... import (...)' and changed the indentation when the previous line ends with '(', '[' or '{'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
147 else:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
148 self.editor.insert("import ")
6997
24eabcea4c59 Python and Ruby Typing: added support for 'from ... import (...)' and changed the indentation when the previous line ends with '(', '[' or '{'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
149 self.editor.setCursorPosition(line, col + 7)
7811
31d56b9bc7bd CompleterPython: optimized the handling of chained insertions into one undo group.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7775
diff changeset
150 self.editor.endUndoAction()
7775
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
151 elif self.__dedentElse and self.__elifRX.fullmatch(txt):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 self.__dedentToIf()
7775
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
153 elif self.__dedentExcept and self.__exceptRX.fullmatch(txt):
10069
435cc5875135 Corrected and checked some code style issues (unused function arguments).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9995
diff changeset
154 self.__dedentExceptToTry()
7775
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
155 elif self.__dedentDef and self.__defOnlyRX.fullmatch(txt):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 self.__dedentDefStatement()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
157
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 # comma
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 # insert blank
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
160 elif char == "," and self.__insertBlank:
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
161 self.editor.insert(" ")
8222
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
162 self.editor.setCursorPosition(line, col + 1)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
163
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 # open curly brace
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 # insert closing brace
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
166 elif char == "{" and self.__insertClosingBrace:
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
167 self.editor.insert("}")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
168
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 # open bracket
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 # insert closing bracket
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
171 elif char == "[" and self.__insertClosingBrace:
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
172 self.editor.insert("]")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
173
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 # double quote
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 # insert double quote
8222
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
176 elif char == '"' and self.__insertQuote:
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
177 self.editor.insert('"')
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
178
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 # quote
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 # insert quote
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
181 elif char == "'" and self.__insertQuote:
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
182 self.editor.insert("'")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
183
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 # colon
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 # skip colon, dedent to if for else:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
186 elif char == ":":
86
778f405e9411 Fixed porting bug causing traceback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 85
diff changeset
187 text = self.editor.text(line)
91
f20b944b9c8c Fixed a bug causing a traceback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 86
diff changeset
188 if col < len(text) and char == text[col]:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 if self.__colonDetection:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 self.editor.setSelection(line, col, line, col + 1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 self.editor.removeSelectedText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 else:
86
778f405e9411 Fixed porting bug causing traceback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 85
diff changeset
193 txt = text[:col]
7775
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
194 if self.__dedentElse and self.__elseRX.fullmatch(txt):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 self.__dedentElseToIfWhileForTry()
7775
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
196 elif self.__dedentExcept and self.__exceptcRX.fullmatch(txt):
10069
435cc5875135 Corrected and checked some code style issues (unused function arguments).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9995
diff changeset
197 self.__dedentExceptToTry()
7775
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
198 elif self.__dedentExcept and self.__finallyRX.fullmatch(txt):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 self.__dedentFinallyToTry()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
200
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 # new line
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 # indent to opening brace
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
203 elif char == "\n" and self.__indentBrace:
8222
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
204 txt = self.editor.text(line - 1)
10201
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10126
diff changeset
205 if self.__insertBlank and self.__trailingBlankRe.search(txt):
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10126
diff changeset
206 match = self.__trailingBlankRe.search(txt)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10126
diff changeset
207 if match is not None:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10126
diff changeset
208 startBlanks = match.start(1)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10126
diff changeset
209 endBlanks = match.end(1)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10126
diff changeset
210 if startBlanks != -1 and startBlanks != endBlanks:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10126
diff changeset
211 # previous line ends with whitespace, e.g. caused by
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10126
diff changeset
212 # blank insertion above
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10126
diff changeset
213 self.editor.setSelection(
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10126
diff changeset
214 line - 1, startBlanks, line - 1, endBlanks
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10126
diff changeset
215 )
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10126
diff changeset
216 self.editor.removeSelectedText()
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10126
diff changeset
217 # get the line again for next check
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10126
diff changeset
218 txt = self.editor.text(line - 1)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10126
diff changeset
219
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10126
diff changeset
220 self.editor.setCursorPosition(line, 0)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10126
diff changeset
221 self.editor.editorCommand(QsciScintilla.SCI_VCHOME)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10126
diff changeset
222
8222
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
223 if re.search(":\r?\n", txt) is None:
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
224 self.editor.beginUndoAction()
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
225 stxt = txt.strip()
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
226 if stxt and stxt[-1] in ("(", "[", "{"):
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
227 # indent one more level
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
228 self.editor.indent(line)
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
229 self.editor.editorCommand(QsciScintilla.SCI_VCHOME)
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
230 else:
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
231 # indent to the level of the opening brace
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
232 openCount = len(re.findall("[({[]", txt))
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
233 closeCount = len(re.findall(r"[)}\]]", txt))
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
234 if openCount > closeCount:
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
235 openCount = 0
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
236 closeCount = 0
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
237 openList = list(re.finditer("[({[]", txt))
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
238 index = len(openList) - 1
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
239 while index > -1 and openCount == closeCount:
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
240 lastOpenIndex = openList[index].start()
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
241 txt2 = txt[lastOpenIndex:]
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
242 openCount = len(re.findall("[({[]", txt2))
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
243 closeCount = len(re.findall(r"[)}\]]", txt2))
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
244 index -= 1
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
245 if openCount > closeCount and lastOpenIndex > col:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
246 self.editor.insert(" " * (lastOpenIndex - col + 1))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
247 self.editor.setCursorPosition(line, lastOpenIndex + 1)
8222
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
248 self.editor.endUndoAction()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
249
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 def __dedentToIf(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 Private method to dedent the last line to the last if statement with
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 less (or equal) indentation.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 line, col = self.editor.getCursorPosition()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 indentation = self.editor.indentation(line)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 ifLine = line - 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 while ifLine >= 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 txt = self.editor.text(ifLine)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 edInd = self.editor.indentation(ifLine)
7775
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
261 if rxIndex(self.__elseRX, txt) == 0 and edInd <= indentation:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 indentation = edInd - 1
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
263 elif (
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
264 rxIndex(self.__ifRX, txt) == 0 or rxIndex(self.__elifRX, txt) == 0
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
265 ) and edInd <= indentation:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 self.editor.cancelList()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 self.editor.setIndentation(line, edInd)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 break
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 ifLine -= 1
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
270
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 def __dedentElseToIfWhileForTry(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 Private method to dedent the line of the else statement to the last
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 if, while, for or try statement with less (or equal) indentation.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 line, col = self.editor.getCursorPosition()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 indentation = self.editor.indentation(line)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 if line > 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 prevInd = self.editor.indentation(line - 1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 ifLine = line - 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 while ifLine >= 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 txt = self.editor.text(ifLine)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 edInd = self.editor.indentation(ifLine)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
284 if (rxIndex(self.__elseRX, txt) == 0 and edInd <= indentation) or (
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
285 rxIndex(self.__elifRX, txt) == 0
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
286 and edInd == indentation
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
287 and edInd == prevInd
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
288 ):
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
289 indentation = edInd - 1
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
290 elif (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
291 rxIndex(self.__ifRX, txt) == 0
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
292 or rxIndex(self.__whileRX, txt) == 0
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
293 or rxIndex(self.__forRX, txt) == 0
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
294 or rxIndex(self.__tryRX, txt) == 0
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
295 ) and edInd <= indentation:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296 self.editor.cancelList()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 self.editor.setIndentation(line, edInd)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 break
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 ifLine -= 1
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
300
10069
435cc5875135 Corrected and checked some code style issues (unused function arguments).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9995
diff changeset
301 def __dedentExceptToTry(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
303 Private method to dedent the line of the except statement to the last
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 try statement with less (or equal) indentation.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 line, col = self.editor.getCursorPosition()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 indentation = self.editor.indentation(line)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 tryLine = line - 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 while tryLine >= 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 txt = self.editor.text(tryLine)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 edInd = self.editor.indentation(tryLine)
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
312 if (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
313 rxIndex(self.__exceptcRX, txt) == 0
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
314 or rxIndex(self.__finallyRX, txt) == 0
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
315 ) and edInd <= indentation:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 indentation = edInd - 1
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
317 elif (
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
318 rxIndex(self.__exceptRX, txt) == 0 or rxIndex(self.__tryRX, txt) == 0
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
319 ) and edInd <= indentation:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 self.editor.cancelList()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 self.editor.setIndentation(line, edInd)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 break
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 tryLine -= 1
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
324
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 def __dedentFinallyToTry(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
327 Private method to dedent the line of the except statement to the last
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 try statement with less (or equal) indentation.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 line, col = self.editor.getCursorPosition()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 indentation = self.editor.indentation(line)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 tryLine = line - 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 while tryLine >= 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 txt = self.editor.text(tryLine)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 edInd = self.editor.indentation(tryLine)
7775
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
336 if rxIndex(self.__finallyRX, txt) == 0 and edInd <= indentation:
6997
24eabcea4c59 Python and Ruby Typing: added support for 'from ... import (...)' and changed the indentation when the previous line ends with '(', '[' or '{'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
337 indentation = edInd - 1
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
338 elif (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
339 rxIndex(self.__tryRX, txt) == 0
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
340 or rxIndex(self.__exceptcRX, txt) == 0
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
341 or rxIndex(self.__exceptRX, txt) == 0
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
342 ) and edInd <= indentation:
6997
24eabcea4c59 Python and Ruby Typing: added support for 'from ... import (...)' and changed the indentation when the previous line ends with '(', '[' or '{'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
343 self.editor.cancelList()
24eabcea4c59 Python and Ruby Typing: added support for 'from ... import (...)' and changed the indentation when the previous line ends with '(', '[' or '{'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
344 self.editor.setIndentation(line, edInd)
24eabcea4c59 Python and Ruby Typing: added support for 'from ... import (...)' and changed the indentation when the previous line ends with '(', '[' or '{'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
345 break
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 tryLine -= 1
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
347
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348 def __dedentDefStatement(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
350 Private method to dedent the line of the def statement to a previous
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
351 def statement or class statement.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
352 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353 line, col = self.editor.getCursorPosition()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354 indentation = self.editor.indentation(line)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355 tryLine = line - 1
9992
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
356 inMultiLineString = False
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 while tryLine >= 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 txt = self.editor.text(tryLine)
9992
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
359 if txt.count('"""') % 2 != 0 or txt.count("'''") % 2 != 0:
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
360 inMultiLineString = not inMultiLineString
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
361 if not inMultiLineString:
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
362 edInd = self.editor.indentation(tryLine)
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
363 newInd = -1
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
364 if rxIndex(self.__defRX, txt) == 0 and edInd < indentation:
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
365 newInd = edInd
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
366 elif rxIndex(self.__classRX, txt) == 0 and edInd < indentation:
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
367 newInd = edInd + (
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
368 self.editor.indentationWidth() or self.editor.tabWidth()
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
369 )
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
370 if newInd >= 0:
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
371 self.editor.cancelList()
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
372 self.editor.setIndentation(line, newInd)
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
373 break
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374 tryLine -= 1
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
375
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376 def __isClassMethod(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
378 Private method to check, if the user is defining a class method.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
379
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 @return flag indicating the definition of a class method (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382 line, col = self.editor.getCursorPosition()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 indentation = self.editor.indentation(line)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384 curLine = line - 1
9992
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
385 inMultiLineString = False
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386 while curLine >= 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387 txt = self.editor.text(curLine)
9992
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
388 if txt.count('"""') % 2 != 0 or txt.count("'''") % 2 != 0:
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
389 inMultiLineString = not inMultiLineString
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
390 if not inMultiLineString:
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
391 if (
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
392 (
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
393 rxIndex(self.__defSelfRX, txt) == 0
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
394 or rxIndex(self.__defClsRX, txt) == 0
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
395 )
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
396 and self.editor.indentation(curLine) == indentation
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
397 ) or (
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
398 rxIndex(self.__classRX, txt) == 0
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
399 and self.editor.indentation(curLine) < indentation
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
400 ):
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
401 return True
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
402 elif (
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
403 rxIndex(self.__defRX, txt) == 0
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
404 and self.editor.indentation(curLine) <= indentation
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
405 ):
3d2f1101a23a CompleterPython: fixed an incorrect behavior if code to be checked contained tripple quoted string with valid Python code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9991
diff changeset
406 return False
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407 curLine -= 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 return False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
409
1222
161e4514253b Fixed an issue in the Python typing completer not recognizing static methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
410 def __isClassMethodDef(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411 """
1222
161e4514253b Fixed an issue in the Python typing completer not recognizing static methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
412 Private method to check, if the user is defing a class method
161e4514253b Fixed an issue in the Python typing completer not recognizing static methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
413 (@classmethod).
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
414
1222
161e4514253b Fixed an issue in the Python typing completer not recognizing static methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
415 @return flag indicating the definition of a class method (boolean)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417 line, col = self.editor.getCursorPosition()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
418 indentation = self.editor.indentation(line)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
419 curLine = line - 1
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
420 if (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
421 rxIndex(self.__classmethodRX, self.editor.text(curLine)) == 0
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
422 and self.editor.indentation(curLine) == indentation
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
423 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424 return True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425 return False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
426
1222
161e4514253b Fixed an issue in the Python typing completer not recognizing static methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
427 def __isStaticMethodDef(self):
161e4514253b Fixed an issue in the Python typing completer not recognizing static methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
428 """
161e4514253b Fixed an issue in the Python typing completer not recognizing static methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
429 Private method to check, if the user is defing a static method
161e4514253b Fixed an issue in the Python typing completer not recognizing static methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
430 (@staticmethod) method.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
431
1222
161e4514253b Fixed an issue in the Python typing completer not recognizing static methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
432 @return flag indicating the definition of a static method (boolean)
161e4514253b Fixed an issue in the Python typing completer not recognizing static methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
433 """
161e4514253b Fixed an issue in the Python typing completer not recognizing static methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
434 line, col = self.editor.getCursorPosition()
161e4514253b Fixed an issue in the Python typing completer not recognizing static methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
435 indentation = self.editor.indentation(line)
161e4514253b Fixed an issue in the Python typing completer not recognizing static methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
436 curLine = line - 1
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
437 if (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
438 rxIndex(self.__staticmethodRX, self.editor.text(curLine)) == 0
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
439 and self.editor.indentation(curLine) == indentation
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
440 ):
1222
161e4514253b Fixed an issue in the Python typing completer not recognizing static methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
441 return True
161e4514253b Fixed an issue in the Python typing completer not recognizing static methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
442 return False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
443
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444 def __inComment(self, line, col):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 """
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
446 Private method to check, if the cursor is inside a comment.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
447
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
448 @param line current line (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449 @param col current position within line (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
450 @return flag indicating, if the cursor is inside a comment (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
451 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
452 txt = self.editor.text(line)
85
2d80c7a3e773 Fixed porting bugs causing traceback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
453 if col == len(txt):
2d80c7a3e773 Fixed porting bugs causing traceback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
454 col -= 1
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455 while col >= 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
456 if txt[col] == "#":
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
457 return True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458 col -= 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459 return False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
460
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461 def __inDoubleQuotedString(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
463 Private method to check, if the cursor is within a double quoted
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
464 string.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
465
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
466 @return flag indicating, if the cursor is inside a double
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
467 quoted string (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
468 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
469 return self.editor.currentStyle() == QsciLexerPython.DoubleQuotedString
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
470
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471 def __inTripleDoubleQuotedString(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
472 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
473 Private method to check, if the cursor is within a triple double
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
474 quoted string.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
475
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
476 @return flag indicating, if the cursor is inside a triple double
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
477 quoted string (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
478 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
479 return self.editor.currentStyle() == QsciLexerPython.TripleDoubleQuotedString
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
480
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
481 def __inSingleQuotedString(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
482 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
483 Private method to check, if the cursor is within a single quoted
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
484 string.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
485
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
486 @return flag indicating, if the cursor is inside a single
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
487 quoted string (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
488 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
489 return self.editor.currentStyle() == QsciLexerPython.SingleQuotedString
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
490
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
491 def __inTripleSingleQuotedString(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
492 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
493 Private method to check, if the cursor is within a triple single
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
494 quoted string.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
495
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
496 @return flag indicating, if the cursor is inside a triple single
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
497 quoted string (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
498 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
499 return self.editor.currentStyle() == QsciLexerPython.TripleSingleQuotedString
9493
aeaa6bf49831 Changed typing completer imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
500
aeaa6bf49831 Changed typing completer imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
501
aeaa6bf49831 Changed typing completer imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
502 def createCompleter(editor, parent=None):
aeaa6bf49831 Changed typing completer imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
503 """
aeaa6bf49831 Changed typing completer imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
504 Function to instantiate a typing completer object.
aeaa6bf49831 Changed typing completer imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
505
aeaa6bf49831 Changed typing completer imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
506 @param editor reference to the editor object
aeaa6bf49831 Changed typing completer imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
507 @type QScintilla.Editor
aeaa6bf49831 Changed typing completer imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
508 @param parent reference to the parent object (defaults to None)
aeaa6bf49831 Changed typing completer imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
509 @type QObject (optional)
aeaa6bf49831 Changed typing completer imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
510 @return reference to the instantiated typing completer object
aeaa6bf49831 Changed typing completer imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
511 @rtype CompleterPython
aeaa6bf49831 Changed typing completer imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
512 """
aeaa6bf49831 Changed typing completer imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
513 return CompleterPython(editor, parent=parent)

eric ide

mercurial