Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py

branch
BgService
changeset 3241
957673fc463a
parent 3209
c5432abceb25
child 3412
9364dab2d472
equal deleted inserted replaced
3228:f489068e51e8 3241:957673fc463a
19 from E5Gui.E5Application import e5App 19 from E5Gui.E5Application import e5App
20 20
21 from .Ui_SyntaxCheckerDialog import Ui_SyntaxCheckerDialog 21 from .Ui_SyntaxCheckerDialog import Ui_SyntaxCheckerDialog
22 22
23 import Utilities 23 import Utilities
24 import Preferences
25 import UI.PixmapCache 24 import UI.PixmapCache
26 25
27 26
28 class SyntaxCheckerDialog(QDialog, Ui_SyntaxCheckerDialog): 27 class SyntaxCheckerDialog(QDialog, Ui_SyntaxCheckerDialog):
29 """ 28 """
64 63
65 self.checkProgress.setVisible(False) 64 self.checkProgress.setVisible(False)
66 self.checkProgressLabel.setVisible(False) 65 self.checkProgressLabel.setVisible(False)
67 self.checkProgressLabel.setMaximumWidth(600) 66 self.checkProgressLabel.setMaximumWidth(600)
68 67
69 self.internalServices = e5App().getObject('InternalServices') 68 self.syntaxCheckService = e5App().getObject('SyntaxCheckService')
70 self.internalServices.syntaxChecked.connect(self.__processResult) 69 self.syntaxCheckService.syntaxChecked.connect(self.__processResult)
71 70
72 def __resort(self): 71 def __resort(self):
73 """ 72 """
74 Private method to resort the tree. 73 Private method to resort the tree.
75 """ 74 """
152 151
153 if isinstance(fn, list): 152 if isinstance(fn, list):
154 self.files = fn 153 self.files = fn
155 elif os.path.isdir(fn): 154 elif os.path.isdir(fn):
156 self.files = [] 155 self.files = []
157 extensions = set(Preferences.getPython("PythonExtensions") + 156 for ext in self.syntaxCheckService.getExtensions():
158 Preferences.getPython("Python3Extensions"))
159 for ext in extensions:
160 self.files.extend( 157 self.files.extend(
161 Utilities.direntries(fn, True, '*{0}'.format(ext), 0)) 158 Utilities.direntries(fn, True, '*{0}'.format(ext), 0))
162 else: 159 else:
163 self.files = [fn] 160 self.files = [fn]
164 161
175 self.checkProgress.setMaximum(max(1, len(self.files))) 172 self.checkProgress.setMaximum(max(1, len(self.files)))
176 self.checkProgress.setVisible(len(self.files) > 1) 173 self.checkProgress.setVisible(len(self.files) > 1)
177 self.checkProgressLabel.setVisible(len(self.files) > 1) 174 self.checkProgressLabel.setVisible(len(self.files) > 1)
178 QApplication.processEvents() 175 QApplication.processEvents()
179 176
180 self.checkFlakes = Preferences.getFlakes("IncludeInSyntaxCheck")
181 self.ignoreStarImportWarnings = Preferences.getFlakes(
182 "IgnoreStarImportWarnings")
183
184 # now go through all the files 177 # now go through all the files
185 self.progress = 0 178 self.progress = 0
186 self.check(codestring) 179 self.check(codestring)
187 180
188 def check(self, codestring=''): 181 def check(self, codestring=''):
218 self.progress += 1 211 self.progress += 1
219 # Continue with next file 212 # Continue with next file
220 self.check() 213 self.check()
221 return 214 return
222 215
223 self.internalServices.syntaxCheck( 216 self.syntaxCheckService.syntaxCheck(None, self.filename, self.source)
224 self.filename, self.source, self.checkFlakes,
225 self.ignoreStarImportWarnings)
226 217
227 def __processResult( 218 def __processResult(
228 self, fn, nok, fname, line, index, code, error, warnings): 219 self, fn, nok, line, index, code, error, warnings):
229 """ 220 """
230 Slot to display the reported messages. 221 Slot to display the reported messages.
231 222
232 If checkFlakes is True, warnings contains a list of strings containing 223 If checkFlakes is True, warnings contains a list of strings containing
233 the warnings (marker, file name, line number, message) 224 the warnings (marker, file name, line number, message)
234 The values are only valid, if nok is False. 225 The values are only valid, if nok is False.
235 226
236 @param fn filename of the checked file (str) 227 @param fn filename of the checked file (str)
237 @param nok flag if an error in the source was found (boolean) 228 @param nok flag if an error in the source was found (boolean)
238 @param fname filename of the checked file (str) # TODO: remove dubl.
239 @param line number where the error occured (int) 229 @param line number where the error occured (int)
240 @param index the column where the error occured (int) 230 @param index the column where the error occured (int)
241 @param code the part of the code where the error occured (str) 231 @param code the part of the code where the error occured (str)
242 @param error the name of the error (str) 232 @param error the name of the error (str)
243 @param warnings a list of strings containing the warnings 233 @param warnings a list of strings containing the warnings
248 return 238 return
249 239
250 if nok: 240 if nok:
251 self.noResults = False 241 self.noResults = False
252 self.__createResultItem( 242 self.__createResultItem(
253 fname, line, index, error, code.strip(), False) 243 fn, line, index, error, code.strip(), False)
254 else: 244 else:
255 source = self.source.splitlines() 245 source = self.source.splitlines()
256 for marker, _fn, lineno, col, msg in warnings: 246 for marker, _fn, lineno, col, msg in warnings:
257 self.noResults = False 247 self.noResults = False
258 scr_line = source[lineno - 1].strip() 248 scr_line = source[lineno - 1].strip()

eric ide

mercurial