eric6/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8043
0acf98cd089a
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

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
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7900
diff changeset
3 # Copyright (c) 2003 - 2021 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
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
571
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
11 import fnmatch
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
4235
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4234
diff changeset
13 from PyQt5.QtCore import pyqtSlot, Qt, QTimer
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
14 from PyQt5.QtWidgets import (
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
15 QDialog, QDialogButtonBox, QTreeWidgetItem, QApplication, QHeaderView
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
16 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 53
diff changeset
18 from E5Gui.E5Application import e5App
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
20 from .Ui_SyntaxCheckerDialog import Ui_SyntaxCheckerDialog
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 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
23 import UI.PixmapCache
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 915
diff changeset
25
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 class SyntaxCheckerDialog(QDialog, Ui_SyntaxCheckerDialog):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 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
29 """
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
30 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
31 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
32 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
33 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
34 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
35
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 915
diff changeset
36 def __init__(self, parent=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 @param parent The parent widget. (QWidget)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 """
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
42 super(SyntaxCheckerDialog, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self.setupUi(self)
4278
ccd1e13cb9bd Fixed issues where dialogs could not be minimized on some desktop environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4236
diff changeset
44 self.setWindowFlags(Qt.Window)
0
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
5609
5bf0aaa818e9 Added code to safe-guard against self.__batch not being defined in the sytax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
59 self.__batch = False
4231
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
60 self.__finished = True
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
61 self.__errorItem = None
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62
571
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
63 self.__fileList = []
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
64 self.__project = None
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
65 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
66
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 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
68 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
69 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
70
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
71 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
72 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
73 self.syntaxCheckService.syntaxChecked.connect(self.__processResult)
4231
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
74 self.syntaxCheckService.batchFinished.connect(self.__batchFinished)
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
75 self.syntaxCheckService.error.connect(self.__processError)
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
76 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
77 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
78 self.filename = None
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
79
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 def __resort(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 Private method to resort the tree.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 915
diff changeset
84 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
85 self.resultList.header().sortIndicatorOrder()
3036
30c81c9e88b8 Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
86 )
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
87
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
88 def __createErrorItem(self, filename, message):
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
89 """
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
90 Private slot to create a new error item in the result list.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
92 @param filename name of the file
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
93 @type str
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
94 @param message error message
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
95 @type str
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
96 """
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
97 if self.__errorItem is None:
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
98 self.__errorItem = QTreeWidgetItem(self.resultList, [
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
99 self.tr("Errors")])
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
100 self.__errorItem.setExpanded(True)
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
101 self.__errorItem.setForeground(0, Qt.red)
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
102
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
103 msg = "{0} ({1})".format(self.__project.getRelativePath(filename),
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
104 message)
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
105 if not self.resultList.findItems(msg, Qt.MatchExactly):
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
106 itm = QTreeWidgetItem(self.__errorItem, [msg])
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
107 itm.setForeground(0, Qt.red)
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
108 itm.setFirstColumnSpanned(True)
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
109
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
110 def __createResultItem(self, filename, line, index, error, sourcecode,
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 915
diff changeset
111 isWarning=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 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
114
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
115 @param filename file name of file (string)
915
c1e052773c08 Changed syntax check to report error position within the line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 831
diff changeset
116 @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
117 @param index index number of fault (integer)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 @param error error text (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 @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
120 @param isWarning flag indicating a warning message (boolean)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 """
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
122 if (
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
123 self.__lastFileItem is None or
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
124 self.__lastFileItem.data(0, self.filenameRole) != filename
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
125 ):
90
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
126 # It's a new file
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
127 self.__lastFileItem = QTreeWidgetItem(self.resultList, [
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
128 self.__project.getRelativePath(filename)])
90
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
129 self.__lastFileItem.setFirstColumnSpanned(True)
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
130 self.__lastFileItem.setExpanded(True)
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
131 self.__lastFileItem.setData(0, self.filenameRole, filename)
90
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
132
1640
1699d46026cd Fixed a compatibility issue with Qt 4.8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
133 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
134 if isWarning:
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
135 itm.setIcon(0, UI.PixmapCache.getIcon("warning"))
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
136 else:
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
137 itm.setIcon(0, UI.PixmapCache.getIcon("syntaxError"))
1640
1699d46026cd Fixed a compatibility issue with Qt 4.8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
138 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
139 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
140 itm.setData(2, Qt.DisplayRole, sourcecode)
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
141 itm.setData(0, self.filenameRole, filename)
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 466
diff changeset
142 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
143 itm.setData(0, self.indexRole, index)
90
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
144 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
145 itm.setData(0, self.warningRole, isWarning)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146
571
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
147 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
148 """
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
149 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
150
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
151 @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
152 @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
153 """
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
154 self.__fileList = fileList[:]
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
155 self.__project = project
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
156
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
157 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
158 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
159 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
160
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
161 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
162
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
163 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
164 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
165 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
166 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
167
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 915
diff changeset
168 def start(self, fn, codestring=""):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 Public slot to start the syntax check.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 @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
173 (string or list of strings)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 @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
175 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
176 """
5609
5bf0aaa818e9 Added code to safe-guard against self.__batch not being defined in the sytax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
177 self.__batch = False
5bf0aaa818e9 Added code to safe-guard against self.__batch not being defined in the sytax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
178
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
179 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
180 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
181 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
182
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
183 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
184 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
185 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
186 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
5828
c8deff89c20c Fixed a little issue in the syntax checker dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5609
diff changeset
187 self.showButton.setEnabled(False)
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
188 self.checkProgress.setVisible(True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 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
190
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
191 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
192 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
193 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
194 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
195 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
196 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
197 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
198 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
199 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
200
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
201 self.__errorItem = None
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
202 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
203
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
204 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
205 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
206 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
207 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
208 QApplication.processEvents()
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
209
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
210 # 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
211 self.progress = 0
4231
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
212 self.files.sort()
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
213 if codestring or len(self.files) == 1:
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
214 self.__batch = False
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
215 self.check(codestring)
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
216 else:
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
217 self.__batch = True
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
218 self.checkBatch()
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
219
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
220 def check(self, codestring=''):
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 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
223
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3177
diff changeset
224 The results are reported to the __processResult slot.
7900
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7849
diff changeset
225
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7849
diff changeset
226 @param codestring optional sourcestring (str)
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
227 """
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
228 if self.syntaxCheckService is None or not self.files:
4231
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
229 self.checkProgressLabel.setPath("")
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
230 self.checkProgress.setMaximum(1)
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
231 self.checkProgress.setValue(1)
3618
49e7fbd66ef9 Fixed behavior and output if a file is deleted outside eric.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3591
diff changeset
232 self.__finish()
49e7fbd66ef9 Fixed behavior and output if a file is deleted outside eric.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3591
diff changeset
233 return
49e7fbd66ef9 Fixed behavior and output if a file is deleted outside eric.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3591
diff changeset
234
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
235 self.filename = self.files.pop(0)
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
236 self.checkProgress.setValue(self.progress)
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
237 self.checkProgressLabel.setPath(self.filename)
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
238 QApplication.processEvents()
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
239 self.__resort()
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
240
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
241 if self.cancelled:
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
242 return
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
243
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
244 self.__lastFileItem = None
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
245
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
246 if codestring:
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
247 self.source = codestring
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
248 else:
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
249 try:
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
250 self.source = Utilities.readEncodedFile(self.filename)[0]
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
251 self.source = Utilities.normalizeCode(self.source)
7836
2f0d208b8137 Changed code to not use the OSError aliases (IOError, EnvironmentError, socket.error and select.error) anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
252 except (UnicodeError, OSError) as msg:
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
253 self.noResults = False
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
254 self.__createResultItem(
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
255 self.filename, 1, 0,
3484
645c12de6b0c Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3456 3447
diff changeset
256 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
257 .rstrip(), "")
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
258 self.progress += 1
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
259 # Continue with next file
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
260 self.check()
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
261 return
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
262
4231
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
263 self.__finished = False
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
264 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
265
4231
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
266 def checkBatch(self):
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
267 """
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
268 Public method to start a style check batch job.
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
269
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
270 The results are reported to the __processResult slot.
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
271 """
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
272 self.__lastFileItem = None
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
273
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
274 self.checkProgressLabel.setPath(self.tr("Preparing files..."))
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
275 progress = 0
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
276
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
277 argumentsList = []
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
278 for filename in self.files:
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
279 progress += 1
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
280 self.checkProgress.setValue(progress)
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
281 QApplication.processEvents()
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
282
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
283 try:
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
284 source = Utilities.readEncodedFile(filename)[0]
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
285 source = Utilities.normalizeCode(source)
7836
2f0d208b8137 Changed code to not use the OSError aliases (IOError, EnvironmentError, socket.error and select.error) anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
286 except (UnicodeError, OSError) as msg:
4231
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
287 self.noResults = False
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
288 self.__createResultItem(
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
289 self.filename, 1, 0,
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
290 self.tr("Error: {0}").format(str(msg))
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
291 .rstrip(), "")
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
292 continue
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
293
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
294 argumentsList.append((filename, source))
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
295
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
296 # reset the progress bar to the checked files
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
297 self.checkProgress.setValue(self.progress)
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
298 self.checkProgressLabel.setPath(self.tr("Transferring data..."))
4231
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
299 QApplication.processEvents()
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
300
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
301 self.__finished = False
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
302 self.syntaxCheckService.syntaxBatchCheck(argumentsList)
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
303
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
304 def __batchFinished(self):
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
305 """
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
306 Private slot handling the completion of a batch job.
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
307 """
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
308 self.checkProgressLabel.setPath("")
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
309 self.checkProgress.setMaximum(1)
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
310 self.checkProgress.setValue(1)
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
311 self.__finish()
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
312
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
313 def __processError(self, fn, msg):
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
314 """
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
315 Private slot to process an error indication from the service.
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
316
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
317 @param fn filename of the file
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
318 @type str
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
319 @param msg error message
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
320 @type str
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
321 """
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
322 self.__createErrorItem(fn, msg)
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
323
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
324 if not self.__batch:
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
325 self.check()
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4501
diff changeset
326
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
327 def __processResult(self, fn, problems):
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
328 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3515
diff changeset
329 Private slot to display the reported messages.
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
330
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
331 @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
332 @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
333 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
334 (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
335 errors), the message) (dict)
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
336 """
4231
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
337 if self.__finished:
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
338 return
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
339
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
340 # Check if it's the requested file, otherwise ignore signal if not
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
341 # in batch mode
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
342 if not self.__batch and fn != self.filename:
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
343 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
344
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
345 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
346 if error:
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
347 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
348 _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
349 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
350
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
351 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
352 if warnings:
4234
40741c858639 Fixed an issue with the batch syntax check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4231
diff changeset
353 if self.__batch:
40741c858639 Fixed an issue with the batch syntax check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4231
diff changeset
354 try:
40741c858639 Fixed an issue with the batch syntax check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4231
diff changeset
355 source = Utilities.readEncodedFile(fn)[0]
40741c858639 Fixed an issue with the batch syntax check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4231
diff changeset
356 source = Utilities.normalizeCode(source)
4500
884269e383f7 Fixed an issue in the syntax checker dialog causing a faulty display in batch mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4433
diff changeset
357 source = source.splitlines()
7836
2f0d208b8137 Changed code to not use the OSError aliases (IOError, EnvironmentError, socket.error and select.error) anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
358 except (UnicodeError, OSError):
4234
40741c858639 Fixed an issue with the batch syntax check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4231
diff changeset
359 source = ""
40741c858639 Fixed an issue with the batch syntax check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4231
diff changeset
360 else:
40741c858639 Fixed an issue with the batch syntax check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4231
diff changeset
361 source = self.source.splitlines()
6188
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
362 for filename, lineno, col, _code, msg in warnings:
4524
5543f4dec8f7 Fixed an issue in the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4522
diff changeset
363 self.noResults = False
5543f4dec8f7 Fixed an issue in the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4522
diff changeset
364 if source:
5543f4dec8f7 Fixed an issue in the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4522
diff changeset
365 try:
5543f4dec8f7 Fixed an issue in the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4522
diff changeset
366 scr_line = source[lineno - 1].strip()
5543f4dec8f7 Fixed an issue in the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4522
diff changeset
367 except IndexError:
5543f4dec8f7 Fixed an issue in the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4522
diff changeset
368 scr_line = ""
5543f4dec8f7 Fixed an issue in the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4522
diff changeset
369 else:
4522
e41020d3c031 Fixed an issue in the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4503
diff changeset
370 scr_line = ""
6188
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
371 self.__createResultItem(filename, lineno, col, msg, scr_line,
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
372 True)
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
373
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
374 self.progress += 1
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
375 self.checkProgress.setValue(self.progress)
4231
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
376 self.checkProgressLabel.setPath(fn)
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
377 QApplication.processEvents()
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
378 self.__resort()
2574
9d6b6cf31ec6 Fix for SyntaxCheckDialog and eflags evaluation.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2525
diff changeset
379
4231
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
380 if not self.__batch:
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
381 self.check()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 def __finish(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384 """
830
6caa4436dee2 Fixed a few smaller issues and some source code formatting issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 804
diff changeset
385 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
386 pressed the button.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387 """
4235
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4234
diff changeset
388 if not self.__finished:
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4234
diff changeset
389 self.__finished = True
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4234
diff changeset
390
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4234
diff changeset
391 self.cancelled = True
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4234
diff changeset
392 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True)
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4234
diff changeset
393 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False)
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4234
diff changeset
394 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4234
diff changeset
395
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4234
diff changeset
396 if self.noResults:
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4234
diff changeset
397 QTreeWidgetItem(self.resultList, [self.tr('No issues found.')])
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4234
diff changeset
398 QApplication.processEvents()
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4234
diff changeset
399 self.showButton.setEnabled(False)
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4234
diff changeset
400 else:
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4234
diff changeset
401 self.showButton.setEnabled(True)
4236
8d4e498a7af8 Fixed a few coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4235
diff changeset
402 self.resultList.header().resizeSections(
8d4e498a7af8 Fixed a few coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4235
diff changeset
403 QHeaderView.ResizeToContents)
4235
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4234
diff changeset
404 self.resultList.header().setStretchLastSection(True)
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4234
diff changeset
405
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4234
diff changeset
406 self.checkProgress.setVisible(False)
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4234
diff changeset
407 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
408
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 def on_buttonBox_clicked(self, button):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
410 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411 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
412
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
413 @param button button that was clicked (QAbstractButton)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
414 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415 if button == self.buttonBox.button(QDialogButtonBox.Close):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416 self.close()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417 elif button == self.buttonBox.button(QDialogButtonBox.Cancel):
4231
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
418 if self.__batch:
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
419 self.syntaxCheckService.cancelSyntaxBatchCheck()
4235
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4234
diff changeset
420 QTimer.singleShot(1000, self.__finish)
4231
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
421 else:
0b38613388c9 Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
422 self.__finish()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
423 elif button == self.showButton:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424 self.on_showButton_clicked()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425
571
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
426 @pyqtSlot()
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
427 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
428 """
830
6caa4436dee2 Fixed a few smaller issues and some source code formatting issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 804
diff changeset
429 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
430 """
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
431 fileList = self.__fileList[:]
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
432
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
433 filterString = self.excludeFilesEdit.text()
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
434 if (
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
435 "ExcludeFiles" not in self.__data or
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
436 filterString != self.__data["ExcludeFiles"]
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
437 ):
571
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
438 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
439 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
440 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
441 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
442 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
443 if filterList:
5597
3d88d53f8c2b Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
444 for fileFilter in filterList:
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
445 fileList = [
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
446 f for f in fileList if not fnmatch.fnmatch(f, fileFilter)
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
447 ]
571
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
448
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
449 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
450 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
451 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
452 self.start(fileList)
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
453
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454 def on_resultList_itemActivated(self, itm, col):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 915
diff changeset
456 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
457
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458 @param itm reference to the activated item (QTreeWidgetItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459 @param col column the item was activated in (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461 if self.noResults:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462 return
90
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
463
4433
7ab862396a8a Workaround for missing lines at vertical scroll bar caused by annotations.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4278
diff changeset
464 vm = e5App().getObject("ViewManager")
7ab862396a8a Workaround for missing lines at vertical scroll bar caused by annotations.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4278
diff changeset
465
90
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
466 if itm.parent():
7849
70e464748aaa Utilities: removed some obsolete functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7836
diff changeset
467 fn = os.path.abspath(itm.data(0, self.filenameRole))
90
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
468 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
469 index = itm.data(0, self.indexRole)
90
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
470 error = itm.data(0, self.errorRole)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471
90
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
472 vm.openSourceFile(fn, lineno)
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
473 editor = vm.getOpenEditor(fn)
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
474
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
475 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
476 editor.toggleWarning(lineno, 0, True, error)
90
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
477 else:
915
c1e052773c08 Changed syntax check to report error position within the line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 831
diff changeset
478 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
479 else:
7849
70e464748aaa Utilities: removed some obsolete functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7836
diff changeset
480 fn = os.path.abspath(itm.data(0, self.filenameRole))
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
481 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
482 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
483 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
484 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
485 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
486 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
487 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
488 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
489 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
490 else:
3004
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2404
diff changeset
491 editor.toggleSyntaxError(
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2404
diff changeset
492 lineno, index, True, error, show=True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
493
4433
7ab862396a8a Workaround for missing lines at vertical scroll bar caused by annotations.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4278
diff changeset
494 editor = vm.activeWindow()
7ab862396a8a Workaround for missing lines at vertical scroll bar caused by annotations.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4278
diff changeset
495 editor.updateVerticalScrollBar()
7ab862396a8a Workaround for missing lines at vertical scroll bar caused by annotations.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4278
diff changeset
496
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
497 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
498 def on_showButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500 Private slot to handle the "Show" button press.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
501 """
90
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
502 vm = e5App().getObject("ViewManager")
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
503
3064
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
504 selectedIndexes = []
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
505 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
506 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
507 selectedIndexes.append(index)
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
508 if len(selectedIndexes) == 0:
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
509 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
510 for index in selectedIndexes:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
511 itm = self.resultList.topLevelItem(index)
7849
70e464748aaa Utilities: removed some obsolete functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7836
diff changeset
512 fn = os.path.abspath(itm.data(0, self.filenameRole))
90
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
513 vm.openSourceFile(fn, 1)
3064
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
514 editor = vm.getOpenEditor(fn)
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
515 editor.clearSyntaxError()
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
516 editor.clearFlakesWarnings()
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
517 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
518 citm = itm.child(cindex)
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
519 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
520 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
521 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
522 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
523 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
524 else:
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
525 editor.toggleSyntaxError(
2e7054d62218 Fixed an issue with the syntax check dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
526 lineno, index, True, error, show=True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
527
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 915
diff changeset
528 # 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
529 # flakes warning markers for files, that are ok
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
530 openFiles = vm.getOpenFilenames()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
531 errorFiles = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
532 for index in range(self.resultList.topLevelItemCount()):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
533 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
534 errorFiles.append(
7849
70e464748aaa Utilities: removed some obsolete functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7836
diff changeset
535 os.path.abspath(itm.data(0, self.filenameRole)))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
536 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
537 if file not in errorFiles:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
538 editor = vm.getOpenEditor(file)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
539 editor.clearSyntaxError()
90
6de42151f9e6 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 89
diff changeset
540 editor.clearFlakesWarnings()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
541
4433
7ab862396a8a Workaround for missing lines at vertical scroll bar caused by annotations.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4278
diff changeset
542 editor = vm.activeWindow()
7ab862396a8a Workaround for missing lines at vertical scroll bar caused by annotations.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4278
diff changeset
543 editor.updateVerticalScrollBar()
7ab862396a8a Workaround for missing lines at vertical scroll bar caused by annotations.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4278
diff changeset
544
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
545 def __clearErrors(self, files):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
546 """
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
547 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
548 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
549
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
550 @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
551 """
53
c3eb7cc1ff8b Renamed e5App to e5App.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 40
diff changeset
552 vm = e5App().getObject("ViewManager")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
553 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
554 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
555 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
556 editor.clearSyntaxError()
571
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
557 editor.clearFlakesWarnings()

eric ide

mercurial