diff --git a/source/ada/lsp-ada_handlers.ads b/source/ada/lsp-ada_handlers.ads index b8192b2d..98543cb7 100644 --- a/source/ada/lsp-ada_handlers.ads +++ b/source/ada/lsp-ada_handlers.ads @@ -428,6 +428,7 @@ private overriding function Project_Tree_Is_Aggregate (Self : Message_Handler) return Boolean is (Self.Project_Tree_Is_Defined + and then Self.Project_Tree.Root_Project.Is_Defined and then Self.Project_Tree.Root_Project.Kind in GPR2.Aggregate_Kind); overriding procedure Reload_Project (Self : in out Message_Handler); diff --git a/testsuite/ada_lsp/hover.no_root_project/default.gpr b/testsuite/ada_lsp/hover.no_root_project/default.gpr new file mode 100644 index 00000000..7d34c924 --- /dev/null +++ b/testsuite/ada_lsp/hover.no_root_project/default.gpr @@ -0,0 +1,6 @@ +-- Include a project that does not exist so that +-- it fails to load in the ALS. +with "unexisting"; + +project Default is +end Default; \ No newline at end of file diff --git a/testsuite/ada_lsp/hover.no_root_project/main.adb b/testsuite/ada_lsp/hover.no_root_project/main.adb new file mode 100644 index 00000000..3330efd6 --- /dev/null +++ b/testsuite/ada_lsp/hover.no_root_project/main.adb @@ -0,0 +1,6 @@ +with Ada.Text_IO; + +procedure Main is +begin + Ada.Text_IO.Put_Line ("Hello"); +end Main; diff --git a/testsuite/ada_lsp/hover.no_root_project/test.json b/testsuite/ada_lsp/hover.no_root_project/test.json new file mode 100644 index 00000000..7acf4888 --- /dev/null +++ b/testsuite/ada_lsp/hover.no_root_project/test.json @@ -0,0 +1,138 @@ +[ + { + "comment": [ + "This test checks that the textDocument/hover request does not crash ", + "even when the project could not be loaded properly." + ] + }, + { + "start": { + "cmd": ["${ALS}"] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": 0, + "method": "initialize", + "params": { + "processId": 1, + "rootUri": "$URI{.}", + "capabilities": {} + } + }, + "wait": [ + { + "id": 0, + "result": { + "capabilities": { + "textDocumentSync": 2 + } + } + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "initialized" + }, + "wait": [] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "workspace/didChangeConfiguration", + "params": { + "settings": { + "ada": { + "projectFile": "$URI{default.gpr}", + "scenarioVariables": {}, + "defaultCharset": "ISO-8859-1", + "enableDiagnostics": false, + "followSymlinks": false, + "documentationStyle": "gnat", + "namedNotationThreshold": 3, + "foldComments": false + } + } + } + }, + "wait": [] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "$URI{main.adb}", + "languageId": "Ada", + "version": 0, + "text": "with Ada.Text_IO;\n\nprocedure Main is\n\nbegin Ada.Text_IO.Put_Line (\"Hello\");\nend Main;\n" + } + } + }, + "wait": [] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": 4, + "method": "textDocument/hover", + "params": { + "textDocument": { + "uri": "$URI{main.adb}" + }, + "position": { + "line": 0, + "character": 12 + } + } + }, + "wait": [ + { + "id": 4, + "result": { + "contents": [ + "", + { + "language": "ada", + "value": "package Ada.Text_IO" + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": 7, + "method": "shutdown" + }, + "wait": [ + { + "id": 7, + "result": null + } + ] + } + }, + { + "stop": { + "exit_code": 0 + } + } +] diff --git a/testsuite/ada_lsp/hover.no_root_project/test.yaml b/testsuite/ada_lsp/hover.no_root_project/test.yaml new file mode 100644 index 00000000..d4f84e97 --- /dev/null +++ b/testsuite/ada_lsp/hover.no_root_project/test.yaml @@ -0,0 +1 @@ +title: 'hover.no_root_project'