Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py

Thu, 18 Dec 2014 18:56:04 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 18 Dec 2014 18:56:04 +0100
changeset 3972
efc9c803ebdc
parent 3971
b78b17dbdcef
child 4021
195a471c327b
permissions
-rw-r--r--

Fixed an issue related to handling an inactive syntax checker in the editor.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
3160
209a07d7e401 Updated copyright for 2014.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3137
diff changeset
3 # Copyright (c) 2003 - 2014 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a simple Python syntax checker.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3143
diff changeset
10 from __future__ import unicode_literals
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2404
diff changeset
11
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 import os
571
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
13 import fnmatch
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3621
diff changeset
15 from PyQt5.QtCore import pyqtSlot, Qt
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3621
diff changeset
16 from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QTreeWidgetItem, \
3004
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2404
diff changeset
17 QApplication, QHeaderView
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 53
diff changeset
19 from E5Gui.E5Application import e5App
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
21 from .Ui_SyntaxCheckerDialog import Ui_SyntaxCheckerDialog
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 import Utilities
88
3701923bccf2 Added my own Python3 port of pyflakes and integrated py3flakes into syntax checker dialog and editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
24 import UI.PixmapCache
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 915
diff changeset
26
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 class SyntaxCheckerDialog(QDialog, Ui_SyntaxCheckerDialog):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 Class implementing a dialog to display the results of a syntax check run.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
88
3701923bccf2 Added my own Python3 port of pyflakes and integrated py3flakes into syntax checker dialog and editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
31 filenameRole = Qt.UserRole + 1
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 915
diff changeset
32 lineRole = Qt.UserRole + 2
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 915
diff changeset
33 indexRole = Qt.UserRole + 3
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 915
diff changeset
34 errorRole = Qt.UserRole + 4
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 915
diff changeset
35 warningRole = Qt.UserRole + 5
88
3701923bccf2 Added my own Python3 port of pyflakes and integrated py3flakes into syntax checker dialog and editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
36
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 915
diff changeset
37 def __init__(self, parent=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 @param parent The parent widget. (QWidget)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2404
diff changeset
43 super(SyntaxCheckerDialog, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self.setupUi(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 500
diff changeset
46 self.showButton = self.buttonBox.addButton(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3175
diff changeset
47 self.tr("Show"), QDialogButtonBox.ActionRole)
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 500
diff changeset
48 self.showButton.setToolTip(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3175
diff changeset
49 self.tr("Press to show all files containing an issue"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 self.resultList.headerItem().setText(self.resultList.columnCount(), "")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self.resultList.header().setSortIndicator(0, Qt.AscendingOrder)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 self.noResults = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 self.cancelled = False
90
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
58 self.__lastFileItem = None
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59
571
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
60 self.__fileList = []
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
61 self.__project = None
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
62 self.filterFrame.setVisible(False)
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
63
3091
8239cae3f947 Made the progress bar of the syntax and indentation checker dialogs only visible, while it is checking and only if more than 1 file are being checked.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3064
diff changeset
64 self.checkProgress.setVisible(False)
3137
59d9f8c238f0 Fixed issues in the syntax checker and indentation checker dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3091
diff changeset
65 self.checkProgressLabel.setVisible(False)
59d9f8c238f0 Fixed issues in the syntax checker and indentation checker dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3091
diff changeset
66 self.checkProgressLabel.setMaximumWidth(600)
3091
8239cae3f947 Made the progress bar of the syntax and indentation checker dialogs only visible, while it is checking and only if more than 1 file are being checked.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3064
diff changeset
67
3972
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
68 try:
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
69 self.syntaxCheckService = e5App().getObject('SyntaxCheckService')
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
70 self.syntaxCheckService.syntaxChecked.connect(self.__processResult)
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
71 except KeyError:
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
72 self.syntaxCheckService = None
3412
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
73 self.filename = None
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
74
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 def __resort(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 Private method to resort the tree.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 915
diff changeset
79 self.resultList.sortItems(self.resultList.sortColumn(),
830
6caa4436dee2 Fixed a few smaller issues and some source code formatting issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 804
diff changeset
80 self.resultList.header().sortIndicatorOrder()
3036
30c81c9e88b8 Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
81 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 915
diff changeset
83 def __createResultItem(self, file, line, index, error, sourcecode,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 915
diff changeset
84 isWarning=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 Private method to create an entry in the result list.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87
915
c1e052773c08 Changed syntax check to report error position within the line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 831
diff changeset
88 @param file file name of file (string)
c1e052773c08 Changed syntax check to report error position within the line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 831
diff changeset
89 @param line line number of faulty source (integer or string)
c1e052773c08 Changed syntax check to report error position within the line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 831
diff changeset
90 @param index index number of fault (integer)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 @param error error text (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 @param sourcecode faulty line of code (string)
88
3701923bccf2 Added my own Python3 port of pyflakes and integrated py3flakes into syntax checker dialog and editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
93 @param isWarning flag indicating a warning message (boolean)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 """
90
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
95 if self.__lastFileItem is None:
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
96 # It's a new file
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
97 self.__lastFileItem = QTreeWidgetItem(self.resultList, [file])
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
98 self.__lastFileItem.setFirstColumnSpanned(True)
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
99 self.__lastFileItem.setExpanded(True)
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
100 self.__lastFileItem.setData(0, self.filenameRole, file)
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
101
1640
1699d46026cd Fixed a compatibility issue with Qt 4.8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
102 itm = QTreeWidgetItem(self.__lastFileItem)
88
3701923bccf2 Added my own Python3 port of pyflakes and integrated py3flakes into syntax checker dialog and editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
103 if isWarning:
3701923bccf2 Added my own Python3 port of pyflakes and integrated py3flakes into syntax checker dialog and editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
104 itm.setIcon(0, UI.PixmapCache.getIcon("warning.png"))
3701923bccf2 Added my own Python3 port of pyflakes and integrated py3flakes into syntax checker dialog and editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
105 else:
3701923bccf2 Added my own Python3 port of pyflakes and integrated py3flakes into syntax checker dialog and editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
106 itm.setIcon(0, UI.PixmapCache.getIcon("syntaxError.png"))
1640
1699d46026cd Fixed a compatibility issue with Qt 4.8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
107 itm.setData(0, Qt.DisplayRole, line)
1699d46026cd Fixed a compatibility issue with Qt 4.8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
108 itm.setData(1, Qt.DisplayRole, error)
1699d46026cd Fixed a compatibility issue with Qt 4.8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
109 itm.setData(2, Qt.DisplayRole, sourcecode)
88
3701923bccf2 Added my own Python3 port of pyflakes and integrated py3flakes into syntax checker dialog and editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
110 itm.setData(0, self.filenameRole, file)
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 466
diff changeset
111 itm.setData(0, self.lineRole, int(line))
915
c1e052773c08 Changed syntax check to report error position within the line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 831
diff changeset
112 itm.setData(0, self.indexRole, index)
90
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
113 itm.setData(0, self.errorRole, error)
88
3701923bccf2 Added my own Python3 port of pyflakes and integrated py3flakes into syntax checker dialog and editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
114 itm.setData(0, self.warningRole, isWarning)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115
571
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
116 def prepare(self, fileList, project):
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
117 """
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
118 Public method to prepare the dialog with a list of filenames.
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
119
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
120 @param fileList list of filenames (list of strings)
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
121 @param project reference to the project object (Project)
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
122 """
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
123 self.__fileList = fileList[:]
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
124 self.__project = project
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
125
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
126 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True)
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
127 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False)
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
128 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
129
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
130 self.filterFrame.setVisible(True)
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
131
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
132 self.__data = self.__project.getData("CHECKERSPARMS", "SyntaxChecker")
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
133 if self.__data is None or "ExcludeFiles" not in self.__data:
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 915
diff changeset
134 self.__data = {"ExcludeFiles": ""}
571
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
135 self.excludeFilesEdit.setText(self.__data["ExcludeFiles"])
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
136
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 915
diff changeset
137 def start(self, fn, codestring=""):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 Public slot to start the syntax check.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 @param fn file or list of files or directory to be checked
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 (string or list of strings)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 @param codestring string containing the code to be checked (string).
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
144 If this is given, fn must be a single file name.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 """
3972
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
146 if self.syntaxCheckService is not None:
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
147 if self.__project is None:
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
148 self.__project = e5App().getObject("Project")
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
149
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
150 self.cancelled = False
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
151 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
152 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True)
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
153 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
154 self.checkProgress.setVisible(True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 QApplication.processEvents()
3972
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
156
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
157 if isinstance(fn, list):
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
158 self.files = fn
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
159 elif os.path.isdir(fn):
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
160 self.files = []
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
161 for ext in self.syntaxCheckService.getExtensions():
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
162 self.files.extend(
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
163 Utilities.direntries(fn, True, '*{0}'.format(ext), 0))
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
164 else:
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
165 self.files = [fn]
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
166
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
167 self.__clearErrors(self.files)
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
168
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
169 if codestring or len(self.files) > 0:
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
170 self.checkProgress.setMaximum(max(1, len(self.files)))
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
171 self.checkProgress.setVisible(len(self.files) > 1)
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
172 self.checkProgressLabel.setVisible(len(self.files) > 1)
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
173 QApplication.processEvents()
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
174
3972
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
175 # now go through all the files
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
176 self.progress = 0
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
177 self.check(codestring)
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
178
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
179 def check(self, codestring=''):
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
180 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3515
diff changeset
181 Public method to start a check for one file.
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
182
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3177
diff changeset
183 The results are reported to the __processResult slot.
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3177
diff changeset
184 @keyparam codestring optional sourcestring (str)
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
185 """
3972
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
186 if self.syntaxCheckService is None or not self.files:
3618
49e7fbd66ef9 Fixed behavior and output if a file is deleted outside eric.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3591
diff changeset
187 self.__finish()
49e7fbd66ef9 Fixed behavior and output if a file is deleted outside eric.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3591
diff changeset
188 return
49e7fbd66ef9 Fixed behavior and output if a file is deleted outside eric.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3591
diff changeset
189
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
190 self.filename = self.files.pop(0)
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
191 self.checkProgress.setValue(self.progress)
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
192 self.checkProgressLabel.setPath(self.filename)
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
193 QApplication.processEvents()
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
194 self.__resort()
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
195
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3159
diff changeset
196 if self.cancelled:
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
197 return
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
198
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
199 self.__lastFileItem = None
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
200
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
201 if codestring:
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
202 self.source = codestring
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
203 else:
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
204 try:
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
205 self.source = Utilities.readEncodedFile(self.filename)[0]
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
206 self.source = Utilities.normalizeCode(self.source)
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
207 except (UnicodeError, IOError) as msg:
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
208 self.noResults = False
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
209 self.__createResultItem(
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
210 self.filename, 1, 0,
3484
645c12de6b0c Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3456 3447
diff changeset
211 self.tr("Error: {0}").format(str(msg))
3618
49e7fbd66ef9 Fixed behavior and output if a file is deleted outside eric.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3591
diff changeset
212 .rstrip(), "")
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
213 self.progress += 1
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
214 # Continue with next file
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
215 self.check()
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
216 return
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
217
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
218 self.syntaxCheckService.syntaxCheck(None, self.filename, self.source)
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
219
3412
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
220 def __processResult(self, fn, problems):
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
221 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3515
diff changeset
222 Private slot to display the reported messages.
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
223
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
224 @param fn filename of the checked file (str)
3412
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
225 @param problems dictionary with the keys 'error' and 'warnings' which
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
226 hold a list containing details about the error/ warnings
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
227 (file name, line number, column, codestring (only at syntax
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
228 errors), the message) (dict)
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
229 """
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
230 # Check if it's the requested file, otherwise ignore signal
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
231 if fn != self.filename:
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
232 return
3412
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
233
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
234 error = problems.get('error')
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
235 if error:
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
236 self.noResults = False
3412
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
237 _fn, lineno, col, code, msg = error
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
238 self.__createResultItem(_fn, lineno, col, msg, code, False)
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
239
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
240 warnings = problems.get('warnings', [])
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
241 if warnings:
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
242 source = self.source.splitlines()
3412
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
243 for _fn, lineno, col, code, msg in warnings:
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
244 self.noResults = False
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
245 scr_line = source[lineno - 1].strip()
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
246 self.__createResultItem(_fn, lineno, col, msg, scr_line, True)
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
247
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
248 self.progress += 1
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
249 self.checkProgress.setValue(self.progress)
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
250 QApplication.processEvents()
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
251 self.__resort()
2574
9d6b6cf31ec6 Fix for SyntaxCheckDialog and eflags evaluation.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2525
diff changeset
252
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
253 if self.files:
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
254 self.check()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 else:
3137
59d9f8c238f0 Fixed issues in the syntax checker and indentation checker dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3091
diff changeset
256 self.checkProgressLabel.setPath("")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 self.checkProgress.setMaximum(1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 self.checkProgress.setValue(1)
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
259 self.__finish()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 def __finish(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 """
830
6caa4436dee2 Fixed a few smaller issues and some source code formatting issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 804
diff changeset
263 Private slot called when the syntax check finished or the user
6caa4436dee2 Fixed a few smaller issues and some source code formatting issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 804
diff changeset
264 pressed the button.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 self.cancelled = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 if self.noResults:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3175
diff changeset
272 QTreeWidgetItem(self.resultList, [self.tr('No issues found.')])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 QApplication.processEvents()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 self.showButton.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 self.showButton.setEnabled(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 self.resultList.header().resizeSections(QHeaderView.ResizeToContents)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 self.resultList.header().setStretchLastSection(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279
3091
8239cae3f947 Made the progress bar of the syntax and indentation checker dialogs only visible, while it is checking and only if more than 1 file are being checked.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3064
diff changeset
280 self.checkProgress.setVisible(False)
3137
59d9f8c238f0 Fixed issues in the syntax checker and indentation checker dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3091
diff changeset
281 self.checkProgressLabel.setVisible(False)
3091
8239cae3f947 Made the progress bar of the syntax and indentation checker dialogs only visible, while it is checking and only if more than 1 file are being checked.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3064
diff changeset
282
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 def on_buttonBox_clicked(self, button):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 Private slot called by a button of the button box clicked.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 @param button button that was clicked (QAbstractButton)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 if button == self.buttonBox.button(QDialogButtonBox.Close):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 self.close()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 elif button == self.buttonBox.button(QDialogButtonBox.Cancel):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 self.__finish()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 elif button == self.showButton:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 self.on_showButton_clicked()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295
571
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
296 @pyqtSlot()
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
297 def on_startButton_clicked(self):
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
298 """
830
6caa4436dee2 Fixed a few smaller issues and some source code formatting issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 804
diff changeset
299 Private slot to start a syntax check run.
571
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
300 """
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
301 fileList = self.__fileList[:]
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
302
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
303 filterString = self.excludeFilesEdit.text()
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
304 if "ExcludeFiles" not in self.__data or \
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
305 filterString != self.__data["ExcludeFiles"]:
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
306 self.__data["ExcludeFiles"] = filterString
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 915
diff changeset
307 self.__project.setData("CHECKERSPARMS", "SyntaxChecker",
830
6caa4436dee2 Fixed a few smaller issues and some source code formatting issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 804
diff changeset
308 self.__data)
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 915
diff changeset
309 filterList = [f.strip() for f in filterString.split(",")
831
f046b97785db Little optimisation in the syntax and indentation checker dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 830
diff changeset
310 if f.strip()]
571
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
311 if filterList:
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
312 for filter in filterList:
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
313 fileList = \
831
f046b97785db Little optimisation in the syntax and indentation checker dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 830
diff changeset
314 [f for f in fileList if not fnmatch.fnmatch(f, filter)]
571
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
315
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
316 self.resultList.clear()
793
cd183f89874b Changed the syntac checker dialog and the tabnanny dialog to use the new eflag: marker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
317 self.noResults = True
cd183f89874b Changed the syntac checker dialog and the tabnanny dialog to use the new eflag: marker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
318 self.cancelled = False
571
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
319 self.start(fileList)
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
320
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 def on_resultList_itemActivated(self, itm, col):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 915
diff changeset
323 Private slot to handle the activation of an item.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 @param itm reference to the activated item (QTreeWidgetItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 @param col column the item was activated in (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 if self.noResults:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 return
90
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
330
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
331 if itm.parent():
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
332 fn = Utilities.normabspath(itm.data(0, self.filenameRole))
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
333 lineno = itm.data(0, self.lineRole)
915
c1e052773c08 Changed syntax check to report error position within the line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 831
diff changeset
334 index = itm.data(0, self.indexRole)
90
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
335 error = itm.data(0, self.errorRole)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336
90
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
337 vm = e5App().getObject("ViewManager")
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
338 vm.openSourceFile(fn, lineno)
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
339 editor = vm.getOpenEditor(fn)
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
340
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
341 if itm.data(0, self.warningRole):
3412
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
342 editor.toggleWarning(lineno, 0, True, error)
90
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
343 else:
915
c1e052773c08 Changed syntax check to report error position within the line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 831
diff changeset
344 editor.toggleSyntaxError(lineno, index, True, error, show=True)
2195
d6cbd81fb692 Added capability to the syntax checker dialog to show all errors/warnings in an editor when the file entry is double activated.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1640
diff changeset
345 else:
d6cbd81fb692 Added capability to the syntax checker dialog to show all errors/warnings in an editor when the file entry is double activated.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1640
diff changeset
346 fn = Utilities.normabspath(itm.data(0, self.filenameRole))
d6cbd81fb692 Added capability to the syntax checker dialog to show all errors/warnings in an editor when the file entry is double activated.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1640
diff changeset
347 vm = e5App().getObject("ViewManager")
d6cbd81fb692 Added capability to the syntax checker dialog to show all errors/warnings in an editor when the file entry is double activated.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1640
diff changeset
348 vm.openSourceFile(fn)
d6cbd81fb692 Added capability to the syntax checker dialog to show all errors/warnings in an editor when the file entry is double activated.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1640
diff changeset
349 editor = vm.getOpenEditor(fn)
d6cbd81fb692 Added capability to the syntax checker dialog to show all errors/warnings in an editor when the file entry is double activated.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1640
diff changeset
350 for index in range(itm.childCount()):
d6cbd81fb692 Added capability to the syntax checker dialog to show all errors/warnings in an editor when the file entry is double activated.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1640
diff changeset
351 citm = itm.child(index)
d6cbd81fb692 Added capability to the syntax checker dialog to show all errors/warnings in an editor when the file entry is double activated.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1640
diff changeset
352 lineno = citm.data(0, self.lineRole)
d6cbd81fb692 Added capability to the syntax checker dialog to show all errors/warnings in an editor when the file entry is double activated.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1640
diff changeset
353 index = citm.data(0, self.indexRole)
d6cbd81fb692 Added capability to the syntax checker dialog to show all errors/warnings in an editor when the file entry is double activated.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1640
diff changeset
354 error = citm.data(0, self.errorRole)
d6cbd81fb692 Added capability to the syntax checker dialog to show all errors/warnings in an editor when the file entry is double activated.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1640
diff changeset
355 if citm.data(0, self.warningRole):
3412
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
356 editor.toggleWarning(lineno, 0, True, error)
2195
d6cbd81fb692 Added capability to the syntax checker dialog to show all errors/warnings in an editor when the file entry is double activated.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1640
diff changeset
357 else:
3004
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2404
diff changeset
358 editor.toggleSyntaxError(
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2404
diff changeset
359 lineno, index, True, error, show=True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362 def on_showButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364 Private slot to handle the "Show" button press.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 """
90
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
366 vm = e5App().getObject("ViewManager")
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
367
3064
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
368 selectedIndexes = []
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 for index in range(self.resultList.topLevelItemCount()):
3064
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
370 if self.resultList.topLevelItem(index).isSelected():
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
371 selectedIndexes.append(index)
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
372 if len(selectedIndexes) == 0:
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
373 selectedIndexes = list(range(self.resultList.topLevelItemCount()))
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
374 for index in selectedIndexes:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375 itm = self.resultList.topLevelItem(index)
90
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
376 fn = Utilities.normabspath(itm.data(0, self.filenameRole))
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
377 vm.openSourceFile(fn, 1)
3064
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
378 editor = vm.getOpenEditor(fn)
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
379 editor.clearSyntaxError()
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
380 editor.clearFlakesWarnings()
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
381 for cindex in range(itm.childCount()):
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
382 citm = itm.child(cindex)
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
383 lineno = citm.data(0, self.lineRole)
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
384 index = citm.data(0, self.indexRole)
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
385 error = citm.data(0, self.errorRole)
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
386 if citm.data(0, self.warningRole):
3412
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
387 editor.toggleWarning(lineno, 0, True, error)
3064
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
388 else:
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
389 editor.toggleSyntaxError(
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
390 lineno, index, True, error, show=True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 915
diff changeset
392 # go through the list again to clear syntax error and
3064
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
393 # flakes warning markers for files, that are ok
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 openFiles = vm.getOpenFilenames()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 errorFiles = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 for index in range(self.resultList.topLevelItemCount()):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 itm = self.resultList.topLevelItem(index)
830
6caa4436dee2 Fixed a few smaller issues and some source code formatting issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 804
diff changeset
398 errorFiles.append(
6caa4436dee2 Fixed a few smaller issues and some source code formatting issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 804
diff changeset
399 Utilities.normabspath(itm.data(0, self.filenameRole)))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
400 for file in openFiles:
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3618
diff changeset
401 if file not in errorFiles:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402 editor = vm.getOpenEditor(file)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403 editor.clearSyntaxError()
90
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
404 editor.clearFlakesWarnings()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405
3175
1a6638ccce9d Fixed an issue in the syntax and code style checker dialogs causing markers of open files not to be checked being cleared.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
406 def __clearErrors(self, files):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407 """
3175
1a6638ccce9d Fixed an issue in the syntax and code style checker dialogs causing markers of open files not to be checked being cleared.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
408 Private method to clear all error and warning markers of
1a6638ccce9d Fixed an issue in the syntax and code style checker dialogs causing markers of open files not to be checked being cleared.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
409 open editors to be checked.
1a6638ccce9d Fixed an issue in the syntax and code style checker dialogs causing markers of open files not to be checked being cleared.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
410
1a6638ccce9d Fixed an issue in the syntax and code style checker dialogs causing markers of open files not to be checked being cleared.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
411 @param files list of files to be checked (list of string)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412 """
53
c3eb7cc1ff8b Renamed e5App to e5App.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 40
diff changeset
413 vm = e5App().getObject("ViewManager")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
414 openFiles = vm.getOpenFilenames()
3175
1a6638ccce9d Fixed an issue in the syntax and code style checker dialogs causing markers of open files not to be checked being cleared.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
415 for file in [f for f in openFiles if f in files]:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416 editor = vm.getOpenEditor(file)
88
3701923bccf2 Added my own Python3 port of pyflakes and integrated py3flakes into syntax checker dialog and editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
417 editor.clearSyntaxError()
571
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
418 editor.clearFlakesWarnings()

eric ide

mercurial