src/eric7/QScintilla/Lexers/LexerXML.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
17 17
18 class LexerXML(Lexer, QsciLexerXML): 18 class LexerXML(Lexer, QsciLexerXML):
19 """ 19 """
20 Subclass to implement some additional lexer dependant methods. 20 Subclass to implement some additional lexer dependant methods.
21 """ 21 """
22
22 def __init__(self, parent=None): 23 def __init__(self, parent=None):
23 """ 24 """
24 Constructor 25 Constructor
25 26
26 @param parent parent widget of this lexer 27 @param parent parent widget of this lexer
27 """ 28 """
28 QsciLexerXML.__init__(self, parent) 29 QsciLexerXML.__init__(self, parent)
29 Lexer.__init__(self) 30 Lexer.__init__(self)
30 31
31 self.streamCommentString = { 32 self.streamCommentString = {"start": "<!-- ", "end": " -->"}
32 'start': '<!-- ', 33
33 'end': ' -->'
34 }
35
36 self.keywordSetDescriptions = [ 34 self.keywordSetDescriptions = [
37 self.tr(""), 35 self.tr(""),
38 self.tr(""), 36 self.tr(""),
39 self.tr(""), 37 self.tr(""),
40 self.tr(""), 38 self.tr(""),
41 self.tr(""), 39 self.tr(""),
42 self.tr("SGML and DTD keywords"), 40 self.tr("SGML and DTD keywords"),
43 ] 41 ]
44 42
45 def initProperties(self): 43 def initProperties(self):
46 """ 44 """
47 Public slot to initialize the properties. 45 Public slot to initialize the properties.
48 """ 46 """
49 self.setFoldPreprocessor(Preferences.getEditor("HtmlFoldPreprocessor")) 47 self.setFoldPreprocessor(Preferences.getEditor("HtmlFoldPreprocessor"))
50 self.setCaseSensitiveTags( 48 self.setCaseSensitiveTags(Preferences.getEditor("HtmlCaseSensitiveTags"))
51 Preferences.getEditor("HtmlCaseSensitiveTags"))
52 self.setFoldCompact(Preferences.getEditor("AllFoldCompact")) 49 self.setFoldCompact(Preferences.getEditor("AllFoldCompact"))
53 with contextlib.suppress(AttributeError): 50 with contextlib.suppress(AttributeError):
54 self.setFoldScriptComments( 51 self.setFoldScriptComments(Preferences.getEditor("HtmlFoldScriptComments"))
55 Preferences.getEditor("HtmlFoldScriptComments")) 52 self.setFoldScriptHeredocs(Preferences.getEditor("HtmlFoldScriptHeredocs"))
56 self.setFoldScriptHeredocs(
57 Preferences.getEditor("HtmlFoldScriptHeredocs"))
58 self.setScriptsStyled(Preferences.getEditor("XMLStyleScripts")) 53 self.setScriptsStyled(Preferences.getEditor("XMLStyleScripts"))
59 54
60 def isCommentStyle(self, style): 55 def isCommentStyle(self, style):
61 """ 56 """
62 Public method to check, if a style is a comment style. 57 Public method to check, if a style is a comment style.
63 58
64 @param style style to check (integer) 59 @param style style to check (integer)
65 @return flag indicating a comment style (boolean) 60 @return flag indicating a comment style (boolean)
66 """ 61 """
67 return style in [QsciLexerXML.HTMLComment, 62 return style in [
68 QsciLexerXML.ASPXCComment, 63 QsciLexerXML.HTMLComment,
69 QsciLexerXML.SGMLComment, 64 QsciLexerXML.ASPXCComment,
70 QsciLexerXML.SGMLParameterComment, 65 QsciLexerXML.SGMLComment,
71 QsciLexerXML.JavaScriptComment, 66 QsciLexerXML.SGMLParameterComment,
72 QsciLexerXML.JavaScriptCommentDoc, 67 QsciLexerXML.JavaScriptComment,
73 QsciLexerXML.JavaScriptCommentLine, 68 QsciLexerXML.JavaScriptCommentDoc,
74 QsciLexerXML.ASPJavaScriptComment, 69 QsciLexerXML.JavaScriptCommentLine,
75 QsciLexerXML.ASPJavaScriptCommentDoc, 70 QsciLexerXML.ASPJavaScriptComment,
76 QsciLexerXML.ASPJavaScriptCommentLine, 71 QsciLexerXML.ASPJavaScriptCommentDoc,
77 QsciLexerXML.VBScriptComment, 72 QsciLexerXML.ASPJavaScriptCommentLine,
78 QsciLexerXML.ASPVBScriptComment, 73 QsciLexerXML.VBScriptComment,
79 QsciLexerXML.PythonComment, 74 QsciLexerXML.ASPVBScriptComment,
80 QsciLexerXML.ASPPythonComment, 75 QsciLexerXML.PythonComment,
81 QsciLexerXML.PHPComment] 76 QsciLexerXML.ASPPythonComment,
82 77 QsciLexerXML.PHPComment,
78 ]
79
83 def isStringStyle(self, style): 80 def isStringStyle(self, style):
84 """ 81 """
85 Public method to check, if a style is a string style. 82 Public method to check, if a style is a string style.
86 83
87 @param style style to check (integer) 84 @param style style to check (integer)
88 @return flag indicating a string style (boolean) 85 @return flag indicating a string style (boolean)
89 """ 86 """
90 return style in [QsciLexerXML.HTMLDoubleQuotedString, 87 return style in [
91 QsciLexerXML.HTMLSingleQuotedString, 88 QsciLexerXML.HTMLDoubleQuotedString,
92 QsciLexerXML.SGMLDoubleQuotedString, 89 QsciLexerXML.HTMLSingleQuotedString,
93 QsciLexerXML.SGMLSingleQuotedString, 90 QsciLexerXML.SGMLDoubleQuotedString,
94 QsciLexerXML.JavaScriptDoubleQuotedString, 91 QsciLexerXML.SGMLSingleQuotedString,
95 QsciLexerXML.JavaScriptSingleQuotedString, 92 QsciLexerXML.JavaScriptDoubleQuotedString,
96 QsciLexerXML.JavaScriptUnclosedString, 93 QsciLexerXML.JavaScriptSingleQuotedString,
97 QsciLexerXML.ASPJavaScriptDoubleQuotedString, 94 QsciLexerXML.JavaScriptUnclosedString,
98 QsciLexerXML.ASPJavaScriptSingleQuotedString, 95 QsciLexerXML.ASPJavaScriptDoubleQuotedString,
99 QsciLexerXML.ASPJavaScriptUnclosedString, 96 QsciLexerXML.ASPJavaScriptSingleQuotedString,
100 QsciLexerXML.VBScriptString, 97 QsciLexerXML.ASPJavaScriptUnclosedString,
101 QsciLexerXML.VBScriptUnclosedString, 98 QsciLexerXML.VBScriptString,
102 QsciLexerXML.ASPVBScriptString, 99 QsciLexerXML.VBScriptUnclosedString,
103 QsciLexerXML.ASPVBScriptUnclosedString, 100 QsciLexerXML.ASPVBScriptString,
104 QsciLexerXML.PythonDoubleQuotedString, 101 QsciLexerXML.ASPVBScriptUnclosedString,
105 QsciLexerXML.PythonSingleQuotedString, 102 QsciLexerXML.PythonDoubleQuotedString,
106 QsciLexerXML.PythonTripleDoubleQuotedString, 103 QsciLexerXML.PythonSingleQuotedString,
107 QsciLexerXML.PythonTripleSingleQuotedString, 104 QsciLexerXML.PythonTripleDoubleQuotedString,
108 QsciLexerXML.ASPPythonDoubleQuotedString, 105 QsciLexerXML.PythonTripleSingleQuotedString,
109 QsciLexerXML.ASPPythonSingleQuotedString, 106 QsciLexerXML.ASPPythonDoubleQuotedString,
110 QsciLexerXML.ASPPythonTripleDoubleQuotedString, 107 QsciLexerXML.ASPPythonSingleQuotedString,
111 QsciLexerXML.ASPPythonTripleSingleQuotedString, 108 QsciLexerXML.ASPPythonTripleDoubleQuotedString,
112 QsciLexerXML.PHPDoubleQuotedString, 109 QsciLexerXML.ASPPythonTripleSingleQuotedString,
113 QsciLexerXML.PHPSingleQuotedString] 110 QsciLexerXML.PHPDoubleQuotedString,
114 111 QsciLexerXML.PHPSingleQuotedString,
112 ]
113
115 def defaultKeywords(self, kwSet): 114 def defaultKeywords(self, kwSet):
116 """ 115 """
117 Public method to get the default keywords. 116 Public method to get the default keywords.
118 117
119 @param kwSet number of the keyword set (integer) 118 @param kwSet number of the keyword set (integer)
120 @return string giving the keywords (string) or None 119 @return string giving the keywords (string) or None
121 """ 120 """
122 return QsciLexerXML.keywords(self, kwSet) 121 return QsciLexerXML.keywords(self, kwSet)

eric ide

mercurial