src/eric7/QScintilla/Lexers/LexerSQL.py

branch
eric7
changeset 9209
b99e7fd55fd3
parent 8881
54e42bc2437a
child 9221
bf71ee032bb4
equal deleted inserted replaced
9208:3fc8dfeb6ebe 9209:b99e7fd55fd3
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2003 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a SQL lexer with some additional methods.
8 """
9
10 import contextlib
11
12 from PyQt6.Qsci import QsciLexerSQL
13
14 from .Lexer import Lexer
15 import Preferences
16
17
18 class LexerSQL(Lexer, QsciLexerSQL):
19 """
20 Subclass to implement some additional lexer dependant methods.
21 """
22 def __init__(self, parent=None):
23 """
24 Constructor
25
26 @param parent parent widget of this lexer
27 """
28 QsciLexerSQL.__init__(self, parent)
29 Lexer.__init__(self)
30
31 self.commentString = "--"
32
33 self.keywordSetDescriptions = [
34 self.tr("Keywords"),
35 self.tr("Database Objects"),
36 self.tr("PLDoc"),
37 self.tr("SQL*Plus"),
38 self.tr("Standard Packages"),
39 self.tr("User defined 1"),
40 self.tr("User defined 2"),
41 self.tr("User defined 3"),
42 ]
43
44 def initProperties(self):
45 """
46 Public slot to initialize the properties.
47 """
48 self.setFoldComments(Preferences.getEditor("SqlFoldComment"))
49 self.setBackslashEscapes(Preferences.getEditor("SqlBackslashEscapes"))
50 self.setFoldCompact(Preferences.getEditor("AllFoldCompact"))
51 with contextlib.suppress(AttributeError):
52 self.setDottedWords(Preferences.getEditor("SqlDottedWords"))
53 self.setFoldAtElse(Preferences.getEditor("SqlFoldAtElse"))
54 self.setFoldOnlyBegin(Preferences.getEditor("SqlFoldOnlyBegin"))
55 self.setHashComments(Preferences.getEditor("SqlHashComments"))
56 self.setQuotedIdentifiers(
57 Preferences.getEditor("SqlQuotedIdentifiers"))
58
59 def isCommentStyle(self, style):
60 """
61 Public method to check, if a style is a comment style.
62
63 @param style style to check (integer)
64 @return flag indicating a comment style (boolean)
65 """
66 return style in [QsciLexerSQL.Comment,
67 QsciLexerSQL.CommentDoc,
68 QsciLexerSQL.CommentLine,
69 QsciLexerSQL.CommentLineHash]
70
71 def isStringStyle(self, style):
72 """
73 Public method to check, if a style is a string style.
74
75 @param style style to check (integer)
76 @return flag indicating a string style (boolean)
77 """
78 return style in [QsciLexerSQL.DoubleQuotedString,
79 QsciLexerSQL.SingleQuotedString]
80
81 def defaultKeywords(self, kwSet):
82 """
83 Public method to get the default keywords.
84
85 @param kwSet number of the keyword set (integer)
86 @return string giving the keywords (string) or None
87 """
88 return QsciLexerSQL.keywords(self, kwSet)
89
90 def maximumKeywordSet(self):
91 """
92 Public method to get the maximum keyword set.
93
94 @return maximum keyword set (integer)
95 """
96 return 8

eric ide

mercurial