QScintilla/TypingCompleters/CompleterPython.py

changeset 1222
161e4514253b
parent 945
8cd4d08fa9f6
child 1509
c0b5e693b0eb
diff -r 291dc0a51947 -r 161e4514253b QScintilla/TypingCompleters/CompleterPython.py
--- a/QScintilla/TypingCompleters/CompleterPython.py	Thu Aug 18 18:03:22 2011 +0200
+++ b/QScintilla/TypingCompleters/CompleterPython.py	Fri Aug 19 17:36:45 2011 +0200
@@ -36,6 +36,7 @@
         self.__classRX = QRegExp(r"""^[ \t]*class \w+\(""")
         self.__importRX = QRegExp(r"""^[ \t]*from [\w.]+ """)
         self.__classmethodRX = QRegExp(r"""^[ \t]*@classmethod""")
+        self.__staticmethodRX = QRegExp(r"""^[ \t]*@staticmethod""")
         
         self.__defOnlyRX = QRegExp(r"""^[ \t]*def """)
         
@@ -108,9 +109,12 @@
             txt = self.editor.text(line)[:col]
             if self.__insertSelf and \
                self.__defRX.exactMatch(txt):
-                if self.__isClassmethodDef():
+                if self.__isClassMethodDef():
                     self.editor.insert('cls')
                     self.editor.setCursorPosition(line, col + 3)
+                elif self.__isStaticMethodDef():
+                    # nothing to insert
+                    pass
                 elif self.__isClassMethod():
                     self.editor.insert('self')
                     self.editor.setCursorPosition(line, col + 4)
@@ -365,12 +369,12 @@
             curLine -= 1
         return False
     
-    def __isClassmethodDef(self):
+    def __isClassMethodDef(self):
         """
-        Private method to check, if the user is defing a classmethod
-        (@classmethod) method.
+        Private method to check, if the user is defing a class method
+        (@classmethod).
         
-        @return flag indicating the definition of a classmethod method (boolean)
+        @return flag indicating the definition of a class method (boolean)
         """
         line, col = self.editor.getCursorPosition()
         indentation = self.editor.indentation(line)
@@ -380,6 +384,21 @@
             return True
         return False
     
+    def __isStaticMethodDef(self):
+        """
+        Private method to check, if the user is defing a static method
+        (@staticmethod) method.
+        
+        @return flag indicating the definition of a static method (boolean)
+        """
+        line, col = self.editor.getCursorPosition()
+        indentation = self.editor.indentation(line)
+        curLine = line - 1
+        if self.__staticmethodRX.indexIn(self.editor.text(curLine)) == 0 and \
+           self.editor.indentation(curLine) == indentation:
+            return True
+        return False
+    
     def __inComment(self, line, col):
         """
         Private method to check, if the cursor is inside a comment

eric ide

mercurial