Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py

Fri, 30 May 2014 11:39:39 +0200

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Fri, 30 May 2014 11:39:39 +0200
changeset 3618
49e7fbd66ef9
parent 3591
2f2a4a76dd22
child 3621
15f23ed3f216
permissions
-rw-r--r--

Fixed behavior and output if a file is deleted outside eric.

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

eric ide

mercurial