Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from flaiker/processor-impl
Implement remaining processors
- Loading branch information
Showing
8 changed files
with
252 additions
and
163 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,52 @@ | ||
"! Attribute processor | ||
CLASS zcl_aap_proc_attribute DEFINITION | ||
PUBLIC | ||
FINAL | ||
INHERITING FROM zcl_aap_proc_base | ||
CREATE PRIVATE. | ||
CREATE PRIVATE | ||
GLOBAL FRIENDS zcl_aap_proc_object. | ||
|
||
PUBLIC SECTION. | ||
METHODS: | ||
load_all REDEFINITION, | ||
is_annotation_present_by_name REDEFINITION, | ||
is_annotation_present_by_descr REDEFINITION, | ||
get_annotation_by_name REDEFINITION, | ||
get_annotation_by_descr REDEFINITION, | ||
get_annotations REDEFINITION. | ||
DATA: | ||
"! Name of the containing class or interface | ||
mv_containing_object_name TYPE abap_classname READ-ONLY, | ||
"! Attribute description | ||
ms_attribute_description TYPE abap_attrdescr READ-ONLY, | ||
"! Attribute name in its containing object | ||
mv_attribute_name TYPE abap_attrname READ-ONLY. | ||
PROTECTED SECTION. | ||
PRIVATE SECTION. | ||
METHODS: | ||
constructor IMPORTING is_attribute_description TYPE abap_attrdescr | ||
iv_containing_object_name TYPE abap_classname. | ||
ENDCLASS. | ||
|
||
|
||
|
||
CLASS zcl_aap_proc_attribute IMPLEMENTATION. | ||
METHOD load_all. | ||
|
||
ENDMETHOD. | ||
METHOD constructor. | ||
super->constructor( ). | ||
|
||
METHOD get_annotations. | ||
ASSERT: iv_containing_object_name IS NOT INITIAL, | ||
is_attribute_description IS NOT INITIAL. | ||
|
||
mv_containing_object_name = iv_containing_object_name. | ||
ms_attribute_description = is_attribute_description. | ||
mv_attribute_name = is_attribute_description-name. | ||
ENDMETHOD. | ||
|
||
METHOD get_annotation_by_descr. | ||
|
||
METHOD load_all ##NEEDED. | ||
" Nothing to do here | ||
ENDMETHOD. | ||
|
||
METHOD get_annotation_by_name. | ||
|
||
ENDMETHOD. | ||
|
||
METHOD is_annotation_present_by_descr. | ||
|
||
ENDMETHOD. | ||
|
||
METHOD is_annotation_present_by_name. | ||
|
||
METHOD get_annotations. | ||
" TODO: Think of propagating the exception in some way | ||
rt_annotations = get_resolver( )->get_annotations_for_attribute( | ||
iv_containing_object_name = mv_containing_object_name | ||
iv_attribute_name = mv_attribute_name | ||
). | ||
ENDMETHOD. | ||
ENDCLASS. |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,110 @@ | ||
"! Method processor | ||
CLASS zcl_aap_proc_method DEFINITION | ||
PUBLIC | ||
FINAL | ||
INHERITING FROM zcl_aap_proc_base | ||
CREATE PUBLIC. | ||
CREATE PRIVATE | ||
GLOBAL FRIENDS zcl_aap_proc_object. | ||
|
||
PUBLIC SECTION. | ||
TYPES: | ||
BEGIN OF gty_parameter_proc, | ||
parameter_name TYPE abap_parmname, | ||
processor TYPE REF TO zcl_aap_proc_parameter, | ||
END OF gty_parameter_proc, | ||
gty_parameter_proc_tab TYPE SORTED TABLE OF gty_parameter_proc | ||
WITH UNIQUE KEY parameter_name. | ||
METHODS: | ||
"! | ||
"! @parameter ro_processor | | ||
get_parameter_processor RETURNING VALUE(ro_processor) TYPE REF TO zcl_aap_proc_parameter, | ||
"! Get all parameter processors | ||
"! @parameter rt_processors | Parameter processors | ||
get_parameter_processors RETURNING VALUE(rt_processors) TYPE gty_parameter_proc_tab, | ||
"! Get parameter processor by name | ||
"! @parameter iv_parameter_name | Parameter name | ||
"! @parameter ro_processor | Found parameter processor | ||
"! @raising zcx_aap_illegal_argument | Parameter does not exist | ||
get_parameter_processor IMPORTING iv_parameter_name TYPE abap_parmname | ||
RETURNING VALUE(ro_processor) TYPE REF TO zcl_aap_proc_parameter | ||
RAISING zcx_aap_illegal_argument, | ||
load_all REDEFINITION, | ||
is_annotation_present_by_name REDEFINITION, | ||
is_annotation_present_by_descr REDEFINITION, | ||
get_annotation_by_name REDEFINITION, | ||
get_annotation_by_descr REDEFINITION, | ||
get_annotations REDEFINITION. | ||
DATA: | ||
mv_method_name TYPE abap_methname READ-ONLY. | ||
"! Name of the containing class or interface | ||
mv_containing_object_name TYPE abap_classname READ-ONLY, | ||
"! Name of the method in its containing object | ||
mv_method_name TYPE abap_methname READ-ONLY, | ||
"! Method description | ||
ms_method_description TYPE abap_methdescr READ-ONLY. | ||
PROTECTED SECTION. | ||
PRIVATE SECTION. | ||
METHODS: | ||
constructor IMPORTING is_methdescr TYPE abap_methdescr | ||
iv_containing_object_name TYPE abap_classname, | ||
load_parameters. | ||
DATA: | ||
mt_parameter_processor_cache TYPE gty_parameter_proc_tab. | ||
ENDCLASS. | ||
|
||
|
||
|
||
CLASS zcl_aap_proc_method IMPLEMENTATION. | ||
METHOD load_all. | ||
METHOD constructor. | ||
super->constructor( ). | ||
|
||
ENDMETHOD. | ||
|
||
METHOD get_annotations. | ||
ASSERT: is_methdescr IS NOT INITIAL, | ||
iv_containing_object_name IS NOT INITIAL. | ||
|
||
ms_method_description = is_methdescr. | ||
mv_method_name = is_methdescr-name. | ||
mv_containing_object_name = iv_containing_object_name. | ||
ENDMETHOD. | ||
|
||
METHOD get_annotation_by_descr. | ||
METHOD load_all. | ||
|
||
ENDMETHOD. | ||
|
||
METHOD get_annotation_by_name. | ||
|
||
METHOD get_annotations. | ||
" TODO: Think of propagating the exception in some way | ||
rt_annotations = get_resolver( )->get_annotations_for_method( | ||
iv_containing_object_name = mv_containing_object_name | ||
iv_method_name = mv_method_name | ||
). | ||
ENDMETHOD. | ||
|
||
METHOD get_parameter_processor. | ||
METHOD get_parameter_processors. | ||
" On demand lazy loading of processors | ||
IF lines( mt_parameter_processor_cache ) = 0. | ||
load_parameters( ). | ||
ENDIF. | ||
|
||
rt_processors = mt_parameter_processor_cache. | ||
ENDMETHOD. | ||
|
||
METHOD is_annotation_present_by_descr. | ||
|
||
METHOD get_parameter_processor. | ||
DATA(lt_processors) = get_parameter_processors( ). | ||
|
||
TRY. | ||
ro_processor = lt_processors[ parameter_name = iv_parameter_name ]-processor. | ||
CATCH cx_sy_itab_line_not_found INTO DATA(lx_ex). | ||
MESSAGE e019(zaap) WITH iv_parameter_name INTO DATA(lv_reason). | ||
RAISE EXCEPTION TYPE zcx_aap_illegal_argument | ||
EXPORTING | ||
is_textid = zcx_aap_illegal_argument=>gc_with_name_and_reason | ||
ix_previous = lx_ex | ||
iv_name = 'IV_PARAMETER_NAME' | ||
iv_reason = lv_reason | ||
iv_value = iv_parameter_name ##NO_TEXT. | ||
ENDTRY. | ||
ENDMETHOD. | ||
|
||
METHOD is_annotation_present_by_name. | ||
|
||
METHOD load_parameters. | ||
LOOP AT ms_method_description-parameters ASSIGNING FIELD-SYMBOL(<ls_parameter>). | ||
INSERT VALUE #( parameter_name = <ls_parameter>-name | ||
processor = NEW zcl_aap_proc_parameter( | ||
is_parameter_description = <ls_parameter> | ||
iv_containing_object_name = mv_containing_object_name | ||
iv_containing_method_name = mv_method_name | ||
) | ||
) INTO TABLE mt_parameter_processor_cache. | ||
ENDLOOP. | ||
ENDMETHOD. | ||
ENDCLASS. |
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
Oops, something went wrong.