Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mbtools/71aa345a8ccb8f375568f9f337569154 to your computer and use it in GitHub Desktop.
Save mbtools/71aa345a8ccb8f375568f9f337569154 to your computer and use it in GitHub Desktop.
abapGit: Auto Pretty-Print Class/Interface Code
METHOD zif_abapgit_exit~custom_serialize_abap_clif.
DATA:
lr_sett_pp TYPE REF TO cl_pretty_printer_wb_settings,
lt_code TYPE rswsourcet,
lt_code_pp TYPE rswsourcet.
CREATE OBJECT lr_sett_pp.
" lowercase setting:
" space = upper case
" X = lower case
" G = upper case keyword
" L = lower case keyword
" A = auto-detect (if supported)
" indent setting:
" 0 = no indent
" 2 = with indent
IF is_class_key-clsname CP '/MBTOOLS/*'.
lr_sett_pp->wb_settings-lowercase = 'G'.
lr_sett_pp->wb_settings-indent = 2.
ELSE.
RETURN.
ENDIF.
IF it_source IS NOT INITIAL.
lt_code[] = it_source.
CALL FUNCTION 'PRETTY_PRINTER'
EXPORTING
inctoo = abap_false
settings = lr_sett_pp
TABLES
ntext = lt_code_pp
otext = lt_code
EXCEPTIONS
enqueue_table_full = 1
include_enqueued = 2
include_readerror = 3
include_writeerror = 4
OTHERS = 5.
IF sy-subrc = 0.
rt_source = lt_code_pp.
ENDIF.
RETURN.
ENDIF.
ENDMETHOD.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment