Created
March 23, 2021 19:00
-
-
Save mbtools/1d67bd896b395b4cc98b171ce606a17c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*&---------------------------------------------------------------------* | |
*& Report ZABAPLINT_LOOKUP | |
*&---------------------------------------------------------------------* | |
*& Takes location of abaplint issue and displays corresponding ABAP code | |
*& or directly jumps to code | |
*& Input example: | |
*& Check failure on line 931 in src/core/#mbtools#cl_tools.clas.abap | |
*&---------------------------------------------------------------------* | |
REPORT zabaplint_lookup. | |
PARAMETERS: | |
p_check TYPE string LOWER CASE, | |
p_jump AS CHECKBOX DEFAULT 'X'. | |
DATA: | |
gv_line TYPE n LENGTH 10, | |
gv_line_number TYPE i, | |
gs_item TYPE zif_abapgit_definitions=>ty_item, | |
gt_source TYPE zif_abapgit_definitions=>ty_string_tt, | |
gv_clsname TYPE seoclsname, | |
gv_program TYPE progname. | |
AT LINE-SELECTION. | |
CALL FUNCTION 'RS_TOOL_ACCESS' | |
EXPORTING | |
operation = 'SHOW' | |
object_name = gv_program | |
object_type = 'PROG' | |
include = gv_program | |
position = gv_line_number | |
in_new_window = abap_false | |
EXCEPTIONS | |
not_executed = 1 | |
invalid_object_type = 2 | |
OTHERS = 3. | |
CLEAR: gs_item, gv_program, gv_line_number. | |
START-OF-SELECTION. | |
IF p_jump IS INITIAL. | |
WRITE: / p_check. | |
ENDIF. | |
FIND REGEX '(\d*) IN SRC\/(.*)\.(.*)\.ABAP' IN to_upper( p_check ) SUBMATCHES gv_line DATA(gv_obj_name) DATA(gv_obj_type). | |
IF sy-subrc <> 0. | |
WRITE: / 'Not found' COLOR COL_NEGATIVE. | |
RETURN. | |
ENDIF. | |
DO 5 TIMES. | |
IF gv_obj_name CS '/'. | |
SPLIT gv_obj_name AT '/' INTO sy-lisel gv_obj_name. | |
ENDIF. | |
ENDDO. | |
REPLACE ALL OCCURRENCES OF '#' IN gv_obj_name WITH '/'. | |
IF gv_obj_type CS '.'. | |
SPLIT gv_obj_type AT '.' INTO gv_obj_type DATA(gv_type). | |
ENDIF. | |
gv_line_number = gv_line. | |
IF p_jump IS INITIAL. | |
WRITE: / gv_obj_type, gv_obj_name, gv_line_number, gv_type. | |
ULINE. | |
ENDIF. | |
gs_item-obj_type = gv_obj_type. | |
gs_item-obj_name = gv_clsname = gv_obj_name. | |
CASE gv_obj_type. | |
WHEN 'CLAS'. | |
CASE gv_type. | |
WHEN 'LOCALS_DEF'. | |
PERFORM read_include USING gv_clsname seop_ext_class_locals_def CHANGING gt_source gv_program. | |
WHEN 'LOCALS_IMP'. | |
PERFORM read_include USING gv_clsname seop_ext_class_locals_imp CHANGING gt_source gv_program. | |
WHEN 'MACROS'. | |
PERFORM read_include USING gv_clsname seop_ext_class_macros CHANGING gt_source gv_program. | |
WHEN 'TESTCLASSES'. | |
PERFORM read_include USING gv_clsname seop_ext_class_testclasses CHANGING gt_source gv_program. | |
WHEN OTHERS. | |
PERFORM read_class USING gv_clsname gv_line CHANGING gt_source gv_program gv_line_number. | |
ENDCASE. | |
WHEN 'INTF'. | |
PERFORM read_interface USING gv_clsname CHANGING gt_source gv_program. | |
WHEN 'PROG'. | |
gv_program = gv_obj_name. | |
READ REPORT gv_program INTO gt_source STATE 'A'. | |
WHEN OTHERS. | |
WRITE: / 'Not supported' COLOR COL_NEGATIVE. | |
RETURN. | |
ENDCASE. | |
IF p_jump IS INITIAL. | |
LOOP AT gt_source INTO DATA(gv_source) FROM ( gv_line - 10 ) TO ( gv_line + 10 ). | |
IF sy-tabix = gv_line. | |
FORMAT COLOR COL_NORMAL INTENSIFIED OFF. | |
WRITE: / sy-tabix HOTSPOT, gv_source HOTSPOT, AT 200 space. | |
HIDE: gs_item, gv_program, gv_line_number. | |
ELSE. | |
FORMAT COLOR COL_NORMAL INTENSIFIED. | |
WRITE: / sy-tabix, gv_source, AT 200 space. | |
ENDIF. | |
ENDLOOP. | |
ELSE. | |
CALL FUNCTION 'RS_TOOL_ACCESS' | |
EXPORTING | |
operation = 'SHOW' | |
object_name = gv_program | |
object_type = 'PROG' | |
include = gv_program | |
position = gv_line_number | |
in_new_window = abap_false | |
EXCEPTIONS | |
not_executed = 1 | |
invalid_object_type = 2 | |
OTHERS = 3. | |
CHECK sy-subrc = 0. | |
ENDIF. | |
FORM read_class | |
USING | |
iv_clsname | |
iv_line | |
CHANGING | |
rt_source TYPE rswsourcet | |
rv_program TYPE progname | |
rv_line TYPE i. | |
DATA: | |
lo_instance TYPE REF TO cl_oo_factory, | |
lo_source TYPE REF TO cl_oo_clif_source, | |
lo_scanner TYPE REF TO cl_oo_source_scanner_class, | |
ls_int TYPE cl_oo_source_scanner_class=>type_source_interval, | |
ls_method TYPE seocpdkey. | |
TRY. | |
lo_instance = cl_oo_factory=>create_instance( ). | |
lo_source ?= lo_instance->create_clif_source( | |
clif_name = iv_clsname | |
version = 'A' ). | |
lo_source->get_source( | |
IMPORTING | |
source = rt_source ). | |
lo_scanner ?= lo_source->get_scanner( ). | |
ls_int = lo_scanner->get_public_section_interval( ). | |
IF iv_line >= ls_int-begin-line AND iv_line < ls_int-end-line. | |
rv_program = cl_oo_classname_service=>get_pubsec_name( iv_clsname ). | |
rv_line = iv_line - ls_int-begin-line + 1. | |
RETURN. | |
ENDIF. | |
ls_int = lo_scanner->get_protected_section_interval( ). | |
IF iv_line >= ls_int-begin-line AND iv_line < ls_int-end-line. | |
rv_program = cl_oo_classname_service=>get_prosec_name( iv_clsname ). | |
rv_line = iv_line - ls_int-begin-line + 1. | |
RETURN. | |
ENDIF. | |
ls_int = lo_scanner->get_private_section_interval( ). | |
IF iv_line >= ls_int-begin-line AND iv_line < ls_int-end-line. | |
rv_program = cl_oo_classname_service=>get_prisec_name( iv_clsname ). | |
rv_line = iv_line - ls_int-begin-line + 1. | |
RETURN. | |
ENDIF. | |
ls_method-clsname = iv_clsname. | |
LOOP AT lo_scanner->get_method_implementations( ) INTO ls_method-cpdname. | |
ls_int = lo_scanner->get_method_impl_interval( ls_method-cpdname ). | |
IF iv_line >= ls_int-begin-line AND iv_line < ls_int-end-line. | |
rv_program = cl_oo_classname_service=>get_method_include( ls_method ). | |
rv_line = iv_line - ls_int-begin-line + 1. | |
RETURN. | |
ENDIF. | |
ENDLOOP. | |
CATCH cx_root INTO DATA(lx_error). | |
MESSAGE lx_error TYPE 'S' DISPLAY LIKE 'E'. | |
ENDTRY. | |
ENDFORM. | |
FORM read_interface | |
USING | |
iv_clsname | |
CHANGING | |
rt_source TYPE rswsourcet | |
rv_program TYPE progname. | |
rv_program = cl_oo_classname_service=>get_intfsec_name( iv_clsname ). | |
READ REPORT rv_program INTO rt_source STATE 'A'. | |
ENDFORM. | |
FORM read_include | |
USING | |
iv_clsname | |
iv_type | |
CHANGING | |
rt_source TYPE rswsourcet | |
rv_program TYPE progname. | |
DATA: ls_include TYPE progstruc. | |
ASSERT iv_type = seop_ext_class_locals_def | |
OR iv_type = seop_ext_class_locals_imp | |
OR iv_type = seop_ext_class_macros | |
OR iv_type = seop_ext_class_testclasses. | |
ls_include-rootname = iv_clsname. | |
TRANSLATE ls_include-rootname USING ' ='. | |
ls_include-categorya = iv_type(1). | |
ls_include-codea = iv_type+1(4). | |
READ REPORT ls_include INTO rt_source STATE 'A'. | |
rv_program = ls_include. | |
ENDFORM. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment