45 try: |
45 try: |
46 SeverityForEditor["information"] = Editor.WarningInfo |
46 SeverityForEditor["information"] = Editor.WarningInfo |
47 except AttributeError: |
47 except AttributeError: |
48 SeverityForEditor["information"] = Editor.WarningCode |
48 SeverityForEditor["information"] = Editor.WarningCode |
49 |
49 |
|
50 |
50 class PyrightCheckerDialog(QDialog, Ui_PyrightCheckerDialog): |
51 class PyrightCheckerDialog(QDialog, Ui_PyrightCheckerDialog): |
51 """ |
52 """ |
52 Class documentation goes here. |
53 Class documentation goes here. |
53 """ |
54 """ |
54 |
55 |
76 "error": self.tr("Error"), |
77 "error": self.tr("Error"), |
77 "warning": self.tr("Warning"), |
78 "warning": self.tr("Warning"), |
78 "information": self.tr("Information"), |
79 "information": self.tr("Information"), |
79 } |
80 } |
80 |
81 |
81 ##self.__severityForEditor = {"warning": Editor.WarningCode} |
|
82 ##try: |
|
83 ##self.__severityForEditor["error"] = Editor.WarningError |
|
84 ##except AttributeError: |
|
85 ##self.__severityForEditor["error"] = Editor.WarningCode |
|
86 ##try: |
|
87 ##self.__severityForEditor["information"] = Editor.WarningInfo |
|
88 ##except AttributeError: |
|
89 ##self.__severityForEditor["information"] = Editor.WarningCode |
|
90 ## |
|
91 self.__exitCodeMapping = { |
82 self.__exitCodeMapping = { |
92 0: self.tr("No issues detected"), |
83 0: self.tr("No issues detected"), |
93 1: self.tr("Issues detected"), |
84 1: self.tr("Issues detected"), |
94 2: self.tr("Fatal error occurred with no errors or warnings reported"), |
85 2: self.tr("Fatal error occurred with no errors or warnings reported"), |
95 3: self.tr("Config file could not be read or parsed"), |
86 3: self.tr("Config file could not be read or parsed"), |
411 @param item reference to the activated item |
402 @param item reference to the activated item |
412 @type QTreeWidgetItem |
403 @type QTreeWidgetItem |
413 @param column column the item was activated in |
404 @param column column the item was activated in |
414 @type int |
405 @type int |
415 """ |
406 """ |
416 if self.__hasResults and item.parent(): |
407 if ( |
|
408 self.__hasResults |
|
409 and item.parent() |
|
410 and item.data(0, self.filenameRole) is not None |
|
411 ): |
417 fn = os.path.abspath(item.data(0, self.filenameRole)) |
412 fn = os.path.abspath(item.data(0, self.filenameRole)) |
418 start = item.data(0, self.startRole) |
413 start = item.data(0, self.startRole) |
419 severity = item.data(0, self.severityRole) |
414 severity = item.data(0, self.severityRole) |
420 |
415 |
421 vm = ericApp().getObject("ViewManager") |
416 vm = ericApp().getObject("ViewManager") |
453 if len(selectedIndexes) == 0: |
448 if len(selectedIndexes) == 0: |
454 selectedIndexes = list(range(self.resultList.topLevelItemCount())) |
449 selectedIndexes = list(range(self.resultList.topLevelItemCount())) |
455 |
450 |
456 for index in selectedIndexes: |
451 for index in selectedIndexes: |
457 itm = self.resultList.topLevelItem(index) |
452 itm = self.resultList.topLevelItem(index) |
458 fn = os.path.abspath(itm.data(0, self.filenameRole)) |
453 if itm.data(0, self.filenameRole) is not None: |
459 vm.openSourceFile(fn, 1) |
454 fn = os.path.abspath(itm.data(0, self.filenameRole)) |
460 editor = vm.getOpenEditor(fn) |
455 vm.openSourceFile(fn, 1) |
461 self.__clearEditorErrors(editor) |
456 editor = vm.getOpenEditor(fn) |
462 for cindex in range(itm.childCount()): |
457 self.__clearEditorErrors(editor) |
463 citm = itm.child(cindex) |
458 for cindex in range(itm.childCount()): |
464 start = citm.data(0, self.startRole) |
459 citm = itm.child(cindex) |
465 severity = citm.data(0, self.severityRole) |
460 start = citm.data(0, self.startRole) |
466 editor.toggleWarning( |
461 severity = citm.data(0, self.severityRole) |
467 start["line"] + 1, |
462 editor.toggleWarning( |
468 start["character"] + 1, |
463 start["line"] + 1, |
469 True, |
464 start["character"] + 1, |
470 citm.text(2), |
465 True, |
471 warningType=SeverityForEditor[severity], |
466 citm.text(2), |
472 ) |
467 warningType=SeverityForEditor[severity], |
|
468 ) |
473 |
469 |
474 @pyqtSlot() |
470 @pyqtSlot() |
475 def on_startButton_clicked(self): |
471 def on_startButton_clicked(self): |
476 """ |
472 """ |
477 Private slot to start the pyright type checking run. |
473 Private slot to start the pyright type checking run. |