Skip to content

Commit ceb6f72

Browse files
author
automatic-merge
committed
Merge remote branch 'origin/master' into edge
2 parents 704bb21 + d76b239 commit ceb6f72

File tree

12 files changed

+205
-39
lines changed

12 files changed

+205
-39
lines changed

source/ada/lsp-ada_handlers-mains_commands.ads

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private
4141

4242
overriding function Priority (Self : Command)
4343
return LSP.Server_Jobs.Job_Priority
44-
is (LSP.Server_Jobs.Low);
44+
is (LSP.Server_Jobs.Immediate);
4545

4646
for Command'External_Tag use "als-mains";
4747

source/ada/lsp-ada_handlers-source_dirs_commands.ads

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ private
4242

4343
overriding function Priority (Self : Command)
4444
return LSP.Server_Jobs.Job_Priority
45-
is (LSP.Server_Jobs.Low);
45+
is (LSP.Server_Jobs.Immediate);
4646

4747
for Command'External_Tag use "als-source-dirs";
4848

testsuite/ada_lsp/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,11 @@ JSON file preprocessing
164164
-----------------------
165165

166166
Before execution Tester does some text substitution in each string literal.
167-
* Each substring `${NAME}` is replaced by an environment variable with
167+
* Each substring `${NAME}` is replaced by an environment variable with
168168
given NAME. The `DIR` environment variable points to test's directory.
169169

170-
* Each substring `$URI{x}` is replaced by corresponding URI `file:///test_dir/x`.
171-
where `x` should be path relative to the directory where `.json` file is located.
170+
* Each substring `$URI{x}` is replaced by corresponding URI `file:///test_dir/x`.
171+
where `x` should be a path relative to the directory where the `.json` file is located.
172172

173+
* Each substring `$FILE{x}` is replaced by corresponding file path `/test_dir/x`.
174+
where `x` should be a path relative to the directory where the `.json` file is located.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
project Default is
2+
for Main use ("main_1.adb", "main_2.adb");
3+
end Default;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
procedure Main_1 is
2+
begin
3+
null;
4+
end Main_1;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
procedure Main_2 is
2+
begin
3+
null;
4+
end Main_2;
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
[
2+
{
3+
"comment": "Check als-mains command"
4+
},
5+
{
6+
"start": {
7+
"cmd": ["${ALS}"]
8+
}
9+
},
10+
{
11+
"send": {
12+
"request": {
13+
"jsonrpc": "2.0",
14+
"id": 0,
15+
"method": "initialize",
16+
"params": {
17+
"processId": 1,
18+
"rootUri": "$URI{.}",
19+
"capabilities": {}
20+
}
21+
},
22+
"wait": [
23+
{
24+
"id": 0,
25+
"result": {
26+
"capabilities": {
27+
"textDocumentSync": 2,
28+
"executeCommandProvider": {
29+
"commands": ["<HAS>", "als-mains"]
30+
}
31+
}
32+
}
33+
}
34+
]
35+
}
36+
},
37+
{
38+
"send": {
39+
"request": {
40+
"jsonrpc": "2.0",
41+
"method": "workspace/didChangeConfiguration",
42+
"params": {
43+
"settings": {
44+
"ada": {
45+
"projectFile": "$URI{default.gpr}"
46+
}
47+
}
48+
}
49+
},
50+
"wait": [
51+
{
52+
"jsonrpc": "2.0",
53+
"id": 1,
54+
"method": "window/workDoneProgress/create",
55+
"params": {
56+
"token": "<ANY>"
57+
}
58+
}
59+
]
60+
}
61+
},
62+
{
63+
"send": {
64+
"request": {
65+
"jsonrpc": "2.0",
66+
"id": "sw1",
67+
"method": "workspace/executeCommand",
68+
"params": {
69+
"command": "als-mains"
70+
}
71+
},
72+
"wait": [
73+
{
74+
"jsonrpc": "2.0",
75+
"id": "sw1",
76+
"result": ["$FILE{main_1.adb}", "$FILE{main_2.adb}"]
77+
}
78+
]
79+
}
80+
},
81+
{
82+
"send": {
83+
"request": {
84+
"jsonrpc": "2.0",
85+
"id": "shutdown",
86+
"method": "shutdown",
87+
"params": null
88+
},
89+
"wait": [{ "id": "shutdown", "result": null }]
90+
}
91+
},
92+
{
93+
"send": {
94+
"request": { "jsonrpc": "2.0", "method": "exit" },
95+
"wait": []
96+
}
97+
},
98+
{
99+
"stop": {
100+
"exit_code": 0
101+
}
102+
}
103+
]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
title: 'commands.mains'

testsuite/drivers/lsp_ada_requests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# TODO: use a library such as pytest-lsp to support most requests
99

1010

11-
def initialize(workspacefolder="."):
11+
def initialize(workspacefolder=URI(".")):
1212
"""This mimics what vs code sends at the moment"""
1313
return LSPMessage(
1414
{

testsuite/drivers/lsp_python_driver.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@
7373
DEBUG_MODE = False
7474

7575

76-
def set_debug_mode(mode : bool = True):
76+
def set_debug_mode(mode: bool = True):
7777
"""Set the debug mode."""
7878
global DEBUG_MODE
7979
DEBUG_MODE = mode
8080

8181

82-
def set_wait_factor(factor : float):
82+
def set_wait_factor(factor: float):
8383
"""Set the wait factor."""
8484
global RLIMIT_SECONDS
8585
global RESPONSE_TIMEOUT
@@ -93,7 +93,7 @@ def __init__(
9393
self,
9494
cl: str | list[str] | None = "ada_language_server",
9595
working_dir: str = ".",
96-
env: dict | None = None
96+
env: dict | None = None,
9797
):
9898
"""Launch an LSP server and provide a way to send messages to it.
9999
cl is the command line to launch the LSP server.
@@ -119,8 +119,9 @@ def __init__(
119119
self.wd = working_dir
120120

121121
# Kill the server when we reach this time
122-
self.kill_me_at = time.time() + RLIMIT_SECONDS * (
123-
1 + os.environ.get("ALS_WAIT_FACTOR", 0))
122+
self.kill_me_at = time.time() + int(
123+
RLIMIT_SECONDS * os.environ.get("ALS_WAIT_FACTOR", 1.0)
124+
)
124125

125126
# This contains either None or a timestamp. If a timestamp,
126127
# then the process should be killed after 2 seconds after this.
@@ -148,7 +149,6 @@ def __init__(
148149
if DEBUG_MODE:
149150
self.debug_here()
150151

151-
152152
def kill_task(self):
153153
while True:
154154
time.sleep(0.2)
@@ -178,7 +178,7 @@ def receive_task(self):
178178
break
179179
if not header.startswith("Content-Length:"):
180180
continue
181-
length = int(header[len("Content-Length:"):])
181+
length = int(header[len("Content-Length:") :])
182182

183183
# TODO: Add support for "Content-Type" header
184184

@@ -199,9 +199,7 @@ def receive_task(self):
199199

200200
time.sleep(0.01)
201201

202-
def send(
203-
self, message: LSPMessage, expect_response=True
204-
) -> LSPResponse | None:
202+
def send(self, message: LSPMessage, expect_response=True) -> LSPResponse | None:
205203
"""Send a message to the LSP server.
206204
If expect_response is True, wait for a response for at most timeout seconds.
207205
Return the response if any, or None if no response
@@ -257,12 +255,13 @@ def shutdown(self):
257255
# If errors were found, capture a replay file.
258256
# Compute the replay dir based on this file
259257
replay_dir = os.path.join(
260-
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
261-
"replays"
258+
os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "replays"
262259
)
263260
# Create the directory if it doesn't exist
264261
os.makedirs(replay_dir, exist_ok=True)
265-
replay_file = os.path.join(replay_dir, os.path.basename(self.wd) + "_replay.txt")
262+
replay_file = os.path.join(
263+
replay_dir, os.path.basename(self.wd) + "_replay.txt"
264+
)
266265
self.errors.append(f"Replay file written to {replay_file}")
267266

268267
# Write a "replay.txt" replay file

0 commit comments

Comments
 (0)