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

Skip to content

Commit f439b3d

Browse files
authored
Merge pull request #339 from jgebal/bugfix/annotation_closing_bracket
Fixed annotation parameter pattern matching
2 parents 63ff106 + 11c5877 commit f439b3d

4 files changed

Lines changed: 44 additions & 61 deletions

File tree

source/core/ut_annotations.pkb

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -30,48 +30,14 @@ create or replace package body ut_annotations as
3030
c_rgexp_identifier constant varchar2(50) := '[a-z][a-z0-9#_$]*';
3131
c_annotation_block_pattern constant varchar2(200) := '(({COMMENT#.+}'||chr(10)||')+)( |'||chr(09)||')*(procedure|function)\s+(' ||
3232
c_rgexp_identifier || ')';
33-
c_annotation_pattern constant varchar2(50) := gc_annotation_qualifier || c_rgexp_identifier || '(\(.*?\))?';
33+
c_annotation_pattern constant varchar2(50) := gc_annotation_qualifier || c_rgexp_identifier || '(\(.*?\)$)?';
3434

3535

3636
function delete_multiline_comments(a_source in clob) return clob is
3737
begin
38-
39-
/* l_tmp_clob := regexp_replace(srcstr => a_source
40-
,pattern => c_multiline_comment_pattern
41-
,modifier => 'n');
42-
l_tmp_clob := regexp_replace(srcstr => l_tmp_clob
43-
,pattern => c_nonannotat_comment_pattern
44-
,modifier => 'm');
45-
46-
-- performance is too low when deleting spaces as it leads to lots of writes
47-
-- l_tmp_clob := regexp_replace(srcstr => l_tmp_cl0ob
48-
-- ,pattern => '(( |'||chr(09)||')*'|| chr(10)||'){3,}'
49-
-- ,replacestr => chr(10)||chr(10));
50-
return l_tmp_clob;
51-
*/
5238
return regexp_replace(srcstr => a_source
5339
,pattern => c_multiline_comment_pattern
5440
,modifier => 'n');
55-
56-
--this is not fast enough as the regexp parten is more complicated
57-
/*
58-
return regexp_replace(srcstr => a_source
59-
,pattern => '('||c_multiline_comment_pattern
60-
||'|'||c_nonannotat_comment_pattern||')'
61-
,modifier => 'mn');
62-
*/
63-
64-
/*
65-
return regexp_replace(
66-
srcstr => regexp_replace(srcstr => regexp_replace(srcstr => a_source
67-
,pattern => c_multiline_comment_pattern
68-
,modifier => 'n')
69-
,pattern => c_nonannotat_comment_pattern, modifier => 'm')
70-
,pattern => '((procedure|function)\s+' || c_rgexp_identifier || ')[^;]*'
71-
,replacestr => '\1'
72-
,modifier => 'mn'
73-
);
74-
*/
7541
end;
7642

7743
function get_annotations(a_source varchar2, a_comments tt_comment_list) return tt_annotations is
@@ -111,7 +77,7 @@ create or replace package body ut_annotations as
11177
,'%(' || c_rgexp_identifier || ')'
11278
,modifier => 'i'
11379
,subexpression => 1));
114-
l_annotation_params_str := trim(regexp_substr(l_annotation_str, '\((.*?)\)', subexpression => 1));
80+
l_annotation_params_str := trim(regexp_substr(l_annotation_str, '\((.*?)\)$', subexpression => 1));
11581

11682
if l_annotation_params_str is not null then
11783

@@ -343,7 +309,7 @@ create or replace package body ut_annotations as
343309

344310
-- TODO: Add cache of annotations. Cache invalidation should be based on DDL timestamp.
345311
-- Cache garbage collection should be executed once in a while to remove annotations cache for packages that were dropped.
346-
312+
347313
begin
348314
l_source := ut_metadata.get_package_spec_source(a_owner_name, a_name);
349315
exception

tests/RunAll.sql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,13 @@ exec ut_coverage.coverage_start_develop();
3838
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.IgnoreWrappedPackageAndDoesNotRaiseException.sql
3939
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationMixedWithWrongBeforeProcedure.sql
4040
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationNotBeforeProcedure.sql
41-
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParseComplexPackage.sql
41+
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationParamsWithBrackets.sql
4242
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParsePackageAndProcedureLevelAnnotations.sql
4343
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotation.sql
4444
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationAccessibleBy.sql
4545
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationMultilineDeclare.sql
4646
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationWithKeyValue.sql
4747
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationWithMultilineComment.sql
48-
4948
@@ut_expectations/ut.expect.not_to_be_null.sql
5049
@@lib/RunTest.sql ut_expectations/ut.expect.to_be_false.GivesFailureWhenExpessionIsNotBoolean.sql
5150
@@lib/RunTest.sql ut_expectations/ut.expect.to_be_false.GivesFailureWhenExpessionIsNull.sql
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
PROMPT Parse package level annotations with annotation params containing brackets
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 := null;
9+
l_results ut_expectation_results;
10+
begin
11+
l_source := 'PACKAGE test_tt AS
12+
-- %suite(Name of suite (including some brackets) and some more text)
13+
END;';
14+
15+
--Act
16+
l_parsing_result := ut_annotations.parse_package_annotations(l_source);
17+
18+
--Assert
19+
l_ann_param.val := 'Name of suite (including some brackets) and some more text';
20+
l_expected.package_annotations('suite')(1) := l_ann_param;
21+
22+
check_annotation_parsing(l_expected, l_parsing_result);
23+
24+
if ut_expectation_processor.get_status = ut_utils.tr_success then
25+
:test_result := ut_utils.tr_success;
26+
else
27+
l_results := ut_expectation_processor.get_expectations_results();
28+
for i in 1 .. l_results.count loop
29+
dbms_output.put_line(l_results(i).message);
30+
end loop;
31+
end if;
32+
33+
end;
34+
/

tests/ut_reporters/ut_documentation_reporter.providesCorrectLineFromStacktrace.sql

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,13 @@ declare
33
l_output varchar2(32767);
44
l_expected varchar2(32767);
55
begin
6-
l_expected := q'[%<!beforeall!>
7-
%passing_test
8-
%<!beforeeach!>
9-
%<!beforetest!>
10-
%<!passing test!>
11-
%<!aftertest!>
12-
%<!aftereach!>
13-
%a test with failing assertion (FAILED - 1)
14-
%<!beforeeach!>
15-
%<!failing test!>
16-
%<!aftereach!>
17-
%a test raising unhandled exception (FAILED - 2)
18-
%<!beforeeach!>
19-
%<!erroring test!>
20-
%<!aftereach!>
21-
%a disabled test (IGNORED)
22-
%<!afterall!>
6+
l_expected := q'[%
237
%Failures:%
24-
%1)%failing_test
25-
%"Fails as values are different"
26-
%Actual: 1 (number) was expected to equal: 2 (number)
27-
%at "%.TEST_REPORTERS%", line%
28-
%2)%erroring_test
8+
%1)%failing_test%
9+
%"Fails as values are different"%
10+
%Actual: 1 (number) was expected to equal: 2 (number)%
11+
%at "%.TEST_REPORTERS%", line%
12+
%2)%erroring_test%
2913
%ORA-06502%
3014
%ORA-06512%
3115
Finished %

0 commit comments

Comments
 (0)