Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8df3f7d

Browse files
committed
Refactoring: Extract function, add variables for readability
1 parent e8f4532 commit 8df3f7d

1 file changed

Lines changed: 25 additions & 11 deletions

File tree

source/core/ut_suite_builder.pkb

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,22 @@ create or replace package body ut_suite_builder is
704704
set_seq_no(a_suite.after_all_list);
705705
end;
706706

707+
function get_next_annotation_of_type(
708+
a_start_position t_annotation_position,
709+
a_annotation_type varchar2,
710+
a_package_annotations in out nocopy tt_annotations_by_name
711+
) return t_annotation_position is
712+
l_result t_annotation_position;
713+
begin
714+
if a_package_annotations.exists(a_annotation_type) then
715+
l_result := a_package_annotations(a_annotation_type).first;
716+
while l_result <= a_start_position loop
717+
l_result := a_package_annotations(a_annotation_type).next(l_result);
718+
end loop;
719+
end if;
720+
return l_result;
721+
end;
722+
707723
function get_endcontext_position(
708724
a_context_ann_pos t_annotation_position,
709725
a_package_annotations in out nocopy tt_annotations_by_name
@@ -712,13 +728,10 @@ create or replace package body ut_suite_builder is
712728
l_next_context_pos t_annotation_position;
713729
l_open_count integer := 0;
714730
begin
715-
if a_package_annotations.exists(gc_endcontext) then
716-
l_next_endcontext_pos := a_package_annotations(gc_endcontext).first;
717-
while l_next_endcontext_pos <= a_context_ann_pos loop
718-
l_next_endcontext_pos := a_package_annotations(gc_endcontext).next(l_next_endcontext_pos);
719-
end loop;
731+
if a_package_annotations.exists(gc_endcontext) and a_package_annotations.exists(gc_context) then
732+
l_next_endcontext_pos := get_next_annotation_of_type(a_context_ann_pos, gc_endcontext, a_package_annotations);
733+
l_next_context_pos := a_package_annotations(gc_context).next(a_context_ann_pos);
720734

721-
l_next_context_pos := a_package_annotations(gc_context).next(a_context_ann_pos);
722735
loop
723736
-- Get all the %context annotations between start and first %endcontext
724737
while l_next_context_pos is not null and l_next_context_pos < l_next_endcontext_pos loop
@@ -742,13 +755,14 @@ create or replace package body ut_suite_builder is
742755
a_package_annotations in out nocopy tt_annotations_by_name
743756
) return boolean is
744757
l_next_endcontext_pos t_annotation_position;
758+
l_next_context_pos t_annotation_position;
745759
begin
746760
if ( a_package_annotations.exists(gc_endcontext) and a_package_annotations.exists(gc_context)) then
747-
l_next_endcontext_pos := a_package_annotations(gc_endcontext).first;
748-
while l_next_endcontext_pos <= a_context_ann_pos loop
749-
l_next_endcontext_pos := a_package_annotations(gc_endcontext).next(l_next_endcontext_pos);
750-
end loop;
751-
return l_next_endcontext_pos > a_package_annotations(gc_context).next(a_context_ann_pos);
761+
l_next_endcontext_pos := get_next_annotation_of_type(a_context_ann_pos, gc_endcontext, a_package_annotations);
762+
l_next_context_pos := a_package_annotations(gc_context).next(a_context_ann_pos);
763+
if ( l_next_context_pos < l_next_endcontext_pos ) then
764+
return true;
765+
end if;
752766
end if;
753767
return false;
754768
end;

0 commit comments

Comments
 (0)