Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Commit b9d84e4

Browse files
committed
fix(editor): update syntax highlights for Java and Kotlin (fixes #1051)
1 parent afcc178 commit b9d84e4

File tree

11 files changed

+71
-33
lines changed

11 files changed

+71
-33
lines changed

editor/src/main/assets/editor/schemes/default-dark/default-dark.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"type": "#4fc3f7",
1616
"keyword": "#ff6060",
1717
"operator": "#4fc3f7",
18-
"attribute": "#4fc3f7",
18+
"attribute": "#afb42b",
1919
"variable": "#ba68c8",
2020
"field" : "#f0be4b",
2121
"constant": "#f0be4b",

editor/src/main/assets/editor/schemes/default-dark/java.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"variable": "@onSurface",
4949
"constant.builtin": "@keyword",
5050
"type": "@type",
51-
"attribute": "@type",
51+
"attribute": "@attribute",
5252
"function.declaration": "@func.decl",
5353
"function.invocation": "@func.call",
5454
"variable.field": "@field",

editor/src/main/assets/editor/schemes/default-dark/kotlin.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
"fg": "@keyword",
3434
"bold": true
3535
},
36+
"label": {
37+
"fg": "@keyword",
38+
"bold": true
39+
},
3640
"type.qualifier": {
3741
"fg": "@keyword",
3842
"bold": true
@@ -66,16 +70,19 @@
6670
"bold": true
6771
},
6872
"number": "@number",
69-
"variable": "@onSurface",
73+
"identifier": "@onSurface",
7074
"parameter": "@variable",
7175
"constant.builtin": "@keyword",
7276
"type": "@type",
73-
"attribute": "@type",
77+
"attribute": "@attribute",
7478
"function.declaration": "@func.decl",
7579
"function.invocation": "@func.call",
7680
"operator": "@operator",
7781
"punctuation.special": "@kt.punctuation.special",
7882
"constructor": "@kt.constructor",
79-
"property": "@kt.property"
83+
"property.class": "@kt.property",
84+
"property.top_level": "@kt.property",
85+
"property.local": "@onSurface",
86+
"bracket": "@onSurface"
8087
}
8188
}

editor/src/main/assets/editor/schemes/default-dark/scheme.prop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
scheme.name=AndroidIDE Default - Dark
33

44
# The version code of the color scheme
5-
scheme.version=11
5+
scheme.version=12
66

77
# Whether the scheme is dark or light
88
scheme.isDark=true

editor/src/main/assets/editor/schemes/default/default.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"type": "#1976d2",
1717
"keyword": "#d32f2f",
1818
"operator": "#1976d2",
19-
"attribute": "#1976d2",
19+
"attribute": "#827717",
2020
"variable": "#ba68c8",
2121
"field" : "#ff6f00",
2222
"constant": "#ff6f00",

editor/src/main/assets/editor/schemes/default/java.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"variable": "@onSurface",
4949
"constant.builtin": "@keyword",
5050
"type": "@type",
51-
"attribute": "@type",
51+
"attribute": "@attribute",
5252
"function.declaration": "@func.decl",
5353
"function.invocation": "@func.call",
5454
"variable.field": "@field",

editor/src/main/assets/editor/schemes/default/kotlin.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
"fg": "@keyword",
3434
"bold": true
3535
},
36+
"label": {
37+
"fg": "@keyword",
38+
"bold": true
39+
},
3640
"type.qualifier": {
3741
"fg": "@keyword",
3842
"bold": true
@@ -66,16 +70,19 @@
6670
"bold": true
6771
},
6872
"number": "@number",
69-
"variable": "@onSurface",
73+
"identifier": "@onSurface",
7074
"parameter": "@variable",
7175
"constant.builtin": "@keyword",
7276
"type": "@type",
73-
"attribute": "@type",
77+
"attribute": "@attribute",
7478
"function.declaration": "@func.decl",
7579
"function.invocation": "@func.call",
7680
"operator": "@operator",
7781
"punctuation.special": "@kt.punctuation.special",
7882
"constructor": "@kt.constructor",
79-
"property": "@kt.property"
83+
"property.class": "@kt.property",
84+
"property.top_level": "@kt.property",
85+
"property.local": "@onSurface",
86+
"bracket": "@onSurface"
8087
}
8188
}

editor/src/main/assets/editor/schemes/default/scheme.prop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
scheme.name=AndroidIDE Default
33

44
# The version code of the color scheme
5-
scheme.version=11
5+
scheme.version=12
66

77
# Whether the scheme is dark or light
88
scheme.isDark=false

editor/src/main/assets/editor/treesitter/java/highlights.scm

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,16 @@
4040
; Annotations
4141

4242
(annotation
43-
name: (identifier) @attribute)
43+
"@" @attribute
44+
name: (identifier) @attribute
45+
(annotation_argument_list
46+
(element_value_pair
47+
key: (identifier) @variable.field)))
48+
4449
(marker_annotation
50+
"@" @attribute
4551
name: (identifier) @attribute)
4652

47-
"@" @operator
48-
4953
; Types
5054

5155
(type_identifier) @type

editor/src/main/assets/editor/treesitter/kt/highlights.scm

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
11
;;; Identifiers
22

3-
(simple_identifier) @variable
3+
(simple_identifier) @identifier
44

55
; `this` this keyword inside classes
66
(this_expression) @variable.builtin
77

88
; `super` keyword inside classes
99
(super_expression) @variable.builtin
1010

11-
(class_parameter
12-
(simple_identifier) @property)
11+
(statements
12+
(property_declaration
13+
(variable_declaration
14+
(simple_identifier) @property.local)))
15+
16+
(source_file
17+
(property_declaration
18+
(variable_declaration
19+
(simple_identifier) @property.top_level)))
1320

1421
(class_body
1522
(property_declaration
1623
(variable_declaration
17-
(simple_identifier) @property)))
24+
(simple_identifier) @property.class)))
25+
26+
(class_parameter
27+
(simple_identifier) @property.class)
1828

1929
; id_1.id_2.id_3: `id_2` and `id_3` are assumed as object properties
2030
(_
2131
(navigation_suffix
22-
(simple_identifier) @property))
32+
(simple_identifier) @property.class))
2333

2434
; SCREAMING CASE identifiers are assumed to be constants
2535
((simple_identifier) @constant
@@ -93,16 +103,25 @@
93103
(setter
94104
("set") @function.builtin)
95105

96-
(primary_constructor) @constructor
106+
(primary_constructor
107+
"constructor" @keyword
108+
(class_parameter
109+
(simple_identifier) @property.class
110+
(_
111+
(type_identifier) @type )))
112+
97113
(secondary_constructor
98-
("constructor") @constructor)
114+
("constructor") @keyword)
115+
116+
(constructor_delegation_call
117+
[ "this" "super" ] @keyword)
99118

100119
(constructor_invocation
101120
(user_type
102121
(type_identifier) @constructor))
103122

104123
(anonymous_initializer
105-
("init") @constructor)
124+
("init") @function.invocation)
106125

107126
(parameter
108127
(simple_identifier) @parameter)
@@ -263,9 +282,6 @@
263282
"interface"
264283
"fun"
265284
; "typeof" ; NOTE: It is reserved for future use
266-
] @keyword
267-
268-
[
269285
"fun"
270286
"for"
271287
"do"
@@ -282,6 +298,8 @@
282298
"break"
283299
] @keyword
284300

301+
(label) @label
302+
285303
(annotation
286304
"@" @attribute (use_site_target)? @attribute)
287305
(annotation
@@ -340,12 +358,15 @@
340358
"as?"
341359
".."
342360
"->"
343-
"(" ")"
344-
"[" "]"
345-
"{" "}"
346361
"."
347362
","
348363
";"
349364
":"
350365
"::"
351-
] @operator
366+
] @operator
367+
368+
[
369+
"(" ")"
370+
"[" "]"
371+
"{" "}"
372+
] @bracket

0 commit comments

Comments
 (0)