Skip to content

Commit 2b36ad0

Browse files
committed
chore: lint, add unit tests
1 parent 4f70cc1 commit 2b36ad0

3 files changed

Lines changed: 1280 additions & 21 deletions

File tree

src/#apmg#cl_html_diff.clas.abap

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ CLASS /apmg/cl_html_diff DEFINITION
1515

1616
PUBLIC SECTION.
1717

18-
CONSTANTS c_version TYPE string VALUE '1.0.1' ##NEEDED.
18+
CONSTANTS c_version TYPE string VALUE '1.1.0' ##NEEDED.
1919

2020
INTERFACES /apmg/if_html_diff.
2121

@@ -39,7 +39,7 @@ CLASS /apmg/cl_html_diff DEFINITION
3939

4040
TYPES:
4141
ty_token TYPE string,
42-
ty_tokens TYPE STANDARD TABLE OF ty_token WITH DEFAULT KEY.
42+
ty_tokens TYPE STANDARD TABLE OF ty_token WITH KEY table_line.
4343

4444
TYPES:
4545
BEGIN OF ty_match,
@@ -49,11 +49,12 @@ CLASS /apmg/cl_html_diff DEFINITION
4949
end_in_before TYPE i,
5050
end_in_after TYPE i,
5151
END OF ty_match,
52-
ty_matches TYPE STANDARD TABLE OF ty_match WITH DEFAULT KEY.
52+
ty_matches TYPE STANDARD TABLE OF ty_match
53+
WITH KEY start_in_before start_in_after length end_in_before end_in_after.
5354

5455
TYPES:
5556
ty_location TYPE i,
56-
ty_locations TYPE SORTED TABLE OF ty_location WITH UNIQUE DEFAULT KEY.
57+
ty_locations TYPE SORTED TABLE OF ty_location WITH UNIQUE KEY table_line.
5758

5859
TYPES:
5960
BEGIN OF ty_index_row,
@@ -62,8 +63,7 @@ CLASS /apmg/cl_html_diff DEFINITION
6263
END OF ty_index_row,
6364
ty_index_tab TYPE HASHED TABLE OF ty_index_row WITH UNIQUE KEY token.
6465

65-
TYPES:
66-
ty_action TYPE string.
66+
TYPES ty_action TYPE string.
6767

6868
TYPES:
6969
BEGIN OF ty_operation,
@@ -72,9 +72,9 @@ CLASS /apmg/cl_html_diff DEFINITION
7272
end_in_before TYPE i,
7373
start_in_after TYPE i,
7474
end_in_after TYPE i,
75-
END OF ty_operation.
76-
TYPES:
77-
ty_operations TYPE STANDARD TABLE OF ty_operation WITH DEFAULT KEY.
75+
END OF ty_operation,
76+
ty_operations TYPE STANDARD TABLE OF ty_operation
77+
WITH KEY action start_in_before end_in_before start_in_after end_in_after.
7878

7979
CONSTANTS:
8080
BEGIN OF c_action,
@@ -151,14 +151,14 @@ CLASS /apmg/cl_html_diff DEFINITION
151151
METHODS find_match
152152
IMPORTING
153153
!it_before_tokens TYPE ty_tokens
154-
!it_after_tokens TYPE ty_tokens ##NEEDED
154+
!it_after_tokens TYPE ty_tokens
155155
!it_index_before_in_after TYPE ty_index_tab
156156
!iv_start_in_before TYPE i
157157
!iv_end_in_before TYPE i
158158
!iv_start_in_after TYPE i
159159
!iv_end_in_after TYPE i
160160
RETURNING
161-
VALUE(rs_result) TYPE ty_match.
161+
VALUE(rs_result) TYPE ty_match ##NEEDED.
162162

163163
METHODS find_matching_blocks
164164
IMPORTING
@@ -176,10 +176,10 @@ CLASS /apmg/cl_html_diff DEFINITION
176176
!iv_end_in_before TYPE i
177177
!iv_start_in_after TYPE i
178178
!iv_end_in_after TYPE i
179+
EXPORTING
180+
et_result TYPE ty_matches
179181
CHANGING
180-
!ct_matching_blocks TYPE ty_matches
181-
RETURNING
182-
VALUE(rt_result) TYPE ty_matches.
182+
!ct_matching_blocks TYPE ty_matches.
183183

184184
METHODS create_index
185185
IMPORTING
@@ -246,7 +246,6 @@ CLASS /apmg/cl_html_diff DEFINITION
246246
!iv_after TYPE string
247247
RETURNING
248248
VALUE(rv_result) TYPE string.
249-
250249
PRIVATE SECTION.
251250

252251
CONSTANTS:
@@ -283,7 +282,7 @@ CLASS /apmg/cl_html_diff DEFINITION
283282

284283
METHODS _inject
285284
IMPORTING
286-
!iv_with_tags TYPE abap_bool.
285+
!iv_with_tags TYPE abap_bool ##CALLED.
287286

288287
METHODS _slice
289288
IMPORTING
@@ -329,7 +328,6 @@ CLASS /apmg/cl_html_diff DEFINITION
329328
!iv_end TYPE i
330329
RETURNING
331330
VALUE(rv_result) TYPE i.
332-
333331
ENDCLASS.
334332

335333

@@ -389,8 +387,7 @@ CLASS /apmg/cl_html_diff IMPLEMENTATION.
389387
lt_operations TYPE ty_operations,
390388
lt_post_processed TYPE ty_operations.
391389

392-
FIELD-SYMBOLS:
393-
<ls_last_op> TYPE ty_operation.
390+
FIELD-SYMBOLS <ls_last_op> TYPE ty_operation.
394391

395392
" any before_tokens?
396393
ASSERT it_before_tokens IS NOT INITIAL.
@@ -692,7 +689,7 @@ CLASS /apmg/cl_html_diff IMPLEMENTATION.
692689
DATA(lt_index_of_before_in_after) = create_index( it_find_these = it_before_tokens
693690
it_in_these = it_after_tokens ).
694691

695-
rt_result = recurs_find_matching_blocks(
692+
recurs_find_matching_blocks(
696693
EXPORTING
697694
it_before_tokens = it_before_tokens
698695
it_after_tokens = it_after_tokens
@@ -701,6 +698,8 @@ CLASS /apmg/cl_html_diff IMPLEMENTATION.
701698
iv_end_in_before = lines( it_before_tokens )
702699
iv_start_in_after = 0
703700
iv_end_in_after = lines( it_after_tokens )
701+
IMPORTING
702+
et_result = rt_result
704703
CHANGING
705704
ct_matching_blocks = lt_matching_blocks ).
706705

@@ -963,6 +962,8 @@ CLASS /apmg/cl_html_diff IMPLEMENTATION.
963962

964963
METHOD recurs_find_matching_blocks.
965964

965+
CLEAR et_result.
966+
966967
DATA(ls_match) = find_match( it_before_tokens = it_before_tokens
967968
it_after_tokens = it_after_tokens
968969
it_index_before_in_after = it_index_before_in_after
@@ -1003,7 +1004,7 @@ CLASS /apmg/cl_html_diff IMPLEMENTATION.
10031004
ENDIF.
10041005
ENDIF.
10051006

1006-
rt_result = ct_matching_blocks.
1007+
et_result = ct_matching_blocks.
10071008

10081009
ENDMETHOD.
10091010

0 commit comments

Comments
 (0)