Skip to content

Commit

Permalink
test ci
Browse files Browse the repository at this point in the history
Signed-off-by: shruti2522 <[email protected]>
  • Loading branch information
shruti2522 committed Jul 5, 2024
1 parent db26741 commit 2a9cf29
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 101 deletions.
60 changes: 30 additions & 30 deletions kclvm/sema/src/advanced_resolver/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ impl<'ctx> MutSelfTypedResultWalker<'ctx> for AdvancedResolver<'ctx> {

fn walk_call_expr(&mut self, call_expr: &'ctx ast::CallExpr) -> Self::Result {
self.expr(&call_expr.func)?;
let mut func_params = Vec::new();
let ty = self
.ctx
.node_ty_map
Expand All @@ -581,14 +582,14 @@ impl<'ctx> MutSelfTypedResultWalker<'ctx> for AdvancedResolver<'ctx> {
.unwrap()
.clone();
if let TypeKind::Function(func_ty) = &ty.kind {
let func_params = &func_ty.params;
self.do_arguments_symbol_resolve_with_hint(
&call_expr.args,
&call_expr.keywords,
true,
func_params.to_vec(),
)?;
func_params.extend(&func_ty.params)
}
self.do_arguments_symbol_resolve_with_hint(
&call_expr.args,
&call_expr.keywords,
true,
func_params
)?;
Ok(None)
}

Expand Down Expand Up @@ -1316,36 +1317,39 @@ impl<'ctx> AdvancedResolver<'ctx> {
args: &'ctx [ast::NodeRef<ast::Expr>],
kwargs: &'ctx [ast::NodeRef<ast::Keyword>],
with_hint: bool,
mut params: Vec<Parameter>,
params: Vec<&Parameter>,
) -> anyhow::Result<()> {
for kw in kwargs.iter() {
if let Some(value) = &kw.node.value {
self.expr(value)?;
}
let (start_pos, end_pos): Range = kw.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),
for (arg, param) in args.iter().zip(params.iter()) {
self.expr(arg)?;
let (start_pos, end_pos) = arg.get_span_pos();
let arg_value = self.gs.get_symbols_mut().alloc_value_symbol(
ValueSymbol::new(param.name.clone(), start_pos, end_pos, None, false),
self.ctx.get_node_key(&arg.id),
self.ctx.current_pkgpath.clone().unwrap(),
);

if let Some(value) = self.gs.get_symbols_mut().values.get_mut(value.get_id()) {
if let Some(val) = self.gs.get_symbols_mut().values.get_mut(arg_value.get_id()) {
let ty = self
.ctx
.node_ty_map
.borrow()
.get(&self.ctx.get_node_key(&kw.id))
.get(&self.ctx.get_node_key(&arg.id))
.map(|ty| ty.clone());
params.retain(|param| param.name != kw.node.arg.node.get_name());
value.sema_info = SymbolSemanticInfo { ty, doc: None };
if with_hint {
val.hint = Some(SymbolHint::VarHint(param.name.clone()));
}
val.sema_info = SymbolSemanticInfo { ty, doc: None };
}
}
for (i, arg) in args.iter().enumerate() {
self.expr(arg)?;
let (start_pos, end_pos) = arg.get_span_pos();

for kw in kwargs.iter() {
if let Some(value) = &kw.node.value {
self.expr(value)?;
}
let (start_pos, end_pos): Range = kw.get_span_pos();
let value = self.gs.get_symbols_mut().alloc_value_symbol(
ValueSymbol::new(params[i].name.clone(), start_pos, end_pos, None, false),
self.ctx.get_node_key(&arg.id),
ValueSymbol::new(kw.node.arg.node.get_name(), start_pos, end_pos, None, false),
self.ctx.get_node_key(&kw.id),
self.ctx.current_pkgpath.clone().unwrap(),
);

Expand All @@ -1354,15 +1358,11 @@ impl<'ctx> AdvancedResolver<'ctx> {
.ctx
.node_ty_map
.borrow()
.get(&self.ctx.get_node_key(&arg.id))
.get(&self.ctx.get_node_key(&kw.id))
.map(|ty| ty.clone());
if with_hint {
value.hint = Some(SymbolHint::VarHint(params[i].name.clone()));
}
value.sema_info = SymbolSemanticInfo { ty, doc: None };
}
}

Ok(())
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: tools/src/LSP/src/inlay_hints.rs
assertion_line: 80
assertion_line: 118
expression: "format!(\"{:#?}\", res)"
---
Some(
Expand Down Expand Up @@ -265,12 +265,8 @@ Some(
kind: None,
text_edits: None,
tooltip: None,
padding_left: Some(
true,
),
padding_right: Some(
true,
),
padding_left: None,
padding_right: None,
data: None,
},
InlayHint {
Expand All @@ -291,12 +287,8 @@ Some(
kind: None,
text_edits: None,
tooltip: None,
padding_left: Some(
true,
),
padding_right: Some(
true,
),
padding_left: None,
padding_right: None,
data: None,
},
InlayHint {
Expand All @@ -317,64 +309,8 @@ Some(
kind: None,
text_edits: None,
tooltip: None,
padding_left: Some(
true,
),
padding_right: Some(
true,
),
data: None,
},
InlayHint {
position: Position {
line: 27,
character: 12,
},
label: LabelParts(
[
InlayHintLabelPart {
value: "y: ",
tooltip: None,
location: None,
command: None,
},
],
),
kind: None,
text_edits: None,
tooltip: None,
padding_left: Some(
true,
),
padding_right: Some(
true,
),
data: None,
},
InlayHint {
position: Position {
line: 27,
character: 19,
},
label: LabelParts(
[
InlayHintLabelPart {
value: "z: ",
tooltip: None,
location: None,
command: None,
},
],
),
kind: None,
text_edits: None,
tooltip: None,
padding_left: Some(
true,
),
padding_right: Some(
true,
),
padding_left: None,
padding_right: None,
data: None,
},
],
Expand Down

0 comments on commit 2a9cf29

Please sign in to comment.