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

Skip to content

Commit fecbcc1

Browse files
committed
Remove redundant parse_object_annotations function overloads and update documentation
1 parent 81e1752 commit fecbcc1

2 files changed

Lines changed: 0 additions & 137 deletions

File tree

source/core/annotations/ut_annotation_parser.pkb

Lines changed: 0 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -87,49 +87,6 @@ create or replace package body ut_annotation_parser as
8787

8888
end add_annotations;
8989

90-
procedure add_procedure_annotations(a_annotations in out nocopy ut_annotations, a_source clob, a_comments in out nocopy tt_comment_list) is
91-
l_proc_comments varchar2(32767);
92-
l_proc_name varchar2(250);
93-
l_annot_proc_ind number;
94-
l_annot_proc_block varchar2(32767);
95-
begin
96-
-- loop through procedures and functions of the package and get all the comment blocks just before it's declaration
97-
l_annot_proc_ind := 1;
98-
loop
99-
--find annotated procedure index
100-
l_annot_proc_ind := regexp_instr(srcstr => a_source
101-
,pattern => gc_annotation_block_pattern
102-
,occurrence => 1
103-
,modifier => 'i'
104-
,position => l_annot_proc_ind);
105-
exit when l_annot_proc_ind = 0;
106-
107-
--get the annotations with procedure name
108-
l_annot_proc_block := regexp_substr(srcstr => a_source
109-
,pattern => gc_annotation_block_pattern
110-
,position => l_annot_proc_ind
111-
,occurrence => 1
112-
,modifier => 'i');
113-
114-
115-
--extract the annotations
116-
l_proc_comments := trim(regexp_substr(srcstr => l_annot_proc_block
117-
,pattern => gc_annotation_block_pattern
118-
,modifier => 'i'
119-
,subexpression => 1));
120-
--extract the procedure name
121-
l_proc_name := trim(regexp_substr(srcstr => l_annot_proc_block
122-
,pattern => gc_annotation_block_pattern
123-
,modifier => 'i'
124-
,subexpression => 5));
125-
126-
-- parse the comment block for the syntactically correct annotations and store them as an array
127-
add_annotations(a_annotations, l_proc_comments, a_comments, l_proc_name);
128-
129-
l_annot_proc_ind := instr(a_source, ';', l_annot_proc_ind + length(l_annot_proc_block) );
130-
end loop;
131-
end add_procedure_annotations;
132-
13390
procedure add_procedure_annotations(
13491
a_annotations in out nocopy ut_annotations,
13592
a_source in dbms_preprocessor.source_lines_t,
@@ -189,55 +146,6 @@ create or replace package body ut_annotation_parser as
189146
end loop;
190147
end add_procedure_annotations;
191148

192-
function extract_and_replace_comments(a_source in out nocopy clob) return tt_comment_list is
193-
l_comments tt_comment_list;
194-
l_comment_pos binary_integer;
195-
l_comment_line binary_integer;
196-
l_comment_replacer varchar2(50);
197-
l_source clob := a_source;
198-
begin
199-
l_comment_pos := 1;
200-
loop
201-
202-
l_comment_pos := regexp_instr(srcstr => a_source
203-
,pattern => gc_annot_comment_pattern
204-
,occurrence => 1
205-
,modifier => 'm'
206-
,position => l_comment_pos);
207-
208-
exit when l_comment_pos = 0;
209-
210-
-- position index is shifted by 1 because gc_annot_comment_pattern contains ^ as first sign
211-
-- but after instr index already points to the char on that line
212-
l_comment_pos := l_comment_pos - 1;
213-
l_comment_line := length(substr(a_source,1,l_comment_pos))
214-
- length(replace(substr(a_source,1,l_comment_pos),chr(10)))
215-
+ 1;
216-
l_comments(l_comment_line) := trim(regexp_substr(srcstr => a_source
217-
,pattern => gc_annot_comment_pattern
218-
,occurrence => 1
219-
,position => l_comment_pos
220-
,modifier => 'm'
221-
,subexpression => 2));
222-
223-
l_comment_replacer := replace(gc_comment_replacer_patter, '%N%', l_comment_line);
224-
225-
l_source := regexp_replace(srcstr => a_source
226-
,pattern => gc_annot_comment_pattern
227-
,replacestr => l_comment_replacer
228-
,position => l_comment_pos
229-
,occurrence => 1
230-
,modifier => 'm');
231-
dbms_lob.freetemporary(a_source);
232-
a_source := l_source;
233-
dbms_lob.freetemporary(l_source);
234-
l_comment_pos := l_comment_pos + length(l_comment_replacer);
235-
236-
end loop;
237-
238-
return l_comments;
239-
end extract_and_replace_comments;
240-
241149
function extract_and_replace_comments(
242150
a_source in out nocopy dbms_preprocessor.source_lines_t
243151
) return tt_comment_list is
@@ -317,38 +225,6 @@ create or replace package body ut_annotation_parser as
317225

318226
end parse_object_annotations;
319227

320-
function parse_object_annotations(a_source clob) return ut_annotations is
321-
l_source clob := a_source;
322-
l_comments tt_comment_list;
323-
l_annotations ut_annotations := ut_annotations();
324-
l_result ut_annotations;
325-
l_comment_index positive;
326-
begin
327-
328-
l_source := ut_utils.replace_multiline_comments(l_source);
329-
330-
-- replace all single line comments with {COMMENT#12} element and store it's content for easier processing
331-
-- this call modifies l_source
332-
l_comments := extract_and_replace_comments(l_source);
333-
334-
add_procedure_annotations(l_annotations, l_source, l_comments);
335-
336-
delete_processed_comments(l_comments, l_annotations);
337-
338-
--at this point, only the comments not related to procedures are left, so we process them all as top-level
339-
l_comment_index := l_comments.first;
340-
while l_comment_index is not null loop
341-
add_annotation( l_annotations, l_comment_index, l_comments( l_comment_index ) );
342-
l_comment_index := l_comments.next(l_comment_index);
343-
end loop;
344-
345-
dbms_lob.freetemporary(l_source);
346-
347-
select /*+ no_parallel */ value(x) bulk collect into l_result from table(l_annotations) x order by x.position asc;
348-
349-
return l_result;
350-
end parse_object_annotations;
351-
352228
function parse_object_annotations(a_source_lines dbms_preprocessor.source_lines_t, a_object_type varchar2) return ut_annotations is
353229
l_processed_lines dbms_preprocessor.source_lines_t;
354230
l_source dbms_preprocessor.source_lines_t;

source/core/annotations/ut_annotation_parser.pks

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,5 @@ create or replace package ut_annotation_parser authid current_user as
2929
*/
3030
function parse_object_annotations(a_source_lines dbms_preprocessor.source_lines_t, a_object_type varchar2) return ut_annotations;
3131

32-
33-
/**
34-
*
35-
* @private
36-
* Parses source code and converts it to annotations
37-
*
38-
* @param a_source_lines ordered lines of source code to be parsed
39-
* @return array containing annotations
40-
*/
41-
function parse_object_annotations(a_source clob) return ut_annotations;
42-
43-
function parse_object_annotations(a_source dbms_preprocessor.source_lines_t) return ut_annotations;
44-
4532
end;
4633
/

0 commit comments

Comments
 (0)