Skip to content

Commit 3373905

Browse files
committed
Merge branch 'als_1717' into 'master'
Replace completion_auto_qualifier test with python test See merge request eng/ide/ada_language_server!2129
2 parents a389bc5 + 9104c5c commit 3373905

File tree

6 files changed

+79
-276
lines changed

6 files changed

+79
-276
lines changed

testsuite/ada_lsp/completion.auto_qualifier/test.json

Lines changed: 0 additions & 276 deletions
This file was deleted.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
"""
2+
Tests that we insert auto-import in the right place,
3+
before the node.
4+
For example:
5+
Ada.Text_IO.Put (LFtip);
6+
^ cursor here
7+
8+
Ada.Text_IO.Put (LFtip);
9+
^ "A." should be inserted here
10+
"""
11+
12+
from typing import List
13+
from drivers import pylsp
14+
from lsprotocol.types import (
15+
Command,
16+
CompletionContext,
17+
CompletionItem,
18+
CompletionList,
19+
CompletionParams,
20+
CompletionTriggerKind,
21+
TextDocumentIdentifier,
22+
)
23+
24+
25+
@pylsp.test()
26+
async def test(lsp: pylsp.ALSLanguageClient) -> None:
27+
file_uri = lsp.didOpenFile("main.adb")
28+
29+
await lsp.awaitIndexingEnd()
30+
31+
result = await lsp.text_document_completion_async(
32+
CompletionParams(
33+
TextDocumentIdentifier(file_uri),
34+
pylsp.Pos(6, 26),
35+
CompletionContext(CompletionTriggerKind.Invoked),
36+
)
37+
)
38+
EXPECTED_LABEL = "LFtip (invisible)"
39+
EXPECTED_COMMAND = Command(
40+
title="",
41+
command="als-auto-import",
42+
arguments=[
43+
{
44+
"context": pylsp.URI("default.gpr"),
45+
"where": {
46+
"textDocument": {"uri": file_uri},
47+
"position": {"line": 5, "character": 20},
48+
},
49+
"import": "A",
50+
"qualifier": "A",
51+
}
52+
],
53+
)
54+
55+
def find_expected_completion_item(
56+
items: List[CompletionItem],
57+
expected_label,
58+
expected_command,
59+
):
60+
"""
61+
Find the expected completion item in the given completion items' list
62+
"""
63+
expected_items = [
64+
item
65+
for item in items
66+
if item.label == expected_label and item.command == expected_command
67+
]
68+
return len(expected_items) == 1
69+
70+
# Verify that we are able to find the expected completion invisible item
71+
# for 'LFtip'
72+
assert isinstance(
73+
result, CompletionList
74+
), "The returned completion list result should be of type CompletionList"
75+
lsp.assertEqual(
76+
find_expected_completion_item(result.items, EXPECTED_LABEL, EXPECTED_COMMAND),
77+
True,
78+
)
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
title: 'completion.auto_qualifier'
2+
driver: pylsp

0 commit comments

Comments
 (0)