Skip to content

Commit

Permalink
Add test for the hover on incomplete types
Browse files Browse the repository at this point in the history
The hover should get the complete type when it is in the
public part.

For #1320
  • Loading branch information
setton committed Apr 10, 2024
1 parent 88e23c7 commit 4dd4055
Show file tree
Hide file tree
Showing 5 changed files with 314 additions and 0 deletions.
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'

0 comments on commit 4dd4055

Please sign in to comment.