You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"Convert upper/lower" case rule does not consider first statement in global class #92
Our team uses the option "Derive from first statement" of the Convert upper/lower case rule. We do this because we work mostly with legacy code and want to keep the formatting settings of the original author.
However, i found a quirky bug when running the rule on global class:
classZCL_TEST definition public final create public .
public section.
METHODS foo.
protected section.
private section.
endclass.
CLASSZCL_TEST IMPLEMENTATION. " I think that SE80 converts this to all-CAPSmethodFOO.
data VAR1 type I.
data VAR2 type I.
final(VAR3) = VAR1 + VAR2.
endmethod.
ENDCLASS.
When i run the abapCleaner on the lines-of-code of FOO( ), it formats everything to CAPS.
methodFOO.
DATA VAR1 TYPE I.
DATA VAR2 TYPE I.
" TODO: variable is assigned but never used (ABAP cleaner)FINAL(VAR3) = VAR1 + VAR2.
endmethod.
My expectation was that the abapCleaner derives the formatting settings from the class ZCL_TEST definition line which are:
keywords in lower case
identifiers in UPPER CASE
The ABAP formatter (aka Pretty Printer) works as expected.
changed the title [-]"Convert upper/lower" rule does not consider first statement in global class[/-][+]"Convert upper/lower" case rule does not consider first statement in global class[/+]on Aug 16, 2023
with "Derive from first statement", ABAP cleaner indeed separately determines the casing from
the first statement in a class definition (i.e. the CLASS ... DEFINITION line itself)
the first statement in a class implementation (i.e. the CLASS ... IMPLEMENTATION line itself)
The idea behind this is that in class definitions, SE80 always seems to use lower case keywords and upper case identifiers (regardless of the settings in menu "Utilities / Settings" -> ABAP Editor -> Pretty Printer), while for class implementations, SE80 does observe these settings, so SE80 could produce different formatting for the implementations (e.g. upper case keywords and lower case identifiers).
Therefore, if "derive from first statement" would now only derive the settings from the CLASS … DEFINITION line and someone in the team still uses SE80, you would always end up to have everything in lower case keywords and upper case identifiers – and that might not be intended, even by the SE80 users.
But you're right: SE80 does seem to put CLASS <NAME> IMPLEMENTATION to upper case! That makes this line rather useless to derive the settings from, of course. I think the best way to solve this would be to derive the settings for the implementation part from the first "METHOD method_name" line.
If that's still not satisfying, we could of course consider to add another option to the "Auto-determine upper/lower case" selection, so everyone could decide for themselves:
"derive from first statement in code document" (as ABAP Formatter does)
"derive from first statement of a class definition / method implementation"
Activity
[-]"Convert upper/lower" rule does not consider first statement in global class[/-][+]"Convert upper/lower" case rule does not consider first statement in global class[/+]jmgrassau commentedon Sep 4, 2023
Hi Suhas,
with "Derive from first statement", ABAP cleaner indeed separately determines the casing from
The idea behind this is that in class definitions, SE80 always seems to use lower case keywords and upper case identifiers (regardless of the settings in menu "Utilities / Settings" -> ABAP Editor -> Pretty Printer), while for class implementations, SE80 does observe these settings, so SE80 could produce different formatting for the implementations (e.g. upper case keywords and lower case identifiers).
Therefore, if "derive from first statement" would now only derive the settings from the CLASS … DEFINITION line and someone in the team still uses SE80, you would always end up to have everything in lower case keywords and upper case identifiers – and that might not be intended, even by the SE80 users.
But you're right: SE80 does seem to put
CLASS <NAME> IMPLEMENTATIONto upper case! That makes this line rather useless to derive the settings from, of course. I think the best way to solve this would be to derive the settings for the implementation part from the first "METHOD method_name" line.If that's still not satisfying, we could of course consider to add another option to the "Auto-determine upper/lower case" selection, so everyone could decide for themselves:
Kind regards,
Jörg-Michael
jmgrassau commentedon Sep 4, 2023
Hi Suhas,
so now with

the implementation section depends on the first "METHOD …" line, therefore you'd get:
Kind regards,
Jörg-Michael
suynwa commentedon Sep 4, 2023
"derive from first statement of a class definition / method implementation"
This is promising 🥇
fix UpperAndLowerCaseRule derive option for implementation section (S…
fix UpperAndLowerCaseRule derive option for implementation section (#92)
jmgrassau commentedon Sep 4, 2023
Hi Suhas,
thanks again for this hint! The renamed option and adjusted behavior was now released with version 1.5.3, hope it helps!
Kind regards,
Jörg-Michael