diff --git a/source/ada/lsp-ada_completions-parameters.adb b/source/ada/lsp-ada_completions-parameters.adb index ef946d53..fb467d23 100644 --- a/source/ada/lsp-ada_completions-parameters.adb +++ b/source/ada/lsp-ada_completions-parameters.adb @@ -528,7 +528,10 @@ package body LSP.Ada_Completions.Parameters is return Res; end if; - if Aggr_Type.Kind in Ada_Type_Decl then + if Aggr_Type.Kind in Ada_Type_Decl + and then Aggr_Type.P_Is_Record_Type + -- P_Shapes can only be called on record types + then declare Base_Type : constant Base_Type_Decl := Aggr_Type.P_Base_Type (Origin => A); diff --git a/testsuite/ada_lsp/completion.aggregates.string/main.adb b/testsuite/ada_lsp/completion.aggregates.string/main.adb new file mode 100644 index 00000000..3a387e5d --- /dev/null +++ b/testsuite/ada_lsp/completion.aggregates.string/main.adb @@ -0,0 +1,9 @@ +with Ada.Text_IO; + +procedure Main is + A : constant String := (1 .. 0 => 'a'); +begin + if A'Last in A'Range then + Ada.Text_IO.Put_Line ("Hello"); + end if; +end Main; diff --git a/testsuite/ada_lsp/completion.aggregates.string/test.gpr b/testsuite/ada_lsp/completion.aggregates.string/test.gpr new file mode 100644 index 00000000..13539987 --- /dev/null +++ b/testsuite/ada_lsp/completion.aggregates.string/test.gpr @@ -0,0 +1,3 @@ +project Test is + for Main use ("main.adb"); +end Test; diff --git a/testsuite/ada_lsp/completion.aggregates.string/test.json b/testsuite/ada_lsp/completion.aggregates.string/test.json new file mode 100644 index 00000000..1899d6f4 --- /dev/null +++ b/testsuite/ada_lsp/completion.aggregates.string/test.json @@ -0,0 +1,228 @@ +[ + { + "comment": [ + "Test the completion provider inside a string aggregate.", + "No exception should happen." + ] + }, { + "start": { + "cmd": [ + "${ALS}" + ] + } + }, + { + "send": { + "request": { + "params": { + "processId": 31570, + "capabilities": { + "textDocument": { + "completion": { + "completionItem": { + "documentationFormat": [ + "plaintext", + "markdown" + ], + "snippetSupport": true + }, + "dynamicRegistration": true + }, + "definition": {}, + "hover": {}, + "formatting": { + "dynamicRegistration": true + }, + "implementation": {}, + "codeLens": {}, + "typeDefinition": {}, + "selectionRange": {}, + "documentHighlight": {}, + "documentSymbol": { + "hierarchicalDocumentSymbolSupport": true + }, + "synchronization": {}, + "references": {}, + "rangeFormatting": {}, + "onTypeFormatting": {}, + "declaration": {}, + "foldingRange": { + "lineFoldingOnly": true + }, + "colorProvider": {} + }, + "workspace": { + "applyEdit": true, + "executeCommand": {}, + "didChangeWatchedFiles": {}, + "workspaceEdit": {}, + "didChangeConfiguration": {} + } + }, + "rootUri": "$URI{.}" + }, + "jsonrpc": "2.0", + "id": 1, + "method": "initialize" + }, + "wait": [ + { + "jsonrpc": "2.0", + "id": 1, + "result": { + "capabilities": { + "textDocumentSync": 2, + "completionProvider": { + "triggerCharacters": [ + ".", + ",", + "'", + "(" + ], + "resolveProvider": true + } + } + } + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "initialized" + }, + "wait": [] + } + }, + { + "send": { + "request": { + "params": { + "settings": { + "ada": { + "scenarioVariables": {}, + "enableDiagnostics": false, + "defaultCharset": "ISO-8859-1" + } + } + }, + "jsonrpc": "2.0", + "method": "workspace/didChangeConfiguration" + }, + "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 A : constant String := (1 .. 0 => 'a');\nbegin\n if A'Last in A'Range then\n Ada.Text_IO.Put_Line (\"Hello\");\n end if;\nend Main;\n" + } + } + }, + "wait": [] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": 7, + "method": "textDocument/completion", + "params": { + "textDocument": { + "uri": "$URI{main.adb}" + }, + "position": { + "line": 3, + "character": 33 + }, + "context": { + "triggerKind": 1 + } + } + }, + "wait": [ + { + "id": 7, + "result": { + "isIncomplete": false, + "items": [] + } + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": 8, + "method": "textDocument/completion", + "params": { + "textDocument": { + "uri": "$URI{main.adb}" + }, + "position": { + "line": 3, + "character": 33 + }, + "context": { + "triggerKind": 1 + } + } + }, + "wait": [ + { + "id": 8, + "result": { + "isIncomplete": false, + "items": [] + } + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "textDocument/didClose", + "params": { + "textDocument": { + "uri": "$URI{src/main.adb" + } + } + }, + "wait": [] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": 9, + "method": "shutdown" + }, + "wait": [ + { + "id": 9, + "result": null + } + ] + } + }, + { + "stop": { + "exit_code": 0 + } + } +] diff --git a/testsuite/ada_lsp/completion.aggregates.string/test.yaml b/testsuite/ada_lsp/completion.aggregates.string/test.yaml new file mode 100644 index 00000000..44544f1d --- /dev/null +++ b/testsuite/ada_lsp/completion.aggregates.string/test.yaml @@ -0,0 +1 @@ +title: 'completion.aggregates.string'