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

Skip to content

Commit d07a98a

Browse files
committed
fix multiline annotations parsing
added accessible by
1 parent d0c9af9 commit d07a98a

4 files changed

Lines changed: 85 additions & 2 deletions

source/core/annotations/ut_annotations.pkb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ create or replace package body ut_annotations as
135135
l_package_comments varchar2(32767);
136136
begin
137137
l_package_comments := regexp_substr(srcstr => a_source
138-
,pattern => '^\s*(CREATE\s+(OR\s+REPLACE)?(\s+(NON)?EDITIONABLE)?\s+)?PACKAGE .*?\s+(AS|IS)\s+((.*?{COMMENT#\d+}\s?)+)'
138+
,pattern => '^\s*(CREATE\s+(OR\s+REPLACE)?(\s+(NON)?EDITIONABLE)?\s+)?PACKAGE(.|\s)*?(\s+(AS|IS)\s+)((.*?{COMMENT#\d+}\s?)+)'
139139
,modifier => 'i'
140-
,subexpression => 6);
140+
,subexpression => 8);
141141

142142
-- parsing for package annotations
143143
return

tests/RunAll.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ create table ut$test_table (val varchar2(1));
6767
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParseComplexPackage.sql
6868
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParsePackageAndProcedureLevelAnnotations.sql
6969
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotation.sql
70+
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationAccessibleBy.sql
71+
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationMultilineDeclare.sql
7072
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationWithKeyValue.sql
7173
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationWithMultilineComment.sql
7274
@@lib/RunTest.sql ut_metadata/ut_metadata.form_name.TrimStandaloneProgramName.sql
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
PROMPT Parse package level annotations Accessible by
2+
3+
--Arrange
4+
declare
5+
l_source clob;
6+
l_parsing_result ut_annotations.typ_annotated_package;
7+
l_expected ut_annotations.typ_annotated_package;
8+
l_ann_param ut_annotations.typ_annotation_param;
9+
10+
begin
11+
l_source := 'PACKAGE test_tt accessible by (foo) AS
12+
-- %suite
13+
-- %displayname(Name of suite)
14+
-- %suitepath(all.globaltests)
15+
16+
procedure foo;
17+
END;';
18+
19+
--Act
20+
l_parsing_result := ut_annotations.parse_package_annotations(l_source);
21+
22+
--Assert
23+
l_ann_param := null;
24+
l_ann_param.val := 'Name of suite';
25+
l_expected.package_annotations('suite') := cast( null as ut_annotations.tt_annotation_params);
26+
l_expected.package_annotations('displayname')(1) := l_ann_param;
27+
28+
l_ann_param := null;
29+
l_ann_param.val := 'all.globaltests';
30+
l_expected.package_annotations('suitepath')(1) := l_ann_param;
31+
32+
check_annotation_parsing(l_expected, l_parsing_result);
33+
34+
if ut_assert_processor.get_aggregate_asserts_result = ut_utils.tr_success then
35+
:test_result := ut_utils.tr_success;
36+
end if;
37+
38+
end;
39+
/
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
PROMPT Parse package level annotations with multiline declaration
2+
3+
--Arrange
4+
declare
5+
l_source clob;
6+
l_parsing_result ut_annotations.typ_annotated_package;
7+
l_expected ut_annotations.typ_annotated_package;
8+
l_ann_param ut_annotations.typ_annotation_param;
9+
10+
begin
11+
l_source := 'PACKAGE test_tt
12+
ACCESSIBLE BY (calling_proc)
13+
authid current_user
14+
AS
15+
-- %suite
16+
-- %displayname(Name of suite)
17+
-- %suitepath(all.globaltests)
18+
19+
procedure foo;
20+
END;';
21+
22+
--Act
23+
l_parsing_result := ut_annotations.parse_package_annotations(l_source);
24+
25+
--Assert
26+
l_ann_param := null;
27+
l_ann_param.val := 'Name of suite';
28+
l_expected.package_annotations('suite') := cast( null as ut_annotations.tt_annotation_params);
29+
l_expected.package_annotations('displayname')(1) := l_ann_param;
30+
31+
l_ann_param := null;
32+
l_ann_param.val := 'all.globaltests';
33+
l_expected.package_annotations('suitepath')(1) := l_ann_param;
34+
35+
check_annotation_parsing(l_expected, l_parsing_result);
36+
37+
if ut_assert_processor.get_aggregate_asserts_result = ut_utils.tr_success then
38+
:test_result := ut_utils.tr_success;
39+
end if;
40+
41+
end;
42+
/

0 commit comments

Comments
 (0)