Skip to content

Commit bbf2ee5

Browse files
author
automatic-merge
committed
Merge remote branch 'origin/master' into edge
2 parents 829c371 + 9791e0f commit bbf2ee5

File tree

51 files changed

+924
-6850
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+924
-6850
lines changed

doc/executables.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
This implements a functionality to query the mains and the executables for a multi targets project.
66

7-
## Capabilities
7+
## Capabilities
88

99
We provide the Build and Run tasks for specific targets in a GPR Projects.
1010

@@ -14,26 +14,22 @@ To check these tasks :
1414

1515
## Change description
1616

17-
We introduce two requests, the first one:
17+
We introduce two commands, the first one:
1818

19-
method: `glsMains`
19+
command: `als-mains`
2020

2121
Which provides the mains for the project, with a response type:
2222

2323
```typesript
24-
type GlsMainResult = {
25-
mains: string[];
26-
};
24+
type GlsMainResult = string[];
2725
```
2826

2927
The second one is:
3028

31-
method: `glsExecutables`
29+
command: `als-executables`
3230

3331
Which provides the executables for the project, with a response type:
3432

3533
```typesript
36-
type GlsExecutableResult = {
37-
executables: string[];
38-
};
34+
type GlsExecutableResult = string[];
3935
```

doc/object_dir.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,21 @@
22

33
## Short introduction
44

5-
This is a custom request used by the VS Code extension to retrieve the Object Directory from the GPR project file, allowing us to get the path to the object directory currently in use.
5+
This is a custom command used by the VS Code extension to retrieve the Object Directory from the GPR project file, allowing us to get the path to the object directory currently in use.
66

77
## Change description
88

99
We introduce a new type to represent the request results:
1010

1111
```typescript
1212

13-
type ObjDirResponse = {
14-
Value : string;
15-
};
13+
type ObjDirResponse = string;
1614

1715
```
1816

19-
And a new request:
17+
And a new command with out arguments:
2018

21-
method: `$/glsObjectDir`
22-
params: null
19+
method: `als-object-dir`
2320

2421
Returning the project file of the loaded project like this:
2522

doc/project_file.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,20 @@
22

33
## Short introduction
44

5-
This is a custom request used by the VS Code extension to retrieve the GPR project file uploaded by the ALS, allowing us to get the path to the project file currently in use.
5+
This is a custom command used by the VS Code extension to retrieve the GPR project file uploaded by the ALS, allowing us to get the path to the project file currently in use.
66

77
## Change description
88

99
We introduce a new type to represent the request results:
1010

1111
```typescript
1212

13-
export type ProjectFileResponse = {
14-
Value : string; // The Path to the GPR project file
15-
};
13+
export type ProjectFileResponse = string; // The Path to the GPR project file
1614
```
1715

18-
And a new request:
16+
And a new command with out arguments:
1917

20-
method: `$/glsProjectFile`
21-
params: null
18+
command: `als-project-file`
2219

2320
Returning the project file of the loaded project like this:
2421

doc/show_dependencies.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ a given unit.
88

99
## Capabilities
1010

11-
The `initialize` request returns a boolean `alsShowDepsProvider` as part of
12-
the `capabilities`, set to true if the server supports this functionality.
11+
The `initialize` request returns `als-show-dependencies` in the list of
12+
supported commands if the server supports this functionality.
1313

1414
## Change description
1515

@@ -23,7 +23,7 @@ export namespace ALS_ShowDependenciesKind {
2323
}
2424

2525
interface ALS_ShowDependenciesParams {
26-
textDocument : TextDocumentIdentifier; /* The queried unit */
26+
uri : DocumentUri; /* The queried unit */
2727
kind : ALS_ShowDependenciesKind; /* The dependencies query kind */
2828
showImplicit : boolean; /* True if implicit dependencies should be returned */
2929
}
@@ -34,15 +34,16 @@ interface ALS_Unit_Description {
3434
}
3535
```
3636

37-
And a new request:
37+
And a new command `als-show-dependencies`:
3838

39-
method: `textDocument/alsShowDependencies`
40-
params: `ALS_ShowDependenciesParams`
39+
method: `workspace/executeCommand`
40+
"params": {
41+
"command": "als-show-dependencies",
42+
"arguments": [
43+
<ALS_ShowDependenciesParams>
44+
]
45+
}
4146

42-
Returning the references to the method identified at the given position:
47+
It returns list of `ALS_Unit_Description`:
4348

4449
result: `ALS_Unit_Description[]`
45-
46-
We also introduce a new boolean field `ALS_showDepsProvider` in the
47-
interface `ServerCapabilities` indicating whether the server supports
48-
this extension.

gnat/ignore_in_317.txt

Lines changed: 0 additions & 16 deletions
This file was deleted.

gnat/lsp_server.gpr

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,11 @@ project LSP_Server is
4040

4141
for Source_Dirs use
4242
("../source/server",
43-
"../source/server/generated",
4443
"../source/ada",
4544
"../source/gpr",
4645
"../source/ada/generated",
4746
"../source/memory");
4847

49-
for Excluded_Source_Dirs use
50-
("../source/server/generated");
51-
52-
for Excluded_Source_List_File use "ignore_in_317.txt";
53-
5448
for Object_Dir use "../.obj/server";
5549
for Main use ("lsp-ada_driver.adb");
5650

integration/vscode/ada/src/helpers.ts

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import { platform } from 'os';
1818
import * as path from 'path';
1919
import * as vscode from 'vscode';
20-
import { LanguageClient } from 'vscode-languageclient/node';
20+
import { ExecuteCommandRequest, LanguageClient } from 'vscode-languageclient/node';
2121

2222
/**
2323
* Substitue any variable reference present in the given string. VS Code
@@ -181,21 +181,6 @@ export function logErrorAndThrow(msg: string, channel: vscode.OutputChannel) {
181181
/*
182182
GPR extensions helper functions
183183
*/
184-
type ProjectFileResponse = {
185-
projectFile: string;
186-
};
187-
188-
type ObjDirResponse = {
189-
objectDir: string;
190-
};
191-
192-
type MainsResponse = {
193-
mains: string[];
194-
};
195-
196-
type ExecutablesResponse = {
197-
executables: string[];
198-
};
199184

200185
/**
201186
* Get the project file from the workspace configuration if available, or from
@@ -205,8 +190,10 @@ type ExecutablesResponse = {
205190
* @returns a string contains the path of the project file
206191
*/
207192
export async function getProjectFile(client: LanguageClient): Promise<string> {
208-
const result: ProjectFileResponse = await client.sendRequest('$/glsProjectFile');
209-
return result.projectFile;
193+
const result: string = (await client.sendRequest(ExecuteCommandRequest.type, {
194+
command: 'als-project-file',
195+
})) as string;
196+
return result;
210197
}
211198

212199
/**
@@ -215,8 +202,10 @@ export async function getProjectFile(client: LanguageClient): Promise<string> {
215202
* @returns a string path
216203
*/
217204
export async function getObjectDir(client: LanguageClient): Promise<string> {
218-
const result: ObjDirResponse = await client.sendRequest('$/glsObjectDir');
219-
return result.objectDir;
205+
const result: string = (await client.sendRequest(ExecuteCommandRequest.type, {
206+
command: 'als-object-dir',
207+
})) as string;
208+
return result;
220209
}
221210

222211
/**
@@ -225,8 +214,10 @@ export async function getObjectDir(client: LanguageClient): Promise<string> {
225214
* @returns a vector of string paths
226215
*/
227216
export async function getMains(client: LanguageClient): Promise<string[]> {
228-
const result: MainsResponse = await client.sendRequest('$/glsMains');
229-
return result.mains;
217+
const result: string[] = (await client.sendRequest(ExecuteCommandRequest.type, {
218+
command: 'als-mains',
219+
})) as string[];
220+
return result;
230221
}
231222

232223
/**
@@ -235,6 +226,8 @@ export async function getMains(client: LanguageClient): Promise<string[]> {
235226
* @returns a vector of string paths
236227
*/
237228
export async function getExecutables(client: LanguageClient): Promise<string[]> {
238-
const result: ExecutablesResponse = await client.sendRequest('$/glsExecutables');
239-
return result.executables;
229+
const result: string[] = (await client.sendRequest(ExecuteCommandRequest.type, {
230+
command: 'als-executables',
231+
})) as string[];
232+
return result;
240233
}

source/ada/lsp-ada_commands.ads

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ package LSP.Ada_Commands is
4141
return Command is abstract;
4242

4343
procedure Execute
44-
(Self : Command;
45-
Handler : not null access LSP.Ada_Handlers.Message_Handler'Class;
46-
Error : in out LSP.Errors.ResponseError_Optional) is abstract;
44+
(Self : Command;
45+
Handler : not null access LSP.Ada_Handlers.Message_Handler'Class;
46+
Response : in out LSP.Structures.LSPAny_Or_Null;
47+
Error : in out LSP.Errors.ResponseError_Optional) is abstract;
4748
-- Execute given command and return Error is something went wrong.
4849
-- Commands are executed on the server side only.
4950
-- The Handler is the access to the message handler executing the command.

source/ada/lsp-ada_driver.adb

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,12 @@ with GNATCOLL.Utils;
3939

4040
with LSP.Ada_Commands;
4141
with LSP.Ada_Handlers;
42+
with LSP.Ada_Handlers.Executables_Commands;
43+
with LSP.Ada_Handlers.Mains_Commands;
4244
with LSP.Ada_Handlers.Named_Parameters_Commands;
45+
with LSP.Ada_Handlers.Object_Dir_Commands;
4346
with LSP.Ada_Handlers.Other_File_Commands;
47+
with LSP.Ada_Handlers.Project_File_Commands;
4448
with LSP.Ada_Handlers.Project_Reload_Commands;
4549
with LSP.Ada_Handlers.Refactor.Add_Parameter;
4650
with LSP.Ada_Handlers.Refactor.Change_Parameter_Mode;
@@ -55,6 +59,7 @@ with LSP.Ada_Handlers.Refactor.Remove_Parameter;
5559
with LSP.Ada_Handlers.Refactor.Replace_Type;
5660
with LSP.Ada_Handlers.Refactor.Sort_Dependencies;
5761
with LSP.Ada_Handlers.Refactor.Suppress_Seperate;
62+
with LSP.Ada_Handlers.Show_Dependencies_Commands;
5863
with LSP.Ada_Handlers.Suspend_Executions;
5964
with LSP.GNATCOLL_Trace_Streams;
6065
with LSP.GNATCOLL_Tracers;
@@ -88,6 +93,16 @@ procedure LSP.Ada_Driver is
8893
(LSP.Ada_Handlers.Suspend_Executions.Suspend_Execution'Tag);
8994
LSP.Ada_Commands.Register
9095
(LSP.Ada_Handlers.Project_Reload_Commands.Command'Tag);
96+
LSP.Ada_Commands.Register
97+
(LSP.Ada_Handlers.Show_Dependencies_Commands.Command'Tag);
98+
LSP.Ada_Commands.Register
99+
(LSP.Ada_Handlers.Executables_Commands.Command'Tag);
100+
LSP.Ada_Commands.Register
101+
(LSP.Ada_Handlers.Mains_Commands.Command'Tag);
102+
LSP.Ada_Commands.Register
103+
(LSP.Ada_Handlers.Project_File_Commands.Command'Tag);
104+
LSP.Ada_Commands.Register
105+
(LSP.Ada_Handlers.Object_Dir_Commands.Command'Tag);
91106
LSP.Ada_Commands.Register
92107
(LSP.Ada_Handlers.Named_Parameters_Commands.Command'Tag);
93108
LSP.Ada_Commands.Register
@@ -302,12 +317,6 @@ begin
302317
GNATCOLL.Memory.Configure (Activate_Monitor => True);
303318
end if;
304319

305-
if not VSS.Command_Line.Is_Specified (Language_GPR_Option) then
306-
-- Load predefined completion items
307-
LSP.Predefined_Completion.Load_Predefined_Completion_Db (Server_Trace);
308-
Register_Commands;
309-
end if;
310-
311320
Ada.Text_IO.Set_Output (Ada.Text_IO.Standard_Error);
312321
-- Protect stdout from pollution by accidental Put_Line calls
313322

@@ -338,6 +347,10 @@ begin
338347
else
339348
Register_Commands;
340349

350+
-- Load predefined completion items
351+
LSP.Predefined_Completion.Load_Predefined_Completion_Db
352+
(Server_Trace);
353+
341354
Server.Run
342355
(Ada_Handler'Unchecked_Access,
343356
Tracer'Unchecked_Access,

0 commit comments

Comments
 (0)