diff --git a/source/gpr/lsp-gpr_documents.adb b/source/gpr/lsp-gpr_documents.adb index d7dbacadd..bb011c327 100644 --- a/source/gpr/lsp-gpr_documents.adb +++ b/source/gpr/lsp-gpr_documents.adb @@ -15,7 +15,10 @@ -- of the license. -- ------------------------------------------------------------------------------ +with Ada.Exceptions; + with GPR2.Message; +with GPR2.Source_Reference; package body LSP.GPR_Documents is @@ -171,12 +174,26 @@ package body LSP.GPR_Documents is Update_Diagnostics; exception + when GPR2.Project_Error | GPR2.Processing_Error => + + Update_Diagnostics; + when E : others => Self.Tracer.Trace_Exception (E); - Update_Diagnostics; + Self.Tree.Log_Messages.Append + (GPR2.Message.Create + (Level => GPR2.Message.Error, + Message => "GPR parser unexpected " & + Ada.Exceptions.Exception_Name (E) & " " & + Ada.Exceptions.Exception_Message (E), + Sloc => GPR2.Source_Reference.Create + (Filename => Self.File.Value, + Line => 1, + Column => 1))); + Update_Diagnostics; end Load; ----------------------------- diff --git a/source/gpr/lsp-gpr_external_tools.adb b/source/gpr/lsp-gpr_external_tools.adb index 0ee5164a0..2bbef17a2 100644 --- a/source/gpr/lsp-gpr_external_tools.adb +++ b/source/gpr/lsp-gpr_external_tools.adb @@ -1,7 +1,7 @@ ------------------------------------------------------------------------------ -- Language Server Protocol -- -- -- --- Copyright (C) 2023, AdaCore -- +-- Copyright (C) 2023-2024, AdaCore -- -- -- -- This is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -184,7 +184,7 @@ package body LSP.GPR_External_Tools is Inherit_From_Extended => Inherit_From_Extended, Is_Set => Is_Set); end if; - if Get_Attribute_Description (Name)'Length > 0 + if Get_Attribute_Description (Name)'Length = 0 and then Description'Length > 0 then Set_Attribute_Description (Name, Description); diff --git a/source/gpr/lsp-gpr_files.adb b/source/gpr/lsp-gpr_files.adb index eb6deaa69..ce730febb 100644 --- a/source/gpr/lsp-gpr_files.adb +++ b/source/gpr/lsp-gpr_files.adb @@ -468,12 +468,47 @@ package body LSP.GPR_Files is package LKD renames LSP.Text_Documents.Langkit_Documents; + function To_Valid_Name + (Name : VSS.Strings.Virtual_String) + return VSS.Strings.Virtual_String; + -- Avoid empty Name, set Name to " " when required. + + procedure Append_New_To_Current (New_Symbol : Symbol); + -- Append New_Symbol to current list. + + --------------------------- + -- Append_New_To_Current -- + --------------------------- + + procedure Append_New_To_Current (New_Symbol : Symbol) is + begin + Current_Symbols.Append (New_Symbol); + end Append_New_To_Current; + + ------------------- + -- To_Valid_Name -- + ------------------- + + function To_Valid_Name + (Name : VSS.Strings.Virtual_String) + return VSS.Strings.Virtual_String is + + begin + if Name.Is_Empty + then + -- avoid name: "", in documentSymbol. + return " "; + else + return Name; + end if; + end To_Valid_Name; + New_Symbol : Symbol := (New_Id, Current_Symbol.Id, Token.Ref, Kind, - Name, + To_Valid_Name (Name), LKD.To_A_Range (Start_Line_Text => File.Get_Line (Location_Range.Start_Line), @@ -489,18 +524,6 @@ package body LSP.GPR_Files is LK_Slocs.Column_Number (Location_Range.End_Column)))); - procedure Append_New_To_Current (New_Symbol : Symbol); - -- Append New_Symbol to current list. - - --------------------------- - -- Append_New_To_Current -- - --------------------------- - - procedure Append_New_To_Current (New_Symbol : Symbol) is - begin - Current_Symbols.Append (New_Symbol); - end Append_New_To_Current; - begin case Kind is when K_Imported => @@ -1466,6 +1489,10 @@ package body LSP.GPR_Files is else return Path_Name.Undefined; end if; + exception + when E : others => + File.Tracer.Trace_Exception (E); + return Path_Name.Undefined; end Get_Referenced_GPR; end LSP.GPR_Files; diff --git a/source/gpr/lsp-gpr_files.ads b/source/gpr/lsp-gpr_files.ads index 185929bd9..8c061a219 100644 --- a/source/gpr/lsp-gpr_files.ads +++ b/source/gpr/lsp-gpr_files.ads @@ -112,6 +112,10 @@ package LSP.GPR_Files is return LSP.Structures.DocumentUri is abstract; -- Turn GPR2 path object into URI. + function Tracer + (Self : access File_Provider) + return LSP.Tracers.Tracer_Access is abstract; + procedure Initialize (Self : in out File; Path : GPR2.Path_Name.Object; diff --git a/source/gpr/lsp-gpr_handlers.ads b/source/gpr/lsp-gpr_handlers.ads index b5a858e7d..bcdd6477d 100644 --- a/source/gpr/lsp-gpr_handlers.ads +++ b/source/gpr/lsp-gpr_handlers.ads @@ -242,4 +242,9 @@ private Document : not null LSP.GPR_Documents.Document_Access); -- Publish diagnostic messages for given document if needed + overriding function Tracer + (Self : access Message_Handler) + return LSP.Tracers.Tracer_Access is + (Self.Tracer); + end LSP.GPR_Handlers; diff --git a/testsuite/gpr_lsp/gpr2_assertions/test.json b/testsuite/gpr_lsp/gpr2_assertions/test.json index ac7c3a206..bba9dcc07 100644 --- a/testsuite/gpr_lsp/gpr2_assertions/test.json +++ b/testsuite/gpr_lsp/gpr2_assertions/test.json @@ -82,6 +82,20 @@ "params": { "uri": "$URI{prj.gpr}", "diagnostics": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "severity": 1, + "message": "GPR parser unexpected ADA.ASSERTIONS.ASSERTION_ERROR DYNAMIC_PREDICATE failed at gpr2-message.adb:23" + } ] } } diff --git a/testsuite/gpr_lsp/gpr2_unexpected_exceptions/prj.gpr b/testsuite/gpr_lsp/gpr2_unexpected_exceptions/prj.gpr new file mode 100644 index 000000000..2b1cb0505 --- /dev/null +++ b/testsuite/gpr_lsp/gpr2_unexpected_exceptions/prj.gpr @@ -0,0 +1,12 @@ +with ""; +project Prj is + for Source_List_File use ""; + for Excluded_Source_List_File use ""; + for Warning_Message use ""; + package Naming is + for Body ("Ada") use "" ; + for Implementation ("Ada") use ""; + for Spec ("Ada") use ""; + for Specification ("Ada") use ""; + end Naming; +end Prj; diff --git a/testsuite/gpr_lsp/gpr2_unexpected_exceptions/test.json b/testsuite/gpr_lsp/gpr2_unexpected_exceptions/test.json new file mode 100644 index 000000000..a2571627e --- /dev/null +++ b/testsuite/gpr_lsp/gpr2_unexpected_exceptions/test.json @@ -0,0 +1,136 @@ +[ + { + "comment": [ + "test gpr unexpected exception handling" + ] + }, + { + "start": { + "cmd": [ + "${ALS}", + "--language-gpr" + ] + } + }, + { + "send": { + "request": { + "params": { + "processId": 30612, + "capabilities": { + "workspace": { + "applyEdit": false + } + }, + "rootUri": "$URI{.}" + }, + "jsonrpc": "2.0", + "id": 1, + "method": "initialize" + }, + "wait": [ + { + "jsonrpc": "2.0", + "id": 1, + "result": { + "capabilities": { + "textDocumentSync": { + "openClose": true, + "change": 1 + }, + "completionProvider": { + "triggerCharacters": [ + " " + ], + "resolveProvider": true + }, + "hoverProvider": true, + "definitionProvider": true, + "documentSymbolProvider": {} + } + } + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "initialized" + }, + "wait": [] + } + }, + { + "send": { + "request": { + "params": { + "textDocument": { + "text": "with \"\";\nproject Prj is\n for Source_List_File use \"\";\n for Excluded_Source_List_File use \"\";\n for Warning_Message use \"\";\n package Naming is\n for Body (\"Ada\") use \"\" ;\n for Implementation (\"Ada\") use \"\";\n for Spec (\"Ada\") use \"\";\n for Specification (\"Ada\") use \"\";\n end Naming;\nend Prj;", + "version": 0, + "uri": "$URI{prj.gpr}", + "languageId": "Gpr" + } + }, + "jsonrpc": "2.0", + "method": "textDocument/didOpen" + }, + "wait": [ + { + "jsonrpc": "2.0", + "method": "textDocument/publishDiagnostics", + "params": { + "uri": "$URI{prj.gpr}", + "diagnostics": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "severity": 1, + "message": "GPR parser unexpected ADA.ASSERTIONS.ASSERTION_ERROR DYNAMIC_PREDICATE failed at gpr2-project-parser.adb:83" + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": "shutdown", + "method": "shutdown", + "params": null + }, + "wait": [ + { + "id": "shutdown", + "result": null + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "exit" + }, + "wait": [] + } + }, + { + "stop": { + "exit_code": 0 + } + } +] \ No newline at end of file diff --git a/testsuite/gpr_lsp/gpr2_unexpected_exceptions/test.yaml b/testsuite/gpr_lsp/gpr2_unexpected_exceptions/test.yaml new file mode 100644 index 000000000..562a94ed2 --- /dev/null +++ b/testsuite/gpr_lsp/gpr2_unexpected_exceptions/test.yaml @@ -0,0 +1 @@ +title: 'gpr2 parsing assertions error handling' diff --git a/testsuite/gpr_lsp/hover/prj1.gpr b/testsuite/gpr_lsp/hover/prj1.gpr index 78029f632..80b3de97c 100644 --- a/testsuite/gpr_lsp/hover/prj1.gpr +++ b/testsuite/gpr_lsp/hover/prj1.gpr @@ -3,4 +3,7 @@ for Source_Dirs use ("src"); package Compiler is for Switches ("Ada") use (); end Compiler; +package IDE is +for Artifacts_Dir use ""; +end IDE; end Prj1; \ No newline at end of file diff --git a/testsuite/gpr_lsp/hover/test.json b/testsuite/gpr_lsp/hover/test.json index b21e3c784..54c08e1b9 100644 --- a/testsuite/gpr_lsp/hover/test.json +++ b/testsuite/gpr_lsp/hover/test.json @@ -149,7 +149,7 @@ "uri":"$URI{prj1.gpr}", "languageId":"Gpr", "version":1, - "text":"project Prj1 is\nfor Source_Dirs use (\"src\");\npackage Compiler is\nfor Switches (\"Ada\") use ();\nend Compiler;\nend Prj1;" + "text":"project Prj1 is\nfor Source_Dirs use (\"src\");\npackage Compiler is\nfor Switches (\"Ada\") use ();\nend Compiler;\npackage IDE is\nfor Artifacts_Dir use \"\";\nend IDE;\nend Prj1;" } } }, @@ -330,6 +330,68 @@ ] } }, + { + "send":{ + "request":{ + "params":{ + "position":{ + "line":5, + "character":8 + }, + "textDocument":{ + "uri":"$URI{prj1.gpr}" + } + }, + "jsonrpc":"2.0", + "id":7, + "method":"textDocument/hover" + }, + "wait":[ + { + "id":7, + "result":{ + "contents":[ + { + "language": "plaintext", + "value": "This package specifies the options used by 'gnatstudio' IDE." + } + ] + } + } + ] + } + }, + { + "send":{ + "request":{ + "params":{ + "position":{ + "line":6, + "character":9 + }, + "textDocument":{ + "uri":"$URI{prj1.gpr}" + } + }, + "jsonrpc":"2.0", + "id":8, + "method":"textDocument/hover" + }, + "wait":[ + { + "id":8, + "result":{ + "contents":[ + { + "language": "plaintext", + "value": "The directory in which the files generated by 'gnatstudio' for this project (cross-references database, locations etc.) are stored by default. Defaults to Object_Dir if not specified." + } + ] + } + } + ] + } + }, { "send":{ "request":{ diff --git a/testsuite/gpr_lsp/import_using_space_string/others/prj.gpr b/testsuite/gpr_lsp/import_using_space_string/others/prj.gpr new file mode 100644 index 000000000..4588a6fc0 --- /dev/null +++ b/testsuite/gpr_lsp/import_using_space_string/others/prj.gpr @@ -0,0 +1,3 @@ +with " "; +project Prj is +end Prj; \ No newline at end of file diff --git a/testsuite/gpr_lsp/import_using_space_string/others/test.json b/testsuite/gpr_lsp/import_using_space_string/others/test.json new file mode 100644 index 000000000..9198c98e9 --- /dev/null +++ b/testsuite/gpr_lsp/import_using_space_string/others/test.json @@ -0,0 +1,254 @@ +[ + { + "comment": [ + "check with \" \"; support" + ] + }, + { + "start": { + "cmd": [ + "${ALS}", + "--language-gpr" + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": "init", + "method": "initialize", + "params": { + "processId": 441587, + "rootUri": "$URI{.}", + "capabilities": { + "workspace": { + "applyEdit": true, + "workspaceEdit": {}, + "didChangeConfiguration": {}, + "didChangeWatchedFiles": {}, + "executeCommand": {} + }, + "textDocument": { + "synchronization": {}, + "completion": { + "dynamicRegistration": true, + "completionItem": { + "snippetSupport": true, + "documentationFormat": [ + "plaintext", + "markdown" + ] + } + }, + "hover": {}, + "definition": {}, + "documentSymbol": { + "hierarchicalDocumentSymbolSupport": true + } + } + } + } + }, + "wait": [ + { + "jsonrpc": "2.0", + "id": "init", + "result": { + "capabilities": { + "textDocumentSync": { + "openClose": true, + "change": 1 + }, + "completionProvider": { + "triggerCharacters": [ + " " + ], + "resolveProvider": true + }, + "hoverProvider": true, + "definitionProvider": true, + "documentSymbolProvider": {} + } + } + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "initialized" + }, + "wait": [] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "$URI{prj.gpr}", + "languageId": "gpr", + "version": 1, + "text": "with \" \";\nproject Prj is\nend Prj;" + } + } + }, + "wait": [ + { + "jsonrpc": "2.0", + "method": "textDocument/publishDiagnostics", + "params": { + "uri": "$URI{prj.gpr}", + "diagnostics": [ + { + "range": { + "start": { + "line": 0, + "character": 5 + }, + "end": { + "line": 0, + "character": 5 + } + }, + "severity": 1, + "message": "imported project file \" .gpr\" not found" + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": "textDocument/documentSymbol_prj_1", + "method": "textDocument/documentSymbol", + "params": { + "textDocument": { + "uri": "$URI{prj.gpr}" + } + } + }, + "wait": [ + { + "jsonrpc": "2.0", + "id": "textDocument/documentSymbol_prj_1", + "result": [ + { + "name": "with clauses", + "kind": 3, + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "selectionRange": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "children": [ + { + "name": " ", + "kind": 3, + "range": { + "start": { + "line": 0, + "character": 5 + }, + "end": { + "line": 0, + "character": 8 + } + }, + "selectionRange": { + "start": { + "line": 0, + "character": 5 + }, + "end": { + "line": 0, + "character": 8 + } + } + } + ] + }, + { + "name": "Prj", + "kind": 2, + "range": { + "start": { + "line": 1, + "character": 0 + }, + "end": { + "line": 1, + "character": 7 + } + }, + "selectionRange": { + "start": { + "line": 1, + "character": 0 + }, + "end": { + "line": 1, + "character": 7 + } + } + } + ] + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": "shutdown", + "method": "shutdown", + "params": null + }, + "wait": [ + { + "id": "shutdown", + "result": null + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "exit" + }, + "wait": [] + } + }, + { + "stop": { + "exit_code": 0 + } + } +] \ No newline at end of file diff --git a/testsuite/gpr_lsp/import_using_space_string/others/test.yaml b/testsuite/gpr_lsp/import_using_space_string/others/test.yaml new file mode 100644 index 000000000..56ea3d85b --- /dev/null +++ b/testsuite/gpr_lsp/import_using_space_string/others/test.yaml @@ -0,0 +1,3 @@ +title: 'check with " "; support' +skip: + - ['SKIP', 'env.build.os.name in ("windows")'] \ No newline at end of file diff --git a/testsuite/gpr_lsp/import_using_space_string/windows/prj.gpr b/testsuite/gpr_lsp/import_using_space_string/windows/prj.gpr new file mode 100644 index 000000000..4588a6fc0 --- /dev/null +++ b/testsuite/gpr_lsp/import_using_space_string/windows/prj.gpr @@ -0,0 +1,3 @@ +with " "; +project Prj is +end Prj; \ No newline at end of file diff --git a/testsuite/gpr_lsp/import_using_space_string/windows/test.json b/testsuite/gpr_lsp/import_using_space_string/windows/test.json new file mode 100644 index 000000000..90cff16e2 --- /dev/null +++ b/testsuite/gpr_lsp/import_using_space_string/windows/test.json @@ -0,0 +1,254 @@ +[ + { + "comment": [ + "check with \" \"; support" + ] + }, + { + "start": { + "cmd": [ + "${ALS}", + "--language-gpr" + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": "init", + "method": "initialize", + "params": { + "processId": 441587, + "rootUri": "$URI{.}", + "capabilities": { + "workspace": { + "applyEdit": true, + "workspaceEdit": {}, + "didChangeConfiguration": {}, + "didChangeWatchedFiles": {}, + "executeCommand": {} + }, + "textDocument": { + "synchronization": {}, + "completion": { + "dynamicRegistration": true, + "completionItem": { + "snippetSupport": true, + "documentationFormat": [ + "plaintext", + "markdown" + ] + } + }, + "hover": {}, + "definition": {}, + "documentSymbol": { + "hierarchicalDocumentSymbolSupport": true + } + } + } + } + }, + "wait": [ + { + "jsonrpc": "2.0", + "id": "init", + "result": { + "capabilities": { + "textDocumentSync": { + "openClose": true, + "change": 1 + }, + "completionProvider": { + "triggerCharacters": [ + " " + ], + "resolveProvider": true + }, + "hoverProvider": true, + "definitionProvider": true, + "documentSymbolProvider": {} + } + } + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "initialized" + }, + "wait": [] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "$URI{prj.gpr}", + "languageId": "gpr", + "version": 1, + "text": "with \" \";\nproject Prj is\nend Prj;" + } + } + }, + "wait": [ + { + "jsonrpc": "2.0", + "method": "textDocument/publishDiagnostics", + "params": { + "uri": "$URI{prj.gpr}", + "diagnostics": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "severity": 1, + "message": "GPR parser unexpected ADA.IO_EXCEPTIONS.NAME_ERROR invalid path name \" \"" + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": "textDocument/documentSymbol_prj_1", + "method": "textDocument/documentSymbol", + "params": { + "textDocument": { + "uri": "$URI{prj.gpr}" + } + } + }, + "wait": [ + { + "jsonrpc": "2.0", + "id": "textDocument/documentSymbol_prj_1", + "result": [ + { + "name": "with clauses", + "kind": 3, + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "selectionRange": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "children": [ + { + "name": " ", + "kind": 3, + "range": { + "start": { + "line": 0, + "character": 5 + }, + "end": { + "line": 0, + "character": 8 + } + }, + "selectionRange": { + "start": { + "line": 0, + "character": 5 + }, + "end": { + "line": 0, + "character": 8 + } + } + } + ] + }, + { + "name": "Prj", + "kind": 2, + "range": { + "start": { + "line": 1, + "character": 0 + }, + "end": { + "line": 1, + "character": 7 + } + }, + "selectionRange": { + "start": { + "line": 1, + "character": 0 + }, + "end": { + "line": 1, + "character": 7 + } + } + } + ] + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": "shutdown", + "method": "shutdown", + "params": null + }, + "wait": [ + { + "id": "shutdown", + "result": null + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "exit" + }, + "wait": [] + } + }, + { + "stop": { + "exit_code": 0 + } + } +] \ No newline at end of file diff --git a/testsuite/gpr_lsp/import_using_space_string/windows/test.yaml b/testsuite/gpr_lsp/import_using_space_string/windows/test.yaml new file mode 100644 index 000000000..042f35bfc --- /dev/null +++ b/testsuite/gpr_lsp/import_using_space_string/windows/test.yaml @@ -0,0 +1,3 @@ +title: 'check with " "; support' +skip: + - ['SKIP', 'env.build.os.name not in ("windows")'] diff --git a/testsuite/gpr_lsp/imported_project_errors_handling/test.json b/testsuite/gpr_lsp/imported_project_errors_handling/test.json index b70d538ba..060459269 100644 --- a/testsuite/gpr_lsp/imported_project_errors_handling/test.json +++ b/testsuite/gpr_lsp/imported_project_errors_handling/test.json @@ -81,7 +81,22 @@ "method": "textDocument/publishDiagnostics", "params": { "uri": "$URI{prj.gpr}", - "diagnostics": [] + "diagnostics": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "severity": 1, + "message": "GPR parser unexpected ADA.ASSERTIONS.ASSERTION_ERROR DYNAMIC_PREDICATE failed at gpr2-project-parser.adb:83" + } + ] } } ] diff --git a/testsuite/gpr_lsp/invalid_file_name_support/others/prj.gpr b/testsuite/gpr_lsp/invalid_file_name_support/others/prj.gpr new file mode 100644 index 000000000..f677aa6f2 --- /dev/null +++ b/testsuite/gpr_lsp/invalid_file_name_support/others/prj.gpr @@ -0,0 +1,4 @@ +with " "; +aggregate project prj extends " " is +for Project_Files use (" "); +end prj; diff --git a/testsuite/gpr_lsp/invalid_file_name_support/others/test.json b/testsuite/gpr_lsp/invalid_file_name_support/others/test.json new file mode 100644 index 000000000..d5fe02a31 --- /dev/null +++ b/testsuite/gpr_lsp/invalid_file_name_support/others/test.json @@ -0,0 +1,466 @@ +[ + { + "comment": [ + "test invalid filename support" + ] + }, + { + "start": { + "cmd": [ + "${ALS}", + "--language-gpr" + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": "init", + "method": "initialize", + "params": { + "processId": 441587, + "rootUri": "$URI{.}", + "capabilities": { + "workspace": { + "applyEdit": true, + "workspaceEdit": {}, + "didChangeConfiguration": {}, + "didChangeWatchedFiles": {}, + "executeCommand": {} + }, + "textDocument": { + "synchronization": {}, + "completion": { + "dynamicRegistration": true, + "completionItem": { + "snippetSupport": true, + "documentationFormat": [ + "plaintext", + "markdown" + ] + } + }, + "hover": {}, + "definition": {}, + "documentSymbol": { + "hierarchicalDocumentSymbolSupport": true + } + } + } + } + }, + "wait": [ + { + "jsonrpc": "2.0", + "id": "init", + "result": { + "capabilities": { + "textDocumentSync": { + "openClose": true, + "change": 1 + }, + "completionProvider": { + "triggerCharacters": [ + " " + ], + "resolveProvider": true + }, + "hoverProvider": true, + "definitionProvider": true, + "documentSymbolProvider": {} + } + } + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "initialized" + }, + "wait": [] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "$URI{prj.gpr}", + "languageId": "gpr", + "version": 1, + "text": "with \" \";\naggregate project prj extends \" \" is\nfor Project_Files use (\" \");\nend prj;\n" + } + } + }, + "wait": [ + { + "jsonrpc": "2.0", + "method": "textDocument/publishDiagnostics", + "params": { + "uri": "$URI{prj.gpr}", + "diagnostics": [ + { + "range": { + "start": { + "line": 0, + "character": 5 + }, + "end": { + "line": 0, + "character": 5 + } + }, + "severity": 1, + "message": "imported project file \" .gpr\" not found" + }, + { + "range": { + "start": { + "line": 1, + "character": 22 + }, + "end": { + "line": 1, + "character": 22 + } + }, + "severity": 1, + "message": "extended project file \" .gpr\" not found" + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": "textDocument/documentSymbol_prj_1", + "method": "textDocument/documentSymbol", + "params": { + "textDocument": { + "uri": "$URI{prj.gpr}" + } + } + }, + "wait": [ + { + "jsonrpc": "2.0", + "id": "textDocument/documentSymbol_prj_1", + "result": [ + { + "name": "with clauses", + "kind": 3, + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "selectionRange": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "children": [ + { + "name": " ", + "kind": 3, + "range": { + "start": { + "line": 0, + "character": 5 + }, + "end": { + "line": 0, + "character": 9 + } + }, + "selectionRange": { + "start": { + "line": 0, + "character": 5 + }, + "end": { + "line": 0, + "character": 9 + } + } + } + ] + }, + { + "name": "prj", + "kind": 2, + "range": { + "start": { + "line": 1, + "character": 10 + }, + "end": { + "line": 1, + "character": 17 + } + }, + "selectionRange": { + "start": { + "line": 1, + "character": 10 + }, + "end": { + "line": 1, + "character": 17 + } + }, + "children": [ + { + "name": "Project_Files", + "kind": 7, + "range": { + "start": { + "line": 2, + "character": 4 + }, + "end": { + "line": 2, + "character": 17 + } + }, + "selectionRange": { + "start": { + "line": 2, + "character": 4 + }, + "end": { + "line": 2, + "character": 17 + } + } + } + ] + } + ] + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": "textDocument/hover_prj_0_7", + "method": "textDocument/hover", + "params": { + "textDocument": { + "uri": "$URI{prj.gpr}" + }, + "position": { + "line": 0, + "character": 7 + } + } + }, + "wait": [ + { + "jsonrpc": "2.0", + "id": "textDocument/hover_prj_0_7", + "result": null + } + ] + } + }, + { + "send": { + "request": { + "params": { + "position": { + "line": 0, + "character": 7 + }, + "textDocument": { + "uri": "$URI{prj.gpr}" + } + }, + "jsonrpc": "2.0", + "id": "definition1", + "method": "textDocument/definition" + }, + "wait": [ + { + "id": "definition1", + "result": [] + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": "textDocument/hover_prj_1_32", + "method": "textDocument/hover", + "params": { + "textDocument": { + "uri": "$URI{prj.gpr}" + }, + "position": { + "line": 1, + "character": 32 + } + } + }, + "wait": [ + { + "jsonrpc": "2.0", + "id": "textDocument/hover_prj_1_32", + "result": null + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": "textDocument/definition_prj_1_32", + "method": "textDocument/definition", + "params": { + "textDocument": { + "uri": "$URI{prj.gpr}" + }, + "position": { + "line": 1, + "character": 32 + } + } + }, + "wait": [ + { + "jsonrpc": "2.0", + "id": "textDocument/definition_prj_1_32", + "result": [] + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": "textDocument/hover_prj_2_25", + "method": "textDocument/hover", + "params": { + "textDocument": { + "uri": "$URI{prj.gpr}" + }, + "position": { + "line": 2, + "character": 25 + } + } + }, + "wait": [ + { + "jsonrpc": "2.0", + "id": "textDocument/hover_prj_2_25", + "result": null + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": "textDocument/definition_prj_2_25", + "method": "textDocument/definition", + "params": { + "textDocument": { + "uri": "$URI{prj.gpr}" + }, + "position": { + "line": 2, + "character": 25 + } + } + }, + "wait": [ + { + "jsonrpc": "2.0", + "id": "textDocument/definition_prj_2_25", + "result": [] + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "$URI{prj.gpr}" + } + } + }, + "wait": [ + { + "jsonrpc": "2.0", + "method": "textDocument/publishDiagnostics", + "params": { + "uri": "$URI{prj.gpr}", + "diagnostics": [] + } + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": "shutdown", + "method": "shutdown", + "params": null + }, + "wait": [ + { + "id": "shutdown", + "result": null + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "exit" + }, + "wait": [] + } + }, + { + "stop": { + "exit_code": 0 + } + } +] \ No newline at end of file diff --git a/testsuite/gpr_lsp/invalid_file_name_support/others/test.yaml b/testsuite/gpr_lsp/invalid_file_name_support/others/test.yaml new file mode 100644 index 000000000..e0d2d5dc0 --- /dev/null +++ b/testsuite/gpr_lsp/invalid_file_name_support/others/test.yaml @@ -0,0 +1,3 @@ +title: 'check invalid filename handling' +skip: + - ['SKIP', 'env.build.os.name in ("windows")'] diff --git a/testsuite/gpr_lsp/invalid_file_name_support/windows/prj.gpr b/testsuite/gpr_lsp/invalid_file_name_support/windows/prj.gpr new file mode 100644 index 000000000..f677aa6f2 --- /dev/null +++ b/testsuite/gpr_lsp/invalid_file_name_support/windows/prj.gpr @@ -0,0 +1,4 @@ +with " "; +aggregate project prj extends " " is +for Project_Files use (" "); +end prj; diff --git a/testsuite/gpr_lsp/invalid_file_name_support/windows/test.json b/testsuite/gpr_lsp/invalid_file_name_support/windows/test.json new file mode 100644 index 000000000..bd96e1dae --- /dev/null +++ b/testsuite/gpr_lsp/invalid_file_name_support/windows/test.json @@ -0,0 +1,453 @@ +[ + { + "comment": [ + "test invalid filename support" + ] + }, + { + "start": { + "cmd": [ + "${ALS}", + "--language-gpr" + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": "init", + "method": "initialize", + "params": { + "processId": 441587, + "rootUri": "$URI{.}", + "capabilities": { + "workspace": { + "applyEdit": true, + "workspaceEdit": {}, + "didChangeConfiguration": {}, + "didChangeWatchedFiles": {}, + "executeCommand": {} + }, + "textDocument": { + "synchronization": {}, + "completion": { + "dynamicRegistration": true, + "completionItem": { + "snippetSupport": true, + "documentationFormat": [ + "plaintext", + "markdown" + ] + } + }, + "hover": {}, + "definition": {}, + "documentSymbol": { + "hierarchicalDocumentSymbolSupport": true + } + } + } + } + }, + "wait": [ + { + "jsonrpc": "2.0", + "id": "init", + "result": { + "capabilities": { + "textDocumentSync": { + "openClose": true, + "change": 1 + }, + "completionProvider": { + "triggerCharacters": [ + " " + ], + "resolveProvider": true + }, + "hoverProvider": true, + "definitionProvider": true, + "documentSymbolProvider": {} + } + } + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "initialized" + }, + "wait": [] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "$URI{prj.gpr}", + "languageId": "gpr", + "version": 1, + "text": "with \" \";\naggregate project prj extends \" \" is\nfor Project_Files use (\" \");\nend prj;\n" + } + } + }, + "wait": [ + { + "jsonrpc": "2.0", + "method": "textDocument/publishDiagnostics", + "params": { + "uri": "$URI{prj.gpr}", + "diagnostics": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "severity": 1, + + "message": "GPR parser unexpected ADA.IO_EXCEPTIONS.NAME_ERROR invalid path name \" \"" + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": "textDocument/documentSymbol_prj_1", + "method": "textDocument/documentSymbol", + "params": { + "textDocument": { + "uri": "$URI{prj.gpr}" + } + } + }, + "wait": [ + { + "jsonrpc": "2.0", + "id": "textDocument/documentSymbol_prj_1", + "result": [ + { + "name": "with clauses", + "kind": 3, + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "selectionRange": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "children": [ + { + "name": " ", + "kind": 3, + "range": { + "start": { + "line": 0, + "character": 5 + }, + "end": { + "line": 0, + "character": 9 + } + }, + "selectionRange": { + "start": { + "line": 0, + "character": 5 + }, + "end": { + "line": 0, + "character": 9 + } + } + } + ] + }, + { + "name": "prj", + "kind": 2, + "range": { + "start": { + "line": 1, + "character": 10 + }, + "end": { + "line": 1, + "character": 17 + } + }, + "selectionRange": { + "start": { + "line": 1, + "character": 10 + }, + "end": { + "line": 1, + "character": 17 + } + }, + "children": [ + { + "name": "Project_Files", + "kind": 7, + "range": { + "start": { + "line": 2, + "character": 4 + }, + "end": { + "line": 2, + "character": 17 + } + }, + "selectionRange": { + "start": { + "line": 2, + "character": 4 + }, + "end": { + "line": 2, + "character": 17 + } + } + } + ] + } + ] + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": "textDocument/hover_prj_0_7", + "method": "textDocument/hover", + "params": { + "textDocument": { + "uri": "$URI{prj.gpr}" + }, + "position": { + "line": 0, + "character": 7 + } + } + }, + "wait": [ + { + "jsonrpc": "2.0", + "id": "textDocument/hover_prj_0_7", + "result": null + } + ] + } + }, + { + "send": { + "request": { + "params": { + "position": { + "line": 0, + "character": 7 + }, + "textDocument": { + "uri": "$URI{prj.gpr}" + } + }, + "jsonrpc": "2.0", + "id": "definition1", + "method": "textDocument/definition" + }, + "wait": [ + { + "id": "definition1", + "result": [] + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": "textDocument/hover_prj_1_32", + "method": "textDocument/hover", + "params": { + "textDocument": { + "uri": "$URI{prj.gpr}" + }, + "position": { + "line": 1, + "character": 32 + } + } + }, + "wait": [ + { + "jsonrpc": "2.0", + "id": "textDocument/hover_prj_1_32", + "result": null + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": "textDocument/definition_prj_1_32", + "method": "textDocument/definition", + "params": { + "textDocument": { + "uri": "$URI{prj.gpr}" + }, + "position": { + "line": 1, + "character": 32 + } + } + }, + "wait": [ + { + "jsonrpc": "2.0", + "id": "textDocument/definition_prj_1_32", + "result": [] + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": "textDocument/hover_prj_2_25", + "method": "textDocument/hover", + "params": { + "textDocument": { + "uri": "$URI{prj.gpr}" + }, + "position": { + "line": 2, + "character": 25 + } + } + }, + "wait": [ + { + "jsonrpc": "2.0", + "id": "textDocument/hover_prj_2_25", + "result": null + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": "textDocument/definition_prj_2_25", + "method": "textDocument/definition", + "params": { + "textDocument": { + "uri": "$URI{prj.gpr}" + }, + "position": { + "line": 2, + "character": 25 + } + } + }, + "wait": [ + { + "jsonrpc": "2.0", + "id": "textDocument/definition_prj_2_25", + "result": [] + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "$URI{prj.gpr}" + } + } + }, + "wait": [ + { + "jsonrpc": "2.0", + "method": "textDocument/publishDiagnostics", + "params": { + "uri": "$URI{prj.gpr}", + "diagnostics": [] + } + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": "shutdown", + "method": "shutdown", + "params": null + }, + "wait": [ + { + "id": "shutdown", + "result": null + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "exit" + }, + "wait": [] + } + }, + { + "stop": { + "exit_code": 0 + } + } +] \ No newline at end of file diff --git a/testsuite/gpr_lsp/invalid_file_name_support/windows/test.yaml b/testsuite/gpr_lsp/invalid_file_name_support/windows/test.yaml new file mode 100644 index 000000000..ec17d5d21 --- /dev/null +++ b/testsuite/gpr_lsp/invalid_file_name_support/windows/test.yaml @@ -0,0 +1,3 @@ +title: 'check invalid filename handling' +skip: + - ['SKIP', 'env.build.os.name not in ("windows")'] diff --git a/testsuite/gpr_lsp/no_symbol_with_empty_name/p.gpr b/testsuite/gpr_lsp/no_symbol_with_empty_name/p.gpr new file mode 100644 index 000000000..6a05b6872 --- /dev/null +++ b/testsuite/gpr_lsp/no_symbol_with_empty_name/p.gpr @@ -0,0 +1 @@ +with"";project P is end P; \ No newline at end of file diff --git a/testsuite/gpr_lsp/no_symbol_with_empty_name/test.json b/testsuite/gpr_lsp/no_symbol_with_empty_name/test.json new file mode 100644 index 000000000..4eff24bb0 --- /dev/null +++ b/testsuite/gpr_lsp/no_symbol_with_empty_name/test.json @@ -0,0 +1,236 @@ +[ + { + "comment": [ + "with \"\"; statement support" + ] + }, + { + "start": { + "cmd": [ + "${ALS}", + "--language-gpr" + ] + } + }, + { + "send": { + "request": { + "params": { + "processId": 30612, + "capabilities": { + "workspace": { + "applyEdit": false + }, + "textDocument": { + "documentSymbol": { + "hierarchicalDocumentSymbolSupport": true + } + } + }, + "rootUri": "$URI{.}" + }, + "jsonrpc": "2.0", + "id": 1, + "method": "initialize" + }, + "wait": [ + { + "jsonrpc": "2.0", + "id": 1, + "result": { + "capabilities": { + "textDocumentSync": { + "openClose": true, + "change": 1 + }, + "completionProvider": { + "triggerCharacters": [ + " " + ], + "resolveProvider": true + }, + "hoverProvider": true, + "definitionProvider": true, + "documentSymbolProvider": {} + } + } + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "initialized" + }, + "wait": [] + } + }, + { + "send": { + "request": { + "params": { + "textDocument": { + "text": "with\"\";project P is end P;", + "version": 0, + "uri": "$URI{p.gpr}", + "languageId": "Gpr" + } + }, + "jsonrpc": "2.0", + "method": "textDocument/didOpen" + }, + "wait": [ + { + "method": "textDocument/publishDiagnostics", + "params": { + "uri": "$URI{p.gpr}", + "diagnostics": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "severity": 1, + "message": "GPR parser unexpected ADA.ASSERTIONS.ASSERTION_ERROR DYNAMIC_PREDICATE failed at gpr2-project-parser.adb:83" + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": "textDocument/documentSymbol", + "method": "textDocument/documentSymbol", + "params": { + "textDocument": { + "uri": "$URI{p.gpr}" + } + } + }, + "wait": [ + { + "jsonrpc": "2.0", + "id": "textDocument/documentSymbol", + "result": [ + { + "name": "with clauses", + "kind": 3, + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "selectionRange": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "children": [ + { + "name": " ", + "kind": 3, + "range": { + "start": { + "line": 0, + "character": 4 + }, + "end": { + "line": 0, + "character": 6 + } + }, + "selectionRange": { + "start": { + "line": 0, + "character": 4 + }, + "end": { + "line": 0, + "character": 6 + } + } + } + ] + }, + { + "name": "P", + "kind": 2, + "range": { + "start": { + "line": 0, + "character": 7 + }, + "end": { + "line": 0, + "character": 14 + } + }, + "selectionRange": { + "start": { + "line": 0, + "character": 7 + }, + "end": { + "line": 0, + "character": 14 + } + } + } + ] + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": "shutdown", + "method": "shutdown", + "params": null + }, + "wait": [ + { + "id": "shutdown", + "result": null + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "exit" + }, + "wait": [] + } + }, + { + "stop": { + "exit_code": 0 + } + } +] \ No newline at end of file diff --git a/testsuite/gpr_lsp/no_symbol_with_empty_name/test.yaml b/testsuite/gpr_lsp/no_symbol_with_empty_name/test.yaml new file mode 100644 index 000000000..a9fcd9a7f --- /dev/null +++ b/testsuite/gpr_lsp/no_symbol_with_empty_name/test.yaml @@ -0,0 +1 @@ +title: 'with empty string statement support'