diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-01-23 15:03:10 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-01-23 15:23:52 +0100 |
| commit | 4653ffebb43d733a3cff873d0903c7d00aaeb499 (patch) | |
| tree | 6a97b2e6a6903b3198547d6f3d0a7e3d2eb023cd /src/ide | |
| parent | 84c6c8b0e6b17996a603ec88b7490107154f38f3 (diff) | |
Math module
Diffstat (limited to 'src/ide')
| -rw-r--r-- | src/ide/complete.rs | 7 | ||||
| -rw-r--r-- | src/ide/tooltip.rs | 14 |
2 files changed, 10 insertions, 11 deletions
diff --git a/src/ide/complete.rs b/src/ide/complete.rs index f0808b21..5b044746 100644 --- a/src/ide/complete.rs +++ b/src/ide/complete.rs @@ -4,7 +4,6 @@ use if_chain::if_chain; use super::{plain_docs_sentence, summarize_font_family}; use crate::model::{CastInfo, Scope, Value}; -use crate::syntax::ast::AstNode; use crate::syntax::{ast, LinkedNode, Source, SyntaxKind}; use crate::util::{format_eco, EcoString}; use crate::World; @@ -118,8 +117,8 @@ fn complete_params(ctx: &mut CompletionContext) -> bool { 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(), + if let Some(ast::Expr::Ident(callee)) = match expr { + ast::Expr::FuncCall(call) => Some(call.callee()), ast::Expr::Set(set) => Some(set.target()), _ => None, }; @@ -377,7 +376,7 @@ impl<'a> CompletionContext<'a> { let leaf = LinkedNode::new(source.root()).leaf_at(cursor)?; Some(Self { world, - scope: &world.library().scope, + scope: &world.library().global.scope(), before: &text[..cursor], after: &text[cursor..], leaf, diff --git a/src/ide/tooltip.rs b/src/ide/tooltip.rs index 0d46695b..076e2b45 100644 --- a/src/ide/tooltip.rs +++ b/src/ide/tooltip.rs @@ -2,7 +2,7 @@ use if_chain::if_chain; use super::{plain_docs_sentence, summarize_font_family}; use crate::model::{CastInfo, Value}; -use crate::syntax::ast::{self, AstNode}; +use crate::syntax::ast; use crate::syntax::{LinkedNode, Source, SyntaxKind}; use crate::World; @@ -23,7 +23,7 @@ fn function_tooltip(world: &dyn World, leaf: &LinkedNode) -> Option<String> { leaf.parent_kind(), Some(SyntaxKind::FuncCall | SyntaxKind::SetRule), ); - if let Some(Value::Func(func)) = world.library().scope.get(&ident); + if let Some(Value::Func(func)) = world.library().global.scope().get(&ident); if let Some(info) = func.info(); then { return Some(plain_docs_sentence(info.docs)); @@ -44,14 +44,14 @@ fn named_param_tooltip(world: &dyn World, leaf: &LinkedNode) -> Option<String> { if matches!(grand.kind(), SyntaxKind::Args); if let Some(grand_grand) = grand.parent(); if let Some(expr) = grand_grand.cast::<ast::Expr>(); - if let Some(callee) = match expr { - ast::Expr::FuncCall(call) => call.callee().as_untyped().cast(), + if let Some(ast::Expr::Ident(callee)) = match expr { + ast::Expr::FuncCall(call) => Some(call.callee()), ast::Expr::Set(set) => Some(set.target()), _ => None, }; // Find metadata about the function. - if let Some(Value::Func(func)) = world.library().scope.get(&callee); + if let Some(Value::Func(func)) = world.library().global.scope().get(&callee); if let Some(info) = func.info(); then { (info, named) } else { return None; } @@ -103,8 +103,8 @@ fn font_family_tooltip(world: &dyn World, leaf: &LinkedNode) -> Option<String> { if matches!(parent.kind(), SyntaxKind::Args); if let Some(grand) = parent.parent(); if let Some(expr) = grand.cast::<ast::Expr>(); - if let Some(callee) = match expr { - ast::Expr::FuncCall(call) => call.callee().as_untyped().cast(), + if let Some(ast::Expr::Ident(callee)) = match expr { + ast::Expr::FuncCall(call) => Some(call.callee()), ast::Expr::Set(set) => Some(set.target()), _ => None, }; |
