mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-12-23 08:47:50 +00:00
dev: record label ref
This commit is contained in:
parent
971069df07
commit
d9dabaff7c
9 changed files with 42 additions and 6 deletions
|
|
@ -122,8 +122,10 @@ impl ExprInfoRepr {
|
|||
self.resolves
|
||||
.iter()
|
||||
.filter(move |(_, r)| match (decl.as_ref(), r.decl.as_ref()) {
|
||||
(Decl::Label(..), Decl::Label(..)) => r.decl == decl,
|
||||
(Decl::Label(..), Decl::ContentRef(..)) => r.decl.name() == decl.name(),
|
||||
(Decl::Label(..), Decl::Label(..))
|
||||
| (Decl::Label(..), Decl::ContentRef(..))
|
||||
| (Decl::ContentRef(..), Decl::Label(..))
|
||||
| (Decl::ContentRef(..), Decl::ContentRef(..)) => r.decl.name() == decl.name(),
|
||||
(Decl::Label(..), _) => false,
|
||||
_ => r.decl == decl || r.root == of,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ expression: "JsonRepr::new_pure(result)"
|
|||
input_file: crates/tinymist-query/src/fixtures/references/cross_file_ref_label.typ
|
||||
---
|
||||
[
|
||||
"base1.typ@0:11:0:13",
|
||||
"base1.typ@1:11:1:13",
|
||||
"base2.typ@1:11:1:13",
|
||||
"base2.typ@3:11:3:13",
|
||||
|
|
|
|||
|
|
@ -4,5 +4,6 @@ expression: "JsonRepr::new_pure(result)"
|
|||
input_file: crates/tinymist-query/src/fixtures/references/label.typ
|
||||
---
|
||||
[
|
||||
"s0.typ@3:11:3:22",
|
||||
"s0.typ@5:1:5:12"
|
||||
]
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ expression: "JsonRepr::new_pure(result)"
|
|||
input_file: crates/tinymist-query/src/fixtures/references/ref_label.typ
|
||||
---
|
||||
[
|
||||
"s0.typ@3:11:3:22",
|
||||
"s0.typ@5:1:5:12",
|
||||
"s0.typ@7:22:7:33",
|
||||
"s0.typ@9:1:9:12"
|
||||
|
|
|
|||
|
|
@ -14,6 +14,11 @@ input_file: crates/tinymist-query/src/fixtures/rename/label.typ
|
|||
"documentChanges": [
|
||||
{
|
||||
"edits": [
|
||||
{
|
||||
"annotationId": "Typst Rename Labels",
|
||||
"newText": "new_name",
|
||||
"range": "4:11:4:22"
|
||||
},
|
||||
{
|
||||
"annotationId": "Typst Rename Labels",
|
||||
"newText": "new_name",
|
||||
|
|
|
|||
|
|
@ -18,6 +18,11 @@ input_file: crates/tinymist-query/src/fixtures/rename/label_content.typ
|
|||
"annotationId": "Typst Rename Labels",
|
||||
"newText": "new_name",
|
||||
"range": "4:22:4:31"
|
||||
},
|
||||
{
|
||||
"annotationId": "Typst Rename Labels",
|
||||
"newText": "new_name",
|
||||
"range": "3:17:3:26"
|
||||
}
|
||||
],
|
||||
"textDocument": {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,11 @@ input_file: crates/tinymist-query/src/fixtures/rename/label_indir.typ
|
|||
"annotationId": "Typst Rename Labels",
|
||||
"newText": "new_name",
|
||||
"range": "4:22:4:31"
|
||||
},
|
||||
{
|
||||
"annotationId": "Typst Rename Labels",
|
||||
"newText": "new_name",
|
||||
"range": "3:17:3:26"
|
||||
}
|
||||
],
|
||||
"textDocument": {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,11 @@ input_file: crates/tinymist-query/src/fixtures/rename/label_indir2.typ
|
|||
"annotationId": "Typst Rename Labels",
|
||||
"newText": "new_name",
|
||||
"range": "8:22:8:31"
|
||||
},
|
||||
{
|
||||
"annotationId": "Typst Rename Labels",
|
||||
"newText": "new_name",
|
||||
"range": "7:17:7:26"
|
||||
}
|
||||
],
|
||||
"textDocument": {
|
||||
|
|
|
|||
|
|
@ -399,10 +399,6 @@ impl ExprWorker<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_label(&mut self, label: ast::Label) -> Expr {
|
||||
Expr::Decl(Decl::label(label.get(), label.span()).into())
|
||||
}
|
||||
|
||||
fn check_element<T: NativeElement>(&mut self, content: EcoVec<Expr>) -> Expr {
|
||||
let elem = Element::of::<T>();
|
||||
Expr::Element(ElementExpr { elem, content }.into())
|
||||
|
|
@ -1105,6 +1101,21 @@ impl ExprWorker<'_> {
|
|||
Expr::Block(items.into())
|
||||
}
|
||||
|
||||
fn check_label(&mut self, label: ast::Label) -> Expr {
|
||||
let decl: Interned<Decl> = Decl::label(label.get(), label.span()).into();
|
||||
|
||||
self.resolve_as(
|
||||
RefExpr {
|
||||
decl: decl.clone(),
|
||||
step: None,
|
||||
root: None,
|
||||
term: None,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
Expr::Decl(decl)
|
||||
}
|
||||
|
||||
fn check_ref(&mut self, ref_node: ast::Ref) -> Expr {
|
||||
let ident = Interned::new(Decl::ref_(ref_node));
|
||||
let body = ref_node
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue