2008 names for Pygments (boolean) |
2009 names for Pygments (boolean) |
2009 @return language of the editor (string) |
2010 @return language of the editor (string) |
2010 """ |
2011 """ |
2011 if self.apiLanguage == "Guessed" or self.apiLanguage.startswith("Pygments|"): |
2012 if self.apiLanguage == "Guessed" or self.apiLanguage.startswith("Pygments|"): |
2012 lang = self.lexer_.name() |
2013 lang = self.lexer_.name() |
2013 if normalized: # __IGNORE_WARNING_Y102__ |
2014 if normalized and lang in ("Python 2.x", "Python"): |
2014 # adjust some Pygments lexer names |
2015 # adjust some Pygments lexer names |
2015 if lang in ("Python 2.x", "Python"): |
2016 lang = "Python3" |
2016 lang = "Python3" |
|
2017 |
2017 |
2018 else: |
2018 else: |
2019 lang = self.apiLanguage |
2019 lang = self.apiLanguage |
2020 if forPygments: # __IGNORE_WARNING_Y102__ |
2020 if forPygments and lang == "Python3": |
2021 # adjust some names to Pygments lexer names |
2021 # adjust some names to Pygments lexer names |
2022 if lang == "Python3": |
2022 lang = "Python" |
2023 lang = "Python" |
|
2024 return lang |
2023 return lang |
2025 |
2024 |
2026 def getApiLanguage(self): |
2025 def getApiLanguage(self): |
2027 """ |
2026 """ |
2028 Public method to get the API language of the editor. |
2027 Public method to get the API language of the editor. |
6231 error = problems.get("error") |
6230 error = problems.get("error") |
6232 if error: |
6231 if error: |
6233 _fn, lineno, col, code, msg = error |
6232 _fn, lineno, col, code, msg = error |
6234 self.toggleSyntaxError(lineno, col, True, msg) |
6233 self.toggleSyntaxError(lineno, col, True, msg) |
6235 |
6234 |
|
6235 warnings = problems.get("py_warnings", []) |
|
6236 for _fn, lineno, col, _code, msg in warnings: |
|
6237 self.toggleWarning(lineno, col, True, msg, warningType=Editor.WarningPython) |
|
6238 |
6236 warnings = problems.get("warnings", []) |
6239 warnings = problems.get("warnings", []) |
6237 for _fn, lineno, col, _code, msg in warnings: |
6240 for _fn, lineno, col, _code, msg in warnings: |
6238 self.toggleWarning(lineno, col, True, msg) |
6241 self.toggleWarning(lineno, col, True, msg, warningType=Editor.WarningCode) |
6239 |
6242 |
6240 self.updateVerticalScrollBar() |
6243 self.updateVerticalScrollBar() |
6241 |
6244 |
6242 def __initOnlineSyntaxCheck(self): |
6245 def __initOnlineSyntaxCheck(self): |
6243 """ |
6246 """ |
6801 def clearFlakesWarnings(self): |
6804 def clearFlakesWarnings(self): |
6802 """ |
6805 """ |
6803 Public slot to clear all pyflakes warnings. |
6806 Public slot to clear all pyflakes warnings. |
6804 """ |
6807 """ |
6805 self.__clearTypedWarning(Editor.WarningCode) |
6808 self.__clearTypedWarning(Editor.WarningCode) |
|
6809 self.__clearTypedWarning(Editor.WarningPython) |
6806 |
6810 |
6807 def clearStyleWarnings(self): |
6811 def clearStyleWarnings(self): |
6808 """ |
6812 """ |
6809 Public slot to clear all style warnings. |
6813 Public slot to clear all style warnings. |
6810 """ |
6814 """ |
6813 def __clearTypedWarning(self, warningKind): |
6817 def __clearTypedWarning(self, warningKind): |
6814 """ |
6818 """ |
6815 Private method to clear warnings of a specific kind. |
6819 Private method to clear warnings of a specific kind. |
6816 |
6820 |
6817 @param warningKind kind of warning to clear (Editor.WarningCode, |
6821 @param warningKind kind of warning to clear (Editor.WarningCode, |
6818 Editor.WarningStyle) |
6822 Editor.WarningPython, Editor.WarningStyle) |
6819 """ |
6823 """ |
6820 for handle in list(self.warnings.keys()): |
6824 for handle in list(self.warnings.keys()): |
6821 warnings = [] |
6825 warnings = [] |
6822 for msg, warningType in self.warnings[handle]: |
6826 for msg, warningType in self.warnings[handle]: |
6823 if warningType == warningKind: |
6827 if warningType == warningKind: |
6927 |
6931 |
6928 # step 1: do warnings |
6932 # step 1: do warnings |
6929 for handle in self.warnings: |
6933 for handle in self.warnings: |
6930 if self.markerLine(handle) == line: |
6934 if self.markerLine(handle) == line: |
6931 for msg, warningType in self.warnings[handle]: |
6935 for msg, warningType in self.warnings[handle]: |
6932 if warningType == self.WarningStyle: |
6936 if warningType == Editor.WarningStyle: |
6933 styleAnnotations.append(self.tr("Style: {0}").format(msg)) |
6937 styleAnnotations.append(self.tr("Style: {0}").format(msg)) |
|
6938 elif warningType == Editor.WarningPython: |
|
6939 warningAnnotations.append(msg) |
6934 else: |
6940 else: |
6935 warningAnnotations.append( |
6941 warningAnnotations.append( |
6936 self.tr("Warning: {0}").format(msg) |
6942 self.tr("Warning: {0}").format(msg) |
6937 ) |
6943 ) |
6938 |
6944 |