156 itm.setData(0, self.lineRole, int(line)) |
157 itm.setData(0, self.lineRole, int(line)) |
157 itm.setData(0, self.indexRole, index) |
158 itm.setData(0, self.indexRole, index) |
158 itm.setData(0, self.errorRole, error) |
159 itm.setData(0, self.errorRole, error) |
159 itm.setData(0, self.warningRole, isWarning) |
160 itm.setData(0, self.warningRole, isWarning) |
160 |
161 |
|
162 def setArguments(self, args): |
|
163 """ |
|
164 Public method to set additional arguments to be used by the syntax check. |
|
165 |
|
166 @param args tuple containing the additional arguments |
|
167 @type tuple of Any |
|
168 """ |
|
169 self.__arguments = args |
|
170 |
161 def prepare(self, fileList, project): |
171 def prepare(self, fileList, project): |
162 """ |
172 """ |
163 Public method to prepare the dialog with a list of filenames. |
173 Public method to prepare the dialog with a list of filenames. |
164 |
174 |
165 @param fileList list of filenames |
175 @param fileList list of filenames |
177 self.filterFrame.setVisible(True) |
187 self.filterFrame.setVisible(True) |
178 |
188 |
179 self.__data = self.__project.getData("CHECKERSPARMS", "SyntaxChecker") |
189 self.__data = self.__project.getData("CHECKERSPARMS", "SyntaxChecker") |
180 if self.__data is None or "ExcludeFiles" not in self.__data: |
190 if self.__data is None or "ExcludeFiles" not in self.__data: |
181 self.__data = {"ExcludeFiles": ""} |
191 self.__data = {"ExcludeFiles": ""} |
|
192 if "AdditionalBuiltins" not in self.__data: |
|
193 self.__data["AdditionalBuiltins"] = "" |
|
194 |
182 self.excludeFilesEdit.setText(self.__data["ExcludeFiles"]) |
195 self.excludeFilesEdit.setText(self.__data["ExcludeFiles"]) |
|
196 self.builtinsEdit.setText(self.__data["AdditionalBuiltins"]) |
183 |
197 |
184 def startForBrowser(self, fn): |
198 def startForBrowser(self, fn): |
185 """ |
199 """ |
186 Public slot to start the syntax check for the project sources browser. |
200 Public slot to start the syntax check for the project sources browser. |
187 |
201 |
212 self.filterFrame.setVisible(True) |
226 self.filterFrame.setVisible(True) |
213 |
227 |
214 self.__data = self.__project.getData("CHECKERSPARMS", "SyntaxChecker") |
228 self.__data = self.__project.getData("CHECKERSPARMS", "SyntaxChecker") |
215 if self.__data is None or "ExcludeFiles" not in self.__data: |
229 if self.__data is None or "ExcludeFiles" not in self.__data: |
216 self.__data = {"ExcludeFiles": ""} |
230 self.__data = {"ExcludeFiles": ""} |
|
231 if "AdditionalBuiltins" not in self.__data: |
|
232 self.__data["AdditionalBuiltins"] = "" |
|
233 |
217 self.excludeFilesEdit.setText(self.__data["ExcludeFiles"]) |
234 self.excludeFilesEdit.setText(self.__data["ExcludeFiles"]) |
|
235 self.builtinsEdit.setText(self.__data["AdditionalBuiltins"]) |
218 |
236 |
219 self.on_startButton_clicked() # press the start button |
237 self.on_startButton_clicked() # press the start button |
220 |
238 |
221 def start(self, fn, codestring=""): |
239 def start(self, fn, codestring=""): |
222 """ |
240 """ |
322 # Continue with next file |
340 # Continue with next file |
323 self.check() |
341 self.check() |
324 return |
342 return |
325 |
343 |
326 self.__finished = False |
344 self.__finished = False |
327 self.syntaxCheckService.syntaxCheck(None, self.filename, self.source) |
345 self.syntaxCheckService.syntaxCheck( |
|
346 None, self.filename, self.source, *self.__arguments |
|
347 ) |
328 |
348 |
329 def checkBatch(self): |
349 def checkBatch(self): |
330 """ |
350 """ |
331 Public method to start a style check batch job. |
351 Public method to start a style check batch job. |
332 |
352 |
353 self.tr("Error: {0}").format(str(msg)).rstrip(), |
373 self.tr("Error: {0}").format(str(msg)).rstrip(), |
354 "", |
374 "", |
355 ) |
375 ) |
356 continue |
376 continue |
357 |
377 |
358 argumentsList.append((filename, source)) |
378 argumentsList.append((filename, source, *self.__arguments)) |
359 |
379 |
360 # reset the progress bar to the checked files |
380 # reset the progress bar to the checked files |
361 self.checkProgress.setValue(self.progress) |
381 self.checkProgress.setValue(self.progress) |
362 QApplication.processEvents() |
382 QApplication.processEvents() |
363 |
383 |
500 Private slot to start a syntax check run. |
520 Private slot to start a syntax check run. |
501 """ |
521 """ |
502 fileList = self.__fileList[:] |
522 fileList = self.__fileList[:] |
503 |
523 |
504 filterString = self.excludeFilesEdit.text() |
524 filterString = self.excludeFilesEdit.text() |
505 if ( |
525 self.__data["ExcludeFiles"] = filterString |
506 "ExcludeFiles" not in self.__data |
526 self.__data["AdditionalBuiltins"] = self.builtinsEdit.text().strip() |
507 or filterString != self.__data["ExcludeFiles"] |
527 if self.__data != self.__project.getData("CHECKERSPARMS", "SyntaxChecker"): |
508 ): |
|
509 self.__data["ExcludeFiles"] = filterString |
|
510 self.__project.setData("CHECKERSPARMS", "SyntaxChecker", self.__data) |
528 self.__project.setData("CHECKERSPARMS", "SyntaxChecker", self.__data) |
511 filterList = [f.strip() for f in filterString.split(",") if f.strip()] |
529 filterList = [f.strip() for f in filterString.split(",") if f.strip()] |
512 if filterList: |
530 if filterList: |
513 for fileFilter in filterList: |
531 for fileFilter in filterList: |
514 fileList = [f for f in fileList if not fnmatch.fnmatch(f, fileFilter)] |
532 fileList = [f for f in fileList if not fnmatch.fnmatch(f, fileFilter)] |
515 |
533 |
516 self.resultList.clear() |
534 self.resultList.clear() |
517 self.noResults = True |
535 self.noResults = True |
518 self.cancelled = False |
536 self.cancelled = False |
|
537 self.setArguments((self.__data["AdditionalBuiltins"].split(),)) |
519 self.start(fileList) |
538 self.start(fileList) |
520 |
539 |
521 def on_resultList_itemActivated(self, itm, col): |
540 def on_resultList_itemActivated(self, itm, col): |
522 """ |
541 """ |
523 Private slot to handle the activation of an item. |
542 Private slot to handle the activation of an item. |