feat: add path conversion actions for absolute and relative paths (#1696)

* feat: add path conversion actions for absolute and relative paths in special function call

* feat: implement matchers

* docs: edit comment

* fix: path on windows

* feat: add a comment

* dev: edit a bit

* dev: use `resolved`

* refactor: simplify path rewriting logic using `diff`

* feat: add absolute path import fixture

* fix: update path check for absolute paths to use `starts_with` to work with windows

* feat: add path expression import fixture

---------

Co-authored-by: Myriad-Dreamin <camiyoru@gmail.com>
This commit is contained in:
Luyan Zhou 2025-04-30 17:15:42 +08:00 committed by GitHub
parent 11cfb08be5
commit 6118b346d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 287 additions and 1 deletions

View file

@ -80,3 +80,29 @@ impl SemanticRequest for CodeActionRequest {
(!worker.actions.is_empty()).then_some(worker.actions)
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::tests::*;
#[test]
fn test() {
snapshot_testing("code_action", &|ctx, path| {
let source = ctx.source_by_path(&path).unwrap();
let request = CodeActionRequest {
path: path.clone(),
range: find_test_range(&source),
};
let result = request.request(ctx);
insta::with_settings!({
description => format!("Code Action on {})", make_range_annoation(&source)),
}, {
assert_snapshot!(JsonRepr::new_redacted(result, &REDACT_LOC));
})
});
}
}