mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-02 13:03:01 +08:00
CLAS: Fix pull for deleted interface methods (#5768)
* CLAS: Fix pull for deleted interface methods In case an interface method was deleted, pulling a class that had implemented such method would not delete the implementation. This resulted in a diff and manual effort to remove the method (or repair the class). The fix will compare the implemented methods and trigger the repair if necessary. Closes #5578 * Update zcl_abapgit_oo_class.clas.abap * return all includes Co-authored-by: Lars Hvam <larshp@hotmail.com>
This commit is contained in:
parent
77fea02b45
commit
16656d8141
|
@ -94,6 +94,16 @@ CLASS zcl_abapgit_oo_class DEFINITION
|
||||||
CLASS-METHODS delete_report
|
CLASS-METHODS delete_report
|
||||||
IMPORTING
|
IMPORTING
|
||||||
!iv_program TYPE programm .
|
!iv_program TYPE programm .
|
||||||
|
CLASS-METHODS get_method_includes
|
||||||
|
IMPORTING
|
||||||
|
!iv_classname TYPE seoclsname
|
||||||
|
RETURNING
|
||||||
|
VALUE(rt_includes) TYPE seop_methods_w_include.
|
||||||
|
CLASS-METHODS repair_classpool
|
||||||
|
IMPORTING
|
||||||
|
!is_key TYPE seoclskey
|
||||||
|
RAISING
|
||||||
|
zcx_abapgit_exception .
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
@ -195,6 +205,13 @@ CLASS zcl_abapgit_oo_class IMPLEMENTATION.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
|
METHOD get_method_includes.
|
||||||
|
" get method includes for implemented interfaces
|
||||||
|
" this will contain also leftover includes for deleted interface methods
|
||||||
|
rt_includes = cl_oo_classname_service=>get_all_method_includes( iv_classname ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
METHOD init_scanner.
|
METHOD init_scanner.
|
||||||
|
|
||||||
DATA: lx_exc TYPE REF TO cx_root,
|
DATA: lx_exc TYPE REF TO cx_root,
|
||||||
|
@ -224,6 +241,21 @@ CLASS zcl_abapgit_oo_class IMPLEMENTATION.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
|
METHOD repair_classpool.
|
||||||
|
|
||||||
|
CALL FUNCTION 'SEO_CLASS_REPAIR_CLASSPOOL'
|
||||||
|
EXPORTING
|
||||||
|
clskey = is_key
|
||||||
|
EXCEPTIONS
|
||||||
|
not_existing = 1
|
||||||
|
OTHERS = 2.
|
||||||
|
IF sy-subrc <> 0.
|
||||||
|
zcx_abapgit_exception=>raise( |Error repairing class { is_key-clsname }| ).
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
METHOD update_cs_number_of_methods.
|
METHOD update_cs_number_of_methods.
|
||||||
|
|
||||||
" Indirect access to keep downward compatibility
|
" Indirect access to keep downward compatibility
|
||||||
|
@ -490,6 +522,7 @@ CLASS zcl_abapgit_oo_class IMPLEMENTATION.
|
||||||
lv_program TYPE program,
|
lv_program TYPE program,
|
||||||
lo_scanner TYPE REF TO cl_oo_source_scanner_class,
|
lo_scanner TYPE REF TO cl_oo_source_scanner_class,
|
||||||
lt_methods TYPE cl_oo_source_scanner_class=>type_method_implementations,
|
lt_methods TYPE cl_oo_source_scanner_class=>type_method_implementations,
|
||||||
|
lt_incls TYPE seop_methods_w_include,
|
||||||
lv_method LIKE LINE OF lt_methods,
|
lv_method LIKE LINE OF lt_methods,
|
||||||
lt_public TYPE seop_source_string,
|
lt_public TYPE seop_source_string,
|
||||||
lt_source TYPE seop_source_string.
|
lt_source TYPE seop_source_string.
|
||||||
|
@ -548,6 +581,8 @@ CLASS zcl_abapgit_oo_class IMPLEMENTATION.
|
||||||
* methods
|
* methods
|
||||||
lt_methods = lo_scanner->get_method_implementations( ).
|
lt_methods = lo_scanner->get_method_implementations( ).
|
||||||
|
|
||||||
|
lt_incls = get_method_includes( is_key-clsname ).
|
||||||
|
|
||||||
LOOP AT lt_methods INTO lv_method.
|
LOOP AT lt_methods INTO lv_method.
|
||||||
TRY.
|
TRY.
|
||||||
lt_source = lo_scanner->get_method_impl_source( lv_method ).
|
lt_source = lo_scanner->get_method_impl_source( lv_method ).
|
||||||
|
@ -561,6 +596,9 @@ CLASS zcl_abapgit_oo_class IMPLEMENTATION.
|
||||||
update_report(
|
update_report(
|
||||||
iv_program = lv_program
|
iv_program = lv_program
|
||||||
it_source = lt_source ).
|
it_source = lt_source ).
|
||||||
|
|
||||||
|
" If method was implemented before, remove from list
|
||||||
|
DELETE lt_incls WHERE cpdkey-clsname = is_key-clsname AND cpdkey-cpdname = lv_method.
|
||||||
ENDLOOP.
|
ENDLOOP.
|
||||||
|
|
||||||
* full class include
|
* full class include
|
||||||
|
@ -568,6 +606,12 @@ CLASS zcl_abapgit_oo_class IMPLEMENTATION.
|
||||||
it_source = it_source
|
it_source = it_source
|
||||||
it_methods = lt_methods ).
|
it_methods = lt_methods ).
|
||||||
|
|
||||||
|
" If there are leftover method includes, then class needs to be repaired
|
||||||
|
" which will delete the obsolete includes
|
||||||
|
IF lt_incls IS NOT INITIAL.
|
||||||
|
repair_classpool( is_key ).
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
update_source_index(
|
update_source_index(
|
||||||
iv_clsname = is_key-clsname
|
iv_clsname = is_key-clsname
|
||||||
io_scanner = lo_scanner ).
|
io_scanner = lo_scanner ).
|
||||||
|
|
Loading…
Reference in New Issue
Block a user