Skip to content

Commit ad6b7fb

Browse files
author
automatic-merge
committed
Merge remote branch 'origin/master' into edge
2 parents 4ee45ab + f077994 commit ad6b7fb

11 files changed

+69
-49
lines changed

integration/vscode/ada/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@
695695
},
696696
{
697697
"command": "ada.addMissingDirsToWorkspace",
698-
"title": "Ada: Add missing source directories to workspace",
698+
"title": "Ada: Add Missing Source Directories To Workspace",
699699
"when": "ADA_PROJECT_CONTEXT"
700700
},
701701
{

integration/vscode/ada/src/commands.ts

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { getOrAskForProgram } from './debugConfigProvider';
99
import { adaExtState, mainOutputChannel } from './extension';
1010
import { getProjectFileRelPath } from './helpers';
1111
import { CustomTaskDefinition, getEnclosingSymbol } from './taskProviders';
12-
import { LanguageClient } from 'vscode-languageclient/node';
1312

1413
export function registerCommands(context: vscode.ExtensionContext, clients: ExtensionState) {
1514
context.subscriptions.push(vscode.commands.registerCommand('ada.otherFile', otherFileHandler));
@@ -52,15 +51,11 @@ export function registerCommands(context: vscode.ExtensionContext, clients: Exte
5251
'ada.addMissingDirsToWorkspace',
5352
async (
5453
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
55-
displayPopupWhenMissing: boolean = false,
54+
atStartup: boolean = false,
5655
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
57-
displayPopupOnSuccess: boolean = true
56+
displayYesNoPopup: boolean = true
5857
) => {
59-
await checkSrcDirectories(
60-
clients.adaClient,
61-
displayPopupWhenMissing,
62-
displayPopupOnSuccess
63-
);
58+
await checkSrcDirectories(atStartup, displayYesNoPopup);
6459
}
6560
)
6661
);
@@ -362,26 +357,27 @@ const otherFileHandler = () => {
362357
* Do nothing if the user did not setup any workspace file.
363358
*
364359
* @param alsClient - the running ALS client
365-
* @param displayPopupWhenMissing - whether or not we should display a yes/no popup
360+
* @param atStartup - whether or not the command is triggered when activating the extension
361+
* or explicitly by the user later via the Command Palette
362+
* @param displayYesNoPopup - whether or not we should display a yes/no popup
366363
* when missing directories
367-
* @param displayPopupOnSuccess - whether or not we should display a popup to notify
368-
* the user that there is no missing directory
369364
*/
370-
export async function checkSrcDirectories(
371-
alsClient: LanguageClient,
372-
displayPopupWhenMissing = true,
373-
displayPopupOnSuccess = true
374-
) {
365+
export async function checkSrcDirectories(atStartup = false, displayYesNoPopup = true) {
375366
type ALSSourceDirDescription = {
376367
name: string;
377368
uri: string;
378369
};
379370

380371
const foldersInSettings = vscode.workspace.getConfiguration().get('folders');
372+
const alsClient = adaExtState.adaClient;
373+
const doNotShowAgainKey = 'ada.addMissingDirsToWorkspace.doNotShowAgain';
374+
const doNotShowAgain = adaExtState.context.workspaceState.get(doNotShowAgainKey);
381375

382376
// Don't propose any popup if we multi-root workspace folders are already set
383-
// explicitly in the workspace's settings.
384-
if (foldersInSettings === undefined) {
377+
// explicitly in the workspace's settings, or if the command has been
378+
// triggered at startup while the user previously clicked on the
379+
// 'Don't show again' button for this workspace
380+
if (foldersInSettings === undefined && !(atStartup && doNotShowAgain)) {
385381
const sourceDirs: ALSSourceDirDescription[] = (await alsClient.sendRequest(
386382
ExecuteCommandRequest.type,
387383
{
@@ -429,17 +425,30 @@ export async function checkSrcDirectories(
429425
if (workspaceDirsToAdd.length > 0) {
430426
let doAdd = true;
431427

432-
if (displayPopupWhenMissing) {
428+
if (displayYesNoPopup) {
429+
const buttons: ('Yes' | 'No' | "Don't Show Again")[] = ['Yes', 'No'];
430+
431+
// Show the 'Don't Show Again' button only at startup
432+
if (atStartup) {
433+
buttons.push("Don't Show Again");
434+
}
435+
433436
await vscode.window
434437
.showInformationMessage(
435438
'Some project source directories are not \
436-
listed in your workspace: do you want to add them?',
437-
'Yes',
438-
'No'
439+
listed in your workspace: do you want to add them?',
440+
...buttons
439441
)
440442
.then((answer) => {
441443
if (answer !== 'Yes') {
442444
doAdd = false;
445+
446+
if (answer === "Don't Show Again") {
447+
void adaExtState.context.workspaceState.update(
448+
doNotShowAgainKey,
449+
true
450+
);
451+
}
443452
}
444453
});
445454
}
@@ -453,7 +462,7 @@ export async function checkSrcDirectories(
453462
...workspaceDirsToAdd
454463
);
455464
}
456-
} else if (displayPopupOnSuccess) {
465+
} else if (!atStartup) {
457466
void vscode.window.showInformationMessage(
458467
"All the project's source directories are already \
459468
available in the current workspace."

integration/vscode/ada/src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ async function activateExtension(context: vscode.ExtensionContext) {
171171
/**
172172
* This can display a dialog to the User so don't wait on the result.
173173
*/
174-
void vscode.commands.executeCommand('ada.addMissingDirsToWorkspace', true, false);
174+
void vscode.commands.executeCommand('ada.addMissingDirsToWorkspace', true);
175175
}
176176

177177
function setUpLogging(context: vscode.ExtensionContext) {

integration/vscode/ada/test/suite/workspace_missing_dirs/workspace_missing_dirs.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ suite('Extensions Advanced Test Suite', function () {
1818

1919
// Execute the 'ada.addMissingDirsToWorkspace' command, that imports the missing
2020
// source directories into the current workspace if needed
21-
await vscode.commands.executeCommand('ada.addMissingDirsToWorkspace', false);
21+
await vscode.commands.executeCommand('ada.addMissingDirsToWorkspace', false, false);
2222

2323
// Check that we have 3 workspace folders after executing the command
2424
folders = vscode.workspace.workspaceFolders;

source/ada/lsp-ada_completions-generic_assoc.adb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Language Server Protocol --
33
-- --
4-
-- Copyright (C) 2022-2023, AdaCore --
4+
-- Copyright (C) 2022-2024, AdaCore --
55
-- --
66
-- This is free software; you can redistribute it and/or modify it under --
77
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -23,6 +23,7 @@ with LSP.Ada_Documents;
2323
with LSP.Enumerations;
2424
with VSS.Strings.Character_Iterators;
2525
with VSS.Strings.Conversions;
26+
with VSS.Transformers.Caseless;
2627
with VSS.Unicode;
2728

2829
pragma Warnings (Off, "is not referenced");
@@ -265,7 +266,7 @@ package body LSP.Ada_Completions.Generic_Assoc is
265266
or else
266267
Name.Starts_With
267268
(Completion_Prefix,
268-
VSS.Strings.Identifier_Caseless)
269+
VSS.Transformers.Caseless.To_Identifier_Caseless)
269270
then
270271
-- Snippet Format: "Name => "
271272
Item.label := Name;

source/ada/lsp-ada_completions-keywords.adb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Language Server Protocol --
33
-- --
4-
-- Copyright (C) 2018-2021, AdaCore --
4+
-- Copyright (C) 2018-2024, AdaCore --
55
-- --
66
-- This is free software; you can redistribute it and/or modify it under --
77
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -19,6 +19,7 @@ with Ada.Strings.Wide_Wide_Unbounded;
1919
with Libadalang.Common;
2020

2121
with VSS.Strings;
22+
with VSS.Transformers.Caseless;
2223

2324
with LSP.Ada_Completions.Filters;
2425
with LSP.Enumerations;
@@ -72,7 +73,7 @@ package body LSP.Ada_Completions.Keywords is
7273

7374
begin
7475
if Label.Starts_With
75-
(Prefix, VSS.Strings.Identifier_Caseless)
76+
(Prefix, VSS.Transformers.Caseless.To_Identifier_Caseless)
7677
then
7778
Item.label := Label;
7879
Item.insertTextFormat := (True, LSP.Enumerations.PlainText);

source/ada/lsp-ada_completions-names.adb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Language Server Protocol --
33
-- --
4-
-- Copyright (C) 2018-2021, AdaCore --
4+
-- Copyright (C) 2018-2024, AdaCore --
55
-- --
66
-- This is free software; you can redistribute it and/or modify it under --
77
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -18,6 +18,7 @@
1818
with Langkit_Support.Errors;
1919

2020
with VSS.Strings;
21+
with VSS.Transformers.Caseless;
2122

2223
with LSP.Ada_Completions.Filters;
2324

@@ -185,7 +186,8 @@ package body LSP.Ada_Completions.Names is
185186
elsif Dotted_Node.Kind in
186187
Libadalang.Common.Ada_Dotted_Name_Range
187188
or else Name.Starts_With
188-
(Prefix, VSS.Strings.Identifier_Caseless)
189+
(Prefix,
190+
VSS.Transformers.Caseless.To_Identifier_Caseless)
189191
then
190192
Completion_Count := Completion_Count + 1;
191193

source/ada/lsp-ada_configurations.adb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Language Server Protocol --
33
-- --
4-
-- Copyright (C) 2018-2023, AdaCore --
4+
-- Copyright (C) 2018-2024, AdaCore --
55
-- --
66
-- This is free software; you can redistribute it and/or modify it under --
77
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -25,16 +25,19 @@ with VSS.JSON.Pull_Readers.Simple;
2525
with VSS.JSON.Streams;
2626
with VSS.Strings.Conversions;
2727
with VSS.Text_Streams.File_Input;
28+
with VSS.Transformers.Casing;
2829

2930
package body LSP.Ada_Configurations is
3031

3132
Doc_Style_Values : constant VSS.String_Vectors.Virtual_String_Vector :=
3233
[for Item in GNATdoc.Comments.Options.Documentation_Style =>
33-
VSS.Strings.To_Virtual_String (Item'Wide_Wide_Image).To_Lowercase];
34+
VSS.Strings.To_Virtual_String (Item'Wide_Wide_Image).Transform
35+
(VSS.Transformers.Casing.To_Lowercase)];
3436

3537
Display_Method_Values : constant VSS.String_Vectors.Virtual_String_Vector :=
3638
[for Item in LSP.Enumerations.AlsDisplayMethodAncestryOnNavigationPolicy
37-
=> VSS.Strings.To_Virtual_String (Item'Wide_Wide_Image).To_Lowercase];
39+
=> VSS.Strings.To_Virtual_String (Item'Wide_Wide_Image).Transform
40+
(VSS.Transformers.Casing.To_Lowercase)];
3841

3942
function "+" (X : VSS.Strings.Virtual_String'Class) return String renames
4043
VSS.Strings.Conversions.To_UTF_8_String;

source/ada/lsp-predefined_completion.adb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Language Server Protocol --
33
-- --
4-
-- Copyright (C) 2020-2021, AdaCore --
4+
-- Copyright (C) 2020-2024, AdaCore --
55
-- --
66
-- This is free software; you can redistribute it and/or modify it under --
77
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -25,6 +25,7 @@ with GNATCOLL.VFS; use GNATCOLL.VFS;
2525
with GNATCOLL.Utils;
2626

2727
with VSS.Strings.Conversions;
28+
with VSS.Transformers.Caseless;
2829

2930
with LSP.Enumerations;
3031
with LSP.Predefined_Completion.Ada2012;
@@ -201,7 +202,7 @@ package body LSP.Predefined_Completion is
201202
begin
202203
for Item of Items loop
203204
if Item.label.Starts_With
204-
(Prefix, VSS.Strings.Identifier_Caseless)
205+
(Prefix, VSS.Transformers.Caseless.To_Identifier_Caseless)
205206
then
206207
Result.Append (Item);
207208
end if;

source/ada/lsp-search-start_word.adb

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Language Server Protocol --
33
-- --
4-
-- Copyright (C) 2021-2023, AdaCore --
4+
-- Copyright (C) 2021-2024, AdaCore --
55
-- --
66
-- This is free software; you can redistribute it and/or modify it under --
77
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -15,6 +15,8 @@
1515
-- of the license. --
1616
------------------------------------------------------------------------------
1717

18+
with VSS.Transformers.Caseless; use VSS.Transformers.Caseless;
19+
1820
package body LSP.Search.Start_Word is
1921

2022
-----------
@@ -54,15 +56,15 @@ package body LSP.Search.Start_Word is
5456
overriding function Match
5557
(Self : Start_Word_Search;
5658
Text : VSS.Strings.Virtual_String)
57-
return Boolean
58-
is
59-
Kind : constant array (Boolean) of VSS.Strings.Case_Sensitivity :=
60-
[False => VSS.Strings.Identifier_Caseless,
61-
True => VSS.Strings.Case_Sensitive];
62-
59+
return Boolean is
6360
begin
64-
return Text.Starts_With (Self.Text, Kind (Self.Case_Sensitive))
65-
xor Self.Negate;
61+
case Self.Case_Sensitive is
62+
when False =>
63+
return Text.Starts_With (Self.Text, To_Identifier_Caseless)
64+
xor Self.Negate;
65+
when True =>
66+
return Text.Starts_With (Self.Text) xor Self.Negate;
67+
end case;
6668
end Match;
6769

6870
end LSP.Search.Start_Word;

0 commit comments

Comments
 (0)