@@ -57,24 +57,28 @@ fn (_ DumbAwareSemanticVisitor) highlight_node(node psi.AstNode, root psi.PsiEle
57
57
if last_child := node.last_child () {
58
58
result << element_to_semantic (last_child, .namespace)
59
59
}
60
- } else if node.type_name == .value_attribute {
61
- first_child := node.first_child () or { return }
62
- result << element_to_semantic (first_child, .decorator)
63
60
} else if node.type_name == .attribute {
64
61
// '['
65
- first_child := node.first_child () or { return }
62
+ if first_child := node.first_child () {
63
+ result << element_to_semantic (first_child, .decorator)
64
+ }
66
65
// ']'
67
- last_child := node.last_child () or { return }
68
- result << element_to_semantic (first_child , .decorator)
69
- result << element_to_semantic (last_child, .decorator)
66
+ if last_child := node.last_child () {
67
+ result << element_to_semantic (last_child , .decorator)
68
+ }
70
69
} else if node.type_name == .key_value_attribute {
71
- value_child := node.child_by_field_name ('value' ) or { return }
72
- if value_child.type_name == .identifier {
73
- result << element_to_semantic (node, .decorator)
70
+ if value_child := node.child_by_field_name ('value' ) {
71
+ if value_child.type_name == .identifier {
72
+ result << element_to_semantic (value_child, .string)
73
+ }
74
74
}
75
75
} else if node.type_name == .qualified_type {
76
- first_child := node.first_child () or { return }
77
- result << element_to_semantic (first_child, .namespace)
76
+ if first_child := node.first_child () {
77
+ result << element_to_semantic (first_child, .namespace)
78
+ }
79
+ if first_child := node.last_child () {
80
+ result << element_to_semantic (first_child, .type_)
81
+ }
78
82
} else if node.type_name == .unknown {
79
83
text := node.text (root.containing_file.source_text)
80
84
@@ -100,40 +104,35 @@ fn (_ DumbAwareSemanticVisitor) highlight_node(node psi.AstNode, root psi.PsiEle
100
104
}
101
105
}
102
106
} else if node.type_name == .enum_declaration {
103
- identifier := node.child_by_field_name ('name' ) or { return }
104
- result << element_to_semantic (identifier, .enum_)
105
- } else if node.type_name == .parameter_declaration || node.type_name == .receiver {
106
- identifier := node.child_by_field_name ('name' ) or { return }
107
- is_mut := if _ := node.child_by_field_name ('mutability' ) {
108
- true
109
- } else {
110
- false
107
+ if identifier := node.child_by_field_name ('name' ) {
108
+ result << element_to_semantic (identifier, .enum_)
111
109
}
112
-
113
- mut mods := []string {}
114
- if is_mut {
115
- mods << 'mutable'
110
+ } else if node.type_name == .parameter_declaration || node.type_name == .receiver {
111
+ if identifier := node.child_by_field_name ('name' ) {
112
+ if _ := node.child_by_field_name ('mutability' ) {
113
+ result << element_to_semantic (identifier, .parameter, 'mutable' )
114
+ } else {
115
+ result << element_to_semantic (identifier, .parameter)
116
+ }
116
117
}
117
- result << element_to_semantic (identifier, .parameter, ...mods)
118
118
} else if node.type_name == .reference_expression {
119
119
def := psi.node_to_var_definition (node, root.containing_file, none )
120
120
if ! isnil (def) {
121
- mods := if def.is_mutable () {
122
- [ 'mutable' ]
121
+ if def.is_mutable () {
122
+ result << element_to_semantic (node, .variable, 'mutable' )
123
123
} else {
124
- [] string {}
124
+ result << element_to_semantic (node, .variable)
125
125
}
126
-
127
- result << element_to_semantic (node, .variable, ...mods)
128
126
}
129
127
130
128
first_char := node.first_char (root.containing_file.source_text)
131
129
if first_char == `@` || first_char == `$` {
132
130
result << element_to_semantic (node, .property) // not a best variant...
133
131
}
134
132
} else if node.type_name == .const_definition {
135
- name := node.child_by_field_name ('name' ) or { return }
136
- result << element_to_semantic (name, .property) // not a best variant...
133
+ if name := node.child_by_field_name ('name' ) {
134
+ result << element_to_semantic (name, .property) // not a best variant...
135
+ }
137
136
} else if node.type_name == .import_path {
138
137
if last_part := node.last_child () {
139
138
result << element_to_semantic (last_part, .namespace)
@@ -143,8 +142,9 @@ fn (_ DumbAwareSemanticVisitor) highlight_node(node psi.AstNode, root psi.PsiEle
143
142
} else if node.type_name == .generic_parameter {
144
143
result << element_to_semantic (node, .type_parameter)
145
144
} else if node.type_name == .global_var_definition {
146
- identifier := node.child_by_field_name ('name' ) or { return }
147
- result << element_to_semantic (identifier, .variable, 'global' )
145
+ if identifier := node.child_by_field_name ('name' ) {
146
+ result << element_to_semantic (identifier, .variable, 'global' )
147
+ }
148
148
} else if node.type_name == .function_declaration {
149
149
if first_child := node.child_by_field_name ('name' ) {
150
150
first_char := first_child.first_char (root.containing_file.source_text)
0 commit comments