From 8bec88376000bd1e6f726f6a1af3cb22769f18be Mon Sep 17 00:00:00 2001 From: Lars Hvam Date: Thu, 13 Nov 2014 07:23:04 +0100 Subject: [PATCH] debug mode commencing :stuck_out_tongue: --- zabapgit.abap | 128 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 119 insertions(+), 9 deletions(-) diff --git a/zabapgit.abap b/zabapgit.abap index 7ca71b111..127bd58e7 100644 --- a/zabapgit.abap +++ b/zabapgit.abap @@ -703,6 +703,89 @@ CLASS lcl_xml IMPLEMENTATION. ENDCLASS. "lcl_xml IMPLEMENTATION +*----------------------------------------------------------------------* +* CLASS lcl_debug DEFINITION +*----------------------------------------------------------------------* +* +*----------------------------------------------------------------------* +CLASS lcl_debug DEFINITION FINAL. + + PUBLIC SECTION. + CLASS-METHODS: debug_toggle. + + CLASS-METHODS: render_objects IMPORTING iv_message TYPE string + it_objects TYPE tt_objects. + + CLASS-METHODS: get_html RETURNING value(rv_html) TYPE string. + + CLASS-METHODS: get_debug RETURNING value(rv_debug) TYPE abap_bool. + + CLASS-METHODS: clear. + + PRIVATE SECTION. + CLASS-DATA: gv_debug TYPE abap_bool VALUE abap_false, + gv_html TYPE string. + +ENDCLASS. "lcl_debug DEFINITION + +*----------------------------------------------------------------------* +* CLASS lcl_debug IMPLEMENTATION +*----------------------------------------------------------------------* +* +*----------------------------------------------------------------------* +CLASS lcl_debug IMPLEMENTATION. + + METHOD get_debug. + rv_debug = gv_debug. + ENDMETHOD. "get_debug + + METHOD get_html. + rv_html = gv_html. + ENDMETHOD. "get_html + + METHOD render_objects. + + FIELD-SYMBOLS: LIKE LINE OF it_objects. + + + IF gv_debug = abap_false. + RETURN. + ENDIF. + + gv_html = gv_html && + '
' && + iv_message && + '
'. + + LOOP AT it_objects ASSIGNING . +* todo + ENDLOOP. + + ENDMETHOD. "render_objects + + METHOD clear. + + gv_html = '

Debug Information

'. + + ENDMETHOD. "clear + + METHOD debug_toggle. + + CASE gv_debug. + WHEN abap_true. + gv_debug = abap_false. + MESSAGE 'Debug mode disabled' TYPE 'S'. "#EC NOTEXT + WHEN abap_false. + gv_debug = abap_true. + MESSAGE 'Debug mode enabled' TYPE 'S'. "#EC NOTEXT + clear( ). + WHEN OTHERS. + ASSERT 1 = 1 + 1. + ENDCASE. + + ENDMETHOD. "debug_toggle + +ENDCLASS. "lcl_debug IMPLEMENTATION *----------------------------------------------------------------------* * CLASS lcl_time DEFINITION @@ -5541,7 +5624,12 @@ CLASS lcl_porcelain IMPLEMENTATION. ENDIF. et_objects = lcl_pack=>decode( lv_pack ). + lcl_debug=>render_objects( iv_message = 'Before deltas' + it_objects = et_objects ). "#EC NOTEXT + lcl_pack=>decode_deltas( CHANGING ct_objects = et_objects ). + lcl_debug=>render_objects( iv_message = 'After deltas' + it_objects = et_objects ). "#EC NOTEXT READ TABLE et_objects INTO ls_object WITH KEY sha1 = ev_branch type = gc_commit. IF sy-subrc <> 0. @@ -5637,6 +5725,9 @@ CLASS lcl_gui DEFINITION FINAL. CLASS-METHODS: render_header RETURNING value(rv_html) TYPE string. + CLASS-METHODS: render_menu + RETURNING value(rv_html) TYPE string. + CLASS-METHODS: render_footer RETURNING value(rv_html) TYPE string. @@ -6030,10 +6121,17 @@ CLASS lcl_gui IMPLEMENTATION. struct_decode( EXPORTING iv_string = getdata CHANGING cg_structure = ls_repo ). pull( ls_repo ). + WHEN 'debug'. + lcl_debug=>debug_toggle( ). WHEN OTHERS. _raise 'Unknown action'. ENDCASE. CATCH lcx_exception INTO lx_exception. + IF lcl_debug=>get_debug( ) = abap_true. + view( render_header( ) && + lcl_debug=>get_html( ) && + render_footer( ) ). + ENDIF. MESSAGE lx_exception->mv_text TYPE 'S' DISPLAY LIKE 'E'. ENDTRY. @@ -6257,6 +6355,12 @@ CLASS lcl_gui IMPLEMENTATION. ' color: grey;' && gc_newline && "#EC NOTEXT ' font-size: smaller;' && gc_newline && "#EC NOTEXT '}' && gc_newline && + 'a.white:link {' && gc_newline && "#EC NOTEXT + ' color: white;' && gc_newline && "#EC NOTEXT + '}' && gc_newline && + 'a.white:visited {' && gc_newline && "#EC NOTEXT + ' color: white;' && gc_newline && "#EC NOTEXT + '}' && gc_newline && 'h1 {' && gc_newline && "#EC NOTEXT ' display: inline;' && gc_newline && "#EC NOTEXT '}' && gc_newline && @@ -6276,6 +6380,17 @@ CLASS lcl_gui IMPLEMENTATION. ENDMETHOD. "render_css + METHOD render_menu. + + rv_html = '

abapGit

 ' && gc_newline && + 'Refresh ' && gc_newline && + 'Clone ' && gc_newline && + 'Explore ' && gc_newline && + 'abapGit@GitHub ' && gc_newline && + '
' && gc_newline. + + ENDMETHOD. "render_menu + METHOD render. DATA: lt_repos TYPE tt_repos_sha1, @@ -6287,13 +6402,7 @@ CLASS lcl_gui IMPLEMENTATION. lt_repos = lcl_persistence=>list( ). - rv_html = render_header( ) && - '

abapGit

 ' && gc_newline && - 'Refresh ' && gc_newline && - 'Clone ' && gc_newline && - 'Explore ' && gc_newline && - 'abapGit@GitHub ' && gc_newline && - '
' && gc_newline. + rv_html = render_header( ) && render_menu( ). LOOP AT lt_repos INTO ls_repo. rv_html = rv_html && @@ -6320,7 +6429,8 @@ CLASS lcl_gui IMPLEMENTATION. ENDLOOP. ENDIF. - rv_html = rv_html && render_footer( ). + rv_html = rv_html && + render_footer( ). ENDMETHOD. "render @@ -6329,7 +6439,7 @@ CLASS lcl_gui IMPLEMENTATION. rv_html = rv_html && '


abapGit Version: ' && gc_version && - '

'. + ' d'. rv_html = rv_html && ''.