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