mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-01 12:20:51 +08:00
Cleanup (#2753)
* refactor IF * fix some indentation * indentation fixes * indentation fixes * indentation * indentation
This commit is contained in:
parent
7f04d59bf9
commit
f6e8332754
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -746,7 +746,8 @@ 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
|
||||
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">|
|
||||
|
|
|
@ -149,11 +149,9 @@ CLASS ZCL_ABAPGIT_CONVERT IMPLEMENTATION.
|
|||
IF lv_bitbyte+lv_offset(1) = '1'.
|
||||
rv_int = 1.
|
||||
ENDIF.
|
||||
ELSE.
|
||||
IF lv_bitbyte+lv_offset(1) = '1'.
|
||||
ELSEIF lv_bitbyte+lv_offset(1) = '1'.
|
||||
rv_int = rv_int + ( 2 ** ( sy-index - 1 ) ).
|
||||
ENDIF.
|
||||
ENDIF.
|
||||
|
||||
lv_offset = lv_offset - 1. "Move Cursor
|
||||
|
||||
|
|
|
@ -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 ).
|
||||
|
||||
|
|
|
@ -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.
|
||||
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,
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -50,7 +50,6 @@ CLASS ZCL_ABAPGIT_SKIP_OBJECTS IMPLEMENTATION.
|
|||
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.
|
||||
|
||||
IF has_sadl_superclass( ls_tadir_class ) = abap_true.
|
||||
APPEND ls_tadir_class TO lt_lines_to_delete.
|
||||
ENDIF.
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ ENDCLASS.
|
|||
|
||||
|
||||
|
||||
CLASS zcl_abapgit_transport_objects IMPLEMENTATION.
|
||||
CLASS ZCL_ABAPGIT_TRANSPORT_OBJECTS IMPLEMENTATION.
|
||||
|
||||
|
||||
METHOD constructor.
|
||||
|
|
|
@ -323,7 +323,8 @@ 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
|
||||
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.
|
||||
|
@ -352,7 +353,8 @@ 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
|
||||
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| ).
|
||||
|
|
Loading…
Reference in New Issue
Block a user