Various hover improvements (#5617)

* Show more info on hover for variables

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Move hover impls to lsp module

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Make hover work on names inside calls, fix doc line breaking, trim docs in tool tips

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Test the new hovers; fix signature syntax

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Hover tips for kwargs

Signed-off-by: Nick Cameron <nrc@ncameron.org>

---------

Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
Nick Cameron
2025-03-04 22:53:31 +13:00
committed by GitHub
parent 6e57a80c13
commit df278c7e6a
200 changed files with 7888 additions and 4459 deletions

View File

@ -60,76 +60,16 @@ mod test_examples_my_func {
);
Ok(())
}
#[tokio::test(flavor = "multi_thread")]
async fn test_mock_example_my_func1() -> miette::Result<()> {
let program =
crate::Program::parse_no_errs("This is code.\nIt does other shit.\nmyFunc").unwrap();
let ctx = crate::ExecutorContext {
engine: std::sync::Arc::new(Box::new(
crate::engine::conn_mock::EngineConnection::new()
.await
.unwrap(),
)),
fs: std::sync::Arc::new(crate::fs::FileManager::new()),
stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
settings: Default::default(),
context_type: crate::execution::ContextType::Mock,
};
if let Err(e) = ctx
.run(
&program,
&mut crate::execution::ExecState::new(&ctx.settings),
)
.await
{
return Err(miette::Report::new(crate::errors::Report {
error: e,
filename: format!("{}{}", "my_func", 1usize),
kcl_source: "This is code.\nIt does other shit.\nmyFunc".to_string(),
}));
}
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
async fn kcl_test_example_my_func1() -> miette::Result<()> {
let code = "This is code.\nIt does other shit.\nmyFunc";
let result = match crate::test_server::execute_and_snapshot(
code,
crate::settings::types::UnitLength::Mm,
None,
)
.await
{
Err(crate::errors::ExecError::Kcl(e)) => {
return Err(miette::Report::new(crate::errors::Report {
error: e.error,
filename: format!("{}{}", "my_func", 1usize),
kcl_source: "This is code.\nIt does other shit.\nmyFunc".to_string(),
}));
}
Err(other_err) => panic!("{}", other_err),
Ok(img) => img,
};
twenty_twenty::assert_image(
&format!("tests/outputs/{}.png", "serial_test_example_my_func1"),
&result,
0.99,
);
Ok(())
}
}
#[allow(non_camel_case_types, missing_docs)]
#[doc = "Std lib function: myFunc\nThis is some function.\nIt does shit."]
#[doc = "Std lib function: myFunc\nThis is some function. It does shit."]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, schemars :: JsonSchema, ts_rs :: TS)]
#[ts(export)]
pub(crate) struct MyFunc {}
#[allow(non_upper_case_globals, missing_docs)]
#[doc = "Std lib function: myFunc\nThis is some function.\nIt does shit."]
#[doc = "Std lib function: myFunc\nThis is some function. It does shit."]
pub(crate) const MyFunc: MyFunc = MyFunc {};
fn boxed_my_func(
exec_state: &mut crate::execution::ExecState,
@ -151,11 +91,11 @@ impl crate::docs::StdLibFn for MyFunc {
}
fn summary(&self) -> String {
"This is some function.".to_string()
"This is some function. It does shit.".to_string()
}
fn description(&self) -> String {
"It does shit.".to_string()
"".to_string()
}
fn tags(&self) -> Vec<String> {
@ -213,10 +153,7 @@ impl crate::docs::StdLibFn for MyFunc {
}
fn examples(&self) -> Vec<String> {
let code_blocks = vec![
"This is another code block.\nyes sirrr.\nmyFunc",
"This is code.\nIt does other shit.\nmyFunc",
];
let code_blocks = vec!["This is another code block.\nyes sirrr.\nmyFunc"];
code_blocks
.iter()
.map(|cb| {
@ -240,10 +177,6 @@ impl crate::docs::StdLibFn for MyFunc {
#[doc = r" This is some function."]
#[doc = r" It does shit."]
#[doc = r""]
#[doc = r" This is code."]
#[doc = r" It does other shit."]
#[doc = r" myFunc"]
#[doc = r""]
#[doc = r" ```"]
#[doc = r" This is another code block."]
#[doc = r" yes sirrr."]