48 """ |
48 """ |
49 Constructor |
49 Constructor |
50 |
50 |
51 @param ui reference to the user interface object (UI.UserInterface) |
51 @param ui reference to the user interface object (UI.UserInterface) |
52 """ |
52 """ |
|
53 from eric7.Plugins.CheckerPlugins.SyntaxChecker.SyntaxCheckService import ( |
|
54 SyntaxCheckService, |
|
55 ) |
|
56 |
53 super().__init__(ui) |
57 super().__init__(ui) |
54 self.__ui = ui |
58 self.__ui = ui |
55 self.__initialize() |
59 self.__initialize() |
56 |
|
57 from eric7.Plugins.CheckerPlugins.SyntaxChecker.SyntaxCheckService import ( |
|
58 SyntaxCheckService, |
|
59 ) |
|
60 |
60 |
61 self.syntaxCheckService = SyntaxCheckService() |
61 self.syntaxCheckService = SyntaxCheckService() |
62 ericApp().registerObject("SyntaxCheckService", self.syntaxCheckService) |
62 ericApp().registerObject("SyntaxCheckService", self.syntaxCheckService) |
63 |
63 |
64 ericPath = getConfig("ericDir") |
64 ericPath = getConfig("ericDir") |
308 |
308 |
309 def __projectSyntaxCheck(self): |
309 def __projectSyntaxCheck(self): |
310 """ |
310 """ |
311 Private slot used to check the project files for syntax errors. |
311 Private slot used to check the project files for syntax errors. |
312 """ |
312 """ |
|
313 from eric7.Plugins.CheckerPlugins.SyntaxChecker.SyntaxCheckerDialog import ( |
|
314 SyntaxCheckerDialog, |
|
315 ) |
|
316 |
313 project = ericApp().getObject("Project") |
317 project = ericApp().getObject("Project") |
314 project.saveAllScripts() |
318 project.saveAllScripts() |
315 ppath = project.getProjectPath() |
319 ppath = project.getProjectPath() |
316 extensions = tuple(self.syntaxCheckService.getExtensions()) |
320 extensions = tuple(self.syntaxCheckService.getExtensions()) |
317 files = [ |
321 files = [ |
318 os.path.join(ppath, file) |
322 os.path.join(ppath, file) |
319 for file in project.pdata["SOURCES"] |
323 for file in project.pdata["SOURCES"] |
320 if file.endswith(extensions) |
324 if file.endswith(extensions) |
321 ] |
325 ] |
322 |
326 |
323 from eric7.Plugins.CheckerPlugins.SyntaxChecker.SyntaxCheckerDialog import ( |
|
324 SyntaxCheckerDialog, |
|
325 ) |
|
326 |
|
327 self.__projectSyntaxCheckerDialog = SyntaxCheckerDialog() |
327 self.__projectSyntaxCheckerDialog = SyntaxCheckerDialog() |
328 self.__projectSyntaxCheckerDialog.show() |
328 self.__projectSyntaxCheckerDialog.show() |
329 self.__projectSyntaxCheckerDialog.prepare(files, project) |
329 self.__projectSyntaxCheckerDialog.prepare(files, project) |
330 |
330 |
331 def __projectBrowserSyntaxCheck(self): |
331 def __projectBrowserSyntaxCheck(self): |
332 """ |
332 """ |
333 Private method to handle the syntax check context menu action of the |
333 Private method to handle the syntax check context menu action of the |
334 project sources browser. |
334 project sources browser. |
335 """ |
335 """ |
|
336 from eric7.Plugins.CheckerPlugins.SyntaxChecker.SyntaxCheckerDialog import ( |
|
337 SyntaxCheckerDialog, |
|
338 ) |
|
339 |
336 browser = ericApp().getObject("ProjectBrowser").getProjectBrowser("sources") |
340 browser = ericApp().getObject("ProjectBrowser").getProjectBrowser("sources") |
337 if browser.getSelectedItemsCount([ProjectBrowserFileItem]) > 1: |
341 if browser.getSelectedItemsCount([ProjectBrowserFileItem]) > 1: |
338 fn = [] |
342 fn = [] |
339 for itm in browser.getSelectedItems([ProjectBrowserFileItem]): |
343 for itm in browser.getSelectedItems([ProjectBrowserFileItem]): |
340 fn.append(itm.fileName()) |
344 fn.append(itm.fileName()) |
343 try: |
347 try: |
344 fn = itm.fileName() |
348 fn = itm.fileName() |
345 except AttributeError: |
349 except AttributeError: |
346 fn = itm.dirName() |
350 fn = itm.dirName() |
347 |
351 |
348 from eric7.Plugins.CheckerPlugins.SyntaxChecker.SyntaxCheckerDialog import ( |
|
349 SyntaxCheckerDialog, |
|
350 ) |
|
351 |
|
352 self.__projectBrowserSyntaxCheckerDialog = SyntaxCheckerDialog() |
352 self.__projectBrowserSyntaxCheckerDialog = SyntaxCheckerDialog() |
353 self.__projectBrowserSyntaxCheckerDialog.show() |
353 self.__projectBrowserSyntaxCheckerDialog.show() |
354 self.__projectBrowserSyntaxCheckerDialog.start(fn) |
354 self.__projectBrowserSyntaxCheckerDialog.start(fn) |
355 |
355 |
356 def __editorOpened(self, editor): |
356 def __editorOpened(self, editor): |
393 def __editorSyntaxCheck(self): |
393 def __editorSyntaxCheck(self): |
394 """ |
394 """ |
395 Private slot to handle the syntax check context menu action of the |
395 Private slot to handle the syntax check context menu action of the |
396 editors. |
396 editors. |
397 """ |
397 """ |
|
398 from eric7.Plugins.CheckerPlugins.SyntaxChecker.SyntaxCheckerDialog import ( |
|
399 SyntaxCheckerDialog, |
|
400 ) |
|
401 |
398 editor = ericApp().getObject("ViewManager").activeWindow() |
402 editor = ericApp().getObject("ViewManager").activeWindow() |
399 if editor is not None: |
403 if editor is not None: |
400 from eric7.Plugins.CheckerPlugins.SyntaxChecker.SyntaxCheckerDialog import ( |
|
401 SyntaxCheckerDialog, |
|
402 ) |
|
403 |
|
404 self.__editorSyntaxCheckerDialog = SyntaxCheckerDialog() |
404 self.__editorSyntaxCheckerDialog = SyntaxCheckerDialog() |
405 self.__editorSyntaxCheckerDialog.show() |
405 self.__editorSyntaxCheckerDialog.show() |
406 if editor.isJavascriptFile(): |
406 if editor.isJavascriptFile(): |
407 unnamed = "Unnamed.js" |
407 unnamed = "Unnamed.js" |
408 else: |
408 else: |