Skip to content

Commit

Permalink
Merge remote branch 'origin/master' into edge
Browse files Browse the repository at this point in the history
  • Loading branch information
automatic-merge committed Jun 5, 2024
2 parents 2adbec2 + 3af8181 commit 4c8888d
Show file tree
Hide file tree
Showing 13 changed files with 387 additions and 16 deletions.
20 changes: 11 additions & 9 deletions source/ada/lsp-ada_handlers-refactor-sort_dependencies.adb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
------------------------------------------------------------------------------
-- Language Server Protocol --
-- --
-- Copyright (C) 2023, AdaCore --
-- Copyright (C) 2023-2024, AdaCore --
-- --
-- This is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
Expand Down Expand Up @@ -133,22 +133,24 @@ package body LSP.Ada_Handlers.Refactor.Sort_Dependencies is

Message_Handler : LSP.Ada_Handlers.Message_Handler renames
LSP.Ada_Handlers.Message_Handler (Handler.all);
Document : constant LSP.Ada_Documents.Document_Access :=
Message_Handler.Get_Open_Document (URI => Self.Where.uri);
Context : LSP.Ada_Contexts.Context renames
Message_Handler.Contexts.Get (Self.Context).all;
File : constant GNATCOLL.VFS.Virtual_File :=
Message_Handler.To_File (Self.Where.uri);
Analysis_Unit : constant Libadalang.Analysis.Analysis_Unit :=
Context.Get_AU (File);
Sloc : constant Source_Location :=
(Langkit_Support.Slocs.Line_Number
(Self.Where.a_range.start.line) + 1,
Langkit_Support.Slocs.Column_Number
(Self.Where.a_range.start.character) + 1);
Where : constant Source_Location_Range :=
Document.To_Source_Location_Range (Self.Where.a_range);
Compilation_Unit : constant Libadalang.Analysis.Compilation_Unit :=
Analysis_Unit.Root.Lookup (Sloc).P_Enclosing_Compilation_Unit;
Analysis_Unit
.Root
.Lookup (Where.Start_Sloc)
.P_Enclosing_Compilation_Unit;
Sorter : constant Dependencies_Sorter :=
Create_Dependencies_Sorter (Compilation_Unit, Where);

Sorter : constant Dependencies_Sorter :=
Create_Dependencies_Sorter (Compilation_Unit);
begin
Edits := Sorter.Refactor (null);
end Refactor;
Expand Down
6 changes: 2 additions & 4 deletions source/ada/lsp-ada_handlers.adb
Original file line number Diff line number Diff line change
Expand Up @@ -1032,10 +1032,8 @@ package body LSP.Ada_Handlers is
use LSP.Ada_Handlers.Refactor.Sort_Dependencies;
use LSP.Structures;

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

Sort_Dependencies_Command :
LSP.Ada_Handlers.Refactor.Sort_Dependencies.Command;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,11 @@
"character": 0
},
"end": {
"line": 51,
"character": 0
"line": 47,
"character": 14
}
},
"newText": "-- Comment 1\nwith Ada.Containers; -- Comment 2\n-- Comment 3\nwith Ada.Containers.Hashed_Sets;\nwith Ada.Containers.Vectors;\nwith Ada.Strings;\nwith Ada.Strings.Hash;\n-- Comment 29\n-- Comment 30\nwith Ada.Strings.Unbounded; -- Comment 6\nwith Bar; use Bar; -- Comment 24\n-- Comment 25\npragma Warnings (Off, -- Comment 26\n Bar);\n-- Comment 16\n-- Comment 17\n-- Comment 18\nwith Foo; -- Comment 19\nuse Foo;\n-- Comment 27\n-- Comment 28\npragma Elaborate_All (Foo);\npragma Warnings (Off, -- Comment 20\n Foo); -- Comment 21\n-- Comment 22\n\nprivate with Ada.Finalization; -- Comment 4\n-- Comment 5\nprivate with Ada.Unchecked_Deallocation; -- Comment 7\n-- Comment 8\n-- Comment 9\n-- Comment 10\nprivate with Qux; -- Comment 11\npragma Elaborate (Qux); -- Comment 12\n\n-- Comment 13\n-- Comment 14\n\n-- Comment 15\n\nlimited with Corge;\n-- Comment 23\n\n"
"newText": "-- Comment 1\nwith Ada.Containers; -- Comment 2\n-- Comment 3\nwith Ada.Containers.Hashed_Sets;\nwith Ada.Containers.Vectors;\nwith Ada.Strings;\nwith Ada.Strings.Hash;\n-- Comment 29\n-- Comment 30\nwith Ada.Strings.Unbounded; -- Comment 6\nwith Bar; use Bar; -- Comment 24\n-- Comment 25\npragma Warnings (Off, -- Comment 26\n Bar);\n-- Comment 16\n-- Comment 17\n-- Comment 18\nwith Foo; -- Comment 19\nuse Foo;\n-- Comment 27\n-- Comment 28\npragma Elaborate_All (Foo);\npragma Warnings (Off, -- Comment 20\n Foo); -- Comment 21\n-- Comment 22\n\nprivate with Ada.Finalization; -- Comment 4\n-- Comment 5\nprivate with Ada.Unchecked_Deallocation; -- Comment 7\n-- Comment 8\n-- Comment 9\n-- Comment 10\nprivate with Qux; -- Comment 11\npragma Elaborate (Qux); -- Comment 12\n\n-- Comment 13\n-- Comment 14\n\n-- Comment 15\n\nlimited with Corge;\n-- Comment 23"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package Bar is
end Bar;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package Corge is
end Corge;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
project Default is
for Main use ("main.adb");
end Default;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package Foo is
end Foo;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
with Main_Package;

procedure Main is
begin
null;
end Main;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package body Main_Package is
begin
null;
end Main_Package;
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
pragma Ada_2012;

-- Comment 1
with Ada.Containers; -- Comment 2
-- Comment 3
private with Ada.Finalization; -- Comment 4
-- Comment 5
with Ada.Strings.Unbounded; -- Comment 6
private with Ada.Unchecked_Deallocation; -- Comment 7
-- Comment 8

-- Comment 9
-- Comment 10
private with Qux; -- Comment 11
pragma Elaborate (Qux); -- Comment 12

-- Comment 13
-- Comment 14

-- Comment 15

-- Comment 16
-- Comment 17
-- Comment 18
with Foo; -- Comment 19
pragma Elaborate_All (Foo);
pragma Warnings (Off, -- Comment 20
Foo); -- Comment 21
-- Comment 22

limited with Corge;
-- Comment 23
with Bar; use Bar; -- Comment 24
-- Comment 25
pragma Warnings (Off, -- Comment 26
Bar);

use Foo;
-- Comment 27
-- Comment 28

with Ada.Strings;
with Ada.Containers.Vectors;
with Ada.Containers.Hashed_Sets;

with Ada.Strings.Hash;
-- Comment 29
-- Comment 30



package Main_Package is
pragma Elaborate_Body;

end Main_Package;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package Qux is
end Qux;
Loading

0 comments on commit 4c8888d

Please sign in to comment.