diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 17dd00f95..4b8e63824 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -1815,7 +1815,7 @@ dependencies = [ [[package]] name = "kcl-bumper" -version = "0.1.71" +version = "0.1.72" dependencies = [ "anyhow", "clap", @@ -1826,7 +1826,7 @@ dependencies = [ [[package]] name = "kcl-derive-docs" -version = "0.1.71" +version = "0.1.72" dependencies = [ "Inflector", "anyhow", @@ -1845,7 +1845,7 @@ dependencies = [ [[package]] name = "kcl-directory-test-macro" -version = "0.1.71" +version = "0.1.72" dependencies = [ "proc-macro2", "quote", @@ -1854,7 +1854,7 @@ dependencies = [ [[package]] name = "kcl-language-server" -version = "0.2.71" +version = "0.2.72" dependencies = [ "anyhow", "clap", @@ -1875,7 +1875,7 @@ dependencies = [ [[package]] name = "kcl-language-server-release" -version = "0.1.71" +version = "0.1.72" dependencies = [ "anyhow", "clap", @@ -1895,7 +1895,7 @@ dependencies = [ [[package]] name = "kcl-lib" -version = "0.2.71" +version = "0.2.72" dependencies = [ "anyhow", "approx 0.5.1", @@ -1971,7 +1971,7 @@ dependencies = [ [[package]] name = "kcl-python-bindings" -version = "0.3.71" +version = "0.3.72" dependencies = [ "anyhow", "kcl-lib", @@ -1986,7 +1986,7 @@ dependencies = [ [[package]] name = "kcl-test-server" -version = "0.1.71" +version = "0.1.72" dependencies = [ "anyhow", "hyper 0.14.32", @@ -1999,7 +1999,7 @@ dependencies = [ [[package]] name = "kcl-to-core" -version = "0.1.71" +version = "0.1.72" dependencies = [ "anyhow", "async-trait", @@ -2013,7 +2013,7 @@ dependencies = [ [[package]] name = "kcl-wasm-lib" -version = "0.1.71" +version = "0.1.72" dependencies = [ "anyhow", "bson", diff --git a/rust/kcl-bumper/Cargo.toml b/rust/kcl-bumper/Cargo.toml index aeaafc7a5..f213f1130 100644 --- a/rust/kcl-bumper/Cargo.toml +++ b/rust/kcl-bumper/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "kcl-bumper" -version = "0.1.71" +version = "0.1.72" edition = "2021" repository = "https://github.com/KittyCAD/modeling-api" rust-version = "1.76" diff --git a/rust/kcl-derive-docs/Cargo.toml b/rust/kcl-derive-docs/Cargo.toml index 6388f414e..9a8555d8d 100644 --- a/rust/kcl-derive-docs/Cargo.toml +++ b/rust/kcl-derive-docs/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "kcl-derive-docs" description = "A tool for generating documentation from Rust derive macros" -version = "0.1.71" +version = "0.1.72" edition = "2021" license = "MIT" repository = "https://github.com/KittyCAD/modeling-app" diff --git a/rust/kcl-directory-test-macro/Cargo.toml b/rust/kcl-directory-test-macro/Cargo.toml index c67bb9292..051c09163 100644 --- a/rust/kcl-directory-test-macro/Cargo.toml +++ b/rust/kcl-directory-test-macro/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "kcl-directory-test-macro" description = "A tool for generating tests from a directory of kcl files" -version = "0.1.71" +version = "0.1.72" edition = "2021" license = "MIT" repository = "https://github.com/KittyCAD/modeling-app" diff --git a/rust/kcl-language-server-release/Cargo.toml b/rust/kcl-language-server-release/Cargo.toml index 0af30eb4f..0688819a2 100644 --- a/rust/kcl-language-server-release/Cargo.toml +++ b/rust/kcl-language-server-release/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kcl-language-server-release" -version = "0.1.71" +version = "0.1.72" edition = "2021" authors = ["KittyCAD Inc "] publish = false diff --git a/rust/kcl-language-server/Cargo.toml b/rust/kcl-language-server/Cargo.toml index 1f3e4822c..45f981906 100644 --- a/rust/kcl-language-server/Cargo.toml +++ b/rust/kcl-language-server/Cargo.toml @@ -2,7 +2,7 @@ name = "kcl-language-server" description = "A language server for KCL." authors = ["KittyCAD Inc "] -version = "0.2.71" +version = "0.2.72" edition = "2021" license = "MIT" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/rust/kcl-lib/Cargo.toml b/rust/kcl-lib/Cargo.toml index 72dc70387..4ad3dfe5d 100644 --- a/rust/kcl-lib/Cargo.toml +++ b/rust/kcl-lib/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "kcl-lib" description = "KittyCAD Language implementation and tools" -version = "0.2.71" +version = "0.2.72" edition = "2021" license = "MIT" repository = "https://github.com/KittyCAD/modeling-app" diff --git a/rust/kcl-lib/src/lsp/tests.rs b/rust/kcl-lib/src/lsp/tests.rs index 5a0558287..de89e8078 100644 --- a/rust/kcl-lib/src/lsp/tests.rs +++ b/rust/kcl-lib/src/lsp/tests.rs @@ -4316,3 +4316,64 @@ sketch001 = startSketchOn(XY) }] ); } + +#[tokio::test(flavor = "multi_thread")] +async fn test_kcl_lsp_diagnostic_compilation_warnings() { + let server = kcl_lsp_server(false).await.unwrap(); + + // Send open file. + server + .did_open(tower_lsp::lsp_types::DidOpenTextDocumentParams { + text_document: tower_lsp::lsp_types::TextDocumentItem { + uri: "file:///test.kcl".try_into().unwrap(), + language_id: "kcl".to_string(), + version: 1, + text: r#"foo = 42 +@settings(defaultLengthUnit = mm)"# + .to_string(), + }, + }) + .await; + + // Send diagnostics request. + let diagnostics = server + .diagnostic(tower_lsp::lsp_types::DocumentDiagnosticParams { + text_document: tower_lsp::lsp_types::TextDocumentIdentifier { + uri: "file:///test.kcl".try_into().unwrap(), + }, + partial_result_params: Default::default(), + work_done_progress_params: Default::default(), + identifier: None, + previous_result_id: None, + }) + .await + .unwrap(); + + // Check the diagnostics. + if let tower_lsp::lsp_types::DocumentDiagnosticReportResult::Report(diagnostics) = diagnostics { + if let tower_lsp::lsp_types::DocumentDiagnosticReport::Full(diagnostics) = diagnostics { + assert_eq!(diagnostics.full_document_diagnostic_report.items.len(), 1); + assert_eq!( + diagnostics.full_document_diagnostic_report.items[0], + tower_lsp::lsp_types::Diagnostic { + range: tower_lsp::lsp_types::Range { + start: tower_lsp::lsp_types::Position { line: 0, character: 8 }, + end: tower_lsp::lsp_types::Position { line: 1, character: 33 }, + }, + severity: Some(tower_lsp::lsp_types::DiagnosticSeverity::WARNING), + code: None, + source: Some("kcl".to_string()), + message: "Named attributes should appear before any declarations or expressions.\n\nBecause named attributes apply to the whole function or module, including code written before them, it can be confusing for readers to not have these attributes at the top of code blocks.".to_string(), + related_information: None, + tags: None, + data: None, + code_description: None, + } + ); + } else { + panic!("Expected full diagnostics"); + } + } else { + panic!("Expected diagnostics"); + } +} diff --git a/rust/kcl-python-bindings/Cargo.toml b/rust/kcl-python-bindings/Cargo.toml index 431b88519..6dad7af7d 100644 --- a/rust/kcl-python-bindings/Cargo.toml +++ b/rust/kcl-python-bindings/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kcl-python-bindings" -version = "0.3.71" +version = "0.3.72" edition = "2021" repository = "https://github.com/kittycad/modeling-app" exclude = ["tests/*", "files/*", "venv/*"] diff --git a/rust/kcl-python-bindings/src/lib.rs b/rust/kcl-python-bindings/src/lib.rs index ba5ef0d96..a3e47bfbd 100644 --- a/rust/kcl-python-bindings/src/lib.rs +++ b/rust/kcl-python-bindings/src/lib.rs @@ -229,7 +229,7 @@ async fn new_context_state(current_file: Option) -> Result<( /// Parse the kcl code from a file path. #[pyfunction] -async fn parse(path: String) -> PyResult<()> { +async fn parse(path: String) -> PyResult { tokio() .spawn(async move { let (code, path) = get_code_and_file_path(&path) @@ -238,7 +238,7 @@ async fn parse(path: String) -> PyResult<()> { let _program = kcl_lib::Program::parse_no_errs(&code) .map_err(|err| into_miette_for_parse(&path.display().to_string(), &code, err))?; - Ok(()) + Ok(true) }) .await .map_err(|err| pyo3::exceptions::PyException::new_err(err.to_string()))? @@ -246,10 +246,10 @@ async fn parse(path: String) -> PyResult<()> { /// Parse the kcl code. #[pyfunction] -fn parse_code(code: String) -> PyResult<()> { +fn parse_code(code: String) -> PyResult { let _program = kcl_lib::Program::parse_no_errs(&code).map_err(|err| into_miette_for_parse("", &code, err))?; - Ok(()) + Ok(true) } /// Execute the kcl code from a file path. diff --git a/rust/kcl-python-bindings/tests/tests.py b/rust/kcl-python-bindings/tests/tests.py index c31bb8249..f11fb79f5 100755 --- a/rust/kcl-python-bindings/tests/tests.py +++ b/rust/kcl-python-bindings/tests/tests.py @@ -53,7 +53,8 @@ async def test_kcl_parse_with_exception(): @pytest.mark.asyncio async def test_kcl_parse(): # Read from a file. - await kcl.parse(lego_file) + result = await kcl.parse(lego_file) + assert result is True @pytest.mark.asyncio @@ -63,7 +64,8 @@ async def test_kcl_parse_code(): code = str(f.read()) assert code is not None assert len(code) > 0 - kcl.parse_code(code) + result = kcl.parse_code(code) + assert result is True @pytest.mark.asyncio diff --git a/rust/kcl-test-server/Cargo.toml b/rust/kcl-test-server/Cargo.toml index 48d2795bf..43c9b7008 100644 --- a/rust/kcl-test-server/Cargo.toml +++ b/rust/kcl-test-server/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "kcl-test-server" description = "A test server for KCL" -version = "0.1.71" +version = "0.1.72" edition = "2021" license = "MIT" diff --git a/rust/kcl-to-core/Cargo.toml b/rust/kcl-to-core/Cargo.toml index 73a7b54a9..5bc9b6232 100644 --- a/rust/kcl-to-core/Cargo.toml +++ b/rust/kcl-to-core/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "kcl-to-core" description = "Utility methods to convert kcl to engine core executable tests" -version = "0.1.71" +version = "0.1.72" edition = "2021" license = "MIT" repository = "https://github.com/KittyCAD/modeling-app" diff --git a/rust/kcl-wasm-lib/Cargo.toml b/rust/kcl-wasm-lib/Cargo.toml index df387f9f6..e2f4eedc0 100644 --- a/rust/kcl-wasm-lib/Cargo.toml +++ b/rust/kcl-wasm-lib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kcl-wasm-lib" -version = "0.1.71" +version = "0.1.72" edition = "2021" repository = "https://github.com/KittyCAD/modeling-app" rust-version = "1.83"