Skip to content

Commit

Permalink
update resolve_names for identifier_expr
Browse files Browse the repository at this point in the history
Signed-off-by: shruti2522 <[email protected]>
  • Loading branch information
shruti2522 committed Jun 3, 2024
1 parent 9690495 commit 91408f2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
34 changes: 30 additions & 4 deletions kclvm/sema/src/advanced_resolver/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1007,10 +1007,36 @@ impl<'ctx> AdvancedResolver<'ctx> {
if maybe_def {
let (start_pos, end_pos): Range = first_name.get_span_pos();
let ast_id = first_name.id.clone();
let first_value = self.gs.get_symbols_mut().alloc_value_symbol(
ValueSymbol::new(first_name.node.clone(), start_pos, end_pos, None, false),
self.ctx.get_node_key(&ast_id),
);

let ty = self
.ctx
.node_ty_map
.get(&self.ctx.get_node_key(&first_name.id));
let first_value = match ty {
Some(ty) if matches!(ty.kind, TypeKind::Function(_)) => {
self.gs.get_symbols_mut().alloc_function_symbol(
FunctionSymbol::new(
first_name.node.clone(),
start_pos,
end_pos,
None,
false,
),
self.ctx.get_node_key(&ast_id),
)
}
_ => self.gs.get_symbols_mut().alloc_value_symbol(
ValueSymbol::new(
first_name.node.clone(),
start_pos,
end_pos,
None,
false,
),
self.ctx.get_node_key(&ast_id),
),
};

self.gs.get_scopes_mut().add_def_to_scope(
cur_scope,
first_name.node.clone(),
Expand Down
2 changes: 1 addition & 1 deletion kclvm/tools/src/LSP/src/semantic_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ mod tests {
(1, 4, 4, 2), // name
(2, 0, 1, 0), // n
(0, 3, 3, 4), // num
(2, 0, 4, 0), // func
(2, 0, 4, 8), // func
(0, 14, 1, 0), // x
(1, 4, 1, 0), // x
];
Expand Down

0 comments on commit 91408f2

Please sign in to comment.