Special comments in the Jedi Code Formatter

The code formatter now  recognizes certain comments  to disable and enable formatting options around blocks of code.

Since the earliest versions, the comments {(*} and {*)} could be used to disable and reenable formatting respectively, in order to exclude a block of code from formatting. 

From version 0.52, a more extensive syntax has been implemented to allow for fine-grained control over which formatting options are temporarily disabled. The original special comments {(*} and {*)} are retained as synonymns for //jcf:format=off and //jcf:format=on  respectively.

For instance, in the following line of code, the formatter will not alter the spacing

//jcf:space=off
  a   :=     a     +     1   ;
//jcf:space=on

As you can see, the new syntax has the form of a comment like //jcf:flag=state, where state is one of on or off, and the flags are listed below.

Flags

Flag Description
all all=on is used to reverse the effects of all off comments, as described below. all=off is not valid
format All formatting
space All processes that insert or remove spaces
addspace All processes that insert spaces
removespace All processes that remove spaces
return All processes that insert or remove returns
addreturn All processes that insert returns
removereturn All processes that remove returns
add All processes that insert spaces or returns
remove All processes that remove spaces or returns
align All processes that align statements - i.e. alignment of variables, constants, types and assignment statements
aligndef Alignment of variables, constants and types
alignfn Alignment of variables and assignments
alignvars Alignment of variables
alignconst Alignment of constants
aligntypedef Alignment of types
alignassign Alignment of assignment
indent Correct block indent of statements and declarations
caps Capitalisation of reserved words or user-specified words
capsreservedwords Capitalisation of reserved words
capsspecificwords Capitalisation of user-specified words
linebreaking Breaking of long lines
blockstyle Line-breaking in blocks of statements
warnings Warnings generated by the code fornatter
findreplace Find and replace
findreplaceuses Maniupulation of the uses clause

The following rules apply:

For exampes see the test case unit TestExclusionFlags.pas, for implmentation see the unit FormatFlags.pas


Index