diff --git a/src/zabapgit.prog.abap b/src/zabapgit.prog.abap index ef48a5c98..410f97ba6 100644 --- a/src/zabapgit.prog.abap +++ b/src/zabapgit.prog.abap @@ -3,7 +3,7 @@ REPORT zabapgit LINE-SIZE 100. * See http://www.abapgit.org CONSTANTS: gc_xml_version TYPE string VALUE 'v1.0.0', "#EC NOTEXT - gc_abap_version TYPE string VALUE 'v1.24.5'. "#EC NOTEXT + gc_abap_version TYPE string VALUE 'v1.24.7'. "#EC NOTEXT ******************************************************************************** * The MIT License (MIT) diff --git a/src/zabapgit_css_common.w3mi.data.css b/src/zabapgit_css_common.w3mi.data.css index d326d2f69..924b1d664 100644 --- a/src/zabapgit_css_common.w3mi.data.css +++ b/src/zabapgit_css_common.w3mi.data.css @@ -503,6 +503,9 @@ table.diff_tab code { table.diff_tab code span.keyword { color: #0a69ce; } table.diff_tab code span.text { color: #48ce4f; } table.diff_tab code span.comment { color: #808080; font-style: italic; } +table.diff_tab code span.xml_tag { color: #3370e0; } +table.diff_tab code span.attr { color: #f20707; } +table.diff_tab code span.attr_val { color: #7a02f9; } table.diff_tab tbody tr:first-child td { padding-top: 0.5em; } table.diff_tab tbody tr:last-child td { padding-bottom: 0.5em; } @@ -597,6 +600,7 @@ div.tutorial { } div.tutorial hr { border-color: #CCC; } +div.tutorial li { margin: 2px 0px } div.tutorial h1 { font-size: 18pt; color: #404040; diff --git a/src/zabapgit_css_common.w3mi.xml b/src/zabapgit_css_common.w3mi.xml index ddab44689..10d1ffd0d 100644 --- a/src/zabapgit_css_common.w3mi.xml +++ b/src/zabapgit_css_common.w3mi.xml @@ -17,24 +17,12 @@ filename ~wwwtmp.css - - MI - ZABAPGIT_CSS_COMMON - filesize - 12615 - MI ZABAPGIT_CSS_COMMON mimetype text/css - - MI - ZABAPGIT_CSS_COMMON - version - - diff --git a/src/zabapgit_definitions.prog.abap b/src/zabapgit_definitions.prog.abap index 139849bfe..6cccf90c5 100644 --- a/src/zabapgit_definitions.prog.abap +++ b/src/zabapgit_definitions.prog.abap @@ -156,7 +156,8 @@ CONSTANTS: gc_newline TYPE abap_char1 VALUE cl_abap_char_utilities=>newline. CONSTANTS: gc_english TYPE spras VALUE 'E'. CONSTANTS: gc_root_dir TYPE string VALUE '/', - gc_dot_abapgit TYPE string VALUE '.abapgit.xml' ##NO_TEXT. + gc_dot_abapgit TYPE string VALUE '.abapgit.xml' ##NO_TEXT, + gc_author_regex TYPE string VALUE '^([\w\s\.@\-_1-9]+) <(.*)> (\d{10}) .\d{4}$' ##NO_TEXT. CONSTANTS: BEGIN OF gc_action, repo_clone TYPE string VALUE 'repo_clone', diff --git a/src/zabapgit_js_common.w3mi.xml b/src/zabapgit_js_common.w3mi.xml index 7860ae90e..51f904696 100644 --- a/src/zabapgit_js_common.w3mi.xml +++ b/src/zabapgit_js_common.w3mi.xml @@ -17,24 +17,12 @@ filename common.js - - MI - ZABAPGIT_JS_COMMON - filesize - 6500 - MI ZABAPGIT_JS_COMMON mimetype text/javascript - - MI - ZABAPGIT_JS_COMMON - version - - diff --git a/src/zabapgit_object_tabl.prog.abap b/src/zabapgit_object_tabl.prog.abap index fcd1c4dac..8f70c2f35 100644 --- a/src/zabapgit_object_tabl.prog.abap +++ b/src/zabapgit_object_tabl.prog.abap @@ -195,6 +195,11 @@ CLASS lcl_object_tabl IMPLEMENTATION. -scrtext_m, -scrtext_l. + IF -masklen = '' OR NOT -masklen CO '0123456789'. +* make sure the field contains valid data, or the XML will dump + CLEAR -masklen. + ENDIF. + IF -comptype = 'E'. * type specified via data element CLEAR: -domname, diff --git a/src/zabapgit_object_tran.prog.abap b/src/zabapgit_object_tran.prog.abap index 5f4b9cbff..9eba8a64a 100644 --- a/src/zabapgit_object_tran.prog.abap +++ b/src/zabapgit_object_tran.prog.abap @@ -387,10 +387,7 @@ CLASS lcl_object_tran IMPLEMENTATION. SELECT SINGLE * FROM tstct INTO ls_tstct WHERE sprsl = mv_language - AND tcode = lv_transaction. "#EC CI_GENBUFF - IF sy-subrc <> 0. - lcx_exception=>raise( 'Transaction description not found' ). - ENDIF. + AND tcode = lv_transaction. "#EC CI_SUBRC "#EC CI_GENBUFF SELECT SINGLE * FROM tstcp INTO ls_tstcp WHERE tcode = lv_transaction. "#EC CI_SUBRC "#EC CI_GENBUFF diff --git a/src/zabapgit_object_w3xx.prog.abap b/src/zabapgit_object_w3xx.prog.abap index f1c17f50d..c14bdc062 100644 --- a/src/zabapgit_object_w3xx.prog.abap +++ b/src/zabapgit_object_w3xx.prog.abap @@ -12,13 +12,20 @@ CLASS lcl_object_w3super DEFINITION INHERITING FROM lcl_objects_super ABSTRACT. PUBLIC SECTION. INTERFACES lif_object. - TYPES: ty_wwwparams_tt TYPE STANDARD TABLE OF wwwparams WITH DEFAULT KEY. + TYPES ty_wwwparams_tt TYPE STANDARD TABLE OF wwwparams WITH DEFAULT KEY. - METHODS: - constructor - IMPORTING - is_item TYPE ty_item - iv_language TYPE spras. + CONSTANTS: BEGIN OF c_param_names, + version TYPE w3_name VALUE 'version', + fileext TYPE w3_name VALUE 'fileextension', + filesize TYPE w3_name VALUE 'filesize', + filename TYPE w3_name VALUE 'filename', + mimetype TYPE w3_name VALUE 'mimetype', + END OF c_param_names. + + METHODS constructor + IMPORTING + is_item TYPE ty_item + iv_language TYPE spras. PROTECTED SECTION. @@ -33,18 +40,19 @@ CLASS lcl_object_w3super DEFINITION INHERITING FROM lcl_objects_super ABSTRACT. RETURNING VALUE(rv_ext) TYPE string RAISING lcx_exception. - METHODS patch_size - IMPORTING iv_size TYPE i OPTIONAL " Overwrite if given - EXPORTING ev_size TYPE i " Return size as integer + METHODS normalize_params + IMPORTING iv_size TYPE i CHANGING ct_params TYPE ty_wwwparams_tt " Param table to patch RAISING lcx_exception. - METHODS patch_filename + METHODS strip_params CHANGING ct_params TYPE ty_wwwparams_tt RAISING lcx_exception. - METHODS clear_version - CHANGING ct_params TYPE ty_wwwparams_tt + METHODS find_param + IMPORTING it_params TYPE ty_wwwparams_tt + iv_name TYPE w3_name + RETURNING VALUE(rv_value) TYPE string RAISING lcx_exception. ENDCLASS. "lcl_object_W3SUPER DEFINITION @@ -145,15 +153,9 @@ CLASS lcl_object_w3super IMPLEMENTATION. lcx_exception=>raise( 'Cannot read W3xx data' ). ENDIF. - " Condense size string + get size to local integer - patch_size( IMPORTING ev_size = lv_size - CHANGING ct_params = lt_w3params ). - - " Remove file path (for security concerns) - patch_filename( CHANGING ct_params = lt_w3params ). - - " Clear version - clear_version( CHANGING ct_params = lt_w3params ). + lv_size = find_param( it_params = lt_w3params iv_name = c_param_names-filesize ). + " Clean params (remove version, filesize & clear filename from path) + strip_params( CHANGING ct_params = lt_w3params ). CASE ms_key-relid. WHEN 'MI'. @@ -264,11 +266,9 @@ CLASS lcl_object_w3super IMPLEMENTATION. lcx_exception=>raise( 'Wrong W3xx type' ). ENDCASE. - " Update size of file (for the case file was actually changed remotely) - " Will also trigger "stage" at next sync if remote XML - " was not updated with the new file size - patch_size( EXPORTING iv_size = lv_size - CHANGING ct_params = lt_w3params ). + " Update size of file based on actual data file size, prove param object name + normalize_params( EXPORTING iv_size = lv_size + CHANGING ct_params = lt_w3params ). CALL FUNCTION 'WWWPARAMS_UPDATE' TABLES @@ -368,67 +368,60 @@ CLASS lcl_object_w3super IMPLEMENTATION. METHOD get_ext. - FIELD-SYMBOLS LIKE LINE OF it_params. - - READ TABLE it_params ASSIGNING WITH KEY name = 'fileextension'. - - IF sy-subrc > 0. - lcx_exception=>raise( |W3xx: Cannot find file ext for { ms_key-objid }| ). - ENDIF. - - rv_ext = -value. + rv_ext = find_param( it_params = it_params iv_name = c_param_names-fileext ). SHIFT rv_ext LEFT DELETING LEADING '.'. ENDMETHOD. " get_ext. - METHOD patch_size. + METHOD normalize_params. FIELD-SYMBOLS LIKE LINE OF ct_params. - READ TABLE ct_params ASSIGNING WITH KEY name = 'filesize'. - - IF sy-subrc > 0. - lcx_exception=>raise( |W3xx: Cannot find file size for { ms_key-objid }| ). + " Ensure filesize param exists + READ TABLE ct_params ASSIGNING WITH KEY name = c_param_names-filesize. + IF sy-subrc <> 0. + APPEND INITIAL LINE TO ct_params ASSIGNING . + -name = c_param_names-filesize. ENDIF. - IF iv_size IS NOT INITIAL. - -value = iv_size. - ENDIF. - CONDENSE -value. + LOOP AT ct_params ASSIGNING . + -relid = ms_key-relid. " Ensure param key = object key + -objid = ms_key-objid. + IF -name = c_param_names-filesize. " Patch filesize = real file size + -value = iv_size. + CONDENSE -value. + ENDIF. + ENDLOOP. - ev_size = -value. + ENDMETHOD. " normalize_params. - ENDMETHOD. " patch_size. - - METHOD patch_filename. + METHOD strip_params. FIELD-SYMBOLS LIKE LINE OF ct_params. - READ TABLE ct_params ASSIGNING WITH KEY name = 'filename'. - - IF sy-subrc > 0. - lcx_exception=>raise( |W3xx: Cannot find file name for { ms_key-objid }| ). - ENDIF. - - " Remove path + " Remove path from filename + find_param( it_params = ct_params iv_name = c_param_names-filename ). " Check exists + READ TABLE ct_params ASSIGNING WITH KEY name = c_param_names-filename. -value = lcl_path=>get_filename_from_syspath( |{ -value }| ). - ENDMETHOD. " patch_filename. + " Clear version & filesize + DELETE ct_params WHERE name = c_param_names-version. + DELETE ct_params WHERE name = c_param_names-filesize. - METHOD clear_version. + ENDMETHOD. " strip_params. - FIELD-SYMBOLS LIKE LINE OF ct_params. + METHOD find_param. - READ TABLE ct_params ASSIGNING WITH KEY name = 'version'. + FIELD-SYMBOLS LIKE LINE OF it_params. + READ TABLE it_params ASSIGNING WITH KEY name = iv_name. IF sy-subrc > 0. - lcx_exception=>raise( |W3xx: Cannot find version for { ms_key-objid }| ). + lcx_exception=>raise( |W3xx: Cannot find { iv_name } for { ms_key-objid }| ). ENDIF. - " Clear version - CLEAR -value. + rv_value = -value. - ENDMETHOD. " clear_version. + ENDMETHOD. " find_param. METHOD lif_object~compare_to_remote_version. CREATE OBJECT ro_comparison_result TYPE lcl_null_comparison_result. diff --git a/src/zabapgit_object_wdyn.prog.abap b/src/zabapgit_object_wdyn.prog.abap index 41e34d645..9f2152da2 100644 --- a/src/zabapgit_object_wdyn.prog.abap +++ b/src/zabapgit_object_wdyn.prog.abap @@ -7,117 +7,129 @@ *----------------------------------------------------------------------* * *----------------------------------------------------------------------* -CLASS lcl_object_wdyn DEFINITION INHERITING FROM lcl_objects_super FINAL. +class lcl_object_wdyn definition inheriting from lcl_objects_super final. - PUBLIC SECTION. - INTERFACES lif_object. - ALIASES mo_files FOR lif_object~mo_files. + public section. + interfaces lif_object. + aliases mo_files for lif_object~mo_files. - PRIVATE SECTION. + private section. - DATA: - mt_components TYPE TABLE OF wdy_ctlr_compo_vrs, - mt_sources TYPE TABLE OF wdy_ctlr_compo_source_vrs. + data: + mt_components type table of wdy_ctlr_compo_vrs, + mt_sources type table of wdy_ctlr_compo_source_vrs. - METHODS: + methods: get_limu_objects - RETURNING VALUE(rt_objects) TYPE wdy_md_transport_keys, + returning value(rt_objects) type wdy_md_transport_keys, read - RETURNING VALUE(rs_component) TYPE wdy_component_metadata - RAISING lcx_exception, + returning value(rs_component) type wdy_component_metadata + raising lcx_exception, read_controller - IMPORTING is_key TYPE wdy_md_controller_key - RETURNING VALUE(rs_controller) TYPE wdy_md_controller_meta_data - RAISING lcx_exception, + importing is_key type wdy_md_controller_key + returning value(rs_controller) type wdy_md_controller_meta_data + raising lcx_exception, read_definition - IMPORTING is_key TYPE wdy_md_component_key - RETURNING VALUE(rs_definition) TYPE wdy_md_component_meta_data - RAISING lcx_exception, + importing is_key type wdy_md_component_key + returning value(rs_definition) type wdy_md_component_meta_data + raising lcx_exception, read_view - IMPORTING is_key TYPE wdy_md_view_key - RETURNING VALUE(rs_view) TYPE wdy_md_view_meta_data - RAISING lcx_exception, + importing is_key type wdy_md_view_key + returning value(rs_view) type wdy_md_view_meta_data + raising lcx_exception, recover_controller - IMPORTING is_controller TYPE wdy_md_controller_meta_data - RAISING lcx_exception, + importing is_controller type wdy_md_controller_meta_data + raising lcx_exception, recover_definition - IMPORTING is_definition TYPE wdy_md_component_meta_data - RAISING lcx_exception, + importing is_definition type wdy_md_component_meta_data + raising lcx_exception, recover_view - IMPORTING is_view TYPE wdy_md_view_meta_data - RAISING lcx_exception, + importing is_view type wdy_md_view_meta_data + raising lcx_exception, delta_controller - IMPORTING is_controller TYPE wdy_md_controller_meta_data - RETURNING VALUE(rs_delta) TYPE svrs2_xversionable_object - RAISING lcx_exception, + importing is_controller type wdy_md_controller_meta_data + returning value(rs_delta) type svrs2_xversionable_object + raising lcx_exception, delta_definition - IMPORTING is_definition TYPE wdy_md_component_meta_data - RETURNING VALUE(rs_delta) TYPE svrs2_xversionable_object - RAISING lcx_exception, + importing is_definition type wdy_md_component_meta_data + returning value(rs_delta) type svrs2_xversionable_object + raising lcx_exception, delta_view - IMPORTING is_view TYPE wdy_md_view_meta_data - RETURNING VALUE(rs_delta) TYPE svrs2_xversionable_object - RAISING lcx_exception. + importing is_view type wdy_md_view_meta_data + returning value(rs_delta) type svrs2_xversionable_object + raising lcx_exception, + add_fm_param_exporting + importing i_name type string + i_value type any + changing ct_param type abap_func_parmbind_tab, + add_fm_param_tables + importing i_name type string + changing ct_value type any table + ct_param type abap_func_parmbind_tab, + add_fm_exception + importing i_name type string + i_value type i + changing ct_exception type abap_func_excpbind_tab. -ENDCLASS. "lcl_object_wdyn DEFINITION +endclass. "lcl_object_wdyn DEFINITION *----------------------------------------------------------------------* * CLASS lcl_object_wdyn IMPLEMENTATION *----------------------------------------------------------------------* * *----------------------------------------------------------------------* -CLASS lcl_object_wdyn IMPLEMENTATION. +class lcl_object_wdyn implementation. - METHOD lif_object~has_changed_since. + method lif_object~has_changed_since. rv_changed = abap_true. - ENDMETHOD. "lif_object~has_changed_since + endmethod. "lif_object~has_changed_since - METHOD lif_object~changed_by. + method lif_object~changed_by. rv_user = c_user_unknown. " todo - ENDMETHOD. + endmethod. "lif_object~changed_by - METHOD lif_object~get_metadata. + method lif_object~get_metadata. rs_metadata = get_metadata( ). - ENDMETHOD. "lif_object~get_metadata + endmethod. "lif_object~get_metadata - METHOD lif_object~exists. + method lif_object~exists. - DATA: lv_component_name TYPE wdy_component-component_name. + data: lv_component_name type wdy_component-component_name. - SELECT SINGLE component_name FROM wdy_component - INTO lv_component_name - WHERE component_name = ms_item-obj_name - AND version = 'A'. "#EC CI_GENBUFF + select single component_name from wdy_component + into lv_component_name + where component_name = ms_item-obj_name + and version = 'A'. "#EC CI_GENBUFF rv_bool = boolc( sy-subrc = 0 ). - ENDMETHOD. "lif_object~exists + endmethod. "lif_object~exists - METHOD delta_definition. + method delta_definition. - DATA: ls_key TYPE wdy_md_component_key, - lv_found TYPE abap_bool, - ls_obj_new TYPE svrs2_versionable_object, - li_component TYPE REF TO if_wdy_md_component, - ls_obj_old TYPE svrs2_versionable_object. + data: ls_key type wdy_md_component_key, + lv_found type abap_bool, + ls_obj_new type svrs2_versionable_object, + li_component type ref to if_wdy_md_component, + ls_obj_old type svrs2_versionable_object. ls_key-component_name = is_definition-definition-component_name. lv_found = cl_wdy_md_component=>check_existency( ls_key-component_name ). - IF lv_found = abap_false. - TRY. + if lv_found = abap_false. + try. cl_wdy_md_component=>create_complete( - EXPORTING + exporting name = ls_key-component_name - IMPORTING + importing component = li_component ). li_component->save_to_database( ). li_component->unlock( ). - CATCH cx_wdy_md_exception. + catch cx_wdy_md_exception. lcx_exception=>raise( 'error creating dummy component' ). - ENDTRY. - ENDIF. + endtry. + endif. ls_obj_new-objtype = wdyn_limu_component_definition. ls_obj_new-objname = ls_key-component_name. @@ -125,7 +137,7 @@ CLASS lcl_object_wdyn IMPLEMENTATION. ls_obj_old-objtype = wdyn_limu_component_definition. ls_obj_old-objname = ls_key-component_name. - APPEND is_definition-definition TO ls_obj_old-wdyd-defin. + append is_definition-definition to ls_obj_old-wdyd-defin. ls_obj_old-wdyd-descr = is_definition-descriptions. ls_obj_old-wdyd-cusag = is_definition-component_usages. ls_obj_old-wdyd-intrf = is_definition-interface_implementings. @@ -133,30 +145,34 @@ CLASS lcl_object_wdyn IMPLEMENTATION. ls_obj_old-wdyd-ctuse = is_definition-ext_ctlr_usages. ls_obj_old-wdyd-ctmap = is_definition-ext_ctx_mappings. - CALL FUNCTION 'SVRS_MAKE_OBJECT_DELTA' - EXPORTING + call function 'SVRS_MAKE_OBJECT_DELTA' + exporting obj_old = ls_obj_new obj_new = ls_obj_old - CHANGING + changing delta = rs_delta - EXCEPTIONS + exceptions inconsistent_objects = 1. - IF sy-subrc <> 0. + if sy-subrc <> 0. lcx_exception=>raise( 'error from SVRS_MAKE_OBJECT_DELTA' ). - ENDIF. + endif. - ENDMETHOD. "delta_definition + endmethod. "delta_definition - METHOD delta_controller. + method delta_controller. - DATA: li_controller TYPE REF TO if_wdy_md_controller, - lv_found TYPE abap_bool, - ls_key TYPE wdy_md_controller_key, - ls_obj_new TYPE svrs2_versionable_object, - ls_obj_old TYPE svrs2_versionable_object. + data: li_controller type ref to if_wdy_md_controller, + lv_found type abap_bool, + ls_key type wdy_md_controller_key, + ls_obj_new type svrs2_versionable_object, + ls_obj_old type svrs2_versionable_object. - FIELD-SYMBOLS: LIKE LINE OF mt_components, - LIKE LINE OF mt_sources. + field-symbols: like line of mt_components, + like line of mt_sources, + type any table, + type any table, + type any table, + type any table. ls_key-component_name = is_controller-definition-component_name. @@ -165,18 +181,18 @@ CLASS lcl_object_wdyn IMPLEMENTATION. lv_found = cl_wdy_md_controller=>check_existency( component_name = ls_key-component_name controller_name = ls_key-controller_name ). - IF lv_found = abap_false. - TRY. + if lv_found = abap_false. + try. li_controller ?= cl_wdy_md_controller=>create_complete( component_name = ls_key-component_name controller_name = ls_key-controller_name controller_type = is_controller-definition-controller_type ). li_controller->save_to_database( ). li_controller->unlock( ). - CATCH cx_wdy_md_exception. + catch cx_wdy_md_exception. lcx_exception=>raise( 'error creating dummy controller' ). - ENDTRY. - ENDIF. + endtry. + endif. ls_obj_new-objtype = wdyn_limu_component_controller. ls_obj_new-objname = ls_key. @@ -184,18 +200,18 @@ CLASS lcl_object_wdyn IMPLEMENTATION. ls_obj_old-objtype = wdyn_limu_component_controller. ls_obj_old-objname = ls_key. - APPEND is_controller-definition TO ls_obj_old-wdyc-defin. + append is_controller-definition to ls_obj_old-wdyc-defin. - LOOP AT mt_components ASSIGNING - WHERE component_name = ls_key-component_name - AND controller_name = ls_key-controller_name. - APPEND TO ls_obj_old-wdyc-ccomp. - ENDLOOP. - LOOP AT mt_sources ASSIGNING - WHERE component_name = ls_key-component_name - AND controller_name = ls_key-controller_name. - APPEND TO ls_obj_old-wdyc-ccoms. - ENDLOOP. + loop at mt_components assigning + where component_name = ls_key-component_name + and controller_name = ls_key-controller_name. + append to ls_obj_old-wdyc-ccomp. + endloop. + loop at mt_sources assigning + where component_name = ls_key-component_name + and controller_name = ls_key-controller_name. + append to ls_obj_old-wdyc-ccoms. + endloop. ls_obj_old-wdyc-descr = is_controller-descriptions. ls_obj_old-wdyc-cusag = is_controller-controller_usages. @@ -205,33 +221,47 @@ CLASS lcl_object_wdyn IMPLEMENTATION. ls_obj_old-wdyc-cnode = is_controller-context_nodes. ls_obj_old-wdyc-cattr = is_controller-context_attributes. ls_obj_old-wdyc-cmapp = is_controller-context_mappings. - ls_obj_old-wdyc-excp = is_controller-controller_exceptions. - ls_obj_old-wdyc-excpt = is_controller-controller_exception_texts. +* Version 702 doesn't have these two attributes so we +* use them dynamically for downward compatibility + assign component 'CONTROLLER_EXCEPTIONS' of structure is_controller to . + if sy-subrc = 0. + assign component 'EXCP' of structure ls_obj_old-wdyc to . + if sy-subrc = 0. + = . + endif. + endif. + assign component 'CONTROLLER_EXCEPTIONS_TEXTS' of structure is_controller to . + if sy-subrc = 0. + assign component 'EXCPT' of structure ls_obj_old-wdyc to . + if sy-subrc = 0. + = . + endif. + endif. ls_obj_old-wdyc-fgrps = is_controller-fieldgroups. - CALL FUNCTION 'SVRS_MAKE_OBJECT_DELTA' - EXPORTING + call function 'SVRS_MAKE_OBJECT_DELTA' + exporting obj_old = ls_obj_new obj_new = ls_obj_old - CHANGING + changing delta = rs_delta - EXCEPTIONS + exceptions inconsistent_objects = 1. - IF sy-subrc <> 0. + if sy-subrc <> 0. lcx_exception=>raise( 'error from SVRS_MAKE_OBJECT_DELTA' ). - ENDIF. + endif. - ENDMETHOD. "delta_controller + endmethod. "delta_controller - METHOD delta_view. + method delta_view. - DATA: ls_key TYPE wdy_md_view_key, - ls_obj_new TYPE svrs2_versionable_object, - ls_obj_old TYPE svrs2_versionable_object, - lv_found TYPE abap_bool, - li_view TYPE REF TO if_wdy_md_abstract_view. + data: ls_key type wdy_md_view_key, + ls_obj_new type svrs2_versionable_object, + ls_obj_old type svrs2_versionable_object, + lv_found type abap_bool, + li_view type ref to if_wdy_md_abstract_view. - FIELD-SYMBOLS: LIKE LINE OF ls_obj_old-wdyv-defin. + field-symbols: like line of ls_obj_old-wdyv-defin. ls_key-component_name = is_view-definition-component_name. @@ -240,18 +270,18 @@ CLASS lcl_object_wdyn IMPLEMENTATION. lv_found = cl_wdy_md_abstract_view=>check_existency( component_name = ls_key-component_name name = ls_key-view_name ). - IF lv_found = abap_false. - TRY. + if lv_found = abap_false. + try. li_view = cl_wdy_md_abstract_view=>create( component_name = is_view-definition-component_name view_name = is_view-definition-view_name type = is_view-definition-type ). li_view->save_to_database( ). li_view->unlock( ). - CATCH cx_wdy_md_exception. + catch cx_wdy_md_exception. lcx_exception=>raise( 'error creating dummy view' ). - ENDTRY. - ENDIF. + endtry. + endif. ls_obj_new-objtype = wdyn_limu_component_view. ls_obj_new-objname = ls_key. @@ -259,8 +289,8 @@ CLASS lcl_object_wdyn IMPLEMENTATION. ls_obj_old-objtype = wdyn_limu_component_view. ls_obj_old-objname = ls_key. - APPEND INITIAL LINE TO ls_obj_old-wdyv-defin ASSIGNING . - MOVE-CORRESPONDING is_view-definition TO . + append initial line to ls_obj_old-wdyv-defin assigning . + move-corresponding is_view-definition to . ls_obj_old-wdyv-descr = is_view-descriptions. ls_obj_old-wdyv-vcont = is_view-view_containers. @@ -280,44 +310,44 @@ CLASS lcl_object_wdyn IMPLEMENTATION. ls_obj_old-wdyv-vshpl = is_view-vsh_placeholders. ls_obj_old-wdyv-views = is_view-viewset_properties. - CALL FUNCTION 'SVRS_MAKE_OBJECT_DELTA' - EXPORTING + call function 'SVRS_MAKE_OBJECT_DELTA' + exporting obj_old = ls_obj_new obj_new = ls_obj_old - CHANGING + changing delta = rs_delta - EXCEPTIONS + exceptions inconsistent_objects = 1. - IF sy-subrc <> 0. + if sy-subrc <> 0. lcx_exception=>raise( 'error from SVRS_MAKE_OBJECT_DELTA' ). - ENDIF. + endif. - ENDMETHOD. "delta_view + endmethod. "delta_view - METHOD recover_definition. + method recover_definition. - DATA: ls_key TYPE wdy_md_component_key, - lv_corrnr TYPE trkorr, - ls_delta TYPE svrs2_xversionable_object. + data: ls_key type wdy_md_component_key, + lv_corrnr type trkorr, + ls_delta type svrs2_xversionable_object. ls_delta = delta_definition( is_definition ). ls_key-component_name = is_definition-definition-component_name. cl_wdy_md_component=>recover_version( - EXPORTING + exporting component_key = ls_key delta = ls_delta-wdyd - CHANGING + changing corrnr = lv_corrnr ). - ENDMETHOD. "recover_definition + endmethod. "recover_definition - METHOD recover_controller. + method recover_controller. - DATA: ls_key TYPE wdy_controller_key, - lv_corrnr TYPE trkorr, - ls_delta TYPE svrs2_xversionable_object. + data: ls_key type wdy_controller_key, + lv_corrnr type trkorr, + ls_delta type svrs2_xversionable_object. ls_delta = delta_controller( is_controller ). @@ -325,19 +355,19 @@ CLASS lcl_object_wdyn IMPLEMENTATION. ls_key-controller_name = is_controller-definition-controller_name. cl_wdy_md_controller=>recover_version( - EXPORTING + exporting controller_key = ls_key delta = ls_delta-wdyc - CHANGING + changing corrnr = lv_corrnr ). - ENDMETHOD. "recover_controller + endmethod. "recover_controller - METHOD recover_view. + method recover_view. - DATA: ls_key TYPE wdy_md_view_key, - lv_corrnr TYPE trkorr, - ls_delta TYPE svrs2_xversionable_object. + data: ls_key type wdy_md_view_key, + lv_corrnr type trkorr, + ls_delta type svrs2_xversionable_object. ls_delta = delta_view( is_view ). @@ -345,78 +375,137 @@ CLASS lcl_object_wdyn IMPLEMENTATION. ls_key-view_name = is_view-definition-view_name. cl_wdy_md_abstract_view=>recover_version( - EXPORTING + exporting view_key = ls_key delta = ls_delta-wdyv - CHANGING + changing corrnr = lv_corrnr ). - ENDMETHOD. "recover_view + endmethod. "recover_view - METHOD read_controller. + method read_controller. - DATA: lt_components TYPE TABLE OF wdy_ctlr_compo_vrs, - lt_sources TYPE TABLE OF wdy_ctlr_compo_source_vrs, - lt_definition TYPE TABLE OF wdy_controller, - lt_psmodilog TYPE TABLE OF smodilog, - lt_psmodisrc TYPE TABLE OF smodisrc. + data: lt_components type table of wdy_ctlr_compo_vrs, + lt_sources type table of wdy_ctlr_compo_source_vrs, + lt_definition type table of wdy_controller, + lt_psmodilog type table of smodilog, + lt_psmodisrc type table of smodisrc, + lt_fm_param type abap_func_parmbind_tab, + lt_fm_exception type abap_func_excpbind_tab. + field-symbols: type any table, + type any table. - CALL FUNCTION 'WDYC_GET_OBJECT' - EXPORTING - controller_key = is_key - get_all_translations = abap_false - TABLES - definition = lt_definition - descriptions = rs_controller-descriptions - controller_usages = rs_controller-controller_usages - controller_components = lt_components - controller_component_sources = lt_sources - controller_component_texts = rs_controller-controller_component_texts - controller_parameters = rs_controller-controller_parameters - controller_parameter_texts = rs_controller-controller_parameter_texts - context_nodes = rs_controller-context_nodes - context_attributes = rs_controller-context_attributes - context_mappings = rs_controller-context_mappings - fieldgroups = rs_controller-fieldgroups - controller_exceptions = rs_controller-controller_exceptions - controller_exception_texts = rs_controller-controller_exception_texts - psmodilog = lt_psmodilog " not optional in all versions - psmodisrc = lt_psmodisrc " not optional in all versions - EXCEPTIONS - not_existing = 1 - OTHERS = 2. - IF sy-subrc <> 0. +* Calling FM dynamically because version 702 has less parameters + +* FM parameters + add_fm_param_exporting( exporting i_name = 'CONTROLLER_KEY' + i_value = is_key + changing ct_param = lt_fm_param ). + add_fm_param_exporting( exporting i_name = 'GET_ALL_TRANSLATIONS' + i_value = abap_false + changing ct_param = lt_fm_param ). + add_fm_param_tables( exporting i_name = 'DEFINITION' + changing ct_value = lt_definition + ct_param = lt_fm_param ). + add_fm_param_tables( exporting i_name = 'DESCRIPTIONS' + changing ct_value = rs_controller-descriptions + ct_param = lt_fm_param ). + add_fm_param_tables( exporting i_name = 'CONTROLLER_USAGES' + changing ct_value = rs_controller-controller_usages + ct_param = lt_fm_param ). + add_fm_param_tables( exporting i_name = 'CONTROLLER_COMPONENTS' + changing ct_value = lt_components + ct_param = lt_fm_param ). + add_fm_param_tables( exporting i_name = 'CONTROLLER_COMPONENT_SOURCES' + changing ct_value = lt_sources + ct_param = lt_fm_param ). + add_fm_param_tables( exporting i_name = 'CONTROLLER_COMPONENT_TEXTS' + changing ct_value = rs_controller-controller_component_texts + ct_param = lt_fm_param ). + add_fm_param_tables( exporting i_name = 'CONTROLLER_PARAMETERS' + changing ct_value = rs_controller-controller_parameters + ct_param = lt_fm_param ). + add_fm_param_tables( exporting i_name = 'CONTROLLER_PARAMETER_TEXTS' + changing ct_value = rs_controller-controller_parameter_texts + ct_param = lt_fm_param ). + add_fm_param_tables( exporting i_name = 'CONTEXT_NODES' + changing ct_value = rs_controller-context_nodes + ct_param = lt_fm_param ). + add_fm_param_tables( exporting i_name = 'CONTEXT_ATTRIBUTES' + changing ct_value = rs_controller-context_attributes + ct_param = lt_fm_param ). + add_fm_param_tables( exporting i_name = 'CONTEXT_MAPPINGS' + changing ct_value = rs_controller-context_mappings + ct_param = lt_fm_param ). + add_fm_param_tables( exporting i_name = 'FIELDGROUPS' + changing ct_value = rs_controller-fieldgroups + ct_param = lt_fm_param ). +* Version 702 doesn't have these two attributes so we +* use them dynamically for downward compatibility + assign component 'CONTROLLER_EXCEPTIONS' of structure rs_controller to . + if sy-subrc = 0. + add_fm_param_tables( exporting i_name = 'CONTROLLER_EXCEPTIONS' + changing ct_value = + ct_param = lt_fm_param ). + endif. + assign component 'CONTROLLER_EXCEPTION_TEXTS' of structure rs_controller to . + if sy-subrc = 0. + add_fm_param_tables( exporting i_name = 'CONTROLLER_EXCEPTION_TEXTS' + changing ct_value = + ct_param = lt_fm_param ). + endif. + add_fm_param_tables( exporting i_name = 'PSMODILOG' + changing ct_value = lt_psmodilog + ct_param = lt_fm_param ). + add_fm_param_tables( exporting i_name = 'PSMODISRC' + changing ct_value = lt_psmodisrc + ct_param = lt_fm_param ). + +* FM exceptions + add_fm_exception( exporting i_name = 'NOT_EXISTING' + i_value = 1 + changing ct_exception = lt_fm_exception ). + add_fm_exception( exporting i_name = 'OTHERS' + i_value = 2 + changing ct_exception = lt_fm_exception ). + + call function 'WDYC_GET_OBJECT' + parameter-table + lt_fm_param + exception-table + lt_fm_exception. + if sy-subrc <> 0. lcx_exception=>raise( 'error from WDYC_GET_OBJECT' ). - ENDIF. + endif. - APPEND LINES OF lt_components TO mt_components. - APPEND LINES OF lt_sources TO mt_sources. + append lines of lt_components to mt_components. + append lines of lt_sources to mt_sources. - READ TABLE lt_definition INDEX 1 INTO rs_controller-definition. - IF sy-subrc <> 0. + read table lt_definition index 1 into rs_controller-definition. + if sy-subrc <> 0. lcx_exception=>raise( 'WDYC, definition not found' ). - ENDIF. + endif. - CLEAR: rs_controller-definition-author, + clear: rs_controller-definition-author, rs_controller-definition-createdon, rs_controller-definition-changedby, rs_controller-definition-changedon. - ENDMETHOD. "read_controller + endmethod. "read_controller - METHOD read_definition. + method read_definition. - DATA: lt_definition TYPE TABLE OF wdy_component, - lt_psmodilog TYPE TABLE OF smodilog, - lt_psmodisrc TYPE TABLE OF smodisrc. + data: lt_definition type table of wdy_component, + lt_psmodilog type table of smodilog, + lt_psmodisrc type table of smodisrc. - CALL FUNCTION 'WDYD_GET_OBJECT' - EXPORTING + call function 'WDYD_GET_OBJECT' + exporting component_key = is_key get_all_translations = abap_false - TABLES + tables definition = lt_definition descriptions = rs_definition-descriptions component_usages = rs_definition-component_usages @@ -426,43 +515,43 @@ CLASS lcl_object_wdyn IMPLEMENTATION. ext_ctx_mappings = rs_definition-ext_ctx_mappings psmodilog = lt_psmodilog " not optional in all versions psmodisrc = lt_psmodisrc " not optional in all versions - EXCEPTIONS + exceptions not_existing = 1 - OTHERS = 2. - IF sy-subrc = 1. - RETURN. - ELSEIF sy-subrc <> 0. + others = 2. + if sy-subrc = 1. + return. + elseif sy-subrc <> 0. lcx_exception=>raise( 'error from WDYD_GET_OBJECT' ). - ENDIF. + endif. - READ TABLE lt_definition INDEX 1 INTO rs_definition-definition. - IF sy-subrc <> 0. + read table lt_definition index 1 into rs_definition-definition. + if sy-subrc <> 0. lcx_exception=>raise( 'WDYD, definition not found' ). - ENDIF. + endif. - CLEAR: rs_definition-definition-author, + clear: rs_definition-definition-author, rs_definition-definition-createdon, rs_definition-definition-changedby, rs_definition-definition-changedon, rs_definition-definition-gendate, rs_definition-definition-gentime. - ENDMETHOD. "read_definition + endmethod. "read_definition - METHOD read_view. + method read_view. - DATA: lt_definition TYPE TABLE OF wdy_view_vrs, - lt_psmodilog TYPE TABLE OF smodilog, - lt_psmodisrc TYPE TABLE OF smodisrc. + data: lt_definition type table of wdy_view_vrs, + lt_psmodilog type table of smodilog, + lt_psmodisrc type table of smodisrc. - FIELD-SYMBOLS: LIKE LINE OF lt_definition. + field-symbols: like line of lt_definition. - CALL FUNCTION 'WDYV_GET_OBJECT' - EXPORTING + call function 'WDYV_GET_OBJECT' + exporting view_key = is_key get_all_translations = abap_false - TABLES + tables definition = lt_definition descriptions = rs_view-descriptions view_containers = rs_view-view_containers @@ -483,104 +572,149 @@ CLASS lcl_object_wdyn IMPLEMENTATION. viewset_properties = rs_view-viewset_properties psmodilog = lt_psmodilog psmodisrc = lt_psmodisrc - EXCEPTIONS + exceptions not_existing = 1 - OTHERS = 2. - IF sy-subrc <> 0. + others = 2. + if sy-subrc <> 0. lcx_exception=>raise( 'error from WDYV_GET_OBJECT' ). - ENDIF. + endif. - READ TABLE lt_definition INDEX 1 ASSIGNING . - ASSERT sy-subrc = 0. - MOVE-CORRESPONDING TO rs_view-definition. + read table lt_definition index 1 assigning . + assert sy-subrc = 0. + move-corresponding to rs_view-definition. - CLEAR: rs_view-definition-author, + clear: rs_view-definition-author, rs_view-definition-createdon, rs_view-definition-changedby, rs_view-definition-changedon. - ENDMETHOD. "read_view + endmethod. "read_view - METHOD get_limu_objects. + method get_limu_objects. - DATA: lv_name TYPE wdy_component_name. + data: lv_name type wdy_component_name. lv_name = ms_item-obj_name. - CALL FUNCTION 'WDYN_GET_LIMU_OBJECTS' - EXPORTING + call function 'WDYN_GET_LIMU_OBJECTS' + exporting component_name = lv_name - IMPORTING + importing limu_objects = rt_objects. - ENDMETHOD. "get_limu_objects + endmethod. "get_limu_objects - METHOD read. + method read. - DATA: lt_objects TYPE wdy_md_transport_keys, - ls_controller_key TYPE wdy_md_controller_key, - ls_component_key TYPE wdy_md_component_key, - ls_view_key TYPE wdy_md_view_key. + data: lt_objects type wdy_md_transport_keys, + ls_controller_key type wdy_md_controller_key, + ls_component_key type wdy_md_component_key, + ls_view_key type wdy_md_view_key. - FIELD-SYMBOLS: LIKE LINE OF lt_objects, - LIKE LINE OF rs_component-ctlr_metadata. + field-symbols: like line of lt_objects, + like line of rs_component-ctlr_metadata, + type any table, + type any table. - CLEAR mt_components. - CLEAR mt_sources. + clear mt_components. + clear mt_sources. lt_objects = get_limu_objects( ). - LOOP AT lt_objects ASSIGNING . - CASE -sub_type. - WHEN wdyn_limu_component_controller. + loop at lt_objects assigning . + case -sub_type. + when wdyn_limu_component_controller. ls_controller_key = -sub_name. - APPEND read_controller( ls_controller_key ) TO rs_component-ctlr_metadata. - WHEN wdyn_limu_component_definition. + append read_controller( ls_controller_key ) to rs_component-ctlr_metadata. + when wdyn_limu_component_definition. ls_component_key = -sub_name. rs_component-comp_metadata = read_definition( ls_component_key ). - WHEN wdyn_limu_component_view. + when wdyn_limu_component_view. ls_view_key = -sub_name. - APPEND read_view( ls_view_key ) TO rs_component-view_metadata. - WHEN OTHERS. - ASSERT 0 = 1. - ENDCASE. - ENDLOOP. + append read_view( ls_view_key ) to rs_component-view_metadata. + when others. + assert 0 = 1. + endcase. + endloop. - SORT rs_component-ctlr_metadata BY - definition-component_name ASCENDING - definition-controller_name ASCENDING. + sort rs_component-ctlr_metadata by + definition-component_name ascending + definition-controller_name ascending. - LOOP AT rs_component-ctlr_metadata ASSIGNING . - SORT -descriptions. - SORT -controller_usages. - SORT -controller_components. - SORT -controller_component_texts. - SORT -controller_parameters. - SORT -controller_parameter_texts. - SORT -context_nodes. - SORT -context_attributes. - SORT -context_mappings. - SORT -fieldgroups. - SORT -controller_exceptions. - SORT -controller_exception_texts. - ENDLOOP. + loop at rs_component-ctlr_metadata assigning . + sort -descriptions. + sort -controller_usages. + sort -controller_components. + sort -controller_component_texts. + sort -controller_parameters. + sort -controller_parameter_texts. + sort -context_nodes. + sort -context_attributes. + sort -context_mappings. + sort -fieldgroups. +* Version 702 doesn't have these two attributes so we +* use them dynamically for downward compatibility + assign component 'CONTROLLER_EXCEPTIONS' of structure to . + if sy-subrc = 0. + sort . + endif. + assign component 'CONTROLLER_EXCEPTION_TEXTS' of structure to . + if sy-subrc = 0. + sort . + endif. + endloop. - SORT mt_components BY - component_name ASCENDING - controller_name ASCENDING - cmpname ASCENDING. + sort mt_components by + component_name ascending + controller_name ascending + cmpname ascending. - SORT mt_sources BY - component_name ASCENDING - controller_name ASCENDING - cmpname ASCENDING - line_number ASCENDING. + sort mt_sources by + component_name ascending + controller_name ascending + cmpname ascending + line_number ascending. - ENDMETHOD. "read + endmethod. "read - METHOD lif_object~serialize. + method add_fm_param_exporting. - DATA: ls_component TYPE wdy_component_metadata. + data: ls_param like line of ct_param. + + ls_param-kind = abap_func_exporting. + ls_param-name = i_name. + get reference of i_value into ls_param-value. + + insert ls_param into table ct_param. + + endmethod. "add_fm_param_exporting + + method add_fm_param_tables. + + data: ls_param like line of ct_param. + + ls_param-kind = abap_func_tables. + ls_param-name = i_name. + get reference of ct_value into ls_param-value. + + insert ls_param into table ct_param. + + endmethod. "add_fm_param_tables + + method add_fm_exception. + + data: ls_exception like line of ct_exception. + + ls_exception-name = i_name. + ls_exception-value = i_value. + + insert ls_exception into table ct_exception. + + endmethod. "add_fm_exception + + method lif_object~serialize. + + data: ls_component type wdy_component_metadata. ls_component = read( ). @@ -592,55 +726,55 @@ CLASS lcl_object_wdyn IMPLEMENTATION. io_xml->add( ig_data = mt_sources iv_name = 'SOURCES' ). - ENDMETHOD. "serialize + endmethod. "serialize - METHOD lif_object~deserialize. + method lif_object~deserialize. - DATA: ls_component TYPE wdy_component_metadata. + data: ls_component type wdy_component_metadata. - FIELD-SYMBOLS: LIKE LINE OF ls_component-view_metadata, - LIKE LINE OF ls_component-ctlr_metadata. + field-symbols: like line of ls_component-view_metadata, + like line of ls_component-ctlr_metadata. - io_xml->read( EXPORTING iv_name = 'COMPONENT' - CHANGING cg_data = ls_component ). - io_xml->read( EXPORTING iv_name = 'COMPONENTS' - CHANGING cg_data = mt_components ). - io_xml->read( EXPORTING iv_name = 'SOURCES' - CHANGING cg_data = mt_sources ). + io_xml->read( exporting iv_name = 'COMPONENT' + changing cg_data = ls_component ). + io_xml->read( exporting iv_name = 'COMPONENTS' + changing cg_data = mt_components ). + io_xml->read( exporting iv_name = 'SOURCES' + changing cg_data = mt_sources ). ls_component-comp_metadata-definition-author = sy-uname. ls_component-comp_metadata-definition-createdon = sy-datum. recover_definition( ls_component-comp_metadata ). - LOOP AT ls_component-ctlr_metadata ASSIGNING . + loop at ls_component-ctlr_metadata assigning . -definition-author = sy-uname. -definition-createdon = sy-datum. recover_controller( ). - ENDLOOP. - LOOP AT ls_component-view_metadata ASSIGNING . + endloop. + loop at ls_component-view_metadata assigning . -definition-author = sy-uname. -definition-createdon = sy-datum. recover_view( ). - ENDLOOP. + endloop. lcl_objects_activation=>add_item( ms_item ). - ENDMETHOD. "deserialize + endmethod. "deserialize - METHOD lif_object~delete. + method lif_object~delete. - DATA: lo_component TYPE REF TO cl_wdy_wb_component, - lo_request TYPE REF TO cl_wb_request, - li_state TYPE REF TO if_wb_program_state, - lv_object_name TYPE seu_objkey. + data: lo_component type ref to cl_wdy_wb_component, + lo_request type ref to cl_wb_request, + li_state type ref to if_wb_program_state, + lv_object_name type seu_objkey. - CREATE OBJECT lo_component. + create object lo_component. lv_object_name = ms_item-obj_name. - CREATE OBJECT lo_request - EXPORTING + create object lo_request + exporting p_object_type = 'YC' p_object_name = lv_object_name p_operation = swbm_c_op_delete_no_dialog. @@ -649,21 +783,21 @@ CLASS lcl_object_wdyn IMPLEMENTATION. p_wb_request = lo_request p_wb_program_state = li_state ). - ENDMETHOD. "delete + endmethod. "delete - METHOD lif_object~jump. + method lif_object~jump. - CALL FUNCTION 'RS_TOOL_ACCESS' - EXPORTING + call function 'RS_TOOL_ACCESS' + exporting operation = 'SHOW' object_name = ms_item-obj_name object_type = ms_item-obj_type in_new_window = abap_true. - ENDMETHOD. "jump + endmethod. "jump - METHOD lif_object~compare_to_remote_version. - CREATE OBJECT ro_comparison_result TYPE lcl_null_comparison_result. - ENDMETHOD. + method lif_object~compare_to_remote_version. + create object ro_comparison_result type lcl_null_comparison_result. + endmethod. "lif_object~compare_to_remote_version -ENDCLASS. "lcl_object_wdyn IMPLEMENTATION \ No newline at end of file +endclass. "lcl_object_wdyn IMPLEMENTATION \ No newline at end of file diff --git a/src/zabapgit_objects.prog.abap b/src/zabapgit_objects.prog.abap index 30887800b..de9c64f8b 100644 --- a/src/zabapgit_objects.prog.abap +++ b/src/zabapgit_objects.prog.abap @@ -768,7 +768,7 @@ CLASS lcl_objects_bridge IMPLEMENTATION. * No exception in class-contructor possible. * Anyway, a shortdump is more appropriate in this case ASSERT 'There must not be' = - |multiple ABAPGit-Plugins for the same object type { + |multiple abapGit-Plugins for the same object type { ls_objtype_map-obj_typ }|. ENDIF. ENDLOOP. diff --git a/src/zabapgit_page_branch_overview.prog.abap b/src/zabapgit_page_branch_overview.prog.abap index 1c820ea70..0873eea5c 100644 --- a/src/zabapgit_page_branch_overview.prog.abap +++ b/src/zabapgit_page_branch_overview.prog.abap @@ -193,7 +193,7 @@ CLASS lcl_branch_overview IMPLEMENTATION. SPLIT ls_raw-body AT gc_newline INTO ls_commit-message lv_trash. * unix time stamps are in same time zone, so ignore the zone, - FIND REGEX '^([\w\s\.@]+) <(.*)> (\d{10}) .\d{4}$' IN ls_raw-author + FIND REGEX gc_author_regex IN ls_raw-author SUBMATCHES ls_commit-author ls_commit-email diff --git a/src/zabapgit_page_diff.prog.abap b/src/zabapgit_page_diff.prog.abap index 0cab80365..79ed392c0 100644 --- a/src/zabapgit_page_diff.prog.abap +++ b/src/zabapgit_page_diff.prog.abap @@ -255,24 +255,21 @@ CLASS lcl_gui_page_diff IMPLEMENTATION. METHOD render_lines. - DATA: lo_highlighter TYPE REF TO lcl_code_highlighter, + DATA: lo_highlighter TYPE REF TO lcl_syntax_highlighter, lt_diffs TYPE lcl_diff=>ty_diffs_tt, lv_local TYPE string, lv_remote TYPE string, lv_lattr TYPE string, lv_rattr TYPE string, - lv_highlight TYPE abap_bool, lv_insert_nav TYPE abap_bool. FIELD-SYMBOLS LIKE LINE OF lt_diffs. - CREATE OBJECT lo_highlighter. + lo_highlighter = lcl_syntax_highlighter=>create( is_diff-filename ). CREATE OBJECT ro_html. lt_diffs = is_diff-o_diff->get( ). - lv_highlight = boolc( is_diff-filename CP '*.abap' ). - LOOP AT lt_diffs ASSIGNING . IF -short = abap_false. lv_insert_nav = abap_true. @@ -292,7 +289,7 @@ CLASS lcl_gui_page_diff IMPLEMENTATION. lv_remote = -old. ENDIF. - IF lv_highlight = abap_true. + IF lo_highlighter IS BOUND. lv_local = lo_highlighter->process_line( lv_local ). lv_remote = lo_highlighter->process_line( lv_remote ). ELSE. diff --git a/src/zabapgit_page_merge.prog.abap b/src/zabapgit_page_merge.prog.abap index df5f4c004..c415d02eb 100644 --- a/src/zabapgit_page_merge.prog.abap +++ b/src/zabapgit_page_merge.prog.abap @@ -283,7 +283,7 @@ CLASS lcl_merge IMPLEMENTATION. -commit = lv_commit. -tree = ls_commit-tree. -body = ls_commit-body. - FIND REGEX '^[\w\s]+ <.*> (\d{10}) .\d{4}$' IN ls_commit-author + FIND REGEX gc_author_regex IN ls_commit-author SUBMATCHES -time ##NO_TEXT. ASSERT sy-subrc = 0. ENDLOOP. diff --git a/src/zabapgit_repo.prog.abap b/src/zabapgit_repo.prog.abap index bc9646648..6d6eb40b5 100644 --- a/src/zabapgit_repo.prog.abap +++ b/src/zabapgit_repo.prog.abap @@ -46,6 +46,8 @@ CLASS lcl_repo DEFINITION ABSTRACT FRIENDS lcl_repo_srv. update_local_checksums IMPORTING it_files TYPE ty_file_signatures_tt RAISING lcx_exception, + rebuild_local_checksums + RAISING lcx_exception, is_offline RETURNING VALUE(rv_offline) TYPE abap_bool RAISING lcx_exception. @@ -118,8 +120,7 @@ CLASS lcl_repo_online DEFINITION INHERITING FROM lcl_repo FINAL. RETURNING VALUE(rt_results) TYPE ty_results_tt RAISING lcx_exception, reset_status, - rebuild_local_checksums - RAISING lcx_exception, + rebuild_local_checksums REDEFINITION, push IMPORTING is_comment TYPE ty_comment io_stage TYPE REF TO lcl_stage diff --git a/src/zabapgit_repo_impl.prog.abap b/src/zabapgit_repo_impl.prog.abap index ed9bc0599..4953a8fa1 100644 --- a/src/zabapgit_repo_impl.prog.abap +++ b/src/zabapgit_repo_impl.prog.abap @@ -243,7 +243,7 @@ CLASS lcl_repo_online IMPLEMENTATION. ENDMETHOD. - METHOD rebuild_local_checksums. + METHOD rebuild_local_checksums. "REMOTE DATA: lt_remote TYPE ty_files_tt, lt_local TYPE ty_files_item_tt, @@ -639,6 +639,40 @@ CLASS lcl_repo IMPLEMENTATION. rv_yes = ms_data-write_protect. ENDMETHOD. "is_write_protected + METHOD rebuild_local_checksums. "LOCAL (BASE) + + DATA: lt_local TYPE ty_files_item_tt, + ls_last_item TYPE ty_item, + lt_checksums TYPE lcl_persistence_repo=>ty_local_checksum_tt. + + FIELD-SYMBOLS: LIKE LINE OF lt_checksums, + LIKE LINE OF -files, + LIKE LINE OF lt_local. + + lt_local = get_files_local( ). + + DELETE lt_local " Remove non-code related files except .abapgit + WHERE item IS INITIAL + AND NOT ( file-path = gc_root_dir AND file-filename = gc_dot_abapgit ). + + SORT lt_local BY item. + + LOOP AT lt_local ASSIGNING . + IF ls_last_item <> -item OR sy-tabix = 1. " First or New item reached ? + APPEND INITIAL LINE TO lt_checksums ASSIGNING . + -item = -item. + ls_last_item = -item. + ENDIF. + + APPEND INITIAL LINE TO -files ASSIGNING . + MOVE-CORRESPONDING -file TO . + + ENDLOOP. + + set( it_checksums = lt_checksums ). + + ENDMETHOD. " rebuild_local_checksums. + ENDCLASS. "lcl_repo IMPLEMENTATION *----------------------------------------------------------------------* diff --git a/src/zabapgit_services_abapgit.prog.abap b/src/zabapgit_services_abapgit.prog.abap index 1b7fb6efa..00e8dd053 100644 --- a/src/zabapgit_services_abapgit.prog.abap +++ b/src/zabapgit_services_abapgit.prog.abap @@ -37,7 +37,7 @@ CLASS lcl_services_abapgit DEFINITION FINAL. iv_text TYPE c iv_url TYPE string iv_package TYPE devclass - RAISING lcx_exception. + RAISING lcx_exception. ENDCLASS. "lcl_services_abapgit @@ -78,7 +78,7 @@ CLASS lcl_services_abapgit IMPLEMENTATION. RETURN. ENDIF. - lv_text = |Confirm to install current version of ABAPGit to package { c_package_abapgit }|. + lv_text = |Confirm to install current version of abapGit to package { c_package_abapgit }|. do_install( iv_title = lc_title iv_text = lv_text @@ -100,7 +100,7 @@ CLASS lcl_services_abapgit IMPLEMENTATION. RETURN. ENDIF. - lv_text = |Confirm to install current version ABAPGit plugins to package { + lv_text = |Confirm to install current version abapGit plugins to package { c_package_plugins }|. do_install( iv_title = lc_title @@ -140,6 +140,7 @@ CLASS lcl_services_abapgit IMPLEMENTATION. lo_repo->status( ). " check for errors lo_repo->deserialize( ). + lcl_services_repo=>toggle_favorite( lo_repo->get_key( ) ). ENDIF. COMMIT WORK. diff --git a/src/zabapgit_services_repo.prog.abap b/src/zabapgit_services_repo.prog.abap index 0a4858a85..2c9863854 100644 --- a/src/zabapgit_services_repo.prog.abap +++ b/src/zabapgit_services_repo.prog.abap @@ -265,16 +265,20 @@ CLASS lcl_services_repo IMPLEMENTATION. DATA: lv_answer TYPE c, lv_question TYPE string, - lo_repo TYPE REF TO lcl_repo_online. + lo_repo TYPE REF TO lcl_repo. lo_repo ?= lcl_app=>repo_srv( )->get( iv_key ). - lv_question = 'This will rebuild and overwrite local repo checksums.' + lv_question = 'This will rebuild and overwrite local repo checksums.'. + + IF lo_repo->is_offline( ) = abap_false. + lv_question = lv_question && ' The logic: if local and remote file differs then:' && ' if remote branch is ahead then assume changes are remote,' && ' else (branches are equal) assume changes are local.' && ' This will lead to incorrect state for files changed on both sides.' && ' Please make sure you don''t have ones like that.'. + ENDIF. lv_answer = lcl_popups=>popup_to_confirm( titlebar = 'Warning' diff --git a/src/zabapgit_syntax_highlighter.prog.abap b/src/zabapgit_syntax_highlighter.prog.abap index 8ccef3149..c80816ab0 100644 --- a/src/zabapgit_syntax_highlighter.prog.abap +++ b/src/zabapgit_syntax_highlighter.prog.abap @@ -1,43 +1,30 @@ *&---------------------------------------------------------------------* *& Include ZABAPGIT_SYNTAX_HIGHLIGHTER *&---------------------------------------------------------------------* -*&---------------------------------------------------------------------* -*& Class lcl_code_highligher -*&---------------------------------------------------------------------* -CLASS ltcl_code_highlighter1 DEFINITION DEFERRED. -CLASS ltcl_code_highlighter2 DEFINITION DEFERRED. +CLASS ltcl_syntax_cases DEFINITION DEFERRED. +CLASS ltcl_syntax_basic_logic DEFINITION DEFERRED. + +CLASS lcl_syntax_abap DEFINITION DEFERRED. +CLASS lcl_syntax_xml DEFINITION DEFERRED. *----------------------------------------------------------------------* -* CLASS lcl_code_highlighter DEFINITION +* CLASS lcl_syntax_highlighter DEFINITION *----------------------------------------------------------------------* -CLASS lcl_code_highlighter DEFINITION FRIENDS ltcl_code_highlighter1 ltcl_code_highlighter2. +CLASS lcl_syntax_highlighter DEFINITION ABSTRACT + FRIENDS ltcl_syntax_cases ltcl_syntax_basic_logic. PUBLIC SECTION. - CLASS-METHODS: - class_constructor. - METHODS: - process_line + CLASS-METHODS create + IMPORTING iv_filename TYPE string + RETURNING VALUE(ro_instance) TYPE REF TO lcl_syntax_highlighter. + + METHODS process_line IMPORTING iv_line TYPE string RETURNING VALUE(rv_line) TYPE string. - PRIVATE SECTION. - CONSTANTS: - BEGIN OF c_token, - keyword TYPE c VALUE 'K', - text TYPE c VALUE 'T', - comment TYPE c VALUE 'C', - none TYPE c VALUE 'N', - END OF c_token. - - CONSTANTS: - BEGIN OF c_css, - keyword TYPE string VALUE 'keyword', - text TYPE string VALUE 'text', - comment TYPE string VALUE 'comment', - none TYPE string VALUE 'none', - END OF c_css. + PROTECTED SECTION. TYPES: BEGIN OF ty_match, @@ -51,73 +38,328 @@ CLASS lcl_code_highlighter DEFINITION FRIENDS ltcl_code_highlighter1 ltcl_code_h ty_match_tt TYPE STANDARD TABLE OF ty_match WITH DEFAULT KEY. TYPES: - BEGIN OF ty_regex, - regex TYPE REF TO cl_abap_regex, - token TYPE char1, - END OF ty_regex. + BEGIN OF ty_rule, + regex TYPE REF TO cl_abap_regex, + token TYPE char1, + style TYPE string, + END OF ty_rule. + + CONSTANTS c_token_none TYPE c VALUE '.'. + + DATA mt_rules TYPE STANDARD TABLE OF ty_rule. + + METHODS parse_line + IMPORTING iv_line TYPE string + EXPORTING et_matches TYPE ty_match_tt. + + METHODS order_matches ABSTRACT + IMPORTING iv_line TYPE string + CHANGING ct_matches TYPE ty_match_tt. + + METHODS extend_matches + IMPORTING iv_line TYPE string + CHANGING ct_matches TYPE ty_match_tt. + + METHODS format_line + IMPORTING iv_line TYPE string + it_matches TYPE ty_match_tt + RETURNING VALUE(rv_line) TYPE string. + + METHODS apply_style + IMPORTING iv_line TYPE string + iv_class TYPE string + RETURNING VALUE(rv_line) TYPE string. + +ENDCLASS. " lcl_syntax_highlighter DEFINITION + +*----------------------------------------------------------------------* +* CLASS lcl_syntax_abap DEFINITION +*----------------------------------------------------------------------* +CLASS lcl_syntax_abap DEFINITION INHERITING FROM lcl_syntax_highlighter FINAL. + + PUBLIC SECTION. + + CLASS-METHODS class_constructor. + METHODS constructor. + + CONSTANTS: + BEGIN OF c_css, + keyword TYPE string VALUE 'keyword', "#EC NOTEXT + text TYPE string VALUE 'text', "#EC NOTEXT + comment TYPE string VALUE 'comment', "#EC NOTEXT + END OF c_css, + + BEGIN OF c_token, + keyword TYPE c VALUE 'K', "#EC NOTEXT + text TYPE c VALUE 'T', "#EC NOTEXT + comment TYPE c VALUE 'C', "#EC NOTEXT + END OF c_token, - CLASS-DATA: BEGIN OF c_regex, - comment TYPE string, - text TYPE string, - keyword TYPE string, + comment TYPE string VALUE '##|"|^\*', + text TYPE string VALUE '`|''|\||\{|\}', + keyword TYPE string VALUE '&&|\b[-_a-z0-9]+\b', END OF c_regex. - CLASS-DATA: mo_regex_table TYPE TABLE OF ty_regex. + PROTECTED SECTION. - METHODS: - parse_line - IMPORTING iv_line TYPE string - RETURNING VALUE(rt_matches) TYPE ty_match_tt. + CLASS-DATA gt_keywords TYPE HASHED TABLE OF string WITH UNIQUE KEY table_line. - METHODS: - order_matches - IMPORTING iv_line TYPE string - CHANGING ct_matches TYPE ty_match_tt. + CLASS-METHODS init_keywords. + CLASS-METHODS is_keyword + IMPORTING iv_chunk TYPE string + RETURNING VALUE(rv_yes) TYPE abap_bool. - METHODS: - format_line - IMPORTING iv_line TYPE string - it_matches TYPE ty_match_tt - RETURNING VALUE(rv_line) TYPE string. + METHODS order_matches REDEFINITION. + METHODS parse_line REDEFINITION. - METHODS: - apply_style - IMPORTING iv_line TYPE string - iv_class TYPE string - RETURNING VALUE(rv_line) TYPE string. - -ENDCLASS. "lcl_code_highlighter DEFINITION +ENDCLASS. " lcl_syntax_abap DEFINITION *----------------------------------------------------------------------* -* Macros +* CLASS lcl_syntax_xml DEFINITION +*----------------------------------------------------------------------* +CLASS lcl_syntax_xml DEFINITION INHERITING FROM lcl_syntax_highlighter FINAL. + + PUBLIC SECTION. + + METHODS constructor. + + CONSTANTS: + BEGIN OF c_css, + xml_tag TYPE string VALUE 'xml_tag', "#EC NOTEXT + attr TYPE string VALUE 'attr', "#EC NOTEXT + attr_val TYPE string VALUE 'attr_val', "#EC NOTEXT + END OF c_css, + + BEGIN OF c_token, + xml_tag TYPE c VALUE 'X', "#EC NOTEXT + attr TYPE c VALUE 'A', "#EC NOTEXT + attr_val TYPE c VALUE 'V', "#EC NOTEXT + END OF c_token, + + BEGIN OF c_regex, + xml_tag TYPE string VALUE '[<>]', "#EC NOTEXT + attr TYPE string VALUE '\s[-a-z:_0-9]+\s*(?==)', "#EC NOTEXT + attr_val TYPE string VALUE '["''][^''"]+[''"]', "#EC NOTEXT + END OF c_regex. + + PROTECTED SECTION. + + METHODS order_matches REDEFINITION. + +ENDCLASS. " lcl_syntax_xml DEFINITION + +*----------------------------------------------------------------------* +* Macros to fill table with a regular expressions to be parsed *----------------------------------------------------------------------* -DEFINE _add_regex. +DEFINE _add_rule. - CREATE OBJECT ls_regex_table-regex + CREATE OBJECT ls_rule-regex EXPORTING pattern = c_regex-&1 ignore_case = abap_true. - ls_regex_table-token = c_token-&1. - APPEND ls_regex_table TO mo_regex_table. + ls_rule-token = c_token-&1. + ls_rule-style = c_css-&1. + APPEND ls_rule TO mt_rules. -END-OF-DEFINITION. +END-OF-DEFINITION. " _add_rule *----------------------------------------------------------------------* -* CLASS lcl_code_highlighter IMPLEMENTATION +* CLASS lcl_syntax_highlighter IMPLEMENTATION *----------------------------------------------------------------------* -CLASS lcl_code_highlighter IMPLEMENTATION. +* Implementation of syntax highligther for ABAP source code +*----------------------------------------------------------------------* + +CLASS lcl_syntax_highlighter IMPLEMENTATION. + + METHOD create. + + " Create instance of highighter dynamically dependent on syntax type + IF iv_filename CP '*.abap'. + CREATE OBJECT ro_instance TYPE lcl_syntax_abap. + ELSEIF iv_filename CP '*.xml'. + CREATE OBJECT ro_instance TYPE lcl_syntax_xml. + ELSE. + CLEAR ro_instance. + ENDIF. + + ENDMETHOD. " create. + + METHOD parse_line. + + DATA: + lo_regex TYPE REF TO cl_abap_regex, + lo_matcher TYPE REF TO cl_abap_matcher, + lt_result TYPE match_result_tab, + ls_match TYPE ty_match. + + FIELD-SYMBOLS: + LIKE LINE OF mt_rules, + TYPE match_result, + TYPE ty_match. + + CLEAR et_matches. + + " Process syntax-dependent regex table and find all matches + LOOP AT mt_rules ASSIGNING . + lo_regex = -regex. + lo_matcher = lo_regex->create_matcher( text = iv_line ). + lt_result = lo_matcher->find_all( ). + + " Save matches into custom table with predefined tokens + LOOP AT lt_result ASSIGNING . + CLEAR: ls_match. + ls_match-token = -token. + ls_match-offset = -offset. + ls_match-length = -length. + APPEND ls_match TO et_matches. + ENDLOOP. + ENDLOOP. + + ENDMETHOD. " parse_line + + METHOD extend_matches. + + DATA: + lv_line_len TYPE i, + lv_last_pos TYPE i VALUE 0, + lv_length TYPE i, + ls_match TYPE ty_match. + + FIELD-SYMBOLS TYPE ty_match. + + lv_line_len = strlen( iv_line ). + + SORT ct_matches BY offset. + + " Add entries refering to parts of text that should not be formatted + LOOP AT ct_matches ASSIGNING . + IF -offset > lv_last_pos. + lv_length = -offset - lv_last_pos. + ls_match-token = c_token_none. + ls_match-offset = lv_last_pos. + ls_match-length = lv_length. + INSERT ls_match INTO ct_matches INDEX sy-tabix. + ENDIF. + lv_last_pos = -offset + -length. + ENDLOOP. + + " Add remainder of the string + IF lv_line_len > lv_last_pos. + lv_length = lv_line_len - lv_last_pos. + ls_match-token = c_token_none. + ls_match-offset = lv_last_pos. + ls_match-length = lv_length. + APPEND ls_match TO ct_matches. + ENDIF. + + ENDMETHOD. " extend_matches + + METHOD format_line. + + DATA: + lv_chunk TYPE string, + ls_rule LIKE LINE OF mt_rules. + + FIELD-SYMBOLS TYPE ty_match. + + LOOP AT it_matches ASSIGNING . + lv_chunk = substring( val = iv_line off = -offset len = -length ). + + CLEAR ls_rule. " Failed read equals no style + READ TABLE mt_rules INTO ls_rule WITH KEY token = -token. + + lv_chunk = me->apply_style( iv_line = lv_chunk + iv_class = ls_rule-style ). + + rv_line = rv_line && lv_chunk. + ENDLOOP. + + ENDMETHOD. " format_line + + METHOD apply_style. + + DATA lv_escaped TYPE string. + + lv_escaped = escape( val = iv_line format = cl_abap_format=>e_html_attr ). + IF iv_class IS NOT INITIAL. + rv_line = |{ lv_escaped }|. + ELSE. + rv_line = lv_escaped. + ENDIF. + + ENDMETHOD. " apply_style + + METHOD process_line. + + DATA: lt_matches TYPE ty_match_tt. + + IF strlen( iv_line ) = 0. + RETURN. + ENDIF. + + me->parse_line( EXPORTING iv_line = iv_line + IMPORTING et_matches = lt_matches ). + + me->order_matches( EXPORTING iv_line = iv_line + CHANGING ct_matches = lt_matches ). + + me->extend_matches( EXPORTING iv_line = iv_line + CHANGING ct_matches = lt_matches ). + + rv_line = me->format_line( iv_line = iv_line + it_matches = lt_matches ). + + ENDMETHOD. " process_line + +ENDCLASS. " lcl_syntax_highlighter IMPLEMENTATION + +*----------------------------------------------------------------------* +* CLASS lcl_syntax_abap IMPLEMENTATION +*----------------------------------------------------------------------* +* Implementation of syntax highligther for XML source code +*----------------------------------------------------------------------* + +CLASS lcl_syntax_abap IMPLEMENTATION. METHOD class_constructor. - DATA: ls_regex_table TYPE ty_regex. + init_keywords( ). - c_regex-comment = '##|"|^\*'. - c_regex-text = '`|''|\||\{|\}'. - c_regex-keyword = '&&|\b(' && - '\*-INPUT|\?TO|ABAP-SOURCE|ABBREVIATED|ABS|ABSTRACT|ACCEPT|ACCEPTING|ACCESSPOLICY' && + ENDMETHOD. " class_constructor + + METHOD is_keyword. + + DATA lv_str TYPE string. + + lv_str = to_upper( iv_chunk ). + READ TABLE gt_keywords WITH KEY table_line = lv_str TRANSPORTING NO FIELDS. + rv_yes = boolc( sy-subrc = 0 ). + + ENDMETHOD. " is_keyword. + + METHOD constructor. + + DATA ls_rule LIKE LINE OF mt_rules. + + super->constructor( ). + + " Initialize instances of regular expression + _add_rule keyword. + _add_rule comment. + _add_rule text. + + ENDMETHOD. " constructor + + METHOD init_keywords. + + DATA: lv_keywords TYPE string, + lt_keywords TYPE STANDARD TABLE OF string. + + lv_keywords = + '&&|?TO|ABAP-SOURCE|ABBREVIATED|ABS|ABSTRACT|ACCEPT|ACCEPTING|ACCESSPOLICY' && '|ACCORDING|ACOS|ACTIVATION|ACTUAL|ADD|ADD-CORRESPONDING|ADJACENT|AFTER|ALIAS' && '|ALIASES|ALIGN|ALL|ALLOCATE|ALPHA|ANALYSIS|ANALYZER|AND|ANY|APPEND|APPENDAGE' && '|APPENDING|APPLICATION|ARCHIVE|AREA|ARITHMETIC|AS|ASCENDING|ASIN|ASPECT|ASSERT' && @@ -190,17 +432,18 @@ CLASS lcl_code_highlighter IMPLEMENTATION. '|REPLACEMENT|REPLACING|REPORT|REQUEST|REQUESTED|RESERVE|RESET|RESOLUTION' && '|RESPECTING|RESPONSIBLE|RESULT|RESULTS|RESUMABLE|RESUME|RETRY|RETURN|RETURNCODE' && '|RETURNING|RIGHT|RIGHT-JUSTIFIED|RIGHTPLUS|RIGHTSPACE|RISK|RMC_COMMUNICATION_FAILURE' && - '|RMC_INVALID_STATUS|RMC_SYSTEM_FAILURE|ROLE|ROLLBACK|ROUND|ROWS|RTTI|RUN|SAP|SAP-SPOOL' && - '|SAVING|SCALE_PRESERVING|SCALE_PRESERVING_SCIENTIFIC|SCAN|SCIENTIFIC|SCIENTIFIC_WITH_LEADING_ZERO' && - '|SCREEN|SCROLL|SCROLL-BOUNDARY|SCROLLING|SEARCH|SECONDARY|SECONDS|SECTION|SELECT|SELECTION' && - '|SELECTIONS|SELECTION-SCREEN|SELECTION-SET|SELECTION-SETS|SELECTION-TABLE|SELECT-OPTIONS' && - '|SELECTOR|SELECTOR|SEND|SEPARATE|SEPARATED|SET|SHARED|SHIFT|SHORT|SHORTDUMP-ID|SIGN' && - '|SIGN_AS_POSTFIX|SIMPLE|SIN|SINGLE|SINH|SIZE|SKIP|SKIPPING|SMART|SOME|SORT|SORTABLE' && - '|SORTED|SOURCE|SPACE|SPECIFIED|SPLIT|SPOOL|SPOTS|SQL|SQLSCRIPT|SQRT|STABLE|STAMP' && - '|STANDARD|STARTING|START-OF-SELECTION|STATE|STATEMENT|STATEMENTS|STATIC|STATICS|STATUSINFO' && - '|STEP-LOOP|STOP|STRLEN|STRUCTURE|STRUCTURES|STYLE|SUBKEY|SUBMATCHES|SUBMIT|SUBROUTINE' && - '|SUBSCREEN|SUBSTRING|SUBTRACT|SUBTRACT-CORRESPONDING|SUFFIX|SUM|SUMMARY|SUMMING|SUPPLIED' && - '|SUPPLY|SUPPRESS|SWITCH|SWITCHSTATES|SYMBOL|SYNCPOINTS|SYNTAX|SYNTAX-CHECK|SYNTAX-TRACE' && + '|RMC_INVALID_STATUS|RMC_SYSTEM_FAILURE|ROLE|ROLLBACK|ROUND|ROWS|RTTI|RUN|SAP' && + '|SAP-SPOOL|SAVING|SCALE_PRESERVING|SCALE_PRESERVING_SCIENTIFIC|SCAN|SCIENTIFIC' && + '|SCIENTIFIC_WITH_LEADING_ZERO|SCREEN|SCROLL|SCROLL-BOUNDARY|SCROLLING|SEARCH' && + '|SECONDARY|SECONDS|SECTION|SELECT|SELECTION|SELECTIONS|SELECTION-SCREEN|SELECTION-SET' && + '|SELECTION-SETS|SELECTION-TABLE|SELECT-OPTIONS|SELECTOR|SEND|SEPARATE|SEPARATED|SET' && + '|SHARED|SHIFT|SHORT|SHORTDUMP-ID|SIGN|SIGN_AS_POSTFIX|SIMPLE|SIN|SINGLE|SINH|SIZE' && + '|SKIP|SKIPPING|SMART|SOME|SORT|SORTABLE|SORTED|SOURCE|SPACE|SPECIFIED|SPLIT|SPOOL' && + '|SPOTS|SQL|SQLSCRIPT|SQRT|STABLE|STAMP|STANDARD|STARTING|START-OF-SELECTION|STATE' && + '|STATEMENT|STATEMENTS|STATIC|STATICS|STATUSINFO|STEP-LOOP|STOP|STRLEN|STRUCTURE' && + '|STRUCTURES|STYLE|SUBKEY|SUBMATCHES|SUBMIT|SUBROUTINE|SUBSCREEN|SUBSTRING|SUBTRACT' && + '|SUBTRACT-CORRESPONDING|SUFFIX|SUM|SUMMARY|SUMMING|SUPPLIED|SUPPLY|SUPPRESS|SWITCH' && + '|SWITCHSTATES|SYMBOL|SYNCPOINTS|SYNTAX|SYNTAX-CHECK|SYNTAX-TRACE' && '|SYSTEM-CALL|SYSTEM-EXCEPTIONS|SYSTEM-EXIT|TAB|TABBED|TABLE|TABLES|TABLEVIEW|TABSTRIP' && '|TAN|TANH|TARGET|TASK|TASKS|TEST|TESTING|TEXT|TEXTPOOL|THEN|THROW|TIME|TIMES|TIMESTAMP' && '|TIMEZONE|TITLE|TITLEBAR|TITLE-LINES|TO|TOKENIZATION|TOKENS|TOP-LINES|TOP-OF-PAGE' && @@ -210,58 +453,40 @@ CLASS lcl_code_highlighter IMPLEMENTATION. '|UNWIND|UP|UPDATE|UPPER|USER|USER-COMMAND|USING|UTF-8|VALID|VALUE|VALUE-REQUEST|VALUES' && '|VARY|VARYING|VERIFICATION-MESSAGE|VERSION|VIA|VIEW|VISIBLE|WAIT|WARNING|WHEN|WHENEVER' && '|WHERE|WHILE|WIDTH|WINDOW|WINDOWS|WITH|WITH-HEADING|WITHOUT|WITH-TITLE|WORD|WORK' && - '|WRITE|WRITER|X|XML|XOR|XSD|XSTRLEN|YELLOW|YES|YYMMDD|Z|ZERO|ZONE' && - ')\b'. + '|WRITE|WRITER|X|XML|XOR|XSD|XSTRLEN|YELLOW|YES|YYMMDD|Z|ZERO|ZONE'. - " Initialize instances of regular expressions - _add_regex keyword. - _add_regex comment. - _add_regex text. + SPLIT lv_keywords AT '|' INTO TABLE lt_keywords. + gt_keywords = lt_keywords. " Hash table - ENDMETHOD. "class_constructor + ENDMETHOD. " init_keywords - METHOD parse_line. + METHOD parse_line. "REDEFINITION - DATA: - lo_regex TYPE REF TO cl_abap_regex, - lo_matcher TYPE REF TO cl_abap_matcher, - lt_result TYPE match_result_tab, - ls_match TYPE ty_match. + DATA lv_index TYPE i. - FIELD-SYMBOLS: - TYPE ty_regex, - TYPE match_result, - TYPE ty_match. + FIELD-SYMBOLS LIKE LINE OF et_matches. - LOOP AT mo_regex_table ASSIGNING . - lo_regex = -regex. - lo_matcher = lo_regex->create_matcher( text = iv_line ). - lt_result = lo_matcher->find_all( ). + super->parse_line( EXPORTING iv_line = iv_line + IMPORTING et_matches = et_matches ). - LOOP AT lt_result ASSIGNING . - ls_match-token = -token. - ls_match-offset = -offset. - ls_match-length = -length. - - IF ls_match-token = c_token-text. - ls_match-text_tag = substring( val = iv_line off = ls_match-offset len = ls_match-length ). - ENDIF. - - APPEND ls_match TO rt_matches. - ENDLOOP. + " Remove non-keywords + LOOP AT et_matches ASSIGNING WHERE token = c_token-keyword. + lv_index = sy-tabix. + IF abap_false = is_keyword( substring( val = iv_line + off = -offset + len = -length ) ). + DELETE et_matches INDEX lv_index. + ENDIF. ENDLOOP. - ENDMETHOD. " parse_line + ENDMETHOD. " parse_line. METHOD order_matches. DATA: lv_index TYPE sy-tabix, lv_line_len TYPE i, - lv_prev_token TYPE c, - lv_last_pos TYPE i VALUE 0, - lv_length TYPE i, - ls_match TYPE ty_match. + lv_prev_token TYPE c. FIELD-SYMBOLS: TYPE ty_match, @@ -281,182 +506,205 @@ CLASS lcl_code_highlighter IMPLEMENTATION. ENDIF. CASE -token. + WHEN c_token-keyword. + IF -offset > 0. + " Delete match if keyword is part of structure or field symbol + IF substring( val = iv_line off = ( -offset - 1 ) len = 1 ) CA '-<'. + DELETE ct_matches INDEX lv_index. + CONTINUE. + ENDIF. + ENDIF. + WHEN c_token-comment. -length = lv_line_len - -offset. DELETE ct_matches FROM lv_index + 1. CONTINUE. + WHEN c_token-text. + -text_tag = substring( val = iv_line + off = -offset + len = -length ). IF lv_prev_token = c_token-text. IF -text_tag = -text_tag. -length = -offset + -length - -offset. CLEAR lv_prev_token. ELSEIF -text_tag = '}' AND -text_tag = '{'. - -length = -offset - -offset - 1. " Shifted } out of highlight - -offset = -offset + 1. " Shifted { out of highlight + -length = -offset - -offset - 1. " Shift } out of scope + -offset = -offset + 1. " Shift { out of scope CLEAR lv_prev_token. ELSEIF -text_tag = '{'. -length = -offset - -offset. CLEAR lv_prev_token. ELSEIF -text_tag = '}'. -length = -offset - -offset. - -offset = -offset + 1. " Shifted } out of highlight + -offset = -offset + 1. " Shift } out of scope CLEAR lv_prev_token. ENDIF. DELETE ct_matches INDEX lv_index. CONTINUE. ENDIF. + ENDCASE. lv_prev_token = -token. ASSIGN TO . ENDLOOP. - " Add entries refering to parts of text that should not be formatted - LOOP AT ct_matches ASSIGNING . - IF -offset > lv_last_pos. - lv_length = -offset - lv_last_pos. - ls_match-token = c_token-none. - ls_match-offset = lv_last_pos. - ls_match-length = lv_length. - INSERT ls_match INTO ct_matches INDEX sy-tabix. - ENDIF. - lv_last_pos = -offset + -length. - ENDLOOP. + ENDMETHOD. " order_matches. - " Add remainder of the string - IF lv_line_len > lv_last_pos. - lv_length = lv_line_len - lv_last_pos. - ls_match-token = c_token-none. - ls_match-offset = lv_last_pos. - ls_match-length = lv_length. - APPEND ls_match TO ct_matches. - ENDIF. +ENDCLASS. " lcl_syntax_abap IMPLEMENTATION - ENDMETHOD. " order_matches. +*----------------------------------------------------------------------* +* CLASS lcl_syntax_xml IMPLEMENTATION +*----------------------------------------------------------------------* +* +*----------------------------------------------------------------------* +CLASS lcl_syntax_xml IMPLEMENTATION. - METHOD format_line. + METHOD constructor. + + DATA ls_rule LIKE LINE OF mt_rules. + + super->constructor( ). + + " Initialize instances of regular expressions + _add_rule xml_tag. + _add_rule attr. + _add_rule attr_val. + + ENDMETHOD. + + METHOD order_matches. DATA: - lv_chunk TYPE string, - lv_css_class TYPE string. + lv_index TYPE sy-tabix, + lv_line_len TYPE i, + lv_prev_token TYPE c, + lv_state TYPE c VALUE 'O'. " O - for open tag; C - for closed tag; FIELD-SYMBOLS: - TYPE ty_match. + TYPE ty_match, + TYPE ty_match. - LOOP AT it_matches ASSIGNING . - lv_chunk = substring( val = iv_line off = -offset len = -length ). + SORT ct_matches BY offset. + + lv_line_len = strlen( iv_line ). + + LOOP AT ct_matches ASSIGNING . + lv_index = sy-tabix. CASE -token. - WHEN c_token-keyword. - lv_css_class = c_css-keyword. - WHEN c_token-comment. - lv_css_class = c_css-comment. - WHEN c_token-text. - lv_css_class = c_css-text. - WHEN c_token-none. - CLEAR: lv_css_class. + WHEN c_token-xml_tag. + -text_tag = substring( val = iv_line + off = -offset + len = -length ). + + " No other matches between two tags + IF -text_tag = '>' AND lv_prev_token = c_token-xml_tag. + lv_state = 'C'. + -length = -offset - -offset + -length. + DELETE ct_matches INDEX lv_index. + CONTINUE. + + " Adjust length and offset of closing tag + ELSEIF -text_tag = '>' AND lv_prev_token <> c_token-xml_tag. + lv_state = 'C'. + -length = -offset - -offset - -length + -length. + -offset = -offset + -length. + ELSE. + lv_state = 'O'. + ENDIF. + + WHEN OTHERS. + IF lv_prev_token = c_token-xml_tag. + -length = -offset - -offset. " Extend length of the opening tag + ENDIF. + + IF lv_state = 'C'. " Delete all matches between tags + DELETE ct_matches INDEX lv_index. + CONTINUE. + ENDIF. + ENDCASE. - lv_chunk = me->apply_style( iv_line = lv_chunk - iv_class = lv_css_class ). - - rv_line = rv_line && lv_chunk. + lv_prev_token = -token. + ASSIGN TO . ENDLOOP. - ENDMETHOD. "format_line + ENDMETHOD. " order_matches - METHOD apply_style. - - DATA lv_escaped TYPE string. - - lv_escaped = escape( val = iv_line format = cl_abap_format=>e_html_attr ). - IF iv_class IS NOT INITIAL. - rv_line = |{ lv_escaped }|. - ELSE. - rv_line = lv_escaped. - ENDIF. - - ENDMETHOD. "apply_style - - METHOD process_line. - - DATA: lt_matches TYPE ty_match_tt. - - IF strlen( iv_line ) = 0. - RETURN. - ENDIF. - - lt_matches = me->parse_line( iv_line ). - - me->order_matches( EXPORTING iv_line = iv_line - CHANGING ct_matches = lt_matches ). - - rv_line = me->format_line( iv_line = iv_line - it_matches = lt_matches ). - - ENDMETHOD. " process_line - -ENDCLASS. " lcl_code_highlighter IMPLEMENTATION +ENDCLASS. " lcl_syntax_xml IMPLEMENTATION *----------------------------------------------------------------------* -* CLASS ltcl_code_highlighter definition +* CLASS ltcl_syntax_cases definition *----------------------------------------------------------------------* -CLASS ltcl_code_highlighter1 DEFINITION FINAL +CLASS ltcl_syntax_cases DEFINITION FINAL FOR TESTING RISK LEVEL HARMLESS DURATION SHORT. PRIVATE SECTION. DATA: - mo TYPE REF TO lcl_code_highlighter, - mt_after_parse TYPE lcl_code_highlighter=>ty_match_tt, - ms_match TYPE lcl_code_highlighter=>ty_match, - mt_after_order TYPE lcl_code_highlighter=>ty_match_tt. + mt_after_parse TYPE lcl_syntax_highlighter=>ty_match_tt, + mt_after_order TYPE lcl_syntax_highlighter=>ty_match_tt, + mt_after_extend TYPE lcl_syntax_highlighter=>ty_match_tt, + ms_match TYPE lcl_syntax_highlighter=>ty_match. METHODS: - setup, - test IMPORTING iv_line TYPE string, - test01 FOR TESTING, - test02 FOR TESTING, - test03 FOR TESTING, - test04 FOR TESTING, - test05 FOR TESTING, - test06 FOR TESTING, - test07 FOR TESTING. + do_test IMPORTING iv_line TYPE string + iv_filename TYPE string + RETURNING VALUE(ro_instance) TYPE REF TO lcl_syntax_highlighter, + test_abap_01 FOR TESTING, + test_abap_02 FOR TESTING, + test_abap_03 FOR TESTING, + test_abap_04 FOR TESTING, + test_abap_05 FOR TESTING, + test_abap_06 FOR TESTING, + test_abap_07 FOR TESTING, + test_abap_08 FOR TESTING, + test_xml_01 FOR TESTING, + test_xml_02 FOR TESTING, + test_xml_03 FOR TESTING, + test_xml_04 FOR TESTING, + test_xml_05 FOR TESTING. -ENDCLASS. " ltcl_code_highlighter +ENDCLASS. " ltcl_syntax_cases *----------------------------------------------------------------------* -* CLASS ltcl_code_highlighter IMPLEMENTATION +* CLASS ltcl_syntax_cases IMPLEMENTATION *----------------------------------------------------------------------* -CLASS ltcl_code_highlighter1 IMPLEMENTATION. +CLASS ltcl_syntax_cases IMPLEMENTATION. DEFINE _generate_parse. ms_match-token = &1. ms_match-offset = &2. ms_match-length = &3. - ms_match-text_tag = &4. - APPEND ms_match to mt_after_parse. - END-OF-DEFINITION. + append ms_match to mt_after_parse. + END-OF-DEFINITION. " _generate_parse DEFINE _generate_order. ms_match-token = &1. ms_match-offset = &2. ms_match-length = &3. ms_match-text_tag = &4. - APPEND ms_match to mt_after_order. - END-OF-DEFINITION. + append ms_match to mt_after_order. + END-OF-DEFINITION. " _generate_order - METHOD setup. - CREATE OBJECT mo. - CLEAR mt_after_parse. - CLEAR mt_after_order. - ENDMETHOD. " setup + DEFINE _generate_extend. + ms_match-token = &1. + ms_match-offset = &2. + ms_match-length = &3. + ms_match-text_tag = &4. + append ms_match to mt_after_extend. + END-OF-DEFINITION. " _generate_extend - METHOD test. + METHOD do_test. - DATA: lt_matches_act TYPE lcl_code_highlighter=>ty_match_tt. + DATA: lt_matches_act TYPE lcl_syntax_highlighter=>ty_match_tt, + lo TYPE REF TO lcl_syntax_highlighter. - lt_matches_act = mo->parse_line( iv_line ). + lo = lcl_syntax_highlighter=>create( iv_filename ). + lo->parse_line( EXPORTING iv_line = iv_line + IMPORTING et_matches = lt_matches_act ). SORT lt_matches_act BY offset. @@ -464,246 +712,471 @@ CLASS ltcl_code_highlighter1 IMPLEMENTATION. act = lt_matches_act msg = | Error during parsing: { iv_line }| ). - IF lines( mt_after_order ) > 0. - mo->order_matches( EXPORTING iv_line = iv_line - CHANGING ct_matches = lt_matches_act ). + lo->order_matches( EXPORTING iv_line = iv_line + CHANGING ct_matches = lt_matches_act ). - cl_abap_unit_assert=>assert_equals( exp = mt_after_order - act = lt_matches_act - msg = | Error during ordering: { iv_line }| ). - ENDIF. + cl_abap_unit_assert=>assert_equals( exp = mt_after_order + act = lt_matches_act + msg = | Error during ordering: { iv_line }| ). - ENDMETHOD. + lo->extend_matches( EXPORTING iv_line = iv_line + CHANGING ct_matches = lt_matches_act ). + cl_abap_unit_assert=>assert_equals( exp = mt_after_extend + act = lt_matches_act + msg = | Error during extending: { iv_line }| ). + + ENDMETHOD. "test ****************************************************** * Test parsing and ordering of comments * ****************************************************** - METHOD test01. + METHOD test_abap_01. - DATA: lv_line TYPE string. + DATA lv_line TYPE string. - lv_line = '* commented out line with key word data'. + lv_line = '* commented out line with key word data'. "#EC NOTEXT " Generate table with expected values after parsing - _generate_parse 'C' 0 1 ''. - _generate_parse 'K' 12 3 ''. - _generate_parse 'K' 16 4 ''. - _generate_parse 'K' 21 4 ''. - _generate_parse 'K' 26 3 ''. - _generate_parse 'K' 30 4 ''. - _generate_parse 'K' 35 4 ''. + _generate_parse 'C' 0 1. + _generate_parse 'K' 12 3. + _generate_parse 'K' 16 4. + _generate_parse 'K' 21 4. + _generate_parse 'K' 26 3. + _generate_parse 'K' 30 4. + _generate_parse 'K' 35 4. " Generate table with expected values after ordering _generate_order 'C' 0 39 ''. - test( lv_line ). + " Generate table with expected values after ordering + _generate_extend 'C' 0 39 ''. - ENDMETHOD. + do_test( iv_line = lv_line iv_filename = '*.abap' ). + + ENDMETHOD. " test_abap_01 ****************************************************** * Test parsing and ordering of remainder of string * ****************************************************** - METHOD test02. + METHOD test_abap_02. - DATA: lv_line TYPE string. + DATA lv_line TYPE string. - lv_line = 'data: lv_var_name type string.'. + lv_line = 'data: lv_var_name type string.'. "#EC NOTEXT " Generate table with expected values after parsing - _generate_parse 'K' 0 4 ''. - _generate_parse 'K' 18 4 ''. + _generate_parse 'K' 0 4. + _generate_parse 'K' 18 4. " Generate table with expected values after ordering _generate_order 'K' 0 4 ''. - _generate_order 'N' 4 14 ''. _generate_order 'K' 18 4 ''. - _generate_order 'N' 22 8 ''. - test( lv_line ). + " Generate table with expected values after extending + _generate_extend 'K' 0 4 ''. + _generate_extend '.' 4 14 ''. + _generate_extend 'K' 18 4 ''. + _generate_extend '.' 22 8 ''. - ENDMETHOD. + do_test( iv_line = lv_line iv_filename = '*.abap' ). + + ENDMETHOD. " test_abap_02 ****************************************************** * Test parsing and ordering of key words & texts * ****************************************************** - METHOD test03. + METHOD test_abap_03. - DATA: lv_line TYPE string. + DATA lv_line TYPE string. - lv_line = 'call function ''FM_NAME''. " Commented'. + + lv_line = 'call function ''FM_NAME''. " Commented'. "#EC NOTEXT " Generate table with expected values after parsing - _generate_parse 'K' 0 4 ''. - _generate_parse 'K' 5 8 ''. - _generate_parse 'T' 14 1 ''''. - _generate_parse 'T' 22 1 ''''. - _generate_parse 'C' 25 1 ''. + _generate_parse 'K' 0 4. + _generate_parse 'K' 5 8. + _generate_parse 'T' 14 1. + _generate_parse 'T' 22 1. + _generate_parse 'C' 25 1. " Generate table with expected values after ordering _generate_order 'K' 0 4 ''. - _generate_order 'N' 4 1 ''. _generate_order 'K' 5 8 ''. - _generate_order 'N' 13 1 ''. _generate_order 'T' 14 9 ''''. - _generate_order 'N' 23 2 ''. _generate_order 'C' 25 11 ''. - test( lv_line ). + " Generate table with expected values after extending + _generate_extend 'K' 0 4 ''. + _generate_extend '.' 4 1 ''. + _generate_extend 'K' 5 8 ''. + _generate_extend '.' 13 1 ''. + _generate_extend 'T' 14 9 ''''. + _generate_extend '.' 23 2 ''. + _generate_extend 'C' 25 11 ''. - ENDMETHOD. + do_test( iv_line = lv_line iv_filename = '*.abap' ). + + ENDMETHOD. " test_abap_03 ****************************************************** * Test parsing and ordering of key words in texts * ****************************************************** - METHOD test04. + METHOD test_abap_04. - DATA: lv_line TYPE string. + DATA lv_line TYPE string. - lv_line = 'constants: lc_var type string value ''simpletext data simpletext''.'. + lv_line = 'constants: lc_var type string value ''simpletext data simpletext''.'. "#EC NOTEXT " Generate table with expected values after parsing - _generate_parse 'K' 0 9 ''. - _generate_parse 'K' 18 4 ''. - _generate_parse 'K' 30 5 ''. - _generate_parse 'T' 36 1 ''''. - _generate_parse 'K' 48 4 ''. - _generate_parse 'T' 63 1 ''''. + _generate_parse 'K' 0 9. + _generate_parse 'K' 18 4. + _generate_parse 'K' 30 5. + _generate_parse 'T' 36 1. + _generate_parse 'K' 48 4. + _generate_parse 'T' 63 1. " Generate table with expected values after ordering _generate_order 'K' 0 9 ''. - _generate_order 'N' 9 9 ''. _generate_order 'K' 18 4 ''. - _generate_order 'N' 22 8 ''. _generate_order 'K' 30 5 ''. - _generate_order 'N' 35 1 ''. _generate_order 'T' 36 28 ''''. - _generate_order 'N' 64 1 ''. - test( lv_line ). + " Generate table with expected values after ordering + _generate_extend 'K' 0 9 ''. + _generate_extend '.' 9 9 ''. + _generate_extend 'K' 18 4 ''. + _generate_extend '.' 22 8 ''. + _generate_extend 'K' 30 5 ''. + _generate_extend '.' 35 1 ''. + _generate_extend 'T' 36 28 ''''. + _generate_extend '.' 64 1 ''. - ENDMETHOD. + do_test( iv_line = lv_line iv_filename = '*.abap' ). + + ENDMETHOD. " test_abap_04 ****************************************************** * Test parsing and ordering texts in curly brackets * ****************************************************** - METHOD test05. + METHOD test_abap_05. - DATA: lv_line TYPE string. + DATA lv_line TYPE string. - lv_line = 'a = |{ b }={ c }|.'. + lv_line = 'a = |{ b }={ c }|.'. "#EC NOTEXT " Generate table with expected values after parsing - _generate_parse 'T' 4 1 '|'. - _generate_parse 'T' 5 1 '{'. - _generate_parse 'T' 9 1 '}'. - _generate_parse 'T' 11 1 '{'. - _generate_parse 'K' 13 1 ''. - _generate_parse 'T' 15 1 '}'. - _generate_parse 'T' 16 1 '|'. + _generate_parse 'T' 4 1. + _generate_parse 'T' 5 1. + _generate_parse 'T' 9 1. + _generate_parse 'T' 11 1. + _generate_parse 'K' 13 1. + _generate_parse 'T' 15 1. + _generate_parse 'T' 16 1. " Generate table with expected values after ordering - _generate_order 'N' 0 4 ''. _generate_order 'T' 4 1 '|'. - _generate_order 'N' 5 5 ''. _generate_order 'T' 10 1 '}'. - _generate_order 'N' 11 2 ''. _generate_order 'K' 13 1 ''. - _generate_order 'N' 14 2 ''. _generate_order 'T' 16 1 '}'. - _generate_order 'N' 17 1 ''. - test( lv_line ). + " Generate table with expected values after extending + _generate_extend '.' 0 4 ''. + _generate_extend 'T' 4 1 '|'. + _generate_extend '.' 5 5 ''. + _generate_extend 'T' 10 1 '}'. + _generate_extend '.' 11 2 ''. + _generate_extend 'K' 13 1 ''. + _generate_extend '.' 14 2 ''. + _generate_extend 'T' 16 1 '}'. + _generate_extend '.' 17 1 ''. - ENDMETHOD. + do_test( iv_line = lv_line iv_filename = '*.abap' ). + + ENDMETHOD. " test_abap_05 ****************************************************** * Test parsing and ordering of texts * ****************************************************** - METHOD test06. + METHOD test_abap_06. - DATA: lv_line TYPE string. + DATA lv_line TYPE string. - lv_line = 'lv_line = lc_constant && |XYZ { ''ab'' && |ac{ ''UU'' }| }|'. + lv_line = 'lv_line = lc_constant && |XYZ { ''ab'' && |ac{ ''UU'' }| }|'. "#EC NOTEXT " Generate table with expected values after parsing - _generate_parse 'K' 22 2 ''. - _generate_parse 'T' 25 1 '|'. - _generate_parse 'T' 30 1 '{'. - _generate_parse 'T' 32 1 ''''. - _generate_parse 'T' 35 1 ''''. - _generate_parse 'K' 37 2 ''. - _generate_parse 'T' 40 1 '|'. - _generate_parse 'T' 43 1 '{'. - _generate_parse 'T' 45 1 ''''. - _generate_parse 'T' 48 1 ''''. - _generate_parse 'T' 50 1 '}'. - _generate_parse 'T' 51 1 '|'. - _generate_parse 'T' 53 1 '}'. - _generate_parse 'T' 54 1 '|'. + _generate_parse 'K' 22 2. + _generate_parse 'T' 25 1. + _generate_parse 'T' 30 1. + _generate_parse 'T' 32 1. + _generate_parse 'T' 35 1. + _generate_parse 'K' 37 2. + _generate_parse 'T' 40 1. + _generate_parse 'T' 43 1. + _generate_parse 'T' 45 1. + _generate_parse 'T' 48 1. + _generate_parse 'T' 50 1. + _generate_parse 'T' 51 1. + _generate_parse 'T' 53 1. + _generate_parse 'T' 54 1. " Generate table with expected values after ordering - _generate_order 'N' 00 22 ''. _generate_order 'K' 22 2 ''. - _generate_order 'N' 24 1 ''. _generate_order 'T' 25 5 '|'. - _generate_order 'N' 30 2 ''. _generate_order 'T' 32 4 ''''. - _generate_order 'N' 36 1 ''. _generate_order 'K' 37 2 ''. - _generate_order 'N' 39 1 ''. _generate_order 'T' 40 3 '|'. - _generate_order 'N' 43 2 ''. _generate_order 'T' 45 4 ''''. - _generate_order 'N' 49 2 ''. _generate_order 'T' 51 1 '}'. - _generate_order 'N' 52 2 ''. _generate_order 'T' 54 1 '}'. - test( lv_line ). + " Generate table with expected values after extending + _generate_extend '.' 00 22 ''. + _generate_extend 'K' 22 2 ''. + _generate_extend '.' 24 1 ''. + _generate_extend 'T' 25 5 '|'. + _generate_extend '.' 30 2 ''. + _generate_extend 'T' 32 4 ''''. + _generate_extend '.' 36 1 ''. + _generate_extend 'K' 37 2 ''. + _generate_extend '.' 39 1 ''. + _generate_extend 'T' 40 3 '|'. + _generate_extend '.' 43 2 ''. + _generate_extend 'T' 45 4 ''''. + _generate_extend '.' 49 2 ''. + _generate_extend 'T' 51 1 '}'. + _generate_extend '.' 52 2 ''. + _generate_extend 'T' 54 1 '}'. - ENDMETHOD. + do_test( iv_line = lv_line iv_filename = '*.abap' ). - METHOD test07. + ENDMETHOD. " test_abap_06 - DATA: lv_line TYPE string. +******************************************************** +* Check that '*' in select statement is not a match * +******************************************************** + METHOD test_abap_07. - lv_line = 'SELECT * FROM foo'. + DATA lv_line TYPE string. + + lv_line = 'SELECT * FROM foo'. "#EC NOTEXT " Generate table with expected values after parsing - _generate_parse 'K' 0 6 ''. - _generate_parse 'K' 9 4 ''. + _generate_parse 'K' 0 6. + _generate_parse 'K' 9 4. - test( lv_line ). + " Generate table with expected values after ordering + _generate_order 'K' 0 6 ''. + _generate_order 'K' 9 4 ''. - ENDMETHOD. + " Generate table with expected values after extending + _generate_extend 'K' 0 6 ''. + _generate_extend '.' 6 3 ''. + _generate_extend 'K' 9 4 ''. + _generate_extend '.' 13 4 ''. -ENDCLASS. + do_test( iv_line = lv_line iv_filename = '*.abap' ). -CLASS ltcl_code_highlighter2 DEFINITION FINAL + ENDMETHOD. " test_abap_07 + +******************************************************** +* Test parsing and ordering of key words in structures * +******************************************************** + METHOD test_abap_08. + + DATA lv_line TYPE string. + + lv_line = 'lv_length = -length.'. "#EC NOTEXT + + " Generate table with expected values after parsing + _generate_parse 'K' 13 5. + _generate_parse 'K' 20 6. + + " Generate table with expected values after extending + _generate_extend '.' 0 27 ''. + + do_test( iv_line = lv_line iv_filename = '*.abap' ). + + ENDMETHOD. " test_abap_08 + +******************************************************** +* Test parsing and ordering of tags in xml * +******************************************************** + METHOD test_xml_01. + + DATA lv_line TYPE string. + + lv_line = 'Text'. "#EC NOTEXT + + " Generate table with expected values after parsing + _generate_parse 'X' 0 1. + _generate_parse 'X' 4 1. + _generate_parse 'X' 9 1. + _generate_parse 'X' 14 1. + + " Generate table with expected values after ordering + _generate_order 'X' 0 5 '<'. + _generate_order 'X' 9 6 '<'. + + " Generate table with expected values after extending + _generate_extend 'X' 0 5 '<'. + _generate_extend '.' 5 4 ''. + _generate_extend 'X' 9 6 '<'. + + do_test( iv_line = lv_line iv_filename = '*.xml' ). + + ENDMETHOD. " test_xml_01 + + METHOD test_xml_02. + + DATA lv_line TYPE string. + + lv_line = ''. "#EC NOTEXT + + " Generate table with expected values after parsing + _generate_parse 'X' 0 1. + _generate_parse 'X' 5 1. + + " Generate table with expected values after ordering + _generate_order 'X' 0 6 '<'. + + " Generate table with expected values after extending + _generate_extend 'X' 0 6 '<'. + + do_test( iv_line = lv_line iv_filename = '*.xml' ). + + ENDMETHOD. " test_xml_02 + + METHOD test_xml_03. + + DATA lv_line TYPE string. + + lv_line = ''. "#EC NOTEXT + + " Generate table with expected values after parsing + _generate_parse 'X' 0 1. + _generate_parse 'A' 4 10. + _generate_parse 'V' 15 7. + _generate_parse 'X' 23 1. + + " Generate table with expected values after ordering + _generate_order 'X' 0 4 '<'. + _generate_order 'A' 4 10 ''. + _generate_order 'V' 15 7 ''. + _generate_order 'X' 22 2 '>'. + + " Generate table with expected values after extending + _generate_extend 'X' 0 4 '<'. + _generate_extend 'A' 4 10 ''. + _generate_extend '.' 14 1 ''. + _generate_extend 'V' 15 7 ''. + _generate_extend 'X' 22 2 '>'. + + do_test( iv_line = lv_line iv_filename = '*.xml' ). + + ENDMETHOD. " test_xml_03 + + METHOD test_xml_04. + + DATA lv_line TYPE string. + + lv_line = ''. "#EC NOTEXT + + " Generate table with expected values after parsing + _generate_parse 'X' 0 1. + _generate_parse 'A' 5 8. + _generate_parse 'V' 14 5. + _generate_parse 'X' 20 1. + + " Generate table with expected values after ordering + _generate_order 'X' 0 5 '<'. + _generate_order 'A' 5 8 ''. + _generate_order 'V' 14 5 ''. + _generate_order 'X' 19 2 '>'. + + " Generate table with expected values after extending + _generate_extend 'X' 0 5 '<'. + _generate_extend 'A' 5 8 ''. + _generate_extend '.' 13 1 ''. + _generate_extend 'V' 14 5 ''. + _generate_extend 'X' 19 2 '>'. + + do_test( iv_line = lv_line iv_filename = '*.xml' ). + + ENDMETHOD. " test_xml_04 + + METHOD test_xml_05. + + DATA lv_line TYPE string. + + lv_line = '"text"'. "#EC NOTEXT + + " Generate table with expected values after parsing + _generate_parse 'X' 0 1. + _generate_parse 'A' 7 6. + _generate_parse 'V' 14 4. + _generate_parse 'A' 18 6. + _generate_parse 'V' 25 4. + _generate_parse 'X' 29 1. + _generate_parse 'V' 30 6. + _generate_parse 'X' 36 1. + _generate_parse 'X' 44 1. + + " Generate table with expected values after ordering + _generate_order 'X' 0 7 '<'. + _generate_order 'A' 7 6 ''. + _generate_order 'V' 14 4 ''. + _generate_order 'A' 18 6 ''. + _generate_order 'V' 25 4 ''. + _generate_order 'X' 29 1 '>'. + _generate_order 'X' 36 9 '<'. + + " Generate table with expected values after extending + _generate_extend 'X' 0 7 '<'. + _generate_extend 'A' 7 6 ''. + _generate_extend '.' 13 1 ''. + _generate_extend 'V' 14 4 ''. + _generate_extend 'A' 18 6 ''. + _generate_extend '.' 24 1 ''. + _generate_extend 'V' 25 4 ''. + _generate_extend 'X' 29 1 '>'. + _generate_extend '.' 30 6 ''. + _generate_extend 'X' 36 9 '<'. + + do_test( iv_line = lv_line iv_filename = '*.xml' ). + + ENDMETHOD. " test_xml_05 + +ENDCLASS. " ltcl_syntax_cases IMPLEMENTATION + +*----------------------------------------------------------------------* +* CLASS ltcl_syntax_basic_logic DEFINITION +*----------------------------------------------------------------------* +* +*----------------------------------------------------------------------* +CLASS ltcl_syntax_basic_logic DEFINITION FINAL FOR TESTING RISK LEVEL HARMLESS DURATION SHORT. PRIVATE SECTION. - DATA: - mo TYPE REF TO lcl_code_highlighter. + DATA mo TYPE REF TO lcl_syntax_highlighter. - METHODS: setup. - METHODS: process_line FOR TESTING. - METHODS: format_line FOR TESTING. - METHODS: apply_style FOR TESTING. + METHODS: + setup, + process_line FOR TESTING, + format_line FOR TESTING, + apply_style FOR TESTING. -ENDCLASS. " ltcl_code_highlighter +ENDCLASS. " ltcl_syntax_basic_logic *----------------------------------------------------------------------* -* CLASS ltcl_code_highlighter IMPLEMENTATION +* CLASS ltcl_syntax_highlighter IMPLEMENTATION *----------------------------------------------------------------------* -CLASS ltcl_code_highlighter2 IMPLEMENTATION. - +CLASS ltcl_syntax_basic_logic IMPLEMENTATION. METHOD setup. - CREATE OBJECT mo. - ENDMETHOD. + mo = lcl_syntax_highlighter=>create( '*.abap' ). + ENDMETHOD. " setup METHOD format_line. @@ -712,15 +1185,15 @@ CLASS ltcl_code_highlighter2 IMPLEMENTATION. lv_line_act TYPE string, lv_line_exp TYPE string. - lv_line = 'call function ''FM_NAME''. " Commented'. + lv_line = 'call function ''FM_NAME''. " Commented'. "#EC NOTEXT lv_line_exp = - 'call' && - ' function' && - ' 'FM_NAME'.' && - ' " Commented'. + 'call' && "#EC NOTEXT + ' function' && "#EC NOTEXT + ' 'FM_NAME'.' && "#EC NOTEXT + ' " Commented'. "#EC NOTEXT - lv_line_act = mo->process_line( lv_line ). + lv_line_act = mo->process_line( iv_line = lv_line ). cl_abap_unit_assert=>assert_equals( exp = lv_line_exp act = lv_line_act @@ -729,35 +1202,40 @@ CLASS ltcl_code_highlighter2 IMPLEMENTATION. ENDMETHOD. " format_line METHOD apply_style. - DATA: - lv_line_act TYPE string. + + DATA lv_line_act TYPE string. " Call the method and compare results - lv_line_act = mo->apply_style( iv_line = 'CALL FUNCTION' - iv_class = lcl_code_highlighter=>c_css-keyword ). + lv_line_act = mo->apply_style( iv_line = 'CALL FUNCTION' "#EC NOTEXT + iv_class = lcl_syntax_abap=>c_css-keyword ). + + cl_abap_unit_assert=>assert_equals( + act = lv_line_act + exp = 'CALL FUNCTION' "#EC NOTEXT + msg = 'Failure during applying of style.' ). "#EC NOTEXT - cl_abap_unit_assert=>assert_equals( act = lv_line_act - exp = 'CALL FUNCTION' - msg = 'Failure during applying of style.' ). ENDMETHOD. " apply_style METHOD process_line. - DATA: - lv_line_act TYPE string. + + DATA lv_line_act TYPE string. " Call the method with empty parameter and compare results lv_line_act = mo->process_line( iv_line = '' ). - cl_abap_unit_assert=>assert_equals( act = lv_line_act - exp = '' - msg = 'Failure in method process_line.' ). + cl_abap_unit_assert=>assert_equals( + act = lv_line_act + exp = '' + msg = 'Failure in method process_line.' ). "#EC NOTEXT " Call the method with non-empty line and compare results - lv_line_act = mo->process_line( iv_line = '* CALL FUNCTION' ). + lv_line_act = mo->process_line( iv_line = '* CALL FUNCTION' ). "#EC NOTEXT + + cl_abap_unit_assert=>assert_equals( + act = lv_line_act + exp = '* CALL FUNCTION' "#EC NOTEXT + msg = 'Failure in method process_line.' ). "#EC NOTEXT - cl_abap_unit_assert=>assert_equals( act = lv_line_act - exp = '* CALL FUNCTION' - msg = 'Failure in method process_line.' ). ENDMETHOD. " process_line -ENDCLASS. " ltcl_code_highlighter \ No newline at end of file +ENDCLASS. " ltcl_syntax_highlighter \ No newline at end of file diff --git a/src/zabapgit_view_repo.prog.abap b/src/zabapgit_view_repo.prog.abap index 70d53ac4d..e71d0064a 100644 --- a/src/zabapgit_view_repo.prog.abap +++ b/src/zabapgit_view_repo.prog.abap @@ -260,12 +260,12 @@ CLASS lcl_gui_view_repo_content IMPLEMENTATION. iv_act = |{ gc_action-repo_remote_change }?{ lv_key }| ). lo_tb_advanced->add( iv_txt = 'Make off-line' iv_act = |{ gc_action-repo_remote_detach }?{ lv_key }| ). - lo_tb_advanced->add( iv_txt = 'Update local checksums' - iv_act = |{ gc_action-repo_refresh_checksums }?{ lv_key }| ). ELSE. lo_tb_advanced->add( iv_txt = 'Make on-line' iv_act = |{ gc_action-repo_remote_attach }?{ lv_key }| ). ENDIF. + lo_tb_advanced->add( iv_txt = 'Update local checksums' + iv_act = |{ gc_action-repo_refresh_checksums }?{ lv_key }| ). lo_tb_advanced->add( iv_txt = 'Remove' iv_act = |{ gc_action-repo_remove }?{ lv_key }| ). lo_tb_advanced->add( iv_txt = 'Uninstall' diff --git a/src/zabapgit_view_tutorial.prog.abap b/src/zabapgit_view_tutorial.prog.abap index e264ac50c..d7ea7f729 100644 --- a/src/zabapgit_view_tutorial.prog.abap +++ b/src/zabapgit_view_tutorial.prog.abap @@ -31,14 +31,6 @@ CLASS lcl_gui_view_tutorial IMPLEMENTATION. _add '

Tutorial

'. _add '
'. - _add '

Repository list and favorites

'. - _add '

    '. - _add '
  • To choose a repo press at the favorite bar.
  • '. - _add '
  • To add a repo as favorite'. - _add ' click icon at repo toolbar.
  • '. - _add '

'. - - _add '

Adding and cloning repos

'. _add '

    '. _add `
  • To clone a remote repo (e.g. from github) click `. @@ -51,8 +43,13 @@ CLASS lcl_gui_view_tutorial IMPLEMENTATION. _add ' or just serialize as a zip file
  • '. _add '

'. - _add '

abapGit related repositories

'. + _add '

Repository list and favorites

'. + _add '

    '. + _add '
  • To choose a repo press at the favorite bar.
  • '. + _add '
  • To favorite a repo click icon at repo toolbar.
  • '. + _add '

'. + _add '

abapGit related repositories

'. _add '

    '. _add '
  • '. ro_html->add_anchor( iv_txt = 'install abapGit repo' iv_act = gc_action-abapgit_install ).