abap-cleaner icon indicating copy to clipboard operation
abap-cleaner copied to clipboard

bugs in DDL Annotations -> Standardize annotation layout

Open dag27 opened this issue 3 months ago • 3 comments

Hi colleagues,

abap-cleaner does not align the following code correctly under DDL ANNOTATIONS -> Standardize annotation layout

  1. with option "Align 'tables' of structure-identical annotations in arrays" = true => Same fields should be aligned under each other in @UI.facet.
  2. with option "Align values of nested elements (unless an element contains a dot)" = true => values of @UI.headerInfo.typeName, @UI.headerInfo.typeNamePlural, ...title, and ...description should be aligned.

original: @Metadata.layer: #CORE @Search.searchable: true

@UI: { headerInfo: { typeName: 'Check Group Execution', typeNamePlural: 'Check Group Executions', title: { value: 'Id', label: 'Check Group Execution ID' }, description: { value: 'CheckGroupDefinitionId' } }, presentationVariant: [ { sortOrder: [ { by: 'StartDateTime', direction: #DESC } ] } ] }

annotate entity c_manage_abc with { @UI.facet:[ { type: #COLLECTION, id: 'List', label: 'Check Group Execution' }, { type: #LINEITEM_REFERENCE, id: 'CEX', label: 'Checks', position: 10, targetElement: 'CheckExecution' }, { type: #LINEITEM_REFERENCE, id: 'Sel', label: 'Selection Criteria', position: 20, targetElement: 'SelectionCriteria' }, { type: #LINEITEM_REFERENCE, id: 'ParamDef', label: 'Parameter Definition', position: 30, targetElement: 'ParameterDefinition' }, { type: #LINEITEM_REFERENCE, id: 'Log', label: 'Log', position: 40, targetElement: 'Log' },
{ type: #IDENTIFICATION_REFERENCE, id: 'Ident', label: 'Identification', position: 50 }, { type: #FIELDGROUP_REFERENCE, id: 'Exec', label: 'Execution', position: 60, targetQualifier: 'Exec' } ]

/* Element List */

@UI.hidden: true uuid;

}

abap-cleaner with "Align 'tables' of structure-identical annotations in arrays" = true with "Align values of nested elements (unless an element contains a dot)" = true

@Metadata.layer: #CORE @Search.searchable: true

@UI: { headerInfo: { typeName: 'Check Group Execution', typeNamePlural: 'Check Group Executions', title: { value: 'Id', label: 'Check Group Execution ID' }, description.value: 'CheckGroupDefinitionId' }, presentationVariant: [ { sortOrder: [ { by: 'StartDateTime', direction: #DESC } ] } ] }

annotate entity c_manage_abc with

{ @UI: { facet: [ { type: #COLLECTION, id: 'List', label: 'Check Group Execution' }, { type: #LINEITEM_REFERENCE, id: 'CEX', label: 'Checks', position: 10, targetElement: 'CheckExecution' }, { type: #LINEITEM_REFERENCE, id: 'Sel', label: 'Selection Criteria', position: 20, targetElement: 'SelectionCriteria' }, { type: #LINEITEM_REFERENCE, id: 'ParamDef', label: 'Parameter Definition', position: 30, targetElement: 'ParameterDefinition' }, { type: #LINEITEM_REFERENCE, id: 'Log', label: 'Log', position: 40, targetElement: 'Log' }, { type: #IDENTIFICATION_REFERENCE, id: 'Ident', label: 'Identification', position: 50 }, { type: #FIELDGROUP_REFERENCE, id: 'Exec', label: 'Execution', position: 60, targetQualifier: 'Exec' } ], hidden: true }

/* Element List */ uuid; }

Could you please fix this?

Thanks and best regards, Dirk Giebel

dag27 avatar Oct 01 '25 14:10 dag27

Hi Dirk,

so far, I think this is no defect (however, the spaces in your example code are gone, so I could just try the cleanup result on my computer):

Regarding 1.: This would work for an example like this …

Image

… however, in your example, the annotations are not "structure-identical": Some of the lines contain "targetElement", some contain "position", some "targetQualifier". As of now, alignment only works if all lines contain the same elements in the same sequence.

Also, in your case, a higher "Maximum line length for one-liners" (at least 140) and a higher "Max. number of elements for one-liners in select lists etc." (at least 5) would have to be configured.

Regarding 2.: This works for me if "Align values of nested elements (…)" is activated:

Image

Kind regards, Jörg-Michael

jmgrassau avatar Oct 01 '25 15:10 jmgrassau

Hi Dirk,

so far, I think this is no defect (however, the spaces in your example code are gone, so I could just try the cleanup result on my computer):

Regarding 1.: This would work for an example like this …

Image … however, in your example, the annotations are not "structure-identical": Some of the lines contain "targetElement", some contain "position", some "targetQualifier". As of now, alignment only works if all lines contain the same elements in the same sequence.

Also, in your case, a higher "Maximum line length for one-liners" (at least 140) and a higher "Max. number of elements for one-liners in select lists etc." (at least 5) would have to be configured.

Regarding 2.: This works for me if "Align values of nested elements (…)" is activated:

Image Kind regards, Jörg-Michael

Hi Jörg-Michael, bug only occurs when you do abap-cleaner on the complete file, including: /* Element List */ uuid; }

Image Image

BR, Dirk

dag27 avatar Oct 01 '25 17:10 dag27

P.S. concerning 1. yes, it is not "structure identical", meaning not in all lines the same fields are maintained. But in an structure of an array you do only have to maintain the elements for which you want to set a value. I would be nice if this would also work when not all fields are maintained. Just leave the corresponding area blank where the element is not maintained: a = '' b = '' c = '' a = ''______ c = '' ______b = '' c = ''

dag27 avatar Oct 01 '25 17:10 dag27