From 4653ffebb43d733a3cff873d0903c7d00aaeb499 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 23 Jan 2023 15:03:10 +0100 Subject: Math module --- src/ide/complete.rs | 7 +++---- src/ide/tooltip.rs | 14 +++++++------- 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'src/ide') 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::(); 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 { 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 { if matches!(grand.kind(), SyntaxKind::Args); if let Some(grand_grand) = grand.parent(); if let Some(expr) = grand_grand.cast::(); - 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 { if matches!(parent.kind(), SyntaxKind::Args); if let Some(grand) = parent.parent(); if let Some(expr) = grand.cast::(); - 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, }; -- cgit v1.2.3