mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-08-04 10:18:16 +00:00
fix: other two wrong usages of analyze_import
(#967)
This commit is contained in:
parent
2eddcbd87f
commit
fee46d2123
4 changed files with 20 additions and 14 deletions
|
@ -32,9 +32,8 @@ use crate::analysis::{
|
|||
};
|
||||
use crate::docs::{DefDocs, TidyModuleDocs};
|
||||
use crate::syntax::{
|
||||
construct_module_dependencies, find_expr_in_import, get_deref_target, resolve_id_by_path,
|
||||
scan_workspace_files, Decl, DefKind, DerefTarget, ExprInfo, ExprRoute, LexicalScope,
|
||||
ModuleDependency,
|
||||
construct_module_dependencies, get_deref_target, resolve_id_by_path, scan_workspace_files,
|
||||
Decl, DefKind, DerefTarget, ExprInfo, ExprRoute, LexicalScope, ModuleDependency,
|
||||
};
|
||||
use crate::upstream::{tooltip_, CompletionFeat, Tooltip};
|
||||
use crate::{
|
||||
|
@ -387,16 +386,6 @@ impl LocalContext {
|
|||
.or_else(|| self.with_vm(|vm| rr.eval(vm).ok()))
|
||||
}
|
||||
|
||||
/// Get module import at location.
|
||||
pub fn module_ins_at(&mut self, def_fid: TypstFileId, cursor: usize) -> Option<Value> {
|
||||
let def_src = self.source_by_id(def_fid).ok()?;
|
||||
let def_root = LinkedNode::new(def_src.root());
|
||||
let mod_exp = find_expr_in_import(def_root.leaf_at_compat(cursor)?)?;
|
||||
let mod_import = mod_exp.parent()?.clone();
|
||||
let mod_import_node = mod_import.cast::<ast::ModuleImport>()?;
|
||||
self.analyze_import(mod_import_node.source().to_untyped()).1
|
||||
}
|
||||
|
||||
pub(crate) fn cached_tokens(&mut self, source: &Source) -> (SemanticTokens, Option<String>) {
|
||||
let tokens = crate::analysis::semantic_tokens::get_semantic_tokens(self, source);
|
||||
|
||||
|
|
7
crates/tinymist-query/src/fixtures/hover/module_star.typ
Normal file
7
crates/tinymist-query/src/fixtures/hover/module_star.typ
Normal file
|
@ -0,0 +1,7 @@
|
|||
/// path: draw.typ
|
||||
|
||||
/// The draw line.
|
||||
#let line() = 1;
|
||||
-----
|
||||
|
||||
#import "draw.typ": /* position after */ *
|
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
source: crates/tinymist-query/src/hover.rs
|
||||
expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
|
||||
input_file: crates/tinymist-query/src/fixtures/hover/module_star.typ
|
||||
snapshot_kind: text
|
||||
---
|
||||
{
|
||||
"contents": "This star imports line",
|
||||
"range": "0:41:0:42"
|
||||
}
|
|
@ -216,7 +216,7 @@ fn star_tooltip(ctx: &mut LocalContext, mut node: &LinkedNode) -> Option<HoverCo
|
|||
}
|
||||
|
||||
let import_node = node.cast::<ast::ModuleImport>()?;
|
||||
let scope_val = ctx.analyze_import(import_node.source().to_untyped()).1?;
|
||||
let scope_val = ctx.module_by_syntax(import_node.source().to_untyped())?;
|
||||
|
||||
let scope_items = scope_val.scope()?.iter();
|
||||
let mut names = scope_items.map(|item| item.0.as_str()).collect::<Vec<_>>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue