Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py

changeset 3004
c4bf32c791d0
parent 2404
cba0ff902c2b
child 3022
57179e4cdadd
child 3057
10516539f238
equal deleted inserted replaced
3003:cb43c34239b1 3004:c4bf32c791d0
9 9
10 import os 10 import os
11 import fnmatch 11 import fnmatch
12 12
13 from PyQt4.QtCore import pyqtSlot, Qt 13 from PyQt4.QtCore import pyqtSlot, Qt
14 from PyQt4.QtGui import QDialog, QDialogButtonBox, QTreeWidgetItem, QApplication, \ 14 from PyQt4.QtGui import QDialog, QDialogButtonBox, QTreeWidgetItem, \
15 QHeaderView 15 QApplication, QHeaderView
16 16
17 from E5Gui.E5Application import e5App 17 from E5Gui.E5Application import e5App
18 18
19 from .Ui_SyntaxCheckerDialog import Ui_SyntaxCheckerDialog 19 from .Ui_SyntaxCheckerDialog import Ui_SyntaxCheckerDialog
20 20
207 self.__project.getProjectLanguage() in ["Python", 207 self.__project.getProjectLanguage() in ["Python",
208 "Python2"]): 208 "Python2"]):
209 isPy3 = False 209 isPy3 = False
210 nok, fname, line, index, code, error, warnings = \ 210 nok, fname, line, index, code, error, warnings = \
211 Utilities.py2compile(file, 211 Utilities.py2compile(file,
212 checkFlakes=Preferences.getFlakes("IncludeInSyntaxCheck")) 212 checkFlakes=Preferences.getFlakes(
213 "IncludeInSyntaxCheck"))
213 else: 214 else:
214 isPy3 = True 215 isPy3 = True
215 nok, fname, line, index, code, error = \ 216 nok, fname, line, index, code, error = \
216 Utilities.compile(file, source) 217 Utilities.compile(file, source)
217 if nok: 218 if nok:
220 else: 221 else:
221 if Preferences.getFlakes("IncludeInSyntaxCheck"): 222 if Preferences.getFlakes("IncludeInSyntaxCheck"):
222 if isPy3: 223 if isPy3:
223 try: 224 try:
224 from Utilities.py3flakes.checker import Checker 225 from Utilities.py3flakes.checker import Checker
225 from Utilities.py3flakes.messages import ImportStarUsed 226 from Utilities.py3flakes.messages import \
227 ImportStarUsed
226 sourceLines = source.splitlines() 228 sourceLines = source.splitlines()
227 warnings = Checker(source, file) 229 warnings = Checker(source, file)
228 warnings.messages.sort(key=lambda a: a.lineno) 230 warnings.messages.sort(key=lambda a: a.lineno)
229 for warning in warnings.messages: 231 for warning in warnings.messages:
230 if ignoreStarImportWarnings and \ 232 if ignoreStarImportWarnings and \
354 index = citm.data(0, self.indexRole) 356 index = citm.data(0, self.indexRole)
355 error = citm.data(0, self.errorRole) 357 error = citm.data(0, self.errorRole)
356 if citm.data(0, self.warningRole): 358 if citm.data(0, self.warningRole):
357 editor.toggleFlakesWarning(lineno, True, error) 359 editor.toggleFlakesWarning(lineno, True, error)
358 else: 360 else:
359 editor.toggleSyntaxError(lineno, index, True, error, show=True) 361 editor.toggleSyntaxError(
362 lineno, index, True, error, show=True)
360 363
361 @pyqtSlot() 364 @pyqtSlot()
362 def on_showButton_clicked(self): 365 def on_showButton_clicked(self):
363 """ 366 """
364 Private slot to handle the "Show" button press. 367 Private slot to handle the "Show" button press.

eric ide

mercurial