Skip to content

Commit 515d278

Browse files
joaopsazevedosetton
authored andcommitted
SC12-007 Rename files according to naming scheme
(cherry picked from commit 8e86258)
1 parent cbbe8d1 commit 515d278

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
@@ -290,6 +290,24 @@ package LSP.Ada_Contexts is
290290
function Charset (Self : Context) return String;
291291
-- Return the charset for this context
292292

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

295313
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
@@ -3987,11 +3987,27 @@ package body LSP.Ada_Handlers is
39873987
---------------------
39883988

39893989
procedure Process_Context (C : Context_Access) is
3990+
use GNATCOLL.Projects;
3991+
use Laltools.Refactor.Safe_Rename;
3992+
39903993
Node : constant Ada_Node := C.Get_Node_At (Document, Position);
3991-
Name_Node : constant Name := Laltools.Common.Get_Node_As_Name (Node);
3994+
Name_Node : constant Libadalang.Analysis.Name :=
3995+
Laltools.Common.Get_Node_As_Name (Node);
39923996
Definition : constant Defining_Name :=
39933997
Laltools.Common.Resolve_Name_Precisely (Name_Node);
39943998

3999+
function Attribute_Value_Provider_Callback
4000+
(Attribute : GNATCOLL.Projects.Attribute_Pkg_String;
4001+
Index : String := "";
4002+
Default : String := "";
4003+
Use_Extended : Boolean := False)
4004+
return String
4005+
is (C.Project_Attribute_Value
4006+
(Attribute, Index, Default, Use_Extended));
4007+
4008+
Attribute_Value_Provider : constant Attribute_Value_Provider_Access :=
4009+
Attribute_Value_Provider_Callback'Unrestricted_Access;
4010+
39954011
function Analysis_Units return Analysis_Unit_Array is
39964012
(C.Analysis_Units);
39974013
-- Callback needed to provide the analysis units to the safe rename
@@ -4226,11 +4242,12 @@ package body LSP.Ada_Handlers is
42264242
end if;
42274243

42284244
Safe_Renamer := Laltools.Refactor.Safe_Rename.Create_Safe_Renamer
4229-
(Definition => Definition,
4230-
New_Name =>
4245+
(Definition => Definition,
4246+
New_Name =>
42314247
Libadalang.Text.To_Unbounded_Text
42324248
(VSS.Strings.Conversions.To_Wide_Wide_String (Value.newName)),
4233-
Algorithm => Algorithm);
4249+
Algorithm => Algorithm,
4250+
Attribute_Value_Provider => Attribute_Value_Provider);
42344251

42354252
Context_Edits := Safe_Renamer.Refactor (Analysis_Units'Access);
42364253

0 commit comments

Comments
 (0)