Skip to content

Commit d40b0a6

Browse files
Add support to sort prelude slice
1 parent 8391eb2 commit d40b0a6

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

source/ada/lsp-ada_handlers-refactor-sort_dependencies.adb

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Language Server Protocol --
33
-- --
4-
-- Copyright (C) 2023, AdaCore --
4+
-- Copyright (C) 2023-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- --
@@ -134,23 +134,23 @@ package body LSP.Ada_Handlers.Refactor.Sort_Dependencies is
134134
Message_Handler : LSP.Ada_Handlers.Message_Handler renames
135135
LSP.Ada_Handlers.Message_Handler (Handler.all);
136136
Document : constant LSP.Ada_Documents.Document_Access :=
137-
Message_Handler.Get_Open_Document
138-
(URI => Self.Where.uri);
137+
Message_Handler.Get_Open_Document (URI => Self.Where.uri);
139138
Context : LSP.Ada_Contexts.Context renames
140139
Message_Handler.Contexts.Get (Self.Context).all;
141140
File : constant GNATCOLL.VFS.Virtual_File :=
142141
Message_Handler.To_File (Self.Where.uri);
143142
Analysis_Unit : constant Libadalang.Analysis.Analysis_Unit :=
144143
Context.Get_AU (File);
145-
Sloc : constant Source_Location :=
146-
Document.To_Source_Location (Self.Where.a_range.start);
144+
Where : constant Source_Location_Range :=
145+
Document.To_Source_Location_Range (Self.Where.a_range);
147146
Compilation_Unit : constant Libadalang.Analysis.Compilation_Unit :=
148-
Analysis_Unit.Root.Lookup (Sloc).P_Enclosing_Compilation_Unit;
149-
Sorter : constant Dependencies_Sorter :=
150-
Create_Dependencies_Sorter
151-
(Compilation_Unit,
152-
Where => Document.To_Source_Location_Range
153-
(A_Range => Self.Where.a_range));
147+
Analysis_Unit
148+
.Root
149+
.Lookup (Where.Start_Sloc)
150+
.P_Enclosing_Compilation_Unit;
151+
Sorter : constant Dependencies_Sorter :=
152+
Create_Dependencies_Sorter (Compilation_Unit, Where);
153+
154154
begin
155155
Edits := Sorter.Refactor (null);
156156
end Refactor;

source/ada/lsp-ada_handlers.adb

+2-4
Original file line numberDiff line numberDiff line change
@@ -1032,10 +1032,8 @@ package body LSP.Ada_Handlers is
10321032
use LSP.Ada_Handlers.Refactor.Sort_Dependencies;
10331033
use LSP.Structures;
10341034

1035-
Location : constant Source_Location :=
1036-
(Langkit_Support.Slocs.Line_Number
1037-
(Value.a_range.start.line) + 1,
1038-
Column_Number (Value.a_range.start.character) + 1);
1035+
Location : constant Langkit_Support.Slocs.Source_Location_Range :=
1036+
Document.To_Source_Location_Range (Value.a_range);
10391037

10401038
Sort_Dependencies_Command :
10411039
LSP.Ada_Handlers.Refactor.Sort_Dependencies.Command;

0 commit comments

Comments
 (0)