Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
larshp committed Aug 17, 2023
1 parent b103fd8 commit 289ad10
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
10 changes: 3 additions & 7 deletions src/model/zcl_protobuf2_file.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,15 @@ CLASS zcl_protobuf2_file DEFINITION PUBLIC.

INTERFACES zif_protobuf2_artefact.

DATA mt_messages TYPE STANDARD TABLE OF REF TO zcl_protobuf2_message WITH EMPTY KEY.
DATA mt_enums TYPE STANDARD TABLE OF REF TO zcl_protobuf2_enum WITH EMPTY KEY.
DATA mt_artefacts TYPE STANDARD TABLE OF REF TO zif_protobuf2_artefact WITH EMPTY KEY.
ENDCLASS.

CLASS zcl_protobuf2_file IMPLEMENTATION.

METHOD zif_protobuf2_artefact~serialize.
rv_string = |syntax = "proto2";|.
LOOP AT mt_messages INTO DATA(lo_message).
rv_string = rv_string && |\n| && lo_message->zif_protobuf2_artefact~serialize( ).
ENDLOOP.
LOOP AT mt_enums INTO DATA(lo_enum).
rv_string = rv_string && |\n| && lo_enum->zif_protobuf2_artefact~serialize( ).
LOOP AT mt_artefacts INTO DATA(lo_artefact).
rv_string = rv_string && |\n| && lo_artefact->serialize( ).
ENDLOOP.
ENDMETHOD.

Expand Down
4 changes: 2 additions & 2 deletions src/parser/zcl_protobuf2_parser.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ CLASS zcl_protobuf2_parser IMPLEMENTATION.
DATA(lv_token) = io_stream->take_token( ).
CASE lv_token.
WHEN 'message'.
APPEND message( io_stream ) TO io_file->mt_messages.
APPEND message( io_stream ) TO io_file->mt_artefacts.
WHEN 'enum'.
APPEND enum( io_stream ) TO io_file->mt_enums.
APPEND enum( io_stream ) TO io_file->mt_artefacts.
WHEN OTHERS.
WRITE: / 'todo, handle token:', lv_token.
ASSERT 1 = 'todo'.
Expand Down
2 changes: 1 addition & 1 deletion src/parser/zcl_protobuf2_parser.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ CLASS ltcl_test IMPLEMENTATION.

cl_abap_unit_assert=>assert_equals(
exp = 3
act = lines( lo_file->mt_messages ) ).
act = lines( lo_file->mt_artefacts ) ).

cl_abap_unit_assert=>assert_equals(
exp = lv_proto
Expand Down

0 comments on commit 289ad10

Please sign in to comment.