AssistantEric/APIsManager.py

changeset 22
a47afbacaeb5
parent 21
0e54b870314c
child 25
6a68405feb84
equal deleted inserted replaced
21:0e54b870314c 22:a47afbacaeb5
53 """ 53 """
54 file_delete_id_stmt = """ 54 file_delete_id_stmt = """
55 DELETE FROM file WHERE id = :id 55 DELETE FROM file WHERE id = :id
56 """ 56 """
57 57
58 def __init__(self, proxy, language, apiFiles, projectPath = ""): 58 def __init__(self, proxy, language, apiFiles, projectPath = "", refresh = False):
59 """ 59 """
60 Constructor 60 Constructor
61 61
62 @param proxy reference to the object that is proxied (DbAPIs) 62 @param proxy reference to the object that is proxied (DbAPIs)
63 @param language language of the APIs object (string) 63 @param language language of the APIs object (string)
64 @param apiFiles list of API files to process (list of strings) 64 @param apiFiles list of API files to process (list of strings)
65 @param projectPath path of the project. Only needed, if the APIs 65 @param projectPath path of the project. Only needed, if the APIs
66 are extracted out of the sources of a project. (string) 66 are extracted out of the sources of a project. (string)
67 @param refresh flag indicating a refresh of the APIs of one file (boolean)
67 """ 68 """
68 QThread.__init__(self) 69 QThread.__init__(self)
69 70
70 self.setTerminationEnabled(True) 71 self.setTerminationEnabled(True)
71 72
81 self.__proxy = proxy 82 self.__proxy = proxy
82 self.__language = language 83 self.__language = language
83 self.__apiFiles = apiFiles[:] 84 self.__apiFiles = apiFiles[:]
84 self.__aborted = False 85 self.__aborted = False
85 self.__projectPath = projectPath 86 self.__projectPath = projectPath
87 self.__refresh = refresh
86 88
87 def __autoCompletionWordSeparators(self, language): 89 def __autoCompletionWordSeparators(self, language):
88 """ 90 """
89 Private method to get the word separator characters for a language. 91 Private method to get the word separator characters for a language.
90 92
305 QCoreApplication.postEvent(self.__proxy, QEvent(QEvent.Type(WorkerStarted))) 307 QCoreApplication.postEvent(self.__proxy, QEvent(QEvent.Type(WorkerStarted)))
306 308
307 db = QSqlDatabase.database(self.__language) 309 db = QSqlDatabase.database(self.__language)
308 if db.isValid() and db.isOpen(): 310 if db.isValid() and db.isOpen():
309 # step 1: remove API files not wanted any longer 311 # step 1: remove API files not wanted any longer
310 loadedApiFiles = self.__proxy.getApiFiles() 312 if not self.__refresh:
311 for apiFile in loadedApiFiles: 313 loadedApiFiles = self.__proxy.getApiFiles()
312 if not self.__aborted and apiFile not in self.__apiFiles: 314 for apiFile in loadedApiFiles:
313 self.__deleteApiFile(apiFile) 315 if not self.__aborted and apiFile not in self.__apiFiles:
316 self.__deleteApiFile(apiFile)
314 317
315 # step 2: (re-)load api files 318 # step 2: (re-)load api files
316 for apiFile in self.__apiFiles: 319 for apiFile in self.__apiFiles:
317 if not self.__aborted: 320 if not self.__aborted:
318 self.__loadApiFileIfNewer(apiFile) 321 self.__loadApiFileIfNewer(apiFile)
745 if self.__language == ApisNameProject: 748 if self.__language == ApisNameProject:
746 projectPath = self.__project.getProjectPath() 749 projectPath = self.__project.getProjectPath()
747 apiFiles = [apiFiles[0].replace(projectPath + os.sep, "")] 750 apiFiles = [apiFiles[0].replace(projectPath + os.sep, "")]
748 else: 751 else:
749 projectPath = "" 752 projectPath = ""
750 self.__worker = DbAPIsWorker(self, self.__language, apiFiles, projectPath) 753 self.__worker = DbAPIsWorker(self, self.__language, apiFiles, projectPath,
754 refresh = True)
751 self.__worker.start() 755 self.__worker.start()
752 756
753 def getLexer(self): 757 def getLexer(self):
754 """ 758 """
755 Public method to return a reference to our lexer object. 759 Public method to return a reference to our lexer object.

eric ide

mercurial