From 2f620db1d894533a8e859843b840801bf54cd86c Mon Sep 17 00:00:00 2001 From: HolonProduction Date: Fri, 15 Nov 2024 19:32:00 +0100 Subject: LSP: Fix spec violations that break the VSCode outline --- .../tests/scripts/lsp/first_line_comment.gd | 2 ++ modules/gdscript/tests/test_lsp.h | 31 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 modules/gdscript/tests/scripts/lsp/first_line_comment.gd (limited to 'modules/gdscript/tests') diff --git a/modules/gdscript/tests/scripts/lsp/first_line_comment.gd b/modules/gdscript/tests/scripts/lsp/first_line_comment.gd new file mode 100644 index 0000000000..34ead5fabb --- /dev/null +++ b/modules/gdscript/tests/scripts/lsp/first_line_comment.gd @@ -0,0 +1,2 @@ +# Some comment +extends Node diff --git a/modules/gdscript/tests/test_lsp.h b/modules/gdscript/tests/test_lsp.h index b85c727bc5..b49f6cce4d 100644 --- a/modules/gdscript/tests/test_lsp.h +++ b/modules/gdscript/tests/test_lsp.h @@ -375,6 +375,18 @@ func f(): gd.to_lsp(lines); } + SUBCASE("special case: zero column for root class") { + GodotPosition gd(1, 0); + lsp::Position expected = lsp_pos(0, 0); + lsp::Position actual = gd.to_lsp(lines); + CHECK_EQ(actual, expected); + } + SUBCASE("special case: zero line and column for root class") { + GodotPosition gd(0, 0); + lsp::Position expected = lsp_pos(0, 0); + lsp::Position actual = gd.to_lsp(lines); + CHECK_EQ(actual, expected); + } SUBCASE("special case: negative line for root class") { GodotPosition gd(-1, 0); lsp::Position expected = lsp_pos(0, 0); @@ -468,6 +480,25 @@ func f(): test_resolve_symbols(uri, all_test_data, all_test_data); } + memdelete(proto); + finish_language(); + } + TEST_CASE("[workspace][document_symbol]") { + GDScriptLanguageProtocol *proto = initialize(root); + REQUIRE(proto); + + SUBCASE("selectionRange of root class must be inside range") { + String path = "res://lsp/first_line_comment.gd"; + assert_no_errors_in(path); + GDScriptLanguageProtocol::get_singleton()->get_workspace()->parse_local_script(path); + ExtendGDScriptParser *parser = GDScriptLanguageProtocol::get_singleton()->get_workspace()->parse_results[path]; + REQUIRE(parser); + lsp::DocumentSymbol cls = parser->get_symbols(); + + REQUIRE(((cls.range.start.line == cls.selectionRange.start.line && cls.range.start.character <= cls.selectionRange.start.character) || (cls.range.start.line < cls.selectionRange.start.line))); + REQUIRE(((cls.range.end.line == cls.selectionRange.end.line && cls.range.end.character >= cls.selectionRange.end.character) || (cls.range.end.line > cls.selectionRange.end.line))); + } + memdelete(proto); finish_language(); } -- cgit v1.2.3 From f2f48aaf36507bb1ade6261905296bfd560e921d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Fri, 22 Nov 2024 21:25:32 +0100 Subject: Fix stringification of Projection --- modules/gdscript/tests/scripts/runtime/features/stringify.gd | 1 + modules/gdscript/tests/scripts/runtime/features/stringify.out | 1 + 2 files changed, 2 insertions(+) (limited to 'modules/gdscript/tests') diff --git a/modules/gdscript/tests/scripts/runtime/features/stringify.gd b/modules/gdscript/tests/scripts/runtime/features/stringify.gd index 463d207e59..69aecec6a8 100644 --- a/modules/gdscript/tests/scripts/runtime/features/stringify.gd +++ b/modules/gdscript/tests/scripts/runtime/features/stringify.gd @@ -22,6 +22,7 @@ func test(): print(AABB(Vector3.ZERO, Vector3.ONE)) print(Basis.from_euler(Vector3(0, 0, 0))) print(Transform3D.IDENTITY) + print(Projection.IDENTITY) print(Color(1, 2, 3, 4)) print(StringName("hello")) diff --git a/modules/gdscript/tests/scripts/runtime/features/stringify.out b/modules/gdscript/tests/scripts/runtime/features/stringify.out index 9983366db0..b044f8105d 100644 --- a/modules/gdscript/tests/scripts/runtime/features/stringify.out +++ b/modules/gdscript/tests/scripts/runtime/features/stringify.out @@ -17,6 +17,7 @@ hello world [P: (0.0, 0.0, 0.0), S: (1.0, 1.0, 1.0)] [X: (1.0, 0.0, 0.0), Y: (0.0, 1.0, 0.0), Z: (0.0, 0.0, 1.0)] [X: (1.0, 0.0, 0.0), Y: (0.0, 1.0, 0.0), Z: (0.0, 0.0, 1.0), O: (0.0, 0.0, 0.0)] +[X: (1.0, 0.0, 0.0, 0.0), Y: (0.0, 1.0, 0.0, 0.0), Z: (0.0, 0.0, 1.0, 0.0), W: (0.0, 0.0, 0.0, 1.0)] (1.0, 2.0, 3.0, 4.0) hello hello/world -- cgit v1.2.3