* refactor IF

* fix some indentation

* indentation fixes

* indentation fixes

* indentation

* indentation
This commit is contained in:
Lars Hvam 2019-06-25 03:02:51 -07:00 committed by GitHub
parent 7f04d59bf9
commit f6e8332754
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 188 additions and 186 deletions

View File

@ -4,7 +4,7 @@ CLASS ltcl_abapgit_syntax_xml DEFINITION FINAL FOR TESTING
PRIVATE SECTION.
DATA:
mo_cut TYPE REF TO zcl_abapgit_syntax_xml.
mo_cut TYPE REF TO zcl_abapgit_syntax_xml.
METHODS:
setup,

View File

@ -300,7 +300,8 @@ CLASS zcl_abapgit_gui IMPLEMENTATION.
TRY.
" Home must be processed by router if it presents
IF ( iv_action <> c_action-go_home OR mi_router IS NOT BOUND )
AND mi_cur_page IS BOUND AND zcl_abapgit_gui_utils=>is_event_handler( mi_cur_page ) = abap_true.
AND mi_cur_page IS BOUND
AND zcl_abapgit_gui_utils=>is_event_handler( mi_cur_page ) = abap_true.
li_page_eh ?= mi_cur_page.
li_page_eh->on_event(
EXPORTING

View File

@ -74,130 +74,6 @@ ENDCLASS.
CLASS ZCL_ABAPGIT_HTML IMPLEMENTATION.
METHOD add_icon.
add( icon( iv_name = iv_name
iv_class = iv_class
iv_hint = iv_hint ) ).
ENDMETHOD.
METHOD class_constructor.
CREATE OBJECT go_single_tags_re
EXPORTING
pattern = '<(AREA|BASE|BR|COL|COMMAND|EMBED|HR|IMG|INPUT|LINK|META|PARAM|SOURCE|!)'
ignore_case = abap_false.
ENDMETHOD.
METHOD indent_line.
DATA: ls_study TYPE ty_study_result,
lv_x_str TYPE string.
ls_study = study_line(
is_context = cs_context
iv_line = cv_line ).
" First closing tag - shift back exceptionally
IF ( ls_study-script_close = abap_true
OR ls_study-style_close = abap_true
OR ls_study-curly_close = abap_true
OR ls_study-tag_close = abap_true )
AND cs_context-indent > 0.
lv_x_str = repeat( val = ` ` occ = ( cs_context-indent - 1 ) * c_indent_size ).
cv_line = lv_x_str && cv_line.
ELSE.
cv_line = cs_context-indent_str && cv_line.
ENDIF.
" Context status update
CASE abap_true.
WHEN ls_study-script_open.
cs_context-within_js = abap_true.
cs_context-within_style = abap_false.
WHEN ls_study-style_open.
cs_context-within_js = abap_false.
cs_context-within_style = abap_true.
WHEN ls_study-script_close OR ls_study-style_close.
cs_context-within_js = abap_false.
cs_context-within_style = abap_false.
ls_study-closings = ls_study-closings + 1.
ENDCASE.
" More-less logic chosen due to possible double tags in a line '<a><b>'
IF ls_study-openings <> ls_study-closings.
IF ls_study-openings > ls_study-closings.
cs_context-indent = cs_context-indent + 1.
ELSEIF cs_context-indent > 0. " AND ls_study-openings < ls_study-closings
cs_context-indent = cs_context-indent - 1.
ENDIF.
cs_context-indent_str = repeat( val = ` ` occ = cs_context-indent * c_indent_size ).
ENDIF.
ENDMETHOD.
METHOD study_line.
DATA: lv_line TYPE string,
lv_len TYPE i.
lv_line = to_upper( shift_left( val = iv_line sub = ` ` ) ).
lv_len = strlen( lv_line ).
" Some assumptions for simplification and speed
" - style & scripts tag should be opened/closed in a separate line
" - style & scripts opening and closing in one line is possible but only once
" TODO & Issues
" - What if the string IS a well formed html already not just single line ?
IF is_context-within_js = abap_true OR is_context-within_style = abap_true.
IF is_context-within_js = abap_true AND lv_len >= 8 AND lv_line(8) = '</SCRIPT'.
rs_result-script_close = abap_true.
ELSEIF is_context-within_style = abap_true AND lv_len >= 7 AND lv_line(7) = '</STYLE'.
rs_result-style_close = abap_true.
ENDIF.
IF is_context-no_indent_jscss = abap_false.
IF lv_len >= 1 AND lv_line(1) = '}'.
rs_result-curly_close = abap_true.
ENDIF.
FIND ALL OCCURRENCES OF '{' IN lv_line MATCH COUNT rs_result-openings.
FIND ALL OCCURRENCES OF '}' IN lv_line MATCH COUNT rs_result-closings.
ENDIF.
ELSE.
IF lv_len >= 7 AND lv_line(7) = '<SCRIPT'.
FIND FIRST OCCURRENCE OF '</SCRIPT' IN lv_line.
IF sy-subrc > 0. " Not found
rs_result-script_open = abap_true.
ENDIF.
ENDIF.
IF lv_len >= 6 AND lv_line(6) = '<STYLE'.
FIND FIRST OCCURRENCE OF '</STYLE' IN lv_line.
IF sy-subrc > 0. " Not found
rs_result-style_open = abap_true.
ENDIF.
ENDIF.
IF lv_len >= 2 AND lv_line(2) = '</'.
rs_result-tag_close = abap_true.
ENDIF.
FIND ALL OCCURRENCES OF '<' IN lv_line MATCH COUNT rs_result-openings.
FIND ALL OCCURRENCES OF '</' IN lv_line MATCH COUNT rs_result-closings.
FIND ALL OCCURRENCES OF REGEX go_single_tags_re IN lv_line MATCH COUNT rs_result-singles.
rs_result-openings = rs_result-openings - rs_result-closings - rs_result-singles.
ENDIF.
ENDMETHOD.
METHOD a.
DATA: lv_class TYPE string,
@ -293,6 +169,31 @@ CLASS ZCL_ABAPGIT_HTML IMPLEMENTATION.
ENDMETHOD.
METHOD add_icon.
add( icon( iv_name = iv_name
iv_class = iv_class
iv_hint = iv_hint ) ).
ENDMETHOD.
METHOD checkbox.
rv_html = |<input type="checkbox" id="{ iv_id }">|
&& |{ co_span_link_hint }|.
ENDMETHOD.
METHOD class_constructor.
CREATE OBJECT go_single_tags_re
EXPORTING
pattern = '<(AREA|BASE|BR|COL|COMMAND|EMBED|HR|IMG|INPUT|LINK|META|PARAM|SOURCE|!)'
ignore_case = abap_false.
ENDMETHOD.
METHOD icon.
DATA: lv_hint TYPE string,
@ -324,6 +225,54 @@ CLASS ZCL_ABAPGIT_HTML IMPLEMENTATION.
ENDMETHOD.
METHOD indent_line.
DATA: ls_study TYPE ty_study_result,
lv_x_str TYPE string.
ls_study = study_line(
is_context = cs_context
iv_line = cv_line ).
" First closing tag - shift back exceptionally
IF ( ls_study-script_close = abap_true
OR ls_study-style_close = abap_true
OR ls_study-curly_close = abap_true
OR ls_study-tag_close = abap_true )
AND cs_context-indent > 0.
lv_x_str = repeat( val = ` ` occ = ( cs_context-indent - 1 ) * c_indent_size ).
cv_line = lv_x_str && cv_line.
ELSE.
cv_line = cs_context-indent_str && cv_line.
ENDIF.
" Context status update
CASE abap_true.
WHEN ls_study-script_open.
cs_context-within_js = abap_true.
cs_context-within_style = abap_false.
WHEN ls_study-style_open.
cs_context-within_js = abap_false.
cs_context-within_style = abap_true.
WHEN ls_study-script_close OR ls_study-style_close.
cs_context-within_js = abap_false.
cs_context-within_style = abap_false.
ls_study-closings = ls_study-closings + 1.
ENDCASE.
" More-less logic chosen due to possible double tags in a line '<a><b>'
IF ls_study-openings <> ls_study-closings.
IF ls_study-openings > ls_study-closings.
cs_context-indent = cs_context-indent + 1.
ELSEIF cs_context-indent > 0. " AND ls_study-openings < ls_study-closings
cs_context-indent = cs_context-indent - 1.
ENDIF.
cs_context-indent_str = repeat( val = ` ` occ = cs_context-indent * c_indent_size ).
ENDIF.
ENDMETHOD.
METHOD is_empty.
rv_yes = boolc( lines( mt_buffer ) = 0 ).
ENDMETHOD.
@ -348,18 +297,69 @@ CLASS ZCL_ABAPGIT_HTML IMPLEMENTATION.
ENDMETHOD.
METHOD study_line.
DATA: lv_line TYPE string,
lv_len TYPE i.
lv_line = to_upper( shift_left( val = iv_line sub = ` ` ) ).
lv_len = strlen( lv_line ).
" Some assumptions for simplification and speed
" - style & scripts tag should be opened/closed in a separate line
" - style & scripts opening and closing in one line is possible but only once
" TODO & Issues
" - What if the string IS a well formed html already not just single line ?
IF is_context-within_js = abap_true OR is_context-within_style = abap_true.
IF is_context-within_js = abap_true AND lv_len >= 8 AND lv_line(8) = '</SCRIPT'.
rs_result-script_close = abap_true.
ELSEIF is_context-within_style = abap_true AND lv_len >= 7 AND lv_line(7) = '</STYLE'.
rs_result-style_close = abap_true.
ENDIF.
IF is_context-no_indent_jscss = abap_false.
IF lv_len >= 1 AND lv_line(1) = '}'.
rs_result-curly_close = abap_true.
ENDIF.
FIND ALL OCCURRENCES OF '{' IN lv_line MATCH COUNT rs_result-openings.
FIND ALL OCCURRENCES OF '}' IN lv_line MATCH COUNT rs_result-closings.
ENDIF.
ELSE.
IF lv_len >= 7 AND lv_line(7) = '<SCRIPT'.
FIND FIRST OCCURRENCE OF '</SCRIPT' IN lv_line.
IF sy-subrc > 0. " Not found
rs_result-script_open = abap_true.
ENDIF.
ENDIF.
IF lv_len >= 6 AND lv_line(6) = '<STYLE'.
FIND FIRST OCCURRENCE OF '</STYLE' IN lv_line.
IF sy-subrc > 0. " Not found
rs_result-style_open = abap_true.
ENDIF.
ENDIF.
IF lv_len >= 2 AND lv_line(2) = '</'.
rs_result-tag_close = abap_true.
ENDIF.
FIND ALL OCCURRENCES OF '<' IN lv_line MATCH COUNT rs_result-openings.
FIND ALL OCCURRENCES OF '</' IN lv_line MATCH COUNT rs_result-closings.
FIND ALL OCCURRENCES OF REGEX go_single_tags_re IN lv_line MATCH COUNT rs_result-singles.
rs_result-openings = rs_result-openings - rs_result-closings - rs_result-singles.
ENDIF.
ENDMETHOD.
METHOD zif_abapgit_html~add_checkbox.
add( checkbox( iv_id ) ).
ENDMETHOD.
METHOD checkbox.
rv_html = |<input type="checkbox" id="{ iv_id }">|
&& |{ co_span_link_hint }|.
ENDMETHOD.
ENDCLASS.

View File

@ -746,8 +746,9 @@ CLASS ZCL_ABAPGIT_GUI_VIEW_REPO IMPLEMENTATION.
ro_html->add( '<div class="repo_container">' ).
" Offline match banner
IF mo_repo->is_offline( ) = abap_true AND mo_repo->has_remote_source( ) = abap_true
AND lv_lstate IS INITIAL AND lv_rstate IS INITIAL.
IF mo_repo->is_offline( ) = abap_true
AND mo_repo->has_remote_source( ) = abap_true
AND lv_lstate IS INITIAL AND lv_rstate IS INITIAL.
ro_html->add(
|<div class="repo_banner panel success">|
&& |ZIP source is attached and completely <b>matches</b> to the local state|

View File

@ -149,10 +149,8 @@ CLASS ZCL_ABAPGIT_CONVERT IMPLEMENTATION.
IF lv_bitbyte+lv_offset(1) = '1'.
rv_int = 1.
ENDIF.
ELSE.
IF lv_bitbyte+lv_offset(1) = '1'.
rv_int = rv_int + ( 2 ** ( sy-index - 1 ) ).
ENDIF.
ELSEIF lv_bitbyte+lv_offset(1) = '1'.
rv_int = rv_int + ( 2 ** ( sy-index - 1 ) ).
ENDIF.
lv_offset = lv_offset - 1. "Move Cursor
@ -236,12 +234,12 @@ CLASS ZCL_ABAPGIT_CONVERT IMPLEMENTATION.
METHOD xstring_to_bintab.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = iv_xstr
IMPORTING
output_length = ev_size
TABLES
binary_tab = et_bintab.
EXPORTING
buffer = iv_xstr
IMPORTING
output_length = ev_size
TABLES
binary_tab = et_bintab.
ENDMETHOD.

View File

@ -78,9 +78,9 @@ CLASS ZCL_ABAPGIT_LOG IMPLEMENTATION.
METHOD zif_abapgit_log~add_error.
zif_abapgit_log~add(
iv_msg = iv_msg
iv_type = 'E'
is_item = is_item ).
iv_msg = iv_msg
iv_type = 'E'
is_item = is_item ).
ENDMETHOD.

View File

@ -97,8 +97,9 @@ CLASS ZCL_ABAPGIT_PROGRESS IMPLEMENTATION.
ENDIF.
"We only do a progress indication if enough time has passed
IF lv_time >= mv_cv_time_next AND sy-datum = mv_cv_datum_next OR
sy-datum > mv_cv_datum_next.
IF lv_time >= mv_cv_time_next
AND sy-datum = mv_cv_datum_next
OR sy-datum > mv_cv_datum_next.
lv_pct = calc_pct( iv_current ).

View File

@ -143,12 +143,12 @@ CLASS ZCL_ABAPGIT_REQUIREMENT_HELPER IMPLEMENTATION.
METHOD show_requirement_popup.
TYPES: BEGIN OF lty_color_line,
color TYPE lvc_t_scol.
INCLUDE TYPE ty_requirement_status.
TYPES: END OF lty_color_line,
lty_color_tab TYPE STANDARD TABLE OF lty_color_line WITH DEFAULT KEY.
INCLUDE TYPE ty_requirement_status.
TYPES: END OF lty_color_line.
TYPES: lty_color_tab TYPE STANDARD TABLE OF lty_color_line WITH DEFAULT KEY.
DATA: lo_alv TYPE REF TO cl_salv_table,
lo_column TYPE REF TO cl_salv_column,

View File

@ -172,7 +172,7 @@ CLASS ZCL_ABAPGIT_MERGE IMPLEMENTATION.
* added in source and target
<ls_result>-sha1 = <ls_source>-sha1.
ELSEIF lv_found_common = abap_false
AND <ls_target>-sha1 <> <ls_source>-sha1.
AND <ls_target>-sha1 <> <ls_source>-sha1.
INSERT INITIAL LINE INTO TABLE mt_conflicts ASSIGNING <ls_conflict>.
<ls_conflict>-path = <ls_file>-path.
@ -197,8 +197,8 @@ CLASS ZCL_ABAPGIT_MERGE IMPLEMENTATION.
ENDIF.
IF lv_found_source = abap_false
OR lv_found_target = abap_false
OR lv_found_common = abap_false.
OR lv_found_target = abap_false
OR lv_found_common = abap_false.
ms_merge-conflict = |{ <ls_file>-name } merge conflict, not found anywhere|.
CONTINUE.
ENDIF.

View File

@ -163,8 +163,8 @@ CLASS ZCL_ABAPGIT_REPO_CONTENT_LIST IMPLEMENTATION.
ls_file-lstate = <ls_status>-lstate.
APPEND ls_file TO <ls_repo_item>-files.
IF <ls_status>-inactive = abap_true AND
<ls_repo_item>-sortkey > c_sortkey-changed.
IF <ls_status>-inactive = abap_true
AND <ls_repo_item>-sortkey > c_sortkey-changed.
<ls_repo_item>-sortkey = c_sortkey-inactive.
ENDIF.

View File

@ -388,8 +388,8 @@ CLASS ZCL_ABAPGIT_SETTINGS IMPLEMENTATION.
METHOD set_ui_theme.
ms_user_settings-ui_theme = iv_ui_theme.
IF ms_user_settings-ui_theme <> c_ui_theme-default
AND ms_user_settings-ui_theme <> c_ui_theme-dark
AND ms_user_settings-ui_theme <> c_ui_theme-belize.
AND ms_user_settings-ui_theme <> c_ui_theme-dark
AND ms_user_settings-ui_theme <> c_ui_theme-belize.
ms_user_settings-ui_theme = c_ui_theme-default. " Reset to default
ENDIF.
ENDMETHOD.

View File

@ -49,8 +49,7 @@ CLASS ZCL_ABAPGIT_SKIP_OBJECTS IMPLEMENTATION.
rt_tadir = it_tadir.
LOOP AT it_tadir INTO ls_tadir WHERE object = 'DDLS'.
LOOP AT rt_tadir INTO ls_tadir_class
WHERE object = 'CLAS' AND obj_name CS ls_tadir-obj_name.
WHERE object = 'CLAS' AND obj_name CS ls_tadir-obj_name.
IF has_sadl_superclass( ls_tadir_class ) = abap_true.
APPEND ls_tadir_class TO lt_lines_to_delete.
ENDIF.

View File

@ -63,8 +63,8 @@ CLASS ZCL_ABAPGIT_STAGE_LOGIC IMPLEMENTATION.
iv_path = <ls_remote>-path
iv_filename = <ls_remote>-filename ) = abap_true.
DELETE cs_files-remote INDEX lv_index.
ELSEIF <ls_remote>-path = zif_abapgit_definitions=>c_root_dir
AND <ls_remote>-filename = zif_abapgit_definitions=>c_dot_abapgit.
ELSEIF <ls_remote>-path = zif_abapgit_definitions=>c_root_dir
AND <ls_remote>-filename = zif_abapgit_definitions=>c_dot_abapgit.
" Remove .abapgit from remotes - it cannot be removed or ignored
DELETE cs_files-remote INDEX lv_index.
ENDIF.

View File

@ -229,11 +229,11 @@ CLASS lcl_transport_zipper IMPLEMENTATION.
ENDMETHOD.
METHOD get_filename .
METHOD get_filename.
* Generate filename
CONCATENATE is_trkorr-trkorr '_' is_trkorr-as4text '_' gv_timestamp gc_zip_ext
INTO rv_filename.
INTO rv_filename.
* Remove reserved characters (for Windows based systems)
TRANSLATE rv_filename USING '/ \ : " * > < ? | '.
@ -256,7 +256,7 @@ CLASS lcl_transport_zipper IMPLEMENTATION.
zcl_abapgit_zip=>save_binstring_to_localfile( iv_binstring = lv_zipbinstring
iv_filename = get_filename( ls_trkorr ) ).
ENDLOOP. "it_trkorr
ENDLOOP.
ENDMETHOD.

View File

@ -23,7 +23,7 @@ ENDCLASS.
CLASS zcl_abapgit_transport_objects IMPLEMENTATION.
CLASS ZCL_ABAPGIT_TRANSPORT_OBJECTS IMPLEMENTATION.
METHOD constructor.
@ -46,7 +46,7 @@ CLASS zcl_abapgit_transport_objects IMPLEMENTATION.
WHEN zif_abapgit_definitions=>c_state-added OR zif_abapgit_definitions=>c_state-modified.
IF ls_transport_object-delflag = abap_true.
zcx_abapgit_exception=>raise( |Object { ls_transport_object-obj_name
} should be added/modified, but has deletion flag in transport| ).
} should be added/modified, but has deletion flag in transport| ).
ENDIF.
READ TABLE is_stage_objects-local
@ -56,7 +56,7 @@ CLASS zcl_abapgit_transport_objects IMPLEMENTATION.
file-filename = ls_object_status-filename.
IF sy-subrc <> 0.
zcx_abapgit_exception=>raise( |Object { ls_transport_object-obj_name
} not found in the local repository files| ).
} not found in the local repository files| ).
ELSE.
io_stage->add(
iv_path = ls_local_file-file-path
@ -66,7 +66,7 @@ CLASS zcl_abapgit_transport_objects IMPLEMENTATION.
WHEN zif_abapgit_definitions=>c_state-deleted.
IF ls_transport_object-delflag = abap_false.
zcx_abapgit_exception=>raise( |Object { ls_transport_object-obj_name
} should be removed, but has NO deletion flag in transport| ).
} should be removed, but has NO deletion flag in transport| ).
ENDIF.
io_stage->rm(
iv_path = ls_object_status-path

View File

@ -214,9 +214,9 @@ CLASS ltcl_transport_objects IMPLEMENTATION.
ENDMETHOD.
METHOD deleted_to_removed_files.
given_the_transport_object(
iv_obj_name = 'CL_FOO'
iv_obj_type = 'CLAS'
iv_delflag = abap_true ).
iv_obj_name = 'CL_FOO'
iv_obj_type = 'CLAS'
iv_delflag = abap_true ).
given_the_object_status(
iv_obj_name = 'CL_FOO'
@ -235,9 +235,9 @@ CLASS ltcl_transport_objects IMPLEMENTATION.
METHOD should_delete_all_related.
"i.e. Should also delete the XMLs related to the transport objects
given_the_transport_object(
iv_obj_name = 'CL_FOO'
iv_obj_type = 'CLAS'
iv_delflag = abap_true ).
iv_obj_name = 'CL_FOO'
iv_obj_type = 'CLAS'
iv_delflag = abap_true ).
given_the_object_status(
iv_obj_name = 'CL_FOO'
@ -323,10 +323,11 @@ CLASS ltcl_transport_objects IMPLEMENTATION.
lt_staged_objects = mo_stage->get_all( ).
READ TABLE lt_staged_objects TRANSPORTING NO FIELDS
WITH KEY file-filename = is_local_file-file-filename
file-path = is_local_file-file-path
file-data = is_local_file-file-data
method = zcl_abapgit_stage=>c_method-add.
WITH KEY
file-filename = is_local_file-file-filename
file-path = is_local_file-file-path
file-data = is_local_file-file-data
method = zcl_abapgit_stage=>c_method-add.
IF sy-subrc <> 0.
cl_abap_unit_assert=>fail( |Object { is_local_file-file-filename } not added to stage| ).
ENDIF.
@ -352,8 +353,9 @@ CLASS ltcl_transport_objects IMPLEMENTATION.
lt_staged_objects = mo_stage->get_all( ).
READ TABLE lt_staged_objects TRANSPORTING NO FIELDS
WITH KEY file-filename = iv_filename
file-path = iv_path.
WITH KEY
file-filename = iv_filename
file-path = iv_path.
IF sy-subrc <> 0.
cl_abap_unit_assert=>fail( |Object { iv_filename } not removed in stage| ).
ENDIF.