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 Jun 28, 2024
2 parents 4219b09 + 432cbb6 commit 1674a7b
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 29 deletions.
7 changes: 7 additions & 0 deletions .markdownlint.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"no-inline-html": {
"allowed_elements": ["img"]
},
"line-length": false,
"ul-style": false
}
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ extension at
- [Tasks](#tasks)
- [Task Customization](#task-customization)
- [Tasks for Project Mains](#tasks-for-project-mains)
- [GNATtest Support](#gnattest-support)
- [ALIRE Support](#alire-support)
- [Commands and Shortcuts](#commands-and-shortcuts)
- [Ada: Go to other file](#ada-go-to-other-file)
Expand All @@ -71,7 +72,6 @@ extension at
- [Contribute](#contribute)
- [License](#license)


## Install

You can build language server from sources.
Expand Down Expand Up @@ -275,6 +275,34 @@ For example, if the project defines a `main1.adb` and `main2.adb` located under
* `ada: Run main - src/main2.adb`
* `ada: Build and run main - src/main2.adb`

#### GNATtest Support

If you install GNATtest, the Ada & SPARK extension for VS Code will provide the following functionalities:

* The task `ada: Create/update test skeletons for the project` will call `gnattest` to create test skeletons for your project automatically. You can use standard VS Code task customization to configure command line arguments to your liking in a `tasks.json` file.

* Tests created with GNATtest will be loaded in the VS Code **Testing** view as follows.

<img src="doc/gnattest-test-tree.png" width="650" alt="GNATtest Test Tree">

* Tests can be executed individually or in batch through the available buttons in the interface, or through the `Test: Run All Tests` command or related commands.

* Test execution results are reflected in the test tree.

<img src="doc/gnattest-results.png" width="500" alt="GNATtest Test Results">

GNATtest support has the following known limitations:

* The extension relies on the default conventions of GNATtest such as the naming, location and object directory of the test harness project.
If those aspects are configured or altered manually, the features may no longer work.

* Test execution always starts with a `gprbuild` call on the test harness project. It is not possible to disable that call or customize its arguments. This limitation will be lifted in future releases.

* Language support such as navigation and auto-completion is limited when editing test sources. A workaround is to modify the `ada.projectFile` setting to point to the test harness project created by GNATtest. That should restore language support when developing tests.

* Sections of test sources delimited by `begin read only` and `end read only` comments are not really protected from inadvertant edits.
To ensure proper interactions with GNATtest, you must refrain from making edits in those sections.

#### ALIRE Support

When the workspace is an ALIRE project (i.e. it contains an `alire.toml` file), tasks automatically use standard ALIRE commands.
Expand Down
Binary file added doc/gnattest-results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/gnattest-test-tree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 14 additions & 9 deletions doc/traces.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
# ALS Trace File

Default trace file name is `$HOME/.als/traces.cfg`.
You can provide another file by `--tracefile=<FILE>` command line option.
Default trace file name is `$HOME/.als/traces.cfg`. This file gets automatically created
if not present on the disk. The first line of the traces file
defines the traces output stream (a filename in our case) and the other
lines are used to enable or disable traces.

Here is a list of supported settings.
Note that you can provide another traces file via the `--tracefile=<FILE>` command line option.

Here is a list of the most useful supported traces:

## `ALS.IN` (default no)
Show all the server input. Use this way:
Shows all the server's input. Use this way:

ALS.IN=yes > inout.txt:buffer_size=0
ALS.IN=yes

## `ALS.OUT` (default no)
Show all the server output. Use this way:
Shows all the server's output. Use this way:

ALS.OUT=yes > inout.txt:buffer_size=0
ALS.OUT=yes

## `ALS.MAIN` (default no)
Trace requests, notifications and responses in an ALS log file.
## `ALS.MAIN` (default yes)
Trace requests, notifications and responses in ALS log files. Will
also log any exception that occurs when handling LSP requests.

ALS.MAIN=yes

Expand Down
58 changes: 39 additions & 19 deletions source/ada/lsp-ada_driver.adb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
--
-- This is driver to run LSP server for Ada language.

with Ada.Characters.Latin_1;
with Ada.Text_IO;
with Ada.Strings.Unbounded;
with GNAT.OS_Lib;
Expand Down Expand Up @@ -257,6 +258,14 @@ procedure LSP.Ada_Driver is
GNATdebug : constant Virtual_File := Create_From_Base
(".gnatdebug");

Default_Traces_File_Contents : constant String :=
">als.$T.txt:buffer_size=0" & Ada.Characters.Latin_1.LF
& "ALS.MAIN=yes" & Ada.Characters.Latin_1.LF
& "ALS.IN=no" & Ada.Characters.Latin_1.LF
& "ALS.OUT=no" & Ada.Characters.Latin_1.LF;

Traces_File : Virtual_File;

Trace_File_Option : constant VSS.Command_Line.Value_Option :=
(Short_Name => "",
Long_Name => "tracefile",
Expand Down Expand Up @@ -309,31 +318,42 @@ begin
-- - in a .gnatdebug file locally
-- - in "traces.cfg" in the ALS home directory
if VSS.Command_Line.Is_Specified (Trace_File_Option) then
declare
Traces_File : constant Virtual_File := Create_From_UTF8
(VSS.Strings.Conversions.To_UTF_8_String
(VSS.Command_Line.Value (Trace_File_Option)));
begin
if not Traces_File.Is_Regular_File then
Ada.Text_IO.Put_Line ("Could not find the specified traces file");
GNAT.OS_Lib.OS_Exit (1);
end if;
Traces_File := Create_From_UTF8
(VSS.Strings.Conversions.To_UTF_8_String
(VSS.Command_Line.Value (Trace_File_Option)));
if not Traces_File.Is_Regular_File then
Ada.Text_IO.Put_Line ("Could not find the specified traces file");
GNAT.OS_Lib.OS_Exit (1);
end if;

Parse_Config_File (Traces_File);

Parse_Config_File (Traces_File);
end;
elsif GNATdebug.Is_Regular_File then
Parse_Config_File (GNATdebug);

elsif ALS_Dir.Is_Directory then
Clean_ALS_Dir := True;
else
-- No $HOME/.als directory: create one first
if not ALS_Dir.Is_Directory then
Make_Dir (ALS_Dir);
end if;

-- Search for custom traces config in traces.cfg
Parse_Config_File (+Virtual_File'(ALS_Dir / "traces.cfg").Full_Name);
Traces_File := Create_From_Dir
(Dir => ALS_Dir,
Base_Name => "traces.cfg");

-- No default traces file found: create one
if not Traces_File.Is_Regular_File then
declare
W_Traces_File : Writable_File;
begin
W_Traces_File := Traces_File.Write_File;
W_Traces_File.Write (Default_Traces_File_Contents);
W_Traces_File.Close;
end;
end if;

-- Set log file
Set_Default_Stream
(">" & (+Virtual_File'(ALS_Dir / "als").Full_Name) &
".$T.$$.log:buffer_size=0");
Clean_ALS_Dir := True;
Parse_Config_File (Traces_File);
end if;

-- Look for a config file, that contains the configuration for the server
Expand Down
3 changes: 3 additions & 0 deletions testsuite/.als/traces.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ ALS.RUNTIME_INDEXING=no

# Disable advanced PP formatting of snippet for most tests
ALS.COMPLETION.FORMATTING=no

# Disable logging in LSP formatting module
ALS.FORMATTING=no

0 comments on commit 1674a7b

Please sign in to comment.