Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix call arg symbol pos #1494

Merged
merged 3 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions kclvm/sema/src/advanced_resolver/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,7 @@ impl<'ctx> AdvancedResolver<'ctx> {
if let Some(value) = &kw.node.value {
self.expr(value)?;
}
let (start_pos, end_pos): Range = kw.get_span_pos();
let (start_pos, end_pos): Range = kw.node.arg.get_span_pos();
let value = self.gs.get_symbols_mut().alloc_value_symbol(
ValueSymbol::new(kw.node.arg.node.get_name(), start_pos, end_pos, None, false),
self.ctx.get_node_key(&kw.id),
Expand Down Expand Up @@ -1353,7 +1353,7 @@ impl<'ctx> AdvancedResolver<'ctx> {
if let Some(value) = &kw.node.value {
self.expr(value)?;
}
let (start_pos, end_pos): Range = kw.get_span_pos();
let (start_pos, end_pos): Range = kw.node.arg.get_span_pos();
let value = self.gs.get_symbols_mut().alloc_value_symbol(
ValueSymbol::new(kw.node.arg.node.get_name(), start_pos, end_pos, None, false),
self.ctx.get_node_key(&kw.id),
Expand Down
38 changes: 21 additions & 17 deletions kclvm/tools/src/LSP/src/semantic_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,22 +153,7 @@ mod tests {
#[test]
#[bench_test]
fn semantic_tokens_full_test() {
let (file, _, _, gs) = compile_test_file("src/test_data/sema_token.k");
let expected = [
(0, 15, 1, 3), // m
(1, 5, 3, 4), // num
(1, 7, 7, 1), // Persons
(1, 4, 4, 2), // name
(2, 0, 2, 0), // p5
(0, 4, 7, 1), // Persons
(0, 10, 7, 1), // Persons
(1, 4, 4, 2), // name
(2, 0, 1, 0), // n
(0, 3, 3, 4), // num
(2, 0, 4, 8), // func
(0, 14, 1, 0), // x
(1, 4, 1, 0), // x
];
let (file, _, _, gs) = compile_test_file("src/test_data/sema_token/sema_token.k");
let res = semantic_tokens_full(&file, &gs);
if let Some(tokens) = res {
match &tokens {
Expand All @@ -185,7 +170,26 @@ mod tests {
)
})
.collect();
assert_eq!(get, expected);
// (delta line, delta col(if delta line != 0, from 0), length, kind)
// (0, 15, 1, 3), // m
// (1, 5, 3, 4), // num
// (1, 7, 7, 1), // Persons
// (1, 4, 4, 2), // name
// (2, 0, 2, 0), // p5
// (0, 4, 7, 1), // Persons
// (0, 10, 7, 1), // Persons
// (1, 4, 4, 2), // name
// (2, 0, 1, 0), // n
// (0, 3, 3, 4), // num
// (2, 0, 4, 8), // func
// (0, 14, 1, 0), // x
// (1, 4, 1, 0), // x
// (3, 0, 1, 0), // a
// (0, 4, 4, 8), // func
// (1, 0, 1, 0), // b
// (0, 4, 4, 8), // func
// (0, 5, 1, 0) // x
insta::assert_snapshot!(format!("{:?}", get));
}
lsp_types::SemanticTokensResult::Partial(_) => {
panic!("test failed")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: tools/src/LSP/src/semantic_token.rs
expression: "format!(\"{:?}\", get)"
---
[(0, 15, 1, 3), (1, 5, 3, 4), (1, 7, 7, 1), (1, 4, 4, 2), (2, 0, 2, 0), (0, 4, 7, 1), (0, 10, 7, 1), (1, 4, 4, 2), (2, 0, 1, 0), (0, 3, 3, 4), (2, 0, 4, 8), (0, 14, 1, 0), (1, 4, 1, 0), (3, 0, 1, 0), (0, 4, 4, 8), (1, 0, 1, 0), (0, 4, 4, 8), (0, 5, 1, 0)]
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ n: num = 1

func = lambda x{
x
}
}

a = func("123")
b = func(x="123")
Loading