-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'topic/vadim/lsp' into 'master'
Few enhancements for use in LSP Closes #214 and #215 See merge request eng/ide/VSS!283
- Loading branch information
Showing
6 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
source/text/implementation/vss-strings-formatters-generic_modulars.adb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
-- | ||
-- Copyright (C) 2023, AdaCore | ||
-- | ||
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
-- | ||
|
||
package body VSS.Strings.Formatters.Generic_Modulars is | ||
|
||
------------ | ||
-- Format -- | ||
------------ | ||
|
||
overriding function Format | ||
(Self : Formatter; | ||
Format : VSS.Strings.Formatters.Format_Information) | ||
return VSS.Strings.Virtual_String | ||
is | ||
Buffer : constant Wide_Wide_String := | ||
Modular_Type'Wide_Wide_Image (Self.Value); | ||
|
||
begin | ||
if Buffer (Buffer'First) = ' ' then | ||
return | ||
VSS.Strings.To_Virtual_String | ||
(Buffer (Buffer'First + 1 .. Buffer'Last)); | ||
|
||
else | ||
return VSS.Strings.To_Virtual_String (Buffer); | ||
end if; | ||
end Format; | ||
|
||
----------- | ||
-- Image -- | ||
----------- | ||
|
||
function Image (Item : Modular_Type) return Formatter is | ||
begin | ||
return (Name => <>, Value => Item); | ||
end Image; | ||
|
||
----------- | ||
-- Image -- | ||
----------- | ||
|
||
function Image | ||
(Name : VSS.Strings.Virtual_String; | ||
Item : Modular_Type) return Formatter is | ||
begin | ||
return (Name => Name, Value => Item); | ||
end Image; | ||
|
||
---------- | ||
-- Name -- | ||
---------- | ||
|
||
overriding function Name | ||
(Self : Formatter) return VSS.Strings.Virtual_String is | ||
begin | ||
return Self.Name; | ||
end Name; | ||
|
||
end VSS.Strings.Formatters.Generic_Modulars; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
-- | ||
-- Copyright (C) 2023, AdaCore | ||
-- | ||
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
-- | ||
|
||
-- This package provides formatter for integer types. | ||
-- | ||
-- Integer_Formatter supports following formatting options: | ||
-- [0][1-9[0-9]*][#[1-9][0-9]+] | ||
-- | ||
-- 0 - fill leading zeros | ||
-- | ||
-- By default, leading zeros is not filled. | ||
-- | ||
-- 1-9[0-9]* - number of digits (not include sign) | ||
-- | ||
-- By default, shortest number of digits is used. | ||
-- | ||
-- #[1-9][0-9]* - base | ||
-- | ||
-- By default, base is 10. | ||
|
||
generic | ||
type Modular_Type is mod <>; | ||
|
||
package VSS.Strings.Formatters.Generic_Modulars is | ||
|
||
pragma Preelaborate; | ||
|
||
type Formatter is | ||
new VSS.Strings.Formatters.Abstract_Formatter with private; | ||
|
||
function Image (Item : Modular_Type) return Formatter; | ||
|
||
function Image | ||
(Name : VSS.Strings.Virtual_String; | ||
Item : Modular_Type) return Formatter; | ||
|
||
private | ||
|
||
type Formatter is | ||
new VSS.Strings.Formatters.Abstract_Formatter with record | ||
Name : VSS.Strings.Virtual_String; | ||
Value : Modular_Type; | ||
end record; | ||
|
||
overriding function Name | ||
(Self : Formatter) return VSS.Strings.Virtual_String; | ||
|
||
overriding function Format | ||
(Self : Formatter; | ||
Format : VSS.Strings.Formatters.Format_Information) | ||
return VSS.Strings.Virtual_String; | ||
|
||
end VSS.Strings.Formatters.Generic_Modulars; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
-- | ||
-- Copyright (C) 2020-2023, AdaCore | ||
-- | ||
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
-- | ||
|
||
separate (Test_String) | ||
procedure Test_Asterisk_Character is | ||
|
||
use type VSS.Strings.Virtual_String; | ||
|
||
begin | ||
declare | ||
R : constant VSS.Strings.Virtual_String := 0 * 'A'; | ||
|
||
begin | ||
Test_Support.Assert (R.Is_Empty); | ||
-- Test_Support.Assert (not R.Is_Null); | ||
-- XXX Should it be non-null string? | ||
end; | ||
|
||
declare | ||
R : constant VSS.Strings.Virtual_String := 5 * 'B'; | ||
|
||
begin | ||
Test_Support.Assert (not R.Is_Empty); | ||
Test_Support.Assert (R = "BBBBB"); | ||
end; | ||
end Test_Asterisk_Character; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters