@@ -722,32 +722,25 @@ create or replace package body ut_suite_builder is
722722
723723 function get_endcontext_position(
724724 a_context_ann_pos t_annotation_position,
725- a_package_annotations in out nocopy tt_annotations_by_name
725+ a_package_annotations in tt_annotations_by_line
726726 ) return t_annotation_position is
727- l_next_endcontext_pos t_annotation_position;
728- l_next_context_pos t_annotation_position ;
729- l_open_count integer := 0 ;
727+ l_result t_annotation_position;
728+ l_open_count integer := 1 ;
729+ l_idx t_annotation_position := a_package_annotations.next(a_context_ann_pos) ;
730730 begin
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);
734-
735- loop
736- -- Get all the %context annotations between start and first %endcontext
737- while l_next_context_pos is not null and l_next_context_pos < l_next_endcontext_pos loop
738- l_open_count := l_open_count+1;
739- l_next_context_pos := a_package_annotations(gc_context).next(l_next_context_pos);
740- end loop;
741- -- Skip as many %endcontexts as we had additional contexts open
742- while l_open_count > 0 loop
743- l_open_count := l_open_count-1;
744- l_next_endcontext_pos := a_package_annotations(gc_endcontext).next(l_next_endcontext_pos);
745- end loop;
746- -- Repeat until the next %context is later than next %endcontext
747- exit when l_next_context_pos is null or l_next_context_pos > l_next_endcontext_pos;
748- end loop;
731+ while l_open_count > 0 and l_idx is not null loop
732+ if ( a_package_annotations(l_idx).name = gc_context ) then
733+ l_open_count := l_open_count+1;
734+ elsif ( a_package_annotations(l_idx).name = gc_endcontext ) then
735+ l_open_count := l_open_count-1;
736+ l_result := l_idx;
737+ end if;
738+ l_idx := a_package_annotations.next(l_idx);
739+ end loop;
740+ if ( l_open_count > 0 ) then
741+ l_result := null;
749742 end if;
750- return l_next_endcontext_pos ;
743+ return l_result ;
751744 end;
752745
753746 function has_nested_context(
@@ -826,7 +819,7 @@ create or replace package body ut_suite_builder is
826819 l_context_names := a_annotations.by_name( gc_name );
827820 l_end_position :=
828821 least(
829- coalesce( get_endcontext_position(a_start_position, a_annotations.by_name ), a_annotations.by_line.last ),
822+ coalesce( get_endcontext_position(a_start_position, a_annotations.by_line ), a_annotations.by_line.last ),
830823 coalesce( a_annotations.by_name(gc_context).next(a_start_position), a_annotations.by_line.last )
831824 );
832825 l_annotation_pos := l_context_names.first;
@@ -856,10 +849,9 @@ create or replace package body ut_suite_builder is
856849 while l_context_pos is not null loop
857850 l_default_context_name := 'nested_context_#'||l_context_no;
858851 l_context_name := null;
859- l_end_context_pos := get_endcontext_position(l_context_pos, a_annotations.by_name );
852+ l_end_context_pos := get_endcontext_position(l_context_pos, a_annotations.by_line );
860853 l_next_context_pos := a_annotations.by_name(gc_context).next(l_context_pos);
861854 l_context_name := get_context_name(a_parent, l_context_pos);
862-
863855 if not regexp_like( l_context_name, '^(\w|[$#])+$' ) or l_context_name is null then
864856 if not regexp_like( l_context_name, '^(\w|[$#])+$' ) then
865857 a_parent.put_warning(
0 commit comments