Skip to content

Commit

Permalink
Add interface for generator (#269)
Browse files Browse the repository at this point in the history
* Add interface for generator

* Fix abaplint findings

* Add alias

* Add generate method

* Remove duplicate method generate_type

* Update cl_run.clas.abap
  • Loading branch information
wurzka authored Aug 9, 2023
1 parent 01f67ac commit 25ff402
Show file tree
Hide file tree
Showing 10 changed files with 640 additions and 622 deletions.
2 changes: 1 addition & 1 deletion src/z_generate_json_schema.prog.abap
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ CLASS lcl_generator_helper IMPLEMENTATION.
ENDIF.

DATA(generator) = NEW zcl_aff_generator( writer ).
DATA(result_table) = generator->generate_type( <field> ).
DATA(result_table) = generator->zif_aff_generator~generate_type( <field> ).
CONCATENATE LINES OF result_table INTO result SEPARATED BY cl_abap_char_utilities=>newline.

ENDMETHOD.
Expand Down
8 changes: 4 additions & 4 deletions src/z_generate_repo.prog.abap
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ CLASS lcl_generator_helper IMPLEMENTATION.
ENDMETHOD.

METHOD lif_generator~generate_type.
result = me->generator->generate_type( data ).
result = me->generator->zif_aff_generator~generate_type( data ).
ENDMETHOD.

METHOD lif_generator~get_log.
log = me->generator->get_log( ).
log = me->generator->zif_aff_generator~get_log( ).
ENDMETHOD.

ENDCLASS.
Expand Down Expand Up @@ -266,8 +266,8 @@ CLASS lcl_generator IMPLEMENTATION.
IF NOT intf_name CP `z*`.
INSERT VALUE #( to_be_replaced = intf_name replace_with = get_objname_wo_namspace_with_z( to_lower( <intf> ) ) ) INTO TABLE replacing_table_string.
IF intf_name CP `*/*`.
REPLACE FIRST OCCURRENCE OF '/' IN intf_name WITH'('.
REPLACE FIRST OCCURRENCE OF '/' IN intf_name WITH')'.
REPLACE FIRST OCCURRENCE OF '/' IN intf_name WITH '('.
REPLACE FIRST OCCURRENCE OF '/' IN intf_name WITH ')'.
INSERT VALUE #( to_be_replaced = intf_name replace_with = get_objname_wo_namspace_with_z( to_lower( <intf> ) ) ) INTO TABLE replacing_table_string.
ENDIF.
ENDIF.
Expand Down
8 changes: 4 additions & 4 deletions src/zcl_aff_abap_doc_parser.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ CLASS ltcl_aff_abap_doc_parser IMPLEMENTATION.
to_parse = abap_doc_to_parse
CHANGING
log = log ).
exp_abap_doc = VALUE #( description = `This is the description.` title = `Title`).
exp_abap_doc = VALUE #( description = `This is the description.` title = `Title` ).
cl_abap_unit_assert=>assert_equals( exp = exp_abap_doc act = act_abap_doc ).
zcl_aff_tools_unit_test_helper=>assert_log_has_no_message( log = log message_severity_threshold = zif_aff_log=>c_message_type-info ).
ENDMETHOD.
Expand All @@ -72,7 +72,7 @@ CLASS ltcl_aff_abap_doc_parser IMPLEMENTATION.
to_parse = abap_doc_to_parse
CHANGING
log = log ).
exp_abap_doc = VALUE #( description = `This is the description.` title = `Title` minimum = `12` default = `"20"`).
exp_abap_doc = VALUE #( description = `This is the description.` title = `Title` minimum = `12` default = `"20"` ).
cl_abap_unit_assert=>assert_equals( exp = exp_abap_doc act = act_abap_doc ).
zcl_aff_tools_unit_test_helper=>assert_log_has_no_message( log = log message_severity_threshold = zif_aff_log=>c_message_type-info ).
ENDMETHOD.
Expand Down Expand Up @@ -509,7 +509,7 @@ CLASS ltcl_aff_abap_doc_parser IMPLEMENTATION.
to_parse = abap_doc_to_parse
CHANGING
log = log ).
exp_abap_doc = VALUE #( title = `Title` minimum = `12` default = `"20"`).
exp_abap_doc = VALUE #( title = `Title` minimum = `12` default = `"20"` ).
cl_abap_unit_assert=>assert_equals( exp = exp_abap_doc act = act_abap_doc ).
zcl_aff_tools_unit_test_helper=>assert_log_contains_text( log = log
exp_text = zif_aff_log=>co_msg115
Expand All @@ -525,7 +525,7 @@ CLASS ltcl_aff_abap_doc_parser IMPLEMENTATION.
to_parse = abap_doc_to_parse
CHANGING
log = log ).
exp_abap_doc = VALUE #( description = `Here is text between annotation` title = `Title` required = abap_true default = `@link cl_aff_test_types_for_writer.data:enum_values.classic_badi`).
exp_abap_doc = VALUE #( description = `Here is text between annotation` title = `Title` required = abap_true default = `@link cl_aff_test_types_for_writer.data:enum_values.classic_badi` ).
cl_abap_unit_assert=>assert_equals( exp = exp_abap_doc act = act_abap_doc ).
zcl_aff_tools_unit_test_helper=>assert_log_contains_text( log = log
exp_text = zif_aff_log=>co_msg116
Expand Down
18 changes: 3 additions & 15 deletions src/zcl_aff_generator.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,11 @@ CLASS zcl_aff_generator DEFINITION
CREATE PUBLIC.

PUBLIC SECTION.
INTERFACES zif_aff_generator.
METHODS constructor
IMPORTING
writer TYPE REF TO zif_aff_writer.

METHODS generate_type
IMPORTING
data TYPE data
RETURNING
VALUE(result) TYPE string_table
RAISING
zcx_aff_tools.

METHODS get_log
RETURNING
VALUE(log) TYPE REF TO zif_aff_log.

PRIVATE SECTION.
DATA:
writer TYPE REF TO zif_aff_writer,
Expand Down Expand Up @@ -80,7 +69,7 @@ CLASS zcl_aff_generator IMPLEMENTATION.
log = NEW zcl_aff_log( ).
ENDMETHOD.

METHOD generate_type.
METHOD zif_aff_generator~generate_type.
DATA(type_description) = cl_abap_typedescr=>describe_by_data( data ).
check_input( type_description ).
process_type_description( type_description ).
Expand Down Expand Up @@ -187,8 +176,7 @@ CLASS zcl_aff_generator IMPLEMENTATION.
node_description = table_description ).
ENDMETHOD.


METHOD get_log.
METHOD zif_aff_generator~get_log.
log = me->log.
ENDMETHOD.

Expand Down
6 changes: 3 additions & 3 deletions src/zcl_aff_generator.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ CLASS ltcl_type_generator DEFINITION FINAL FOR TESTING

PRIVATE SECTION.
DATA:
cut TYPE REF TO zcl_aff_generator,
cut TYPE REF TO zif_aff_generator,
exp_result TYPE string_table.

METHODS:
Expand All @@ -222,8 +222,8 @@ CLASS ltcl_type_generator DEFINITION FINAL FOR TESTING
no_header FOR TESTING RAISING cx_static_check,
no_format_version FOR TESTING RAISING cx_static_check,
no_structure FOR TESTING RAISING cx_static_check,
structure_on_top_level FOR TESTING RAISING cx_static_check,
table_on_top_level FOR TESTING RAISING cx_static_check,
structure_on_top_level FOR TESTING RAISING cx_static_check,
table_on_top_level FOR TESTING RAISING cx_static_check,
setup,
assert_output_equals
IMPORTING
Expand Down
4 changes: 2 additions & 2 deletions src/zcl_aff_writer_json_schema.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CLASS ltcl_json_writer DEFINITION FINAL FOR TESTING

DATA:
cut TYPE REF TO zcl_aff_writer_json_schema,
test_generator TYPE REF TO zcl_aff_generator.
test_generator TYPE REF TO zif_aff_generator.

METHODS: use_ddic_info_for_element FOR TESTING RAISING cx_static_check,
date_time_element FOR TESTING RAISING cx_static_check,
Expand Down Expand Up @@ -496,7 +496,7 @@ CLASS ltcl_json_writer_abap_doc DEFINITION FINAL FOR TESTING
CONSTANTS:
schema_id TYPE string VALUE 'schema/id.json'.
DATA cut TYPE REF TO zcl_aff_writer_json_schema.
DATA test_generator TYPE REF TO zcl_aff_generator.
DATA test_generator TYPE REF TO zif_aff_generator.
DATA log TYPE REF TO zif_aff_log.

METHODS setup.
Expand Down
Loading

0 comments on commit 25ff402

Please sign in to comment.