only highlight abap files, close #482

This commit is contained in:
larshp 2016-12-03 10:57:56 +00:00
parent b1e35d75b0
commit 5f08a635ea
2 changed files with 35 additions and 24 deletions

View File

@ -3,7 +3,7 @@ REPORT zabapgit LINE-SIZE 100.
* See http://www.abapgit.org * See http://www.abapgit.org
CONSTANTS: gc_xml_version TYPE string VALUE 'v1.0.0', "#EC NOTEXT CONSTANTS: gc_xml_version TYPE string VALUE 'v1.0.0', "#EC NOTEXT
gc_abap_version TYPE string VALUE 'v1.24.1'. "#EC NOTEXT gc_abap_version TYPE string VALUE 'v1.24.2'. "#EC NOTEXT
******************************************************************************** ********************************************************************************
* The MIT License (MIT) * The MIT License (MIT)

View File

@ -54,9 +54,9 @@ CLASS lcl_gui_page_diff DEFINITION FINAL INHERITING FROM lcl_gui_page_super.
EXPORTING ev_lattr TYPE string EXPORTING ev_lattr TYPE string
ev_rattr TYPE string. ev_rattr TYPE string.
METHODS append_diff METHODS append_diff
IMPORTING it_remote TYPE ty_files_tt IMPORTING it_remote TYPE ty_files_tt
it_local TYPE ty_files_item_tt it_local TYPE ty_files_item_tt
is_status TYPE ty_result is_status TYPE ty_result
RAISING lcx_exception. RAISING lcx_exception.
ENDCLASS. "lcl_gui_page_diff ENDCLASS. "lcl_gui_page_diff
@ -121,8 +121,8 @@ CLASS lcl_gui_page_diff IMPLEMENTATION.
METHOD append_diff. METHOD append_diff.
DATA: DATA:
ls_r_dummy LIKE LINE OF it_remote ##NEEDED, ls_r_dummy LIKE LINE OF it_remote ##NEEDED,
ls_l_dummy LIKE LINE OF it_local ##NEEDED. ls_l_dummy LIKE LINE OF it_local ##NEEDED.
FIELD-SYMBOLS: <ls_remote> LIKE LINE OF it_remote, FIELD-SYMBOLS: <ls_remote> LIKE LINE OF it_remote,
@ -202,14 +202,14 @@ CLASS lcl_gui_page_diff IMPLEMENTATION.
CREATE OBJECT ro_html. CREATE OBJECT ro_html.
ro_html->add( '<thead class="header">' ). "#EC NOTEXT ro_html->add( '<thead class="header">' ). "#EC NOTEXT
ro_html->add( '<tr>' ). "#EC NOTEXT ro_html->add( '<tr>' ). "#EC NOTEXT
ro_html->add( '<th class="num"></th>' ). "#EC NOTEXT ro_html->add( '<th class="num"></th>' ). "#EC NOTEXT
ro_html->add( '<th>LOCAL</th>' ). "#EC NOTEXT ro_html->add( '<th>LOCAL</th>' ). "#EC NOTEXT
ro_html->add( '<th class="num"></th>' ). "#EC NOTEXT ro_html->add( '<th class="num"></th>' ). "#EC NOTEXT
ro_html->add( '<th>REMOTE</th>' ). "#EC NOTEXT ro_html->add( '<th>REMOTE</th>' ). "#EC NOTEXT
ro_html->add( '</tr>' ). "#EC NOTEXT ro_html->add( '</tr>' ). "#EC NOTEXT
ro_html->add( '</thead>' ). "#EC NOTEXT ro_html->add( '</thead>' ). "#EC NOTEXT
ENDMETHOD. " render_table_head. ENDMETHOD. " render_table_head.
@ -261,6 +261,7 @@ CLASS lcl_gui_page_diff IMPLEMENTATION.
lv_remote TYPE string, lv_remote TYPE string,
lv_lattr TYPE string, lv_lattr TYPE string,
lv_rattr TYPE string, lv_rattr TYPE string,
lv_highlight TYPE abap_bool,
lv_insert_nav TYPE abap_bool. lv_insert_nav TYPE abap_bool.
FIELD-SYMBOLS <ls_diff> LIKE LINE OF lt_diffs. FIELD-SYMBOLS <ls_diff> LIKE LINE OF lt_diffs.
@ -270,6 +271,8 @@ CLASS lcl_gui_page_diff IMPLEMENTATION.
lt_diffs = is_diff-o_diff->get( ). lt_diffs = is_diff-o_diff->get( ).
lv_highlight = boolc( is_diff-filename CP '*.abap' ).
LOOP AT lt_diffs ASSIGNING <ls_diff>. LOOP AT lt_diffs ASSIGNING <ls_diff>.
IF <ls_diff>-short = abap_false. IF <ls_diff>-short = abap_false.
lv_insert_nav = abap_true. lv_insert_nav = abap_true.
@ -282,11 +285,19 @@ CLASS lcl_gui_page_diff IMPLEMENTATION.
ENDIF. ENDIF.
IF is_diff-mod = c_mod-remote. " Remote file leading changes IF is_diff-mod = c_mod-remote. " Remote file leading changes
lv_local = lo_highlighter->process_line( <ls_diff>-old ). lv_local = <ls_diff>-old.
lv_remote = lo_highlighter->process_line( <ls_diff>-new ). lv_remote = <ls_diff>-new.
ELSE. " Local leading changes or both were modified ELSE. " Local leading changes or both were modified
lv_local = lo_highlighter->process_line( <ls_diff>-new ). lv_local = <ls_diff>-new.
lv_remote = lo_highlighter->process_line( <ls_diff>-old ). lv_remote = <ls_diff>-old.
ENDIF.
IF lv_highlight = abap_true.
lv_local = lo_highlighter->process_line( lv_local ).
lv_remote = lo_highlighter->process_line( lv_remote ).
ELSE.
lv_local = escape( val = lv_local format = cl_abap_format=>e_html_attr ).
lv_remote = escape( val = lv_remote format = cl_abap_format=>e_html_attr ).
ENDIF. ENDIF.
get_line_hl( EXPORTING iv_mod = is_diff-mod get_line_hl( EXPORTING iv_mod = is_diff-mod
@ -315,21 +326,21 @@ CLASS lcl_gui_page_diff IMPLEMENTATION.
" Both file changed ? Or line updated ? - All yellow " Both file changed ? Or line updated ? - All yellow
IF iv_mod = c_mod-both OR iv_result = lcl_diff=>c_diff-update. IF iv_mod = c_mod-both OR iv_result = lcl_diff=>c_diff-update.
ev_lattr = ' class="diff_upd"'. "#EC NOTEXT ev_lattr = ' class="diff_upd"'. "#EC NOTEXT
ev_rattr = ' class="diff_upd"'. "#EC NOTEXT ev_rattr = ' class="diff_upd"'. "#EC NOTEXT
ELSEIF iv_mod = c_mod-local. " Changed locally ELSEIF iv_mod = c_mod-local. " Changed locally
CASE iv_result. CASE iv_result.
WHEN lcl_diff=>c_diff-insert. WHEN lcl_diff=>c_diff-insert.
ev_lattr = ' class="diff_ins"'. "#EC NOTEXT ev_lattr = ' class="diff_ins"'. "#EC NOTEXT
WHEN lcl_diff=>c_diff-delete. WHEN lcl_diff=>c_diff-delete.
ev_rattr = ' class="diff_del"'. "#EC NOTEXT ev_rattr = ' class="diff_del"'. "#EC NOTEXT
ENDCASE. ENDCASE.
ELSEIF iv_mod = c_mod-remote. " Changed remotely - invert sides ELSEIF iv_mod = c_mod-remote. " Changed remotely - invert sides
CASE iv_result. CASE iv_result.
WHEN lcl_diff=>c_diff-insert. WHEN lcl_diff=>c_diff-insert.
ev_rattr = ' class="diff_ins"'. "#EC NOTEXT ev_rattr = ' class="diff_ins"'. "#EC NOTEXT
WHEN lcl_diff=>c_diff-delete. WHEN lcl_diff=>c_diff-delete.
ev_lattr = ' class="diff_del"'. "#EC NOTEXT ev_lattr = ' class="diff_del"'. "#EC NOTEXT
ENDCASE. ENDCASE.
ENDIF. ENDIF.