Skip to content

Commit

Permalink
Merge branch 'topic/vadim/transformations' into 'master'
Browse files Browse the repository at this point in the history
Introduce transformers

See merge request eng/ide/VSS!304
  • Loading branch information
godunko committed Jan 10, 2024
2 parents e7080f9 + 369c54e commit 002502a
Show file tree
Hide file tree
Showing 17 changed files with 872 additions and 221 deletions.
7 changes: 3 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,14 @@ build_lsif:
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
when: manual
allow_failure: true
trigger:
strategy: depend
inherit:
variables: false
variables:
ACI_UPSTREAM_PROJECT_PATH: $CI_PROJECT_PATH
ACI_UPSTREAM_REF_NAME: $CI_COMMIT_REF_NAME
ACI_UPSTREAM_SOURCE_BRANCH: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
ACI_UPSTREAM_TARGET_BRANCH: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
ACI_UPSTREAM_PROJECT_ID: $CI_PROJECT_ID
ACI_UPSTREAM_MERGE_REQUEST_IID: $CI_MERGE_REQUEST_IID

run_als_ci:
<<: *run_ci_common
Expand Down
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,19 @@ check_text:
.objs/tests/test_text_streams
.objs/tests/test_file_text_streams testsuite/stream/test_file_text_stream/vss.197.in.txt /tmp/vss.197.out.txt && diff -u /tmp/vss.197.out.txt testsuite/stream/test_file_text_stream/vss.197.out.txt
.objs/tests/test_string_append
.objs/tests/test_string_casing
.objs/tests/test_string_compare
.objs/tests/test_string_conversions
.objs/tests/test_string_delete
.objs/tests/test_string_hash
.objs/tests/test_string_insert
.objs/tests/test_string_buffer
.objs/tests/test_string_normalization data/ucd
.objs/tests/test_string_slice
.objs/tests/test_string_split
.objs/tests/test_string_split_lines
.objs/tests/test_string
.objs/tests/test_string_template
.objs/tests/test_string_vector
for f in testsuite/text/w3c-i18n-tests-casing/*.txt; do \
echo " $$f"; .objs/tests/test_string_casing_w3c_i18n $$f || return 1; \
done
.objs/tests/test_transformer data/ucd testsuite/text/w3c-i18n-tests-casing/*.txt
.objs/tests/test_word_iterators data/ucd
.objs/tests/test_standard_paths
ifeq ($(OS),Windows_NT)
Expand Down
6 changes: 2 additions & 4 deletions gnat/tests/vss_text_tests.gpr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--
-- Copyright (C) 2020-2023, AdaCore
-- Copyright (C) 2020-2024, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0
--
Expand All @@ -26,21 +26,19 @@ project VSS_Text_Tests is
"test_line_iterators.adb",
"test_string",
"test_string_append",
"test_string_casing.adb",
"test_string_casing_w3c_i18n.adb",
"test_string_compare",
"test_string_conversions.adb",
"test_string_decoder.adb",
"test_string_delete",
"test_string_hash",
"test_string_insert",
"test_string_buffer",
"test_string_normalization",
"test_string_slice",
"test_string_split",
"test_string_split_lines",
"test_string_template",
"test_string_vector",
"test_transformer",
"test_word_iterators");

package Compiler is
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
--
-- Copyright (C) 2022-2023, AdaCore
-- Copyright (C) 2022-2024, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--

with VSS.Transformers.Casing;

with VSS.Regular_Expressions.Category_Maps;

package body VSS.Regular_Expressions.Name_Sets is
Expand Down Expand Up @@ -60,7 +62,9 @@ package body VSS.Regular_Expressions.Name_Sets is
Initialize;
end if;

Cursor := Map.Find (Name.To_Simple_Lowercase);
Cursor :=
Map.Find
(VSS.Transformers.Casing.To_Simple_Lowercase.Transform (Name));

if Category_Maps.Maps.Has_Element (Cursor) then
Value := Category_Maps.Maps.Element (Cursor);
Expand Down
15 changes: 14 additions & 1 deletion source/text/implementation/vss-strings-internals.adb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--
-- Copyright (C) 2020-2022, AdaCore
-- Copyright (C) 2020-2024, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
Expand All @@ -17,6 +17,19 @@ package body VSS.Strings.Internals is
return Self.Data'Unchecked_Access;
end Data_Access_Constant;

-----------------
-- Set_By_Move --
-----------------

procedure Set_By_Move
(Self : in out VSS.Strings.Virtual_String'Class;
To : in out VSS.Implementation.Strings.String_Data) is
begin
VSS.Implementation.Strings.Unreference (Self.Data);
Self.Data := To;
To := (others => <>);
end Set_By_Move;

----------------------------
-- To_Magic_String_Access --
----------------------------
Expand Down
10 changes: 8 additions & 2 deletions source/text/implementation/vss-strings-internals.ads
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--
-- Copyright (C) 2020-2022, AdaCore
-- Copyright (C) 2020-2024, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
Expand Down Expand Up @@ -33,13 +33,19 @@ package VSS.Strings.Internals is
return not null VSS.Strings.Internals.String_Data_Constant_Access;
-- Return access to string data member of the Virtual_String.

procedure Set_By_Move
(Self : in out VSS.Strings.Virtual_String'Class;
To : in out VSS.Implementation.Strings.String_Data);
-- Set given string to given data. Initial data of the Self is
-- unreferenced, given data is copied and given value is reset.

function To_Virtual_String_Access
(Item : VSS.Implementation.Referrers.Magic_String_Access)
return VSS.Implementation.Referrers.Virtual_String_Access with Inline;
function To_Magic_String_Access
(Item : VSS.Implementation.Referrers.Virtual_String_Access)
return VSS.Implementation.Referrers.Magic_String_Access with Inline;
-- Do type conversion. It is intended to be used inside the
-- VSS.Implementation.Refrrals package.
-- VSS.Implementation.Referrals package.

end VSS.Strings.Internals;
128 changes: 25 additions & 103 deletions source/text/implementation/vss-strings.adb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--
-- Copyright (C) 2020-2023, AdaCore
-- Copyright (C) 2020-2024, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
Expand All @@ -17,6 +17,7 @@ with VSS.Strings.Cursors.Iterators.Grapheme_Clusters;
with VSS.Strings.Cursors.Iterators.Lines;
with VSS.Strings.Cursors.Iterators.Words;
with VSS.String_Vectors.Internals;
with VSS.Transformers;

package body VSS.Strings is

Expand Down Expand Up @@ -1231,108 +1232,6 @@ package body VSS.Strings is
end return;
end Tail_From;

------------------
-- To_Lowercase --
------------------

function To_Lowercase (Self : Virtual_String'Class) return Virtual_String is
begin
return Result : Virtual_String do
VSS.Implementation.UTF8_Casing.Convert_Case
(Self.Data,
VSS.Implementation.UTF8_Casing.Lowercase,
Result.Data);
end return;
end To_Lowercase;

-------------------
-- To_Normalized --
-------------------

function To_Normalized
(Self : Virtual_String'Class;
Form : Normalization_Form) return Virtual_String is
begin
return Result : Virtual_String do
VSS.Implementation.UTF8_Normalization.Normalize
(Self.Data, Form, Result.Data);
end return;
end To_Normalized;

-------------------------
-- To_Simple_Lowercase --
-------------------------

function To_Simple_Lowercase
(Self : Virtual_String'Class) return Virtual_String is
begin
return Result : Virtual_String do
VSS.Implementation.UTF8_Casing.Convert_Case
(Self.Data,
VSS.Implementation.UTF8_Casing.Simple_Lowercase,
Result.Data);
end return;
end To_Simple_Lowercase;

-------------------------
-- To_Simple_Titlecase --
-------------------------

-- function To_Simple_Titlecase
-- (Self : Virtual_String'Class) return Virtual_String is
-- begin
-- return Result : Virtual_String do
-- VSS.Implementation.Strings.Handler (Self.Data).Convert_Case
-- (Self.Data,
-- VSS.Implementation.String_Handlers.Simple_Titlecase,
-- Result.Data);
-- end return;
-- end To_Simple_Titlecase;

-------------------------
-- To_Simple_Uppercase --
-------------------------

function To_Simple_Uppercase
(Self : Virtual_String'Class) return Virtual_String is
begin
return Result : Virtual_String do
VSS.Implementation.UTF8_Casing.Convert_Case
(Self.Data,
VSS.Implementation.UTF8_Casing.Simple_Uppercase,
Result.Data);
end return;
end To_Simple_Uppercase;

------------------
-- To_Titlecase --
------------------

-- function To_Titlecase
-- (Self : Virtual_String'Class) return Virtual_String is
-- begin
-- return Result : Virtual_String do
-- VSS.Implementation.Strings.Handler (Self.Data).Convert_Case
-- (Self.Data,
-- VSS.Implementation.String_Handlers.Titlecase,
-- Result.Data);
-- end return;
-- end To_Titlecase;

------------------
-- To_Uppercase --
------------------

function To_Uppercase (Self : Virtual_String'Class) return Virtual_String is
begin
return Result : Virtual_String do
VSS.Implementation.UTF8_Casing.Convert_Case
(Self.Data,
VSS.Implementation.UTF8_Casing.Uppercase,
Result.Data);
end return;
end To_Uppercase;

-----------------------
-- To_Virtual_String --
-----------------------
Expand Down Expand Up @@ -1367,6 +1266,29 @@ package body VSS.Strings is
end return;
end To_Virtual_String;

---------------
-- Transform --
---------------

function Transform
(Self : Virtual_String'Class;
Transformer : VSS.Transformers.Abstract_Transformer'Class)
return Virtual_String is
begin
return Transformer.Transform (Self);
end Transform;

---------------
-- Transform --
---------------

procedure Transform
(Self : in out Virtual_String'Class;
Transformer : VSS.Transformers.Abstract_Transformer'Class) is
begin
Transformer.Transform (Self);
end Transform;

-----------
-- Write --
-----------
Expand Down
Loading

0 comments on commit 002502a

Please sign in to comment.