eric6/QScintilla/Lexers/LexerJSON.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) 2017 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a JSON lexer with some additional methods.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.Qsci import QsciLexerJSON
13
14 from .Lexer import Lexer
15 import Preferences
16
17
18 class LexerJSON(Lexer, QsciLexerJSON):
19 """
20 Subclass to implement some additional lexer dependent methods.
21 """
22 def __init__(self, parent=None):
23 """
24 Constructor
25
26 @param parent parent widget of this lexer
27 """
28 QsciLexerJSON.__init__(self, parent)
29 Lexer.__init__(self)
30
31 self.commentString = "//"
32 self.streamCommentString = {
33 'start': '/* ',
34 'end': ' */'
35 }
36
37 self.keywordSetDescriptions = [
38 self.tr("JSON Keywords"),
39 self.tr("JSON-LD Keywords"),
40 ]
41
42 def initProperties(self):
43 """
44 Public slot to initialize the properties.
45 """
46 self.setHighlightComments(
47 Preferences.getEditor("JSONHightlightComments"))
48 self.setHighlightEscapeSequences(
49 Preferences.getEditor("JSONHighlightEscapeSequences"))
50 self.setFoldCompact(
51 Preferences.getEditor("AllFoldCompact"))
52
53 def isCommentStyle(self, style):
54 """
55 Public method to check, if a style is a comment style.
56
57 @param style style to check (integer)
58 @return flag indicating a comment style (boolean)
59 """
60 return style in [QsciLexerJSON.CommentLine,
61 QsciLexerJSON.CommentBlock]
62
63 def isStringStyle(self, style):
64 """
65 Public method to check, if a style is a string style.
66
67 @param style style to check (integer)
68 @return flag indicating a string style (boolean)
69 """
70 return style in [QsciLexerJSON.String,
71 QsciLexerJSON.UnclosedString]
72
73 def defaultKeywords(self, kwSet):
74 """
75 Public method to get the default keywords.
76
77 @param kwSet number of the keyword set (integer)
78 @return string giving the keywords (string) or None
79 """
80 return QsciLexerJSON.keywords(self, kwSet)
81
82 def maximumKeywordSet(self):
83 """
84 Public method to get the maximum keyword set.
85
86 @return maximum keyword set (integer)
87 """
88 return 2

eric ide

mercurial