mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-07-19 02:35:00 +00:00
feat: analyze lexical hierarchy for def-use relations (#17)
This commit is contained in:
parent
f8194c76b0
commit
ee131ac68a
18 changed files with 637 additions and 230 deletions
|
@ -209,16 +209,18 @@ mod tests {
|
|||
for (i, source) in sources.enumerate() {
|
||||
// find prelude
|
||||
let mut source = source.trim();
|
||||
let path = if source.starts_with("//") {
|
||||
let mut path = None;
|
||||
|
||||
if source.starts_with("//") {
|
||||
let first_line = source.lines().next().unwrap();
|
||||
source = source.strip_prefix(first_line).unwrap().trim();
|
||||
|
||||
let content = first_line.strip_prefix("//").unwrap().trim();
|
||||
content.strip_prefix("path:").unwrap().trim().to_owned()
|
||||
} else {
|
||||
format!("/source{i}.typ")
|
||||
path = content.strip_prefix("path:").map(|e| e.trim().to_owned())
|
||||
};
|
||||
|
||||
let path = path.unwrap_or_else(|| format!("/source{i}.typ"));
|
||||
|
||||
let pw = root.join(Path::new(&path));
|
||||
world
|
||||
.map_shadow(&pw, Bytes::from(source.as_bytes()))
|
||||
|
@ -316,7 +318,11 @@ mod tests {
|
|||
}
|
||||
|
||||
fn pos(v: &Value) -> String {
|
||||
format!("{}:{}", v["line"], v["character"])
|
||||
match v {
|
||||
Value::Object(v) => format!("{}:{}", v["line"], v["character"]),
|
||||
Value::Number(v) => v.to_string(),
|
||||
_ => "<null>".to_owned(),
|
||||
}
|
||||
}
|
||||
|
||||
impl Redact for RedactFields {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue