Skip to content

Commit

Permalink
Merge remote branch 'origin/master' into edge
Browse files Browse the repository at this point in the history
  • Loading branch information
automatic-merge committed Apr 11, 2024
2 parents 29accc2 + 700e0a1 commit ebfa005
Show file tree
Hide file tree
Showing 13 changed files with 1,309 additions and 0 deletions.
50 changes: 50 additions & 0 deletions source/gpr/lsp-gpr_handlers.adb
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ package body LSP.GPR_Handlers is

Capabilities.hoverProvider := LSP.Constants.True;
Capabilities.definitionProvider := LSP.Constants.True;
Capabilities.declarationProvider := LSP.Constants.True;
Capabilities.completionProvider :=
(Is_Set => True,
Value => (triggerCharacters => [" "],
Expand Down Expand Up @@ -431,6 +432,55 @@ package body LSP.GPR_Handlers is
Self.Sender.On_Completion_Resolve_Response (Id, Response);
end On_Completion_Resolve_Request;

----------------------------
-- On_Declaration_Request --
----------------------------

overriding procedure On_Declaration_Request
(Self : in out Message_Handler;
Id : LSP.Structures.Integer_Or_Virtual_String;
Value : LSP.Structures.DeclarationParams)
is
procedure Fill_Declaration;
-- Utility function, appends to Vector the definition if any.

Response : LSP.Structures.Declaration_Result (LSP.Structures.Variant_1);

----------------------
-- Fill_Declaration --
----------------------

procedure Fill_Declaration is
File : constant LSP.GPR_Files.File_Access :=
LSP.GPR_Files.Parse
(File_Provider => Self'Unchecked_Access,
Path => Self.To_File
(Value.textDocument.uri));

Reference : constant Gpr_Parser.Common.Token_Reference :=
LSP.GPR_Files.References.Token_Reference
(File, Value.position);

Location : LSP.Structures.Location;

use type Gpr_Parser.Common.Token_Reference;

begin
if Reference /= Gpr_Parser.Common.No_Token then
Location.uri :=
LSP.GPR_File_Readers.To_URI (Reference.Origin_Filename);
Location.a_range := To_Range (Self'Unchecked_Access, Reference);
Response.Variant_1.Append (Location);
end if;

end Fill_Declaration;

begin
Fill_Declaration;

Self.Sender.On_Declaration_Response (Id, Response);
end On_Declaration_Request;

---------------------------
-- On_Definition_Request --
---------------------------
Expand Down
5 changes: 5 additions & 0 deletions source/gpr/lsp-gpr_handlers.ads
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ private
Id : LSP.Structures.Integer_Or_Virtual_String;
Value : LSP.Structures.DefinitionParams);

overriding procedure On_Declaration_Request
(Self : in out Message_Handler;
Id : LSP.Structures.Integer_Or_Virtual_String;
Value : LSP.Structures.DeclarationParams);

-----------------------------------------
-- LSP.GPR_Documents.Document_Provider --
-----------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions testsuite/ada_lsp/hover.incomplete_types/default.gpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
project Default is
end Default;
9 changes: 9 additions & 0 deletions testsuite/ada_lsp/hover.incomplete_types/main.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
with P;

procedure Main
is
Foo : P.Incomplete;
Bar : P.Incomplete_2;
begin
null;
end Main;
17 changes: 17 additions & 0 deletions testsuite/ada_lsp/hover.incomplete_types/p.ads
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package P is
type Incomplete;
type Incomplete_2;

type Something is record
X : Incomplete;
end record;

type Incomplete is record
Y : Integer;
end record;

private
type Incomplete_2 is record
Z : Integer;
end record;
end P;
285 changes: 285 additions & 0 deletions testsuite/ada_lsp/hover.incomplete_types/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
[
{
"comment": [
"This test checks that the textDocument/hover request works fine ",
"on predefined entities (pragmas, aspects, attributes)."
]
},
{
"start": {
"cmd": ["${ALS}"]
}
},
{
"send": {
"request": {
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"processId": 2357134,
"rootUri": "$URI{.}",
"capabilities": {
"workspace": {
"applyEdit": true,
"workspaceEdit": {
"documentChanges": true,
"resourceOperations": ["rename"]
}
},
"textDocument": {
"synchronization": {},
"completion": {
"dynamicRegistration": true,
"completionItem": {
"snippetSupport": false,
"documentationFormat": ["plaintext", "markdown"],
"resolveSupport": {
"properties": ["detail", "documentation"]
}
}
},
"hover": {},
"signatureHelp": {},
"declaration": {},
"definition": {},
"typeDefinition": {},
"implementation": {},
"documentSymbol": {
"hierarchicalDocumentSymbolSupport": true
},
"codeAction": {
"codeActionLiteralSupport": {
"codeActionKind": {
"valueSet": [
"",
"quickfix",
"refactor",
"refactor.extract",
"refactor.inline",
"refactor.rewrite",
"source",
"source.organizeImports"
]
}
}
},
"formatting": {
"dynamicRegistration": false
},
"rangeFormatting": {
"dynamicRegistration": false
},
"onTypeFormatting": {
"dynamicRegistration": false
},
"publishDiagnostics": {
"relatedInformation": true
},
"foldingRange": {
"lineFoldingOnly": true
}
},
"experimental": {
"advanced_refactorings": ["add_parameter"]
}
}
}
},
"wait": [
{
"id": 1,
"result": {
"capabilities": {
"textDocumentSync": 2,
"completionProvider": {
"triggerCharacters": [".", ",", "'", "("],
"resolveProvider": true
},
"hoverProvider": true,
"signatureHelpProvider": {
"triggerCharacters": [",", "("],
"retriggerCharacters": ["\b"]
},
"declarationProvider": true,
"definitionProvider": true,
"typeDefinitionProvider": true,
"implementationProvider": true,
"referencesProvider": true,
"documentHighlightProvider": true,
"documentSymbolProvider": true,
"codeActionProvider": {
"workDoneProgress": false,
"codeActionKinds": ["quickfix", "refactor.rewrite"],
"resolveProvider": false
},
"workspaceSymbolProvider": true,
"documentFormattingProvider": true,
"documentRangeFormattingProvider": true,
"documentOnTypeFormattingProvider": {
"firstTriggerCharacter": "\n"
},
"renameProvider": {
"prepareProvider": true
},
"foldingRangeProvider": true,
"executeCommandProvider": {
"commands": ["<HAS>", "als-other-file"]
},
"callHierarchyProvider": true,
"semanticTokensProvider": {
"legend": {
"tokenTypes": [],
"tokenModifiers": []
},
"range": true,
"full": true
},
"workspace": {},
"alsReferenceKinds": ["<HAS>", "reference"]
}
}
}
]
}
},
{
"send": {
"request": {
"jsonrpc": "2.0",
"method": "initialized"
},
"wait": []
}
},
{
"send": {
"request": {
"jsonrpc": "2.0",
"method": "workspace/didChangeConfiguration",
"params": {
"settings": {
"ada": {
"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 P;\n\nprocedure Main\nis\n Foo : P.Incomplete;\n Bar : P.Incomplete_2;\nbegin\n null;\nend Main;"
}
}
},
"wait": []
}
},
{
"send": {
"request": {
"jsonrpc": "2.0",
"id": 4,
"method": "textDocument/hover",
"params": {
"textDocument": {
"uri": "$URI{main.adb}"
},
"position": {
"line": 4,
"character": 14
}
}
},
"wait": [
{
"id": 4,
"result": {
"contents": [
{
"language": "ada",
"value": "type Incomplete is record\n Y : Integer;\nend record;"
},
"at p.ads (2:4)"
]
}
}
]
}
},
{
"send": {
"request": {
"jsonrpc": "2.0",
"id": 5,
"method": "textDocument/hover",
"params": {
"textDocument": {
"uri": "$URI{main.adb}"
},
"position": {
"line": 5,
"character": 14
}
}
},
"wait": [
{
"id": 5,
"result": null
}
]
}
},

{
"send": {
"request": {
"jsonrpc": "2.0",
"method": "textDocument/didClose",
"params": {
"textDocument": {
"uri": "$URI{main.adb}"
}
}
},
"wait": []
}
},
{
"send": {
"request": {
"jsonrpc": "2.0",
"id": 7,
"method": "shutdown"
},
"wait": [
{
"id": 7,
"result": null
}
]
}
},
{
"stop": {
"exit_code": 0
}
}
]
1 change: 1 addition & 0 deletions testsuite/ada_lsp/hover.incomplete_types/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
title: 'hover.predefined_entities'
Loading

0 comments on commit ebfa005

Please sign in to comment.