eric6/QScintilla/Lexers/LexerSQL.py

changeset 6942
2602857055c5
parent 6874
5a3a39442711
child 7229
53054eb5b15a
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2003 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a SQL lexer with some additional methods.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.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 try:
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 except AttributeError:
59 pass
60
61 def isCommentStyle(self, style):
62 """
63 Public method to check, if a style is a comment style.
64
65 @param style style to check (integer)
66 @return flag indicating a comment style (boolean)
67 """
68 return style in [QsciLexerSQL.Comment,
69 QsciLexerSQL.CommentDoc,
70 QsciLexerSQL.CommentLine,
71 QsciLexerSQL.CommentLineHash]
72
73 def isStringStyle(self, style):
74 """
75 Public method to check, if a style is a string style.
76
77 @param style style to check (integer)
78 @return flag indicating a string style (boolean)
79 """
80 return style in [QsciLexerSQL.DoubleQuotedString,
81 QsciLexerSQL.SingleQuotedString]
82
83 def defaultKeywords(self, kwSet):
84 """
85 Public method to get the default keywords.
86
87 @param kwSet number of the keyword set (integer)
88 @return string giving the keywords (string) or None
89 """
90 return QsciLexerSQL.keywords(self, kwSet)
91
92 def maximumKeywordSet(self):
93 """
94 Public method to get the maximum keyword set.
95
96 @return maximum keyword set (integer)
97 """
98 return 8

eric ide

mercurial