src/eric7/QScintilla/TypingCompleters/CompleterPython.py

branch
eric7
changeset 9992
3d2f1101a23a
parent 9991
814552ada1fb
child 9995
00eb2b418f8e
equal deleted inserted replaced
9991:814552ada1fb 9992:3d2f1101a23a
116 self.editor.insert("self") 116 self.editor.insert("self")
117 self.editor.setCursorPosition(line, col + 4) 117 self.editor.setCursorPosition(line, col + 4)
118 if self.__insertClosingBrace: 118 if self.__insertClosingBrace:
119 if ( 119 if (
120 self.__defRX.fullmatch(txt) is not None 120 self.__defRX.fullmatch(txt) is not None
121 or self.__classRX.fullmatch(txt) is not None 121 or (
122 self.__classRX.fullmatch(txt) is not None
123 and txt.endswith("(")
124 )
122 ): 125 ):
123 self.editor.insert("):") 126 self.editor.insert("):")
124 else: 127 else:
125 self.editor.insert(")") 128 self.editor.insert(")")
126 self.editor.endUndoAction() 129 self.editor.endUndoAction()
334 def statement or class statement. 337 def statement or class statement.
335 """ 338 """
336 line, col = self.editor.getCursorPosition() 339 line, col = self.editor.getCursorPosition()
337 indentation = self.editor.indentation(line) 340 indentation = self.editor.indentation(line)
338 tryLine = line - 1 341 tryLine = line - 1
342 inMultiLineString = False
339 while tryLine >= 0: 343 while tryLine >= 0:
340 txt = self.editor.text(tryLine) 344 txt = self.editor.text(tryLine)
341 edInd = self.editor.indentation(tryLine) 345 if txt.count('"""') % 2 != 0 or txt.count("'''") % 2 != 0:
342 newInd = -1 346 inMultiLineString = not inMultiLineString
343 if rxIndex(self.__defRX, txt) == 0 and edInd < indentation: 347 if not inMultiLineString:
344 newInd = edInd 348 edInd = self.editor.indentation(tryLine)
345 elif rxIndex(self.__classRX, txt) == 0 and edInd < indentation: 349 newInd = -1
346 newInd = edInd + ( 350 if rxIndex(self.__defRX, txt) == 0 and edInd < indentation:
347 self.editor.indentationWidth() or self.editor.tabWidth() 351 newInd = edInd
348 ) 352 elif rxIndex(self.__classRX, txt) == 0 and edInd < indentation:
349 if newInd >= 0: 353 newInd = edInd + (
350 self.editor.cancelList() 354 self.editor.indentationWidth() or self.editor.tabWidth()
351 self.editor.setIndentation(line, newInd) 355 )
352 break 356 if newInd >= 0:
357 self.editor.cancelList()
358 self.editor.setIndentation(line, newInd)
359 break
353 tryLine -= 1 360 tryLine -= 1
354 361
355 def __isClassMethod(self): 362 def __isClassMethod(self):
356 """ 363 """
357 Private method to check, if the user is defining a class method. 364 Private method to check, if the user is defining a class method.
359 @return flag indicating the definition of a class method (boolean) 366 @return flag indicating the definition of a class method (boolean)
360 """ 367 """
361 line, col = self.editor.getCursorPosition() 368 line, col = self.editor.getCursorPosition()
362 indentation = self.editor.indentation(line) 369 indentation = self.editor.indentation(line)
363 curLine = line - 1 370 curLine = line - 1
371 inMultiLineString = False
364 while curLine >= 0: 372 while curLine >= 0:
365 txt = self.editor.text(curLine) 373 txt = self.editor.text(curLine)
366 if ( 374 if txt.count('"""') % 2 != 0 or txt.count("'''") % 2 != 0:
367 ( 375 inMultiLineString = not inMultiLineString
368 rxIndex(self.__defSelfRX, txt) == 0 376 if not inMultiLineString:
369 or rxIndex(self.__defClsRX, txt) == 0 377 if (
370 ) 378 (
371 and self.editor.indentation(curLine) == indentation 379 rxIndex(self.__defSelfRX, txt) == 0
372 ) or ( 380 or rxIndex(self.__defClsRX, txt) == 0
373 rxIndex(self.__classRX, txt) == 0 381 )
374 and self.editor.indentation(curLine) < indentation 382 and self.editor.indentation(curLine) == indentation
375 ): 383 ) or (
376 return True 384 rxIndex(self.__classRX, txt) == 0
377 elif ( 385 and self.editor.indentation(curLine) < indentation
378 rxIndex(self.__defRX, txt) == 0 386 ):
379 and self.editor.indentation(curLine) <= indentation 387 return True
380 ): 388 elif (
381 return False 389 rxIndex(self.__defRX, txt) == 0
390 and self.editor.indentation(curLine) <= indentation
391 ):
392 return False
382 curLine -= 1 393 curLine -= 1
383 return False 394 return False
384 395
385 def __isClassMethodDef(self): 396 def __isClassMethodDef(self):
386 """ 397 """

eric ide

mercurial