BREAKING: KCL @settings are the source of truth for units (#5808)

This commit is contained in:
Jonathan Tran
2025-03-31 10:56:03 -04:00
committed by GitHub
parent eac5abba79
commit efc8c82d8b
237 changed files with 820 additions and 2146 deletions

View File

@ -69,7 +69,6 @@ pub async fn lsp_run_kcl(config: LspServerConfig, token: String, baseurl: String
let (service, socket) = LspService::build(|client| {
kcl_lib::KclLspBackend::new_wasm(client, executor_ctx, fs, zoo_client, can_send_telemetry).unwrap()
})
.custom_method("kcl/updateUnits", kcl_lib::KclLspBackend::update_units)
.custom_method("kcl/updateCanExecute", kcl_lib::KclLspBackend::update_can_execute)
.finish();

View File

@ -269,6 +269,17 @@ pub fn change_kcl_settings(code: &str, settings_str: &str) -> Result<String, Str
Ok(formatted)
}
/// Returns true if the given KCL is empty or only contains settings that would
/// be auto-generated.
#[wasm_bindgen]
pub fn is_kcl_empty_or_only_settings(code: &str) -> Result<JsValue, String> {
console_error_panic_hook::set_once();
let program = Program::parse_no_errs(code).map_err(|e| e.to_string())?;
JsValue::from_serde(&program.is_empty_or_only_settings()).map_err(|e| e.to_string())
}
/// Get the version of the kcl library.
#[wasm_bindgen]
pub fn get_kcl_version() -> String {