Skip to content

Commit 901f228

Browse files
author
automatic-merge
committed
Merge remote branch 'origin/master' into edge
2 parents c8f71bc + 52a5dc1 commit 901f228

File tree

15 files changed

+327
-50
lines changed

15 files changed

+327
-50
lines changed

.vscode/extensions.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
"gruntfuggly.triggertaskonsave",
1010
"davidanson.vscode-markdownlint",
1111
"adacore.ada",
12-
"ms-vscode.extension-test-runner"
12+
"ms-vscode.extension-test-runner",
13+
"timonwong.shellcheck",
14+
"foxundermoon.shell-format"
1315
]
1416
}

.vscode/settings.json.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
"[yaml]": {
2727
"editor.defaultFormatter": "esbenp.prettier-vscode"
2828
},
29+
"[shellscript]": {
30+
"editor.formatOnSave": true,
31+
"editor.defaultFormatter": "foxundermoon.shell-format"
32+
},
2933
"terminal.integrated.env.osx": {
3034
// Dependencies can be provided under the subprojects/ directory. They
3135
// would automatically be included in GPR_PROJECT_PATH by the following

integration/vscode/ada/test/suite/general/debug.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { exe } from '../../../src/helpers';
99
import { activate } from '../utils';
1010
import { adaExtState } from '../../../src/extension';
1111

12-
suite('Debug Configurations', function () {
12+
suite('Dbg Cfgs', function () {
1313
let expectedConfigs: AdaConfig[];
1414

1515
this.beforeAll(async () => {
@@ -88,7 +88,7 @@ suite('Debug Configurations', function () {
8888
];
8989
});
9090

91-
test('GDB path is explicitely set in offered debug config', async () => {
91+
test('GDB path is set in offered config', async () => {
9292
const firstConfig = (await adaDynamicDebugConfigProvider.provideDebugConfigurations()).at(
9393
0
9494
) as AdaConfig;

source/ada/lsp-ada_document_symbol.adb

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,23 @@ package body LSP.Ada_Document_Symbol is
337337

338338
when Libadalang.Common.Ada_Pragma_Node =>
339339
if Self.Stack.Length < 3 then
340-
Append_Name
341-
(Node.As_Pragma_Node.F_Id,
342-
Kind => LSP.Enumerations.Property,
343-
Detail => VSS.Strings.To_Virtual_String
344-
("(" & Node.As_Pragma_Node.F_Args.Text & ")"));
340+
declare
341+
Pragma_Node : constant Libadalang.Analysis.Pragma_Node :=
342+
Node.As_Pragma_Node;
343+
begin
344+
if not
345+
(Pragma_Node.F_Id.Is_Null
346+
and then Pragma_Node.F_Args.Is_Null)
347+
then
348+
Append_Name
349+
(Node.As_Pragma_Node.F_Id,
350+
Kind => LSP.Enumerations.Property,
351+
Detail =>
352+
VSS.Strings.To_Virtual_String
353+
("("
354+
& Node.As_Pragma_Node.F_Args.Text & ")"));
355+
end if;
356+
end;
345357
end if;
346358

347359
when others =>

source/ada/lsp-ada_documents.adb

Lines changed: 107 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,113 @@ package body LSP.Ada_Documents is
132132
-- Return a suitable sortText according to the completion item's
133133
-- visibility and position in the completion list.
134134

135+
procedure Get_Missing_Unit_And_Qualifier
136+
(Missing_Unit_Name : out VSS.Strings.Virtual_String;
137+
Missing_Qualifier : out VSS.Strings.Virtual_String);
138+
-- Get the missing unit name and qualifier (if needed) for invisible
139+
-- completion items.
140+
135141
procedure Append_Auto_Import_Command;
136142
-- Append the needed command to add the missing with-clause/qualifier
137143
-- when accepting an invisible completion item.
138144

145+
------------------------------------
146+
-- Get_Missing_unit_and_qualifier --
147+
------------------------------------
148+
149+
procedure Get_Missing_Unit_And_Qualifier
150+
(Missing_Unit_Name : out VSS.Strings.Virtual_String;
151+
Missing_Qualifier : out VSS.Strings.Virtual_String)
152+
is
153+
use Libadalang.Analysis;
154+
155+
Prefix : constant VSS.Strings.Virtual_String :=
156+
VSS.Strings.Conversions.To_Virtual_String
157+
(Langkit_Support.Text.To_UTF8 (Node.Text));
158+
159+
Dotted_Node : constant Ada_Node :=
160+
(if Node.Kind in Libadalang.Common.Ada_Dotted_Name_Range then
161+
Node
162+
else
163+
Node.Parent);
164+
165+
Is_Dotted_Name : constant Boolean :=
166+
not Dotted_Node.Is_Null and then
167+
Dotted_Node.Kind in Libadalang.Common.Ada_Dotted_Name_Range;
168+
-- Check if we are completing a dotted name. We want to prepend the
169+
-- right qualifier only if it's not the case.
170+
171+
Dotted_Node_Prefix : VSS.Strings.Virtual_String :=
172+
(if Is_Dotted_Name then
173+
VSS.Strings.Conversions.To_Virtual_String
174+
(Langkit_Support.Text.To_UTF8
175+
(Dotted_Node.As_Dotted_Name.F_Prefix.Text))
176+
else
177+
VSS.Strings.Empty_Virtual_String);
178+
-- The prefix of the dotted name we are completion, or an empty
179+
-- string if we are not completing a dotted name.
180+
181+
Missing_Unit_Root_Decl : constant Libadalang.Analysis.Basic_Decl :=
182+
BD.P_Enclosing_Compilation_Unit.P_Decl;
183+
-- The missing unit root declaration for this invisible symbol (e.g:
184+
-- the "Ada.Text_IO" package declaration for the
185+
-- "Ada.Text_IO.Put_Line" subprogram).
186+
187+
begin
188+
Missing_Unit_Name := VSS.Strings.Conversions.To_Virtual_String
189+
(Langkit_Support.Text.To_UTF8
190+
(Missing_Unit_Root_Decl.P_Fully_Qualified_Name));
191+
192+
-- We are completing a dotted name but its prefix does not match
193+
-- with the completion item's defining name's unit: this means we
194+
-- are dealing with renames (e.g: 'GNAT.Strings.Strings_Access'
195+
-- is a forward declaration of 'System.Strings.String_Access'). In
196+
-- that case, use the prefix specified by the user instead of the
197+
-- completion item's defining name's unit: the user explcitly wants
198+
-- to use the renamed symbol instead of the base one.
199+
200+
if Is_Dotted_Name
201+
and then not Missing_Unit_Name.Starts_With (Dotted_Node_Prefix)
202+
then
203+
declare
204+
Dotted_Prefix_Parts : VSS.String_Vectors.
205+
Virtual_String_Vector :=
206+
Dotted_Node_Prefix.Split
207+
(Separator => VSS.Characters.Latin.Full_Stop);
208+
begin
209+
-- Check if the unit specified as a prefix actually exists.
210+
-- If not, it might be a renamed package
211+
-- declaration/instantiation: in that case we want to add a
212+
-- with-clause on the enclosing unit (e.g: the prefix before
213+
-- the last '.').
214+
215+
while Get_From_Provider
216+
(Context => Context.LAL_Context,
217+
Name => Langkit_Support.Text.To_Text
218+
(VSS.Strings.Conversions.To_UTF_8_String
219+
(Dotted_Node_Prefix)),
220+
Kind => Libadalang.Common.Unit_Specification).Root.Is_Null
221+
loop
222+
Dotted_Prefix_Parts.Delete_Last;
223+
Dotted_Node_Prefix :=
224+
Dotted_Prefix_Parts.Join (VSS.Characters.Latin.Full_Stop);
225+
end loop;
226+
227+
Missing_Unit_Name := Dotted_Node_Prefix;
228+
end;
229+
end if;
230+
231+
-- We should not add any qualifier if the user accepted the
232+
-- completion item corresponding to the missing unit itself (e.g: if
233+
-- the user selects "Ada.Text_IO" in the completion window, we do not
234+
-- need to add any qualifier) or if he's completing a dotted name.
235+
Missing_Qualifier :=
236+
(if Is_Dotted_Name or else BD = Missing_Unit_Root_Decl then
237+
VSS.Strings.Empty_Virtual_String
238+
else
239+
Missing_Unit_Name);
240+
end Get_Missing_Unit_And_Qualifier;
241+
139242
-------------------
140243
-- Get_Sort_Text --
141244
-------------------
@@ -166,43 +269,15 @@ package body LSP.Ada_Documents is
166269

167270
procedure Append_Auto_Import_Command is
168271
use LSP.Ada_Handlers.Refactor;
169-
use Libadalang.Analysis;
170272

171273
Auto_Import_Command : Auto_Import.Command;
172274
-- The auto-import command.
173275

174-
Is_Dotted_Name : constant Boolean :=
175-
Node.Kind in Libadalang.Common.Ada_Dotted_Name_Range
176-
or else
177-
(not Node.Parent.Is_Null and then
178-
Node.Parent.Kind
179-
in Libadalang.Common.Ada_Dotted_Name_Range);
180-
-- Check if we are completing a dotted name. We want to prepend the
181-
-- right qualifier only if it's not the case.
182-
183-
Missing_Unit_Root_Decl : constant Libadalang.Analysis.Basic_Decl :=
184-
BD.P_Enclosing_Compilation_Unit.P_Decl;
185-
-- The missing unit root declaration for this invisible symbol (e.g:
186-
-- the "Ada.Text_IO" package declaration for the
187-
-- "Ada.Text_IO.Put_Line" subprogram).
188-
189-
Missing_Unit_Name : VSS.Strings.Virtual_String :=
190-
VSS.Strings.Conversions.To_Virtual_String
191-
(Langkit_Support.Text.To_UTF8
192-
(Missing_Unit_Root_Decl.P_Fully_Qualified_Name));
193-
-- Get the missing unit name.
194-
195-
Missing_Qualifier : VSS.Strings.Virtual_String :=
196-
(if Is_Dotted_Name or else BD = Missing_Unit_Root_Decl then
197-
VSS.Strings.Empty_Virtual_String
198-
else
199-
Missing_Unit_Name);
200-
-- The missing qualifier. We should not add any qualifier if the
201-
-- user accepted the completion item corresponding to the missing
202-
-- unit itself (e.g: if the user selects "Ada.Text_IO" in the
203-
-- completion window, we do not need to add any qualifier) or if
204-
-- he's completing a dotted name.
276+
Missing_Unit_Name : VSS.Strings.Virtual_String;
277+
Missing_Qualifier : VSS.Strings.Virtual_String;
205278
begin
279+
Get_Missing_Unit_And_Qualifier (Missing_Unit_Name, Missing_Qualifier);
280+
206281
Auto_Import_Command.Initialize
207282
(Context => Context,
208283
Where =>

source/ada/lsp-ada_handlers.adb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3245,9 +3245,7 @@ package body LSP.Ada_Handlers is
32453245
declare
32463246
Message : constant VSS.Strings.Virtual_String :=
32473247
VSS.Strings.Conversions.To_Virtual_String
3248-
("Exception: " &
3249-
Ada.Exceptions.Exception_Name (E) & " (" &
3250-
Ada.Exceptions.Exception_Message (E) & ")");
3248+
("Exception: " & Ada.Exceptions.Exception_Information (E));
32513249

32523250
begin
32533251
Self.Tracer.Trace_Exception (E, "On_Server_Request");

source/ada/lsp-gnatcoll_tracers.adb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ package body LSP.GNATCOLL_Tracers is
9090
(if Message.Is_Empty then "Exception:" else Message);
9191

9292
Self.Trace
93-
(Ada.Exceptions.Exception_Name (Error) & " - " &
94-
Ada.Exceptions.Exception_Message (Error));
93+
(Ada.Exceptions.Exception_Information (Error));
9594

9695
Self.Trace (GNAT.Traceback.Symbolic.Symbolic_Traceback (Error));
9796
end Trace_Exception;

source/gpr/lsp-gpr_documents.adb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,7 @@ package body LSP.GPR_Documents is
240240
(GPR2.Message.Create
241241
(Level => GPR2.Message.Error,
242242
Message => "GPR parser unexpected " &
243-
Ada.Exceptions.Exception_Name (E) & " " &
244-
Ada.Exceptions.Exception_Message (E),
243+
Ada.Exceptions.Exception_Information (E),
245244
Sloc => GPR2.Source_Reference.Create
246245
(Filename => Self.File.Value,
247246
Line => 1,

source/server/lsp-server_request_jobs.adb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ package body LSP.Server_Request_Jobs is
5151
declare
5252
Message : constant VSS.Strings.Virtual_String :=
5353
VSS.Strings.Conversions.To_Virtual_String
54-
("Exception: " &
55-
Ada.Exceptions.Exception_Name (E) & " (" &
56-
Ada.Exceptions.Exception_Message (E) & ")");
54+
("Exception: " & Ada.Exceptions.Exception_Information (E));
5755

5856
begin
5957
Client.On_Error_Response
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package Bar is
2+
3+
procedure Do_Something is null;
4+
5+
end Bar;

0 commit comments

Comments
 (0)