Skip to content

Commit 4a826a3

Browse files
committed
[server] Fix attribute shading
1 parent b59edea commit 4a826a3

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

server/semantic/DumbAwareSemanticVisitor.v

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -57,24 +57,28 @@ fn (_ DumbAwareSemanticVisitor) highlight_node(node psi.AstNode, root psi.PsiEle
5757
if last_child := node.last_child() {
5858
result << element_to_semantic(last_child, .namespace)
5959
}
60-
} else if node.type_name == .value_attribute {
61-
first_child := node.first_child() or { return }
62-
result << element_to_semantic(first_child, .decorator)
6360
} else if node.type_name == .attribute {
6461
// '['
65-
first_child := node.first_child() or { return }
62+
if first_child := node.first_child() {
63+
result << element_to_semantic(first_child, .decorator)
64+
}
6665
// ']'
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+
}
7069
} 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+
}
7474
}
7575
} 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+
}
7882
} else if node.type_name == .unknown {
7983
text := node.text(root.containing_file.source_text)
8084

@@ -100,40 +104,35 @@ fn (_ DumbAwareSemanticVisitor) highlight_node(node psi.AstNode, root psi.PsiEle
100104
}
101105
}
102106
} 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_)
111109
}
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+
}
116117
}
117-
result << element_to_semantic(identifier, .parameter, ...mods)
118118
} else if node.type_name == .reference_expression {
119119
def := psi.node_to_var_definition(node, root.containing_file, none)
120120
if !isnil(def) {
121-
mods := if def.is_mutable() {
122-
['mutable']
121+
if def.is_mutable() {
122+
result << element_to_semantic(node, .variable, 'mutable')
123123
} else {
124-
[]string{}
124+
result << element_to_semantic(node, .variable)
125125
}
126-
127-
result << element_to_semantic(node, .variable, ...mods)
128126
}
129127

130128
first_char := node.first_char(root.containing_file.source_text)
131129
if first_char == `@` || first_char == `$` {
132130
result << element_to_semantic(node, .property) // not a best variant...
133131
}
134132
} 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+
}
137136
} else if node.type_name == .import_path {
138137
if last_part := node.last_child() {
139138
result << element_to_semantic(last_part, .namespace)
@@ -143,8 +142,9 @@ fn (_ DumbAwareSemanticVisitor) highlight_node(node psi.AstNode, root psi.PsiEle
143142
} else if node.type_name == .generic_parameter {
144143
result << element_to_semantic(node, .type_parameter)
145144
} 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+
}
148148
} else if node.type_name == .function_declaration {
149149
if first_child := node.child_by_field_name('name') {
150150
first_char := first_child.first_char(root.containing_file.source_text)

0 commit comments

Comments
 (0)