src/eric7/QScintilla/Lexers/LexerSQL.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
17 17
18 class LexerSQL(Lexer, QsciLexerSQL): 18 class LexerSQL(Lexer, QsciLexerSQL):
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 QsciLexerSQL.__init__(self, parent) 29 QsciLexerSQL.__init__(self, parent)
29 Lexer.__init__(self) 30 Lexer.__init__(self)
30 31
31 self.commentString = "--" 32 self.commentString = "--"
32 33
33 self.keywordSetDescriptions = [ 34 self.keywordSetDescriptions = [
34 self.tr("Keywords"), 35 self.tr("Keywords"),
35 self.tr("Database Objects"), 36 self.tr("Database Objects"),
36 self.tr("PLDoc"), 37 self.tr("PLDoc"),
37 self.tr("SQL*Plus"), 38 self.tr("SQL*Plus"),
38 self.tr("Standard Packages"), 39 self.tr("Standard Packages"),
39 self.tr("User defined 1"), 40 self.tr("User defined 1"),
40 self.tr("User defined 2"), 41 self.tr("User defined 2"),
41 self.tr("User defined 3"), 42 self.tr("User defined 3"),
42 ] 43 ]
43 44
44 def initProperties(self): 45 def initProperties(self):
45 """ 46 """
46 Public slot to initialize the properties. 47 Public slot to initialize the properties.
47 """ 48 """
48 self.setFoldComments(Preferences.getEditor("SqlFoldComment")) 49 self.setFoldComments(Preferences.getEditor("SqlFoldComment"))
51 with contextlib.suppress(AttributeError): 52 with contextlib.suppress(AttributeError):
52 self.setDottedWords(Preferences.getEditor("SqlDottedWords")) 53 self.setDottedWords(Preferences.getEditor("SqlDottedWords"))
53 self.setFoldAtElse(Preferences.getEditor("SqlFoldAtElse")) 54 self.setFoldAtElse(Preferences.getEditor("SqlFoldAtElse"))
54 self.setFoldOnlyBegin(Preferences.getEditor("SqlFoldOnlyBegin")) 55 self.setFoldOnlyBegin(Preferences.getEditor("SqlFoldOnlyBegin"))
55 self.setHashComments(Preferences.getEditor("SqlHashComments")) 56 self.setHashComments(Preferences.getEditor("SqlHashComments"))
56 self.setQuotedIdentifiers( 57 self.setQuotedIdentifiers(Preferences.getEditor("SqlQuotedIdentifiers"))
57 Preferences.getEditor("SqlQuotedIdentifiers")) 58
58
59 def isCommentStyle(self, style): 59 def isCommentStyle(self, style):
60 """ 60 """
61 Public method to check, if a style is a comment style. 61 Public method to check, if a style is a comment style.
62 62
63 @param style style to check (integer) 63 @param style style to check (integer)
64 @return flag indicating a comment style (boolean) 64 @return flag indicating a comment style (boolean)
65 """ 65 """
66 return style in [QsciLexerSQL.Comment, 66 return style in [
67 QsciLexerSQL.CommentDoc, 67 QsciLexerSQL.Comment,
68 QsciLexerSQL.CommentLine, 68 QsciLexerSQL.CommentDoc,
69 QsciLexerSQL.CommentLineHash] 69 QsciLexerSQL.CommentLine,
70 70 QsciLexerSQL.CommentLineHash,
71 ]
72
71 def isStringStyle(self, style): 73 def isStringStyle(self, style):
72 """ 74 """
73 Public method to check, if a style is a string style. 75 Public method to check, if a style is a string style.
74 76
75 @param style style to check (integer) 77 @param style style to check (integer)
76 @return flag indicating a string style (boolean) 78 @return flag indicating a string style (boolean)
77 """ 79 """
78 return style in [QsciLexerSQL.DoubleQuotedString, 80 return style in [
79 QsciLexerSQL.SingleQuotedString] 81 QsciLexerSQL.DoubleQuotedString,
80 82 QsciLexerSQL.SingleQuotedString,
83 ]
84
81 def defaultKeywords(self, kwSet): 85 def defaultKeywords(self, kwSet):
82 """ 86 """
83 Public method to get the default keywords. 87 Public method to get the default keywords.
84 88
85 @param kwSet number of the keyword set (integer) 89 @param kwSet number of the keyword set (integer)
86 @return string giving the keywords (string) or None 90 @return string giving the keywords (string) or None
87 """ 91 """
88 return QsciLexerSQL.keywords(self, kwSet) 92 return QsciLexerSQL.keywords(self, kwSet)
89 93
90 def maximumKeywordSet(self): 94 def maximumKeywordSet(self):
91 """ 95 """
92 Public method to get the maximum keyword set. 96 Public method to get the maximum keyword set.
93 97
94 @return maximum keyword set (integer) 98 @return maximum keyword set (integer)
95 """ 99 """
96 return 8 100 return 8

eric ide

mercurial