Skip to content

Commit

Permalink
Merge remote branch 'origin/master' into edge
Browse files Browse the repository at this point in the history
  • Loading branch information
automatic-merge committed Oct 11, 2023
2 parents 829c371 + 9791e0f commit bbf2ee5
Show file tree
Hide file tree
Showing 51 changed files with 924 additions and 6,850 deletions.
16 changes: 6 additions & 10 deletions doc/executables.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

## Capabilities
## Capabilities

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

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

## Change description

We introduce two requests, the first one:
We introduce two commands, the first one:

method: `glsMains`
command: `als-mains`

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

```typesript
type GlsMainResult = {
mains: string[];
};
type GlsMainResult = string[];
```

The second one is:

method: `glsExecutables`
command: `als-executables`

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

```typesript
type GlsExecutableResult = {
executables: string[];
};
type GlsExecutableResult = string[];
```
11 changes: 4 additions & 7 deletions doc/object_dir.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,21 @@

## Short introduction

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.
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.

## Change description

We introduce a new type to represent the request results:

```typescript

type ObjDirResponse = {
Value : string;
};
type ObjDirResponse = string;

```

And a new request:
And a new command with out arguments:

method: `$/glsObjectDir`
params: null
method: `als-object-dir`

Returning the project file of the loaded project like this:

Expand Down
11 changes: 4 additions & 7 deletions doc/project_file.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@

## Short introduction

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.
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.

## Change description

We introduce a new type to represent the request results:

```typescript

export type ProjectFileResponse = {
Value : string; // The Path to the GPR project file
};
export type ProjectFileResponse = string; // The Path to the GPR project file
```

And a new request:
And a new command with out arguments:

method: `$/glsProjectFile`
params: null
command: `als-project-file`

Returning the project file of the loaded project like this:

Expand Down
23 changes: 12 additions & 11 deletions doc/show_dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ a given unit.

## Capabilities

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

## Change description

Expand All @@ -23,7 +23,7 @@ export namespace ALS_ShowDependenciesKind {
}

interface ALS_ShowDependenciesParams {
textDocument : TextDocumentIdentifier; /* The queried unit */
uri : DocumentUri; /* The queried unit */
kind : ALS_ShowDependenciesKind; /* The dependencies query kind */
showImplicit : boolean; /* True if implicit dependencies should be returned */
}
Expand All @@ -34,15 +34,16 @@ interface ALS_Unit_Description {
}
```

And a new request:
And a new command `als-show-dependencies`:

method: `textDocument/alsShowDependencies`
params: `ALS_ShowDependenciesParams`
method: `workspace/executeCommand`
"params": {
"command": "als-show-dependencies",
"arguments": [
<ALS_ShowDependenciesParams>
]
}

Returning the references to the method identified at the given position:
It returns list of `ALS_Unit_Description`:

result: `ALS_Unit_Description[]`

We also introduce a new boolean field `ALS_showDepsProvider` in the
interface `ServerCapabilities` indicating whether the server supports
this extension.
16 changes: 0 additions & 16 deletions gnat/ignore_in_317.txt

This file was deleted.

6 changes: 0 additions & 6 deletions gnat/lsp_server.gpr
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,11 @@ project LSP_Server is

for Source_Dirs use
("../source/server",
"../source/server/generated",
"../source/ada",
"../source/gpr",
"../source/ada/generated",
"../source/memory");

for Excluded_Source_Dirs use
("../source/server/generated");

for Excluded_Source_List_File use "ignore_in_317.txt";

for Object_Dir use "../.obj/server";
for Main use ("lsp-ada_driver.adb");

Expand Down
41 changes: 17 additions & 24 deletions integration/vscode/ada/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { platform } from 'os';
import * as path from 'path';
import * as vscode from 'vscode';
import { LanguageClient } from 'vscode-languageclient/node';
import { ExecuteCommandRequest, LanguageClient } from 'vscode-languageclient/node';

/**
* Substitue any variable reference present in the given string. VS Code
Expand Down Expand Up @@ -181,21 +181,6 @@ export function logErrorAndThrow(msg: string, channel: vscode.OutputChannel) {
/*
GPR extensions helper functions
*/
type ProjectFileResponse = {
projectFile: string;
};

type ObjDirResponse = {
objectDir: string;
};

type MainsResponse = {
mains: string[];
};

type ExecutablesResponse = {
executables: string[];
};

/**
* Get the project file from the workspace configuration if available, or from
Expand All @@ -205,8 +190,10 @@ type ExecutablesResponse = {
* @returns a string contains the path of the project file
*/
export async function getProjectFile(client: LanguageClient): Promise<string> {
const result: ProjectFileResponse = await client.sendRequest('$/glsProjectFile');
return result.projectFile;
const result: string = (await client.sendRequest(ExecuteCommandRequest.type, {
command: 'als-project-file',
})) as string;
return result;
}

/**
Expand All @@ -215,8 +202,10 @@ export async function getProjectFile(client: LanguageClient): Promise<string> {
* @returns a string path
*/
export async function getObjectDir(client: LanguageClient): Promise<string> {
const result: ObjDirResponse = await client.sendRequest('$/glsObjectDir');
return result.objectDir;
const result: string = (await client.sendRequest(ExecuteCommandRequest.type, {
command: 'als-object-dir',
})) as string;
return result;
}

/**
Expand All @@ -225,8 +214,10 @@ export async function getObjectDir(client: LanguageClient): Promise<string> {
* @returns a vector of string paths
*/
export async function getMains(client: LanguageClient): Promise<string[]> {
const result: MainsResponse = await client.sendRequest('$/glsMains');
return result.mains;
const result: string[] = (await client.sendRequest(ExecuteCommandRequest.type, {
command: 'als-mains',
})) as string[];
return result;
}

/**
Expand All @@ -235,6 +226,8 @@ export async function getMains(client: LanguageClient): Promise<string[]> {
* @returns a vector of string paths
*/
export async function getExecutables(client: LanguageClient): Promise<string[]> {
const result: ExecutablesResponse = await client.sendRequest('$/glsExecutables');
return result.executables;
const result: string[] = (await client.sendRequest(ExecuteCommandRequest.type, {
command: 'als-executables',
})) as string[];
return result;
}
7 changes: 4 additions & 3 deletions source/ada/lsp-ada_commands.ads
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ package LSP.Ada_Commands is
return Command is abstract;

procedure Execute
(Self : Command;
Handler : not null access LSP.Ada_Handlers.Message_Handler'Class;
Error : in out LSP.Errors.ResponseError_Optional) is abstract;
(Self : Command;
Handler : not null access LSP.Ada_Handlers.Message_Handler'Class;
Response : in out LSP.Structures.LSPAny_Or_Null;
Error : in out LSP.Errors.ResponseError_Optional) is abstract;
-- Execute given command and return Error is something went wrong.
-- Commands are executed on the server side only.
-- The Handler is the access to the message handler executing the command.
Expand Down
25 changes: 19 additions & 6 deletions source/ada/lsp-ada_driver.adb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ with GNATCOLL.Utils;

with LSP.Ada_Commands;
with LSP.Ada_Handlers;
with LSP.Ada_Handlers.Executables_Commands;
with LSP.Ada_Handlers.Mains_Commands;
with LSP.Ada_Handlers.Named_Parameters_Commands;
with LSP.Ada_Handlers.Object_Dir_Commands;
with LSP.Ada_Handlers.Other_File_Commands;
with LSP.Ada_Handlers.Project_File_Commands;
with LSP.Ada_Handlers.Project_Reload_Commands;
with LSP.Ada_Handlers.Refactor.Add_Parameter;
with LSP.Ada_Handlers.Refactor.Change_Parameter_Mode;
Expand All @@ -55,6 +59,7 @@ with LSP.Ada_Handlers.Refactor.Remove_Parameter;
with LSP.Ada_Handlers.Refactor.Replace_Type;
with LSP.Ada_Handlers.Refactor.Sort_Dependencies;
with LSP.Ada_Handlers.Refactor.Suppress_Seperate;
with LSP.Ada_Handlers.Show_Dependencies_Commands;
with LSP.Ada_Handlers.Suspend_Executions;
with LSP.GNATCOLL_Trace_Streams;
with LSP.GNATCOLL_Tracers;
Expand Down Expand Up @@ -88,6 +93,16 @@ procedure LSP.Ada_Driver is
(LSP.Ada_Handlers.Suspend_Executions.Suspend_Execution'Tag);
LSP.Ada_Commands.Register
(LSP.Ada_Handlers.Project_Reload_Commands.Command'Tag);
LSP.Ada_Commands.Register
(LSP.Ada_Handlers.Show_Dependencies_Commands.Command'Tag);
LSP.Ada_Commands.Register
(LSP.Ada_Handlers.Executables_Commands.Command'Tag);
LSP.Ada_Commands.Register
(LSP.Ada_Handlers.Mains_Commands.Command'Tag);
LSP.Ada_Commands.Register
(LSP.Ada_Handlers.Project_File_Commands.Command'Tag);
LSP.Ada_Commands.Register
(LSP.Ada_Handlers.Object_Dir_Commands.Command'Tag);
LSP.Ada_Commands.Register
(LSP.Ada_Handlers.Named_Parameters_Commands.Command'Tag);
LSP.Ada_Commands.Register
Expand Down Expand Up @@ -302,12 +317,6 @@ begin
GNATCOLL.Memory.Configure (Activate_Monitor => True);
end if;

if not VSS.Command_Line.Is_Specified (Language_GPR_Option) then
-- Load predefined completion items
LSP.Predefined_Completion.Load_Predefined_Completion_Db (Server_Trace);
Register_Commands;
end if;

Ada.Text_IO.Set_Output (Ada.Text_IO.Standard_Error);
-- Protect stdout from pollution by accidental Put_Line calls

Expand Down Expand Up @@ -338,6 +347,10 @@ begin
else
Register_Commands;

-- Load predefined completion items
LSP.Predefined_Completion.Load_Predefined_Completion_Db
(Server_Trace);

Server.Run
(Ada_Handler'Unchecked_Access,
Tracer'Unchecked_Access,
Expand Down
Loading

0 comments on commit bbf2ee5

Please sign in to comment.