summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ide/complete.rs18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/ide/complete.rs b/src/ide/complete.rs
index 153a9ccb..53d4851f 100644
--- a/src/ide/complete.rs
+++ b/src/ide/complete.rs
@@ -108,7 +108,7 @@ fn complete_rules(ctx: &mut CompletionContext) -> bool {
/// Complete call and set rule parameters.
fn complete_params(ctx: &mut CompletionContext) -> bool {
// Ensure that we are in a function call or set rule's argument list.
- let (callee, args) = if_chain! {
+ let (callee, set, args) = if_chain! {
if let Some(parent) = ctx.leaf.parent();
if let Some(parent) = match parent.kind() {
SyntaxKind::Named => parent.parent(),
@@ -117,13 +117,14 @@ fn complete_params(ctx: &mut CompletionContext) -> bool {
if let Some(args) = parent.cast::<ast::Args>();
if let Some(grand) = parent.parent();
if let Some(expr) = grand.cast::<ast::Expr>();
+ let set = matches!(expr, ast::Expr::Set(_));
if let Some(callee) = match expr {
ast::Expr::FuncCall(call) => call.callee().as_untyped().cast(),
ast::Expr::Set(set) => Some(set.target()),
_ => None,
};
then {
- (callee, args)
+ (callee, set, args)
} else {
return false;
}
@@ -173,7 +174,7 @@ fn complete_params(ctx: &mut CompletionContext) -> bool {
_ => None,
}).collect();
- ctx.param_completions(&callee, &exclude);
+ ctx.param_completions(&callee, set, &exclude);
return true;
}
}
@@ -427,7 +428,12 @@ impl<'a> CompletionContext<'a> {
}
/// Add completions for the parameters of a function.
- fn param_completions(&mut self, callee: &ast::Ident, exclude: &[ast::Ident]) {
+ fn param_completions(
+ &mut self,
+ callee: &ast::Ident,
+ set: bool,
+ exclude: &[ast::Ident],
+ ) {
let info = if_chain! {
if let Some(Value::Func(func)) = self.scope.get(callee);
if let Some(info) = func.info();
@@ -444,6 +450,10 @@ impl<'a> CompletionContext<'a> {
continue;
}
+ if set && !param.settable {
+ continue;
+ }
+
if param.named {
self.completions.push(Completion {
kind: CompletionKind::Param,