6654 |
6654 |
6655 ########################################################################### |
6655 ########################################################################### |
6656 ## Syntax error handling methods below |
6656 ## Syntax error handling methods below |
6657 ########################################################################### |
6657 ########################################################################### |
6658 |
6658 |
6659 def toggleSyntaxError(self, line, index, error, msg="", show=False): |
6659 def toggleSyntaxError(self, line, index, setError, msg="", show=False): |
6660 """ |
6660 """ |
6661 Public method to toggle a syntax error indicator. |
6661 Public method to toggle a syntax error indicator. |
6662 |
6662 |
6663 @param line line number of the syntax error (integer) |
6663 @param line line number of the syntax error |
6664 @param index index number of the syntax error (integer) |
6664 @type int |
6665 @param error flag indicating if the error marker should be |
6665 @param index index number of the syntax error |
6666 set or deleted (boolean) |
6666 @type int |
6667 @param msg error message (string) |
6667 @param setError flag indicating if the error marker should be |
|
6668 set or deleted |
|
6669 @type bool |
|
6670 @param msg error message |
|
6671 @type str |
6668 @param show flag indicating to set the cursor to the error position |
6672 @param show flag indicating to set the cursor to the error position |
6669 (boolean) |
6673 @type bool |
6670 """ |
6674 """ |
6671 if line == 0: |
6675 if line == 0: |
6672 line = 1 |
6676 line = 1 |
6673 # hack to show a syntax error marker, if line is reported to be 0 |
6677 # hack to show a syntax error marker, if line is reported to be 0 |
6674 if error: |
6678 if setError: |
6675 # set a new syntax error marker |
6679 # set a new syntax error marker |
6676 markers = self.markersAtLine(line - 1) |
6680 markers = self.markersAtLine(line - 1) |
6677 index += self.indentation(line - 1) |
6681 index += self.indentation(line - 1) |
6678 if not (markers & (1 << self.syntaxerror)): |
6682 if not (markers & (1 << self.syntaxerror)): |
6679 handle = self.markerAdd(line - 1, self.syntaxerror) |
6683 handle = self.markerAdd(line - 1, self.syntaxerror) |
6740 @pyqtSlot() |
6744 @pyqtSlot() |
6741 def clearSyntaxError(self): |
6745 def clearSyntaxError(self): |
6742 """ |
6746 """ |
6743 Public slot to handle the 'Clear all syntax error' context menu action. |
6747 Public slot to handle the 'Clear all syntax error' context menu action. |
6744 """ |
6748 """ |
6745 for handle in self.syntaxerrors: |
6749 for handle in list(self.syntaxerrors.keys()): |
6746 line = self.markerLine(handle) + 1 |
6750 line = self.markerLine(handle) + 1 |
6747 self.toggleSyntaxError(line, 0, False) |
6751 self.toggleSyntaxError(line, 0, False) |
6748 |
6752 |
6749 self.syntaxerrors.clear() |
6753 self.syntaxerrors.clear() |
6750 self.syntaxerrorToggled.emit(self) |
6754 self.syntaxerrorToggled.emit(self) |
6801 ########################################################################### |
6805 ########################################################################### |
6802 ## Warning handling methods below |
6806 ## Warning handling methods below |
6803 ########################################################################### |
6807 ########################################################################### |
6804 |
6808 |
6805 def toggleWarning( |
6809 def toggleWarning( |
6806 self, line, col, warning, msg="", warningType=WarningCode # noqa: U100 |
6810 self, line, col, setWarning, msg="", warningType=WarningCode # noqa: U100 |
6807 ): |
6811 ): |
6808 """ |
6812 """ |
6809 Public method to toggle a warning indicator. |
6813 Public method to toggle a warning indicator. |
6810 |
6814 |
6811 Note: This method is used to set pyflakes and code style warnings. |
6815 Note: This method is used to set pyflakes and code style warnings. |
6812 |
6816 |
6813 @param line line number of the warning |
6817 @param line line number of the warning |
|
6818 @type int |
6814 @param col column of the warning |
6819 @param col column of the warning |
6815 @param warning flag indicating if the warning marker should be |
6820 @type int |
6816 set or deleted (boolean) |
6821 @param setWarning flag indicating if the warning marker should be |
6817 @param msg warning message (string) |
6822 set or deleted |
6818 @param warningType type of warning message (integer) |
6823 @type bool |
|
6824 @param msg warning message |
|
6825 @type str |
|
6826 @param warningType type of warning message |
|
6827 @type int |
6819 """ |
6828 """ |
6820 if line == 0: |
6829 if line == 0: |
6821 line = 1 |
6830 line = 1 |
6822 # hack to show a warning marker, if line is reported to be 0 |
6831 # hack to show a warning marker, if line is reported to be 0 |
6823 if warning: |
6832 if setWarning: |
6824 # set/amend a new warning marker |
6833 # set/amend a new warning marker |
6825 warn = (msg, warningType) |
6834 warn = (msg, warningType) |
6826 markers = self.markersAtLine(line - 1) |
6835 markers = self.markersAtLine(line - 1) |
6827 if not (markers & (1 << self.warning)): |
6836 if not (markers & (1 << self.warning)): |
6828 handle = self.markerAdd(line - 1, self.warning) |
6837 handle = self.markerAdd(line - 1, self.warning) |