You've already forked ada_language_server
mirror of
https://github.com/AdaCore/ada_language_server.git
synced 2026-02-12 12:45:50 -08:00
Avoid exception on unknown predefined entities
When computing tooltips from the static predefined entities' documentation database. Display a 'not found' tooltip instead. For eng/ide/ada_language_server#1453
This commit is contained in:
@@ -321,10 +321,12 @@ package body LSP.Predefined_Completion is
|
||||
return;
|
||||
end case;
|
||||
|
||||
Item := Filtered_Items.First_Element;
|
||||
if not Filtered_Items.Is_Empty then
|
||||
Item := Filtered_Items.First_Element;
|
||||
|
||||
Declaration_Text := Item.detail;
|
||||
Documentation_Text := Item.documentation.Value.Virtual_String;
|
||||
Declaration_Text := Item.detail;
|
||||
Documentation_Text := Item.documentation.Value.Virtual_String;
|
||||
end if;
|
||||
end Get_Tooltip_Text;
|
||||
|
||||
end LSP.Predefined_Completion;
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
project Default is
|
||||
end Default;
|
||||
10
testsuite/ada_lsp/hover.predefined_entities.unknown/main.adb
Normal file
10
testsuite/ada_lsp/hover.predefined_entities.unknown/main.adb
Normal file
@@ -0,0 +1,10 @@
|
||||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
|
||||
procedure Main
|
||||
with Unknown => Off
|
||||
is
|
||||
Foo : Integer := 30;
|
||||
pragma Unknown (C, Foo);
|
||||
begin
|
||||
Put_Line (Foo'Unknown);
|
||||
end Main;
|
||||
181
testsuite/ada_lsp/hover.predefined_entities.unknown/test.json
Normal file
181
testsuite/ada_lsp/hover.predefined_entities.unknown/test.json
Normal file
@@ -0,0 +1,181 @@
|
||||
[
|
||||
{
|
||||
"comment": [
|
||||
"This test checks that the textDocument/hover request does not ",
|
||||
"fail when hovering on unknown predefined entities."
|
||||
]
|
||||
},
|
||||
{
|
||||
"start": {
|
||||
"cmd": ["${ALS}"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"send": {
|
||||
"request": {
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"method": "initialize",
|
||||
"params": {
|
||||
"rootUri": "$URI{.}",
|
||||
"capabilities": {
|
||||
"textDocument": {
|
||||
"rangeFormatting": {
|
||||
"dynamicRegistration": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"wait": [
|
||||
{
|
||||
"id": 1,
|
||||
"result": {
|
||||
"capabilities": {
|
||||
"hoverProvider": true
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"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 Ada.Text_IO; use Ada.Text_IO;\n\nprocedure Main \n with Unknown => Off\nis\n Foo : Integer := 30;\n pragma Unknown (C, Foo);\nbegin\n Put_Line (Foo'Unknown);\nend Main;\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
"wait": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"send": {
|
||||
"request": {
|
||||
"jsonrpc": "2.0",
|
||||
"id": 4,
|
||||
"method": "textDocument/hover",
|
||||
"params": {
|
||||
"textDocument": {
|
||||
"uri": "$URI{main.adb}"
|
||||
},
|
||||
"position": {
|
||||
"line": 3,
|
||||
"character": 7
|
||||
}
|
||||
}
|
||||
},
|
||||
"wait": [{ "result": null }]
|
||||
}
|
||||
},
|
||||
{
|
||||
"send": {
|
||||
"request": {
|
||||
"jsonrpc": "2.0",
|
||||
"id": 5,
|
||||
"method": "textDocument/hover",
|
||||
"params": {
|
||||
"textDocument": {
|
||||
"uri": "$URI{main.adb}"
|
||||
},
|
||||
"position": {
|
||||
"line": 6,
|
||||
"character": 10
|
||||
}
|
||||
}
|
||||
},
|
||||
"wait": [{ "result": null }]
|
||||
}
|
||||
},
|
||||
{
|
||||
"send": {
|
||||
"request": {
|
||||
"jsonrpc": "2.0",
|
||||
"id": 6,
|
||||
"method": "textDocument/hover",
|
||||
"params": {
|
||||
"textDocument": {
|
||||
"uri": "$URI{main.adb}"
|
||||
},
|
||||
"position": {
|
||||
"line": 8,
|
||||
"character": 17
|
||||
}
|
||||
}
|
||||
},
|
||||
"wait": [{ "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
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1 @@
|
||||
title: 'hover.predefined_entities.unknown'
|
||||
Reference in New Issue
Block a user