Skip to content

Commit 8e86258

Browse files
SC12-007 Rename files according to naming scheme
1 parent 13c8ee2 commit 8e86258

File tree

3 files changed

+53
-4
lines changed

3 files changed

+53
-4
lines changed

source/ada/lsp-ada_contexts.adb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,4 +1051,18 @@ package body LSP.Ada_Contexts is
10511051
return Ada.Strings.Unbounded.To_String (Self.Charset);
10521052
end Charset;
10531053

1054+
-----------------------------
1055+
-- Project_Attribute_Value --
1056+
-----------------------------
1057+
1058+
function Project_Attribute_Value
1059+
(Self : Context;
1060+
Attribute : Attribute_Pkg_String;
1061+
Index : String := "";
1062+
Default : String := "";
1063+
Use_Extended : Boolean := False) return String
1064+
is (if Self.Tree = null then Default
1065+
else Root_Project (Self.Tree.all).
1066+
Attribute_Value (Attribute, Index, Default, Use_Extended));
1067+
10541068
end LSP.Ada_Contexts;

source/ada/lsp-ada_contexts.ads

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,24 @@ package LSP.Ada_Contexts is
286286
function Charset (Self : Context) return String;
287287
-- Return the charset for this context
288288

289+
function Project_Attribute_Value
290+
(Self : Context;
291+
Attribute : GNATCOLL.Projects.Attribute_Pkg_String;
292+
Index : String := "";
293+
Default : String := "";
294+
Use_Extended : Boolean := False) return String;
295+
-- Returns the value for Self's project Attribute.
296+
-- Default is returned if the attribute wasn't set by the user and
297+
-- has no default value.
298+
-- The corresponding attribute would have been set in the project as:
299+
-- for Attribute use "value";
300+
-- or
301+
-- for Attribute (Index) use "value";
302+
--
303+
-- If Use_Extended is True and the attribute is not defined in Project
304+
-- itself, then the attribute is looked up in the project extended by
305+
-- Project (if any).
306+
289307
private
290308

291309
type Context (Trace : GNATCOLL.Traces.Trace_Handle) is tagged limited record

source/ada/lsp-ada_handlers.adb

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3906,11 +3906,27 @@ package body LSP.Ada_Handlers is
39063906
---------------------
39073907

39083908
procedure Process_Context (C : Context_Access) is
3909+
use GNATCOLL.Projects;
3910+
use Laltools.Refactor.Safe_Rename;
3911+
39093912
Node : constant Ada_Node := C.Get_Node_At (Document, Position);
3910-
Name_Node : constant Name := Laltools.Common.Get_Node_As_Name (Node);
3913+
Name_Node : constant Libadalang.Analysis.Name :=
3914+
Laltools.Common.Get_Node_As_Name (Node);
39113915
Definition : constant Defining_Name :=
39123916
Laltools.Common.Resolve_Name_Precisely (Name_Node);
39133917

3918+
function Attribute_Value_Provider_Callback
3919+
(Attribute : GNATCOLL.Projects.Attribute_Pkg_String;
3920+
Index : String := "";
3921+
Default : String := "";
3922+
Use_Extended : Boolean := False)
3923+
return String
3924+
is (C.Project_Attribute_Value
3925+
(Attribute, Index, Default, Use_Extended));
3926+
3927+
Attribute_Value_Provider : constant Attribute_Value_Provider_Access :=
3928+
Attribute_Value_Provider_Callback'Unrestricted_Access;
3929+
39143930
function Analysis_Units return Analysis_Unit_Array is
39153931
(C.Analysis_Units);
39163932
-- Callback needed to provide the analysis units to the safe rename
@@ -4145,11 +4161,12 @@ package body LSP.Ada_Handlers is
41454161
end if;
41464162

41474163
Safe_Renamer := Laltools.Refactor.Safe_Rename.Create_Safe_Renamer
4148-
(Definition => Definition,
4149-
New_Name =>
4164+
(Definition => Definition,
4165+
New_Name =>
41504166
Libadalang.Text.To_Unbounded_Text
41514167
(VSS.Strings.Conversions.To_Wide_Wide_String (Value.newName)),
4152-
Algorithm => Algorithm);
4168+
Algorithm => Algorithm,
4169+
Attribute_Value_Provider => Attribute_Value_Provider);
41534170

41544171
Context_Edits := Safe_Renamer.Refactor (Analysis_Units'Access);
41554172

0 commit comments

Comments
 (0)