src/eric7/QScintilla/Lexers/LexerPO.py

Tue, 23 Apr 2024 11:26:04 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 23 Apr 2024 11:26:04 +0200
branch
eric7
changeset 10692
9becf9ca115c
parent 10683
779cda568acb
child 11090
f5f5f5803935
permissions
-rw-r--r--

Changed the source code and the source code documentation to improve the indication of unused method/function arguments.

3557
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
10439
21c28b0f9e41 Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10431
diff changeset
3 # Copyright (c) 2014 - 2024 Detlev Offenbach <detlev@die-offenbachs.de>
3557
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a Gettext lexer with some additional methods.
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
10 from PyQt6.Qsci import QsciLexerPO
3557
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
12 from eric7 import Preferences
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
13
3557
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from .Lexer import Lexer
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 class LexerPO(Lexer, QsciLexerPO):
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 """
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 Subclass to implement some additional lexer dependant methods.
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
21
3557
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 def __init__(self, parent=None):
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 Constructor
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
25
3557
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 @param parent parent widget of this lexer
10431
64157aeb0312 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
27 @type QWidget
3557
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 """
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 QsciLexerPO.__init__(self, parent)
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 Lexer.__init__(self)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
31
3557
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 self.commentString = "#"
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
33
6874
5a3a39442711 Lexers: extended the keyword set handling by introducing a keyword set description and some set adjustments (harmonized with SciTE).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
34 self.keywordSetDescriptions = []
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
35
3557
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 def initProperties(self):
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 """
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 Public slot to initialize the properties.
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 """
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 self.setFoldComments(Preferences.getEditor("PoFoldComment"))
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.setFoldCompact(Preferences.getEditor("AllFoldCompact"))
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
42
3557
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 def isCommentStyle(self, style):
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 """
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 Public method to check, if a style is a comment style.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
46
10431
64157aeb0312 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
47 @param style style to check
64157aeb0312 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
48 @type int
64157aeb0312 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
49 @return flag indicating a comment style
64157aeb0312 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
50 @rtype bool
3557
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 """
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 return style in [QsciLexerPO.Comment, QsciLexerPO.ProgrammerComment]
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
53
3557
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 def isStringStyle(self, style):
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 """
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 Public method to check, if a style is a string style.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
57
10431
64157aeb0312 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
58 @param style style to check
64157aeb0312 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
59 @type int
64157aeb0312 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
60 @return flag indicating a string style
64157aeb0312 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
61 @rtype bool
3557
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
63 return style in [
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
64 QsciLexerPO.MessageIdText,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
65 QsciLexerPO.MessageStringText,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
66 QsciLexerPO.MessageContextText,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
67 ]
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
68
3557
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 def defaultKeywords(self, kwSet):
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 """
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 Public method to get the default keywords.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
72
10431
64157aeb0312 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
73 @param kwSet number of the keyword set
64157aeb0312 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
74 @type int
64157aeb0312 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
75 @return string giving the keywords or None
64157aeb0312 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
76 @rtype str
3557
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 """
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 return QsciLexerPO.keywords(self, kwSet)
9484
d2eb8f0a5bf0 Changed the way editor lexers are instantiated.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
79
d2eb8f0a5bf0 Changed the way editor lexers are instantiated.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
80
10692
9becf9ca115c Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10683
diff changeset
81 def createLexer(variant, parent=None): # noqa: U100
9484
d2eb8f0a5bf0 Changed the way editor lexers are instantiated.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
82 """
d2eb8f0a5bf0 Changed the way editor lexers are instantiated.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
83 Function to instantiate a lexer object.
d2eb8f0a5bf0 Changed the way editor lexers are instantiated.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
84
10683
779cda568acb Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
85 @param variant name of the language variant (unused)
9484
d2eb8f0a5bf0 Changed the way editor lexers are instantiated.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
86 @type str
d2eb8f0a5bf0 Changed the way editor lexers are instantiated.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
87 @param parent parent widget of this lexer
d2eb8f0a5bf0 Changed the way editor lexers are instantiated.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
88 @type QObject
d2eb8f0a5bf0 Changed the way editor lexers are instantiated.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
89 @return instantiated lexer object
d2eb8f0a5bf0 Changed the way editor lexers are instantiated.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
90 @rtype LexerPO
d2eb8f0a5bf0 Changed the way editor lexers are instantiated.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
91 """
d2eb8f0a5bf0 Changed the way editor lexers are instantiated.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
92 return LexerPO(parent=parent)

eric ide

mercurial