AssistantEric/Assistant.py

changeset 66
f57b151c9761
parent 65
71f50b4cc169
child 69
9082f14126d9
equal deleted inserted replaced
65:71f50b4cc169 66:f57b151c9761
15 15
16 from E5Gui.E5Application import e5App 16 from E5Gui.E5Application import e5App
17 17
18 from .APIsManager import APIsManager, ApisNameProject 18 from .APIsManager import APIsManager, ApisNameProject
19 19
20 from QScintilla.Editor import Editor
21
22 import Preferences 20 import Preferences
23 from Utilities.ModuleParser import Module
24 21
25 AcsAPIs = 0x0001 22 AcsAPIs = 0x0001
26 AcsDocument = 0x0002 23 AcsDocument = 0x0002
27 AcsProject = 0x0004 24 AcsProject = 0x0004
28 AcsOther = 0x1000 25 AcsOther = 0x1000
52 self.__editors = [] 49 self.__editors = []
53 self.__completingContext = False 50 self.__completingContext = False
54 self.__lastContext = None 51 self.__lastContext = None
55 self.__lastFullContext = None 52 self.__lastFullContext = None
56 53
54 from QScintilla.Editor import Editor
57 self.__fromDocumentID = Editor.FromDocumentID 55 self.__fromDocumentID = Editor.FromDocumentID
58 56
59 def activate(self): 57 def activate(self):
60 """ 58 """
61 Public method to perform actions upon activation. 59 Public method to perform actions upon activation.
307 col -= 1 305 col -= 1
308 if col > 0 and beg[col - 1] != " ": 306 if col > 0 and beg[col - 1] != " ":
309 col -= 1 307 col -= 1
310 prefix = editor.getWordLeft(line, col) 308 prefix = editor.getWordLeft(line, col)
311 if editor.isPy2File() or editor.isPy3File(): 309 if editor.isPy2File() or editor.isPy3File():
310 from Utilities.ModuleParser import Module
312 src = editor.text() 311 src = editor.text()
313 fn = editor.getFileName() 312 fn = editor.getFileName()
314 if fn is None: 313 if fn is None:
315 fn = "" 314 fn = ""
316 mod = Module("", fn, imp.PY_SOURCE) 315 mod = Module("", fn, imp.PY_SOURCE)
506 """ 505 """
507 completionsList = [] 506 completionsList = []
508 507
509 prefixFound = False 508 prefixFound = False
510 if prefix and module: 509 if prefix and module:
510 from QScintilla.Editor import Editor
511
511 line, col = editor.getCursorPosition() 512 line, col = editor.getCursorPosition()
512 if prefix in ["cls", "self"]: 513 if prefix in ["cls", "self"]:
513 prefixFound = True 514 prefixFound = True
514 for cl in module.classes.values(): 515 for cl in module.classes.values():
515 if line >= cl.lineno and \ 516 if line >= cl.lineno and \
713 col -= 1 714 col -= 1
714 if col >= 0: 715 if col >= 0:
715 col -= 1 716 col -= 1
716 prefix = editor.getWordLeft(line, col) 717 prefix = editor.getWordLeft(line, col)
717 if editor.isPy2File() or editor.isPy3File(): 718 if editor.isPy2File() or editor.isPy3File():
719 from Utilities.ModuleParser import Module
718 src = editor.text() 720 src = editor.text()
719 fn = editor.getFileName() 721 fn = editor.getFileName()
720 if fn is None: 722 if fn is None:
721 fn = "" 723 fn = ""
722 mod = Module("", fn, imp.PY_SOURCE) 724 mod = Module("", fn, imp.PY_SOURCE)

eric ide

mercurial