Skip to content

Commit

Permalink
Add matching archetypes function to library.
Browse files Browse the repository at this point in the history
  • Loading branch information
wolandscat committed Feb 1, 2024
1 parent e33cf9e commit 4622184
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 8 deletions.
18 changes: 18 additions & 0 deletions components/adl_compiler/src/interface/archetype_compiler.e
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,24 @@ feature -- Commands
build_lineage (ara, 0)
end

build_matching_artefacts (id_regex: STRING)
-- top entry point into a compile run for archetypes matching an id regex
local
regex_matcher: RX_PCRE_REGULAR_EXPRESSION
do
create regex_matcher.make
regex_matcher.set_case_insensitive (True)
regex_matcher.compile (id_regex)
if regex_matcher.is_compiled then
run_list.wipe_out
across current_library.matching_archetypes (id_regex, Void, Void) as aras_csr loop
build_lineage (aras_csr.item, 0)
end
else
call_console_update_agent (get_msg_line ({ADL_MESSAGES_IDS}.ec_regex_e1, <<id_regex>>))
end
end

feature {NONE} -- Build State

from_scratch: BOOLEAN
Expand Down
36 changes: 28 additions & 8 deletions components/archetype_repository/src/library/archetype_library.e
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,41 @@ feature -- Access
Regex_valid: not a_regex.is_empty
Rm_type_valid: attached an_rm_type as att_rm_type implies not att_rm_type.is_empty
Rm_closure_valid: attached an_rm_package as att_rm_closure implies not att_rm_closure.is_empty
do
create Result.make (0)
Result.compare_objects
across matching_archetypes (a_regex, an_rm_type, an_rm_package) as archs_csr loop
Result.extend (archs_csr.key.to_string_8)
end

if Result.count = 0 then
regex_matcher.compile (a_regex)
if not regex_matcher.is_compiled then
Result.extend (get_msg_line (ec_regex_e1, <<a_regex>>))
end
end
end

matching_archetypes (a_regex: STRING; an_rm_type, an_rm_package: detachable STRING): STRING_TABLE [ARCH_LIB_ARCHETYPE]
-- generate list of archetype ids that lexically match the regex pattern and optional rm_type. If rm_type is supplied,
-- we assume that the regex itself does not contain an rm type. Matching using `an_rm_type' and
-- `an_rm_package' is done in lower case. Any case may be supplied for these two
require
Regex_valid: not a_regex.is_empty
Rm_type_valid: attached an_rm_type as att_rm_type implies not att_rm_type.is_empty
Rm_closure_valid: attached an_rm_package as att_rm_closure implies not att_rm_closure.is_empty
local
arch_id: ARCHETYPE_HRID
is_candidate: BOOLEAN
rm_type, rm_closure: detachable STRING
rm_type, rm_package: detachable STRING
do
create Result.make (0)
Result.compare_objects

if attached an_rm_type as rm_t then
rm_type := rm_t.as_lower
end
if attached an_rm_package as rm_cl then
rm_closure := rm_cl.as_lower
if attached an_rm_package as rm_pkg then
rm_package := rm_pkg.as_lower
end

regex_matcher.compile (a_regex)
Expand All @@ -199,19 +221,17 @@ feature -- Access
arch_id := ala.id
if attached rm_type as rmt then
is_candidate := rmt.is_equal (arch_id.rm_class.as_lower)
if is_candidate and attached rm_closure as rmc then
if is_candidate and attached rm_package as rmc then
is_candidate := rmc.is_equal (arch_id.rm_package.as_lower)
end
else
is_candidate := True
end
if is_candidate then
Result.extend (arch_id.physical_id)
Result.put (ala, arch_id.physical_id)
end
end
end
else
Result.extend (get_msg_line (ec_regex_e1, <<a_regex>>))
end
end

Expand Down

0 comments on commit 4622184

Please sign in to comment.