Skip to content

Commit a1c04c6

Browse files
godunkoreznikmm
authored andcommitted
File name formatters.
1 parent 697d09b commit a1c04c6

File tree

5 files changed

+117
-7
lines changed

5 files changed

+117
-7
lines changed

source/ada/lsp-ada_documents.adb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ with LSP.Ada_Documentation;
4949
with LSP.Ada_Documents.LAL_Diagnostics;
5050
with LSP.Ada_Id_Iterators;
5151
with LSP.Enumerations;
52+
with LSP.Formatters.File_Names;
5253
with LSP.Predicates;
5354
with LSP.Utils;
5455
with LSP.Structures.LSPAny_Vectors;
@@ -1115,9 +1116,7 @@ package body LSP.Ada_Documents is
11151116
for Error of PP_Messages loop
11161117
Messages.Append
11171118
(Template.Format
1118-
(VSS.Strings.Formatters.Strings.Image
1119-
(VSS.Strings.Conversions.To_Virtual_String
1120-
(File.Display_Base_Name)),
1119+
(LSP.Formatters.File_Names.Image (File),
11211120
VSS.Strings.Formatters.Integers.Image (Error.Sloc.Line),
11221121
VSS.Strings.Formatters.Integers.Image (Error.Sloc.Col),
11231122
VSS.Strings.Formatters.Strings.Image
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
------------------------------------------------------------------------------
2+
-- Language Server Protocol --
3+
-- --
4+
-- Copyright (C) 2023, AdaCore --
5+
-- --
6+
-- This is free software; you can redistribute it and/or modify it under --
7+
-- terms of the GNU General Public License as published by the Free Soft- --
8+
-- ware Foundation; either version 3, or (at your option) any later ver- --
9+
-- sion. This software is distributed in the hope that it will be useful, --
10+
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11+
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
12+
-- License for more details. You should have received a copy of the GNU --
13+
-- General Public License distributed with this software; see file --
14+
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy --
15+
-- of the license. --
16+
------------------------------------------------------------------------------
17+
18+
with VSS.Strings.Conversions;
19+
20+
package body LSP.Formatters.File_Names is
21+
22+
-----------
23+
-- Image --
24+
-----------
25+
26+
function Image (Item : GNATCOLL.VFS.Virtual_File) return Formatter is
27+
begin
28+
return
29+
(VSS.Strings.Formatters.Strings.Image
30+
(VSS.Strings.Conversions.To_Virtual_String
31+
(Item.Display_Base_Name)) with null record);
32+
end Image;
33+
34+
-----------
35+
-- Image --
36+
-----------
37+
38+
function Image
39+
(Name : VSS.Strings.Virtual_String;
40+
Item : GNATCOLL.VFS.Virtual_File) return Formatter is
41+
begin
42+
return
43+
(VSS.Strings.Formatters.Strings.Image
44+
(Name,
45+
VSS.Strings.Conversions.To_Virtual_String
46+
(Item.Display_Base_Name))
47+
with null record);
48+
end Image;
49+
50+
end LSP.Formatters.File_Names;
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
------------------------------------------------------------------------------
2+
-- Language Server Protocol --
3+
-- --
4+
-- Copyright (C) 2023, AdaCore --
5+
-- --
6+
-- This is free software; you can redistribute it and/or modify it under --
7+
-- terms of the GNU General Public License as published by the Free Soft- --
8+
-- ware Foundation; either version 3, or (at your option) any later ver- --
9+
-- sion. This software is distributed in the hope that it will be useful, --
10+
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11+
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
12+
-- License for more details. You should have received a copy of the GNU --
13+
-- General Public License distributed with this software; see file --
14+
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy --
15+
-- of the license. --
16+
------------------------------------------------------------------------------
17+
18+
-- Formatter to include base file names of Virtual_Files into the text.
19+
20+
with GNATCOLL.VFS;
21+
22+
with VSS.Strings.Formatters;
23+
private with VSS.Strings.Formatters.Strings;
24+
25+
package LSP.Formatters.File_Names is
26+
27+
type Formatter is
28+
new VSS.Strings.Formatters.Abstract_Formatter with private;
29+
30+
function Image (Item : GNATCOLL.VFS.Virtual_File) return Formatter;
31+
32+
function Image
33+
(Name : VSS.Strings.Virtual_String;
34+
Item : GNATCOLL.VFS.Virtual_File) return Formatter;
35+
36+
private
37+
38+
type Formatter is
39+
new VSS.Strings.Formatters.Strings.Formatter with null record;
40+
41+
end LSP.Formatters.File_Names;

source/ada/lsp-formatters.ads

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
------------------------------------------------------------------------------
2+
-- Language Server Protocol --
3+
-- --
4+
-- Copyright (C) 2023, AdaCore --
5+
-- --
6+
-- This is free software; you can redistribute it and/or modify it under --
7+
-- terms of the GNU General Public License as published by the Free Soft- --
8+
-- ware Foundation; either version 3, or (at your option) any later ver- --
9+
-- sion. This software is distributed in the hope that it will be useful, --
10+
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11+
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
12+
-- License for more details. You should have received a copy of the GNU --
13+
-- General Public License distributed with this software; see file --
14+
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy --
15+
-- of the license. --
16+
------------------------------------------------------------------------------
17+
18+
package LSP.Formatters is
19+
20+
pragma Pure;
21+
22+
end LSP.Formatters;

source/ada/lsp-utils.adb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ with Pp.Actions;
3131
with VSS.Strings.Character_Iterators;
3232
with VSS.Strings.Conversions;
3333
with VSS.Strings.Formatters.Generic_Modulars;
34-
with VSS.Strings.Formatters.Strings;
3534
with VSS.Strings.Templates;
3635
with VSS.String_Vectors;
3736
with VSS.Unicode;
3837
with Laltools.Common;
3938

4039
with LSP.Ada_Documents;
4140
with LSP.Constants;
41+
with LSP.Formatters.File_Names;
4242
with URIs;
4343

4444
package body LSP.Utils is
@@ -488,9 +488,7 @@ package body LSP.Utils is
488488
begin
489489
return
490490
Template.Format
491-
(VSS.Strings.Formatters.Strings.Image
492-
(VSS.Strings.Conversions.To_Virtual_String
493-
(File.Display_Base_Name)),
491+
(LSP.Formatters.File_Names.Image (File),
494492
Line_Number_Formatters.Image (Node.Sloc_Range.Start_Line),
495493
Column_Number_Formatters.Image (Node.Sloc_Range.Start_Column));
496494
end Node_Location_Image;

0 commit comments

Comments
 (0)