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

Skip to content

Commit 9334747

Browse files
committed
Fixed annotations on CANADIAN FRENCH NLS settings
Fixed issue with `modifier => 'i'` causing strange behavior when parsing annotations on `CANADIAN FRENCH` `NLS` settings. Resolves #844
1 parent 5c1f193 commit 9334747

3 files changed

Lines changed: 51 additions & 9 deletions

File tree

source/core/annotations/ut_annotation_parser.pkb

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ create or replace package body ut_annotation_parser as
1919
------------------------------
2020
--private definitions
2121

22-
type tt_comment_list is table of varchar2(32767) index by pls_integer;
22+
type tt_comment_list is table of varchar2(32767) index by binary_integer;
2323

2424
gc_annotation_qualifier constant varchar2(1) := '%';
2525
gc_annot_comment_pattern constant varchar2(30) := '^( |'||chr(09)||')*-- *('||gc_annotation_qualifier||'.*?)$'; -- chr(09) is a tab character
2626
gc_comment_replacer_patter constant varchar2(50) := '{COMMENT#%N%}';
2727
gc_comment_replacer_regex_ptrn constant varchar2(25) := '{COMMENT#(\d+)}';
28-
gc_regexp_identifier constant varchar2(50) := '[a-z][a-z0-9#_$]*';
28+
gc_regexp_identifier constant varchar2(50) := '[a-zA-Z][a-zA-Z0-9#_$]*';
2929
gc_annotation_block_pattern constant varchar2(200) := '(({COMMENT#.+}'||chr(10)||')+)( |'||chr(09)||')*(procedure|function)\s+(' ||
3030
gc_regexp_identifier || ')';
3131
gc_annotation_pattern constant varchar2(50) := gc_annotation_qualifier || gc_regexp_identifier || '[ '||chr(9)||']*(\(.*?\)\s*?$)?';
@@ -46,10 +46,7 @@ create or replace package body ut_annotation_parser as
4646
if l_annotation_str is not null then
4747

4848
-- get the annotation name and it's parameters if present
49-
l_annotation_name := lower(regexp_substr(l_annotation_str
50-
,'%(' || gc_regexp_identifier || ')'
51-
,modifier => 'i'
52-
,subexpression => 1));
49+
l_annotation_name := lower(regexp_substr(l_annotation_str ,'%(' || gc_regexp_identifier || ')', subexpression => 1));
5350
l_annotation_text := trim(regexp_substr(l_annotation_str, '\((.*?)\)\s*$', subexpression => 1));
5451

5552
a_annotations.extend;
@@ -59,7 +56,7 @@ create or replace package body ut_annotation_parser as
5956
end;
6057

6158
procedure delete_processed_comments( a_comments in out nocopy tt_comment_list, a_annotations ut_annotations ) is
62-
l_loop_index pls_integer := 1;
59+
l_loop_index binary_integer := 1;
6360
begin
6461
l_loop_index := a_annotations.first;
6562
while l_loop_index is not null loop
@@ -74,8 +71,8 @@ create or replace package body ut_annotation_parser as
7471
a_comments tt_comment_list,
7572
a_subobject_name varchar2 := null
7673
) is
77-
l_loop_index pls_integer := 1;
78-
l_annotation_index pls_integer;
74+
l_loop_index binary_integer := 1;
75+
l_annotation_index binary_integer;
7976
begin
8077
-- loop while there are unprocessed comment blocks
8178
while 0 != nvl(regexp_instr(srcstr => a_source

test/core/annotations/test_annotation_parser.pkb

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,48 @@ END;';
414414
ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected));
415415
end;
416416

417+
procedure test_upper_annot is
418+
l_source clob;
419+
l_actual ut3.ut_annotations;
420+
l_expected ut3.ut_annotations;
421+
begin
422+
l_source := 'PACKAGE test_tt AS
423+
-- %SUITE
424+
-- %DISPLAYNAME(Name of suite)
425+
-- %SUITEPATH(all.globaltests)
426+
427+
-- %ANN1(Name of suite)
428+
-- %ANN2(all.globaltests)
429+
430+
--%TEST
431+
procedure foo;
432+
433+
-- %ANN3(Name of suite)
434+
-- %ANN4(all.globaltests)
435+
436+
--%TEST
437+
procedure bar;
438+
END;';
439+
440+
--Act
441+
l_actual := ut3.ut_annotation_parser.parse_object_annotations(l_source);
442+
443+
--Assert
444+
l_expected := ut3.ut_annotations(
445+
ut3.ut_annotation( 2, 'suite', null, null ),
446+
ut3.ut_annotation( 3, 'displayname', 'Name of suite', null ),
447+
ut3.ut_annotation( 4, 'suitepath', 'all.globaltests', null ),
448+
ut3.ut_annotation( 6, 'ann1', 'Name of suite', null ),
449+
ut3.ut_annotation( 7, 'ann2', 'all.globaltests', null ),
450+
ut3.ut_annotation( 9, 'test', null, 'foo'),
451+
ut3.ut_annotation( 12, 'ann3', 'Name of suite', null ),
452+
ut3.ut_annotation( 13, 'ann4', 'all.globaltests', null ),
453+
ut3.ut_annotation( 15, 'test', null, 'bar')
454+
);
455+
456+
ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected));
457+
458+
end;
417459

418460
end test_annotation_parser;
419461
/

test/core/annotations/test_annotation_parser.pks

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,8 @@ create or replace package test_annotation_parser is
3535
-- %test(Parses annotations with very long object names)
3636
procedure test_annot_very_long_name;
3737

38+
-- %test(Parses upper case annotations)
39+
procedure test_upper_annot;
40+
3841
end test_annotation_parser;
3942
/

0 commit comments

Comments
 (0)