How to Sort the Headers of the Methods ?
Posted: Mon Aug 30, 2010 1:30 pm
I personnaly like to have the local variables names in the header of a function sorted. I can do this with this function:
My question is: How do we sort the headers of the methods in a Class ?
Thanks in advance,
Pierre Gilbert
Code: Select all
r←SortHeader fn_name;header;inter;nr;vars
⍝ Sort the Header of a Function
⍝
⍝ fn_name = Function Name
⍝ Nested Representation of Function
nr←⎕NR fn_name
⍝ Removes the extra Blanks at the End of each line of the Function
nr←(-¯1+(⌽¨' '=¨nr)⍳¨0)↓¨nr
⍝ Extract the Header of the Function
header←1⊃nr
⍝ Check if there is local variables to sort in header
:If ~';'∊header
⍝ no ';' in header. Return without fixing the function.
r←'' ⋄ →0
:Else
⍝ There is local variables in Header
⍝ Split the Header
vars←(header⍳';')↓header
⍝ Sort the variables
vars←';'{⎕ML←1 ⋄ ↑1↓¨(1,⍺=⍵)⊂⍺,⍵}(vars~' ')
vars←vars[⎕AV⍋vars;]
vars←(,';',vars)~' '
⍝ Reassemble the header
header←((¯1+header⍳';')↑header),vars
⍝ Insert the Sorted Header in ⎕NR of function
(1⊃nr)←header
:End
:If (inter←⎕FX nr)≢(fn_name~' ')
⍝ Failure
'Not Able to Fix ',fn_name,' at line: ',⍕inter
:Else
⍝ Success
'Function Sorted: ',fn_name
:EndIf
My question is: How do we sort the headers of the methods in a Class ?
Thanks in advance,
Pierre Gilbert