13 from PyQt6.QtCore import QTimer, QThread, QFileInfo, pyqtSignal, QDateTime, QObject, Qt |
13 from PyQt6.QtCore import QTimer, QThread, QFileInfo, pyqtSignal, QDateTime, QObject, Qt |
14 |
14 |
15 with contextlib.suppress(ImportError): |
15 with contextlib.suppress(ImportError): |
16 from PyQt6.QtSql import QSqlDatabase, QSqlQuery |
16 from PyQt6.QtSql import QSqlDatabase, QSqlQuery |
17 |
17 |
18 from EricWidgets.EricApplication import ericApp |
18 from eric7 import Globals, Preferences, Utilities |
19 |
19 |
20 import QScintilla.Lexers |
20 from eric7.EricWidgets.EricApplication import ericApp |
21 |
21 |
22 import Globals |
22 from eric7.QScintilla import Lexers |
23 import Utilities.ModuleParser |
23 |
24 import Utilities |
24 from eric7.Utilities import ModuleParser |
25 import Preferences |
|
26 |
25 |
27 WorkerStatusStarted = 2001 |
26 WorkerStatusStarted = 2001 |
28 WorkerStatusFinished = 2002 |
27 WorkerStatusFinished = 2002 |
29 WorkerStatusAborted = 2003 |
28 WorkerStatusAborted = 2003 |
30 WorkerStatusFile = 2004 |
29 WorkerStatusFile = 2004 |
114 |
113 |
115 # Get the AC word separators for all of the languages that the editor |
114 # Get the AC word separators for all of the languages that the editor |
116 # supports. This has to be before we create a new thread, because |
115 # supports. This has to be before we create a new thread, because |
117 # access to GUI elements is not allowed from non-GUI threads. |
116 # access to GUI elements is not allowed from non-GUI threads. |
118 self.__wseps = {} |
117 self.__wseps = {} |
119 for lang in QScintilla.Lexers.getSupportedLanguages(): |
118 for lang in Lexers.getSupportedLanguages(): |
120 lexer = QScintilla.Lexers.getLexer(lang) |
119 lexer = Lexers.getLexer(lang) |
121 if lexer is not None: |
120 if lexer is not None: |
122 self.__wseps[lang] = lexer.autoCompletionWordSeparators() |
121 self.__wseps[lang] = lexer.autoCompletionWordSeparators() |
123 |
122 |
124 self.__proxy = proxy |
123 self.__proxy = proxy |
125 self.__language = language |
124 self.__language = language |
215 for className in sorted(module.classes.keys()): |
214 for className in sorted(module.classes.keys()): |
216 _class = module.classes[className] |
215 _class = module.classes[className] |
217 classNameStr = "{0}{1}.".format(moduleName, className) |
216 classNameStr = "{0}{1}.".format(moduleName, className) |
218 for variable in sorted(_class.attributes.keys()): |
217 for variable in sorted(_class.attributes.keys()): |
219 if not _class.attributes[variable].isPrivate(): |
218 if not _class.attributes[variable].isPrivate(): |
220 from QScintilla.Editor import Editor |
219 from eric7.QScintilla.Editor import Editor |
221 |
220 |
222 if _class.attributes[variable].isPublic(): |
221 if _class.attributes[variable].isPublic(): |
223 iconId = Editor.AttributeID |
222 iconId = Editor.AttributeID |
224 elif _class.attributes[variable].isProtected(): |
223 elif _class.attributes[variable].isProtected(): |
225 iconId = Editor.AttributeProtectedID |
224 iconId = Editor.AttributeProtectedID |
238 apis = [] |
237 apis = [] |
239 bases = [] |
238 bases = [] |
240 |
239 |
241 if self.__language == ApisNameProject: |
240 if self.__language == ApisNameProject: |
242 with contextlib.suppress(OSError, ImportError): |
241 with contextlib.suppress(OSError, ImportError): |
243 module = Utilities.ModuleParser.readModule( |
242 module = ModuleParser.readModule( |
244 os.path.join(self.__projectPath, apiFile), |
243 os.path.join(self.__projectPath, apiFile), |
245 basename=self.__projectPath + os.sep, |
244 basename=self.__projectPath + os.sep, |
246 caching=False, |
245 caching=False, |
247 ) |
246 ) |
248 language = module.getType() |
247 language = module.getType() |
249 if language: |
248 if language: |
250 from DocumentationTools.APIGenerator import APIGenerator |
249 from eric7.DocumentationTools.APIGenerator import APIGenerator |
251 |
250 |
252 apiGenerator = APIGenerator(module) |
251 apiGenerator = APIGenerator(module) |
253 apis = apiGenerator.genAPI(True, "", True) |
252 apis = apiGenerator.genAPI(True, "", True) |
254 if os.path.basename(apiFile).startswith("Ui_"): |
253 if os.path.basename(apiFile).startswith("Ui_"): |
255 # it is a forms source file, extract public attributes |
254 # it is a forms source file, extract public attributes |
709 """ |
708 """ |
710 if self.__language == "Python3": |
709 if self.__language == "Python3": |
711 self.__discardFirst = ["self", "cls"] |
710 self.__discardFirst = ["self", "cls"] |
712 else: |
711 else: |
713 self.__discardFirst = [] |
712 self.__discardFirst = [] |
714 self.__lexer = QScintilla.Lexers.getLexer(self.__language) |
713 self.__lexer = Lexers.getLexer(self.__language) |
715 try: |
714 try: |
716 self.__apifiles = Preferences.getEditorAPI( |
715 self.__apifiles = Preferences.getEditorAPI( |
717 self.__language, projectType=self.__projectType |
716 self.__language, projectType=self.__projectType |
718 ) |
717 ) |
719 except TypeError: |
718 except TypeError: |
1234 """ |
1233 """ |
1235 if self.__project.getProjectLanguage() in ("Python3", "MicroPython", "Cython"): |
1234 if self.__project.getProjectLanguage() in ("Python3", "MicroPython", "Cython"): |
1236 self.__discardFirst = ["self", "cls"] |
1235 self.__discardFirst = ["self", "cls"] |
1237 else: |
1236 else: |
1238 self.__discardFirst = [] |
1237 self.__discardFirst = [] |
1239 self.__lexer = QScintilla.Lexers.getLexer(self.__project.getProjectLanguage()) |
1238 self.__lexer = Lexers.getLexer(self.__project.getProjectLanguage()) |
1240 self.__openAPIs() |
1239 self.__openAPIs() |
1241 |
1240 |
1242 def __projectClosed(self): |
1241 def __projectClosed(self): |
1243 """ |
1242 """ |
1244 Private slot to perform actions after a project has been closed. |
1243 Private slot to perform actions after a project has been closed. |
1322 """ |
1321 """ |
1323 try: |
1322 try: |
1324 return self.__apis[(language, projectType)] |
1323 return self.__apis[(language, projectType)] |
1325 except KeyError: |
1324 except KeyError: |
1326 if ( |
1325 if ( |
1327 language in QScintilla.Lexers.getSupportedApiLanguages() |
1326 language in Lexers.getSupportedApiLanguages() |
1328 or language == ApisNameProject |
1327 or language == ApisNameProject |
1329 ): |
1328 ): |
1330 # create the api object |
1329 # create the api object |
1331 api = DbAPIs(language, projectType=projectType) |
1330 api = DbAPIs(language, projectType=projectType) |
1332 api.apiPreparationStatus.connect(self.__apiPreparationStatus) |
1331 api.apiPreparationStatus.connect(self.__apiPreparationStatus) |