http://www.jindent.com |
|
Next: Method Calls |
Maximal gap size of indentations for multiple variable and field declarations |
class MyConstants | { | public: | static char[] constantOne = "Some text here ...", | |--------------------|constantTwo = "Some other text...", | constantThree = CALC_TEXT_MESSAGE( | "parameter"), | constantFour = "bla bla ..."; | } | |
class MyConstants | { | public: | static char[] constantOne = "Some text here ...", | |--relative--|constantTwo = "Some other text...", | constantThree = CALC_TEXT_MESSAGE( | "parameter"), | constantFour = "bla bla ..."; | } | |
class MyConstants | { | public: | static char[] constantOne = "Some text here ...", | |------absolute------|constantTwo = "Some other text...", | constantThree = CALC_TEXT_MESSAGE( | "parameter"), | constantFour = "bla bla ..."; | } | |
class MyConstants | { | public: | static char[] constantOne = "Some text here ...", | |--relative--|constantTwo = "Some other text...", | constantThree = CALC_TEXT_MESSAGE( | "parameter"), | constantFour = "bla bla ..."; | } | |
class MyConstants | { | public: | static char[] constantOne = "Some text here ...", | |--|constantTwo = "Some other text...", | constantThree = CALC_TEXT_MESSAGE("parameter"), | constantFour = "bla bla ..."; | } | |
infinite
to leave gaps untouched.See also: | Maximal gap size of indentations , Align assignments |
Wrap initializers of variable and field declarations to right side (in this case the 'maximal gap settings' will be ignored) |
LongClassName tmp; | char[] stringValue1 = "some text here ..."; | char[] stringValue2 = CALC_TEXT_MESSAGE( | parameter1, parameter2); | |
LongClassName tmp; | char[] stringValue1 = "some text here ..."; | char[] stringValue2 = CALC_TEXT_MESSAGE( | parameter1, parameter2); | |
Wrap colons of base specifiers |
always
:
class MyClass : TestClassA, TestClassB, TestClassC { // ... } |
never
:
class MyClass : TestClassA, TestClassB, TestClassC { // ... } |
on demand
:
class MyVeryLongClassName : TestClassA, TestClassB, TestClassC { // ... | } | { | // ... | |
if line exceeds
works a bit different:
class MyClass : TestClassA, TestClassB, TestClassC { // ... | } | |
TestClassC
exceeds the specified maximal line length,
therefore we consider this case as 'the line exceeds maximal line length'
and the colon will be wrapped.
class MyClass | : TestClassA, TestClassB, TestClassC { | // ... | } | |
Indentation of wrapped colons of base specifiers |
class MyClass : TestClassA, TestClassB, TestClassC { // ... |
class MyClass : TestClassA, TestClassB, TestClassC { // ... |
Wrap first base specifier |
always
:
class MyClass : TestClassA, TestClassB, TestClassC { // ... } |
never
:
class MyClass : TestClassA, TestClassB, TestClassC { // ... } |
on demand
:
class MyClass : | TestClassA, TestClassB, TestClassC { // ... | } | |
if line exceeds
works a bit different:
class MyClass : TestClassA, TestClassB, TestClassC { | // ... | } | |
TestClassC
exceeds the specified maximal line length,
therefore we consider this case as 'the line exceeds maximal line length'
and the first base specifier will be wrapped.
class MyClass : | TestClassA, TestClassB, TestClassC { | // ... | } | |
Indentation of first wrapped base specifier |
class MyClass : TestClassA, TestClassB, TestClassC { // ... } |
class MyClass : TestClassA, TestClassB, TestClassC { // ... } |
Wrap all other base specifiers |
always
:
class MyClass : TestClassA, TestClassB, TestClassC { // ... } |
never
:
class MyClass : TestClassA, TestClassB, TestClassC { // ... } |
on demand
:
class MyClass : TestClassA, TestClassB, | TestClassC { | // ... | } | |
if line exceeds
works a bit different:
class MyClass : TestClassA, TestClassB, TestClassC { | // ... | } | |
TestClassC
exceeds the specified maximal line length,
therefore we consider this case as 'the line exceeds maximal line length'
and the first base specifier will be wrapped.
class MyClass : TestClassA, | TestClassB, | TestClassC { | // ... | } | |
Wrap after method declaration return types |
always
:
float method() { ... } |
never
:
float method() { ... } |
on demand
:
static float | aPrettyLongMethodNameWhichCannotBeWrapped() | { | ... | } | |
if line exceeds
works a bit different:
static int longMethodName(int paramaterOne, int parameterTwo) { | ... | } | |
parameterTwo
exceeds the specified maximal line length,
therefore we consider this case as 'the line exceeds maximal line length'
and it will be wrapped after its return type:
static int | longMethodName(int paramaterOne, int parameterTwo) | { | ... | } | |
Wrap before left parentheses ( |
always
:
void method (int parameterOne, int parameterTwo) { ... } |
never
:
void method(int parameterOne, int parameterTwo) { ... } |
on demand
:
static void aPrettyLongMethodName | (int parameterOne) | { | ... | } | |
if line exceeds
works a bit different:
static int longMethodName(int paramaterOne, int parameterTwo) { | ... | } | |
parameterTwo
exceeds the specified maximal line length,
therefore we consider this case as 'the line exceeds maximal line length'
and it will be wrapped after its left parenthesis:
static int longMethodName | (int paramaterOne, int parameterTwo) | { | ... | } | |
See also: | Indentation of wrapped left parentheses ( |
Indentation of wrapped left parentheses ( |
See also: | Wrap before left parentheses ( |
Wrap first parameter |
always
:
void method( int parameterOne, int parameterTwo) { ... } |
never
:
void method(int parameterOne, int parameterTwo) { ... } |
on demand
:
static void aPrettyLongMethodName( | int parameterOne, int parameterTwo) | { | ... | } | |
if line exceeds
works a bit different:
static int longMethodName(int paramaterOne, int parameterTwo) { | ... | } | |
parameterTwo
exceeds the specified maximal line length,
therefore we consider this case as 'the line exceeds maximal line length'
and first parameter will be wrapped:
static int longMethodName( | int paramaterOne, int parameterTwo) | { | ... | } | |
Indentation of first wrapped parameter |
See also: | Wrap first parameter |
Wrap all other parameters |
always
:
void method(int parameterOne, int parameterTwo, int parameterThree) { ... } |
never
:
void method(int parameterOne, int parameterTwo, int parameterThree) { ... } |
on demand
:
void method(int parameterOne, int parameterTwo, | int parameterThree) | { | ... | } | |
if line exceeds
works a bit different:
void method(int parameterOne, int parameterTwo, int parameterThree) { | ... | } | |
parameterThree
exceeds the specified maximal line length,
therefore we consider this case as 'the line exceeds maximal line length' and all
parameters will be wrapped:
void method(int parameterOne, | int parameterTwo, | int parameterThree) | { | ... | } | |
Wrap before right parentheses ) |
always
:
void method(int parameterOne, int parameterTwo ) { ... } |
never
:
void method(int parameterOne, int parameterTwo) { ... } |
on demand
:
static void aPrettyLongMethodName(int parameterOne, int parameterTwo ) | { | ... | } | |
if line exceeds
works a bit different:
static int longMethodName(int paramaterOne, int parameterTwo) { | ... | } | |
parameterTwo
exceeds the specified maximal line length,
therefore we consider this case as 'the line exceeds maximal line length'
and right parenthesis will be wrapped:
static int longMethodName | ( | int paramaterOne, | int parameterTwo | ) | { | ... | } | |
if line exceeds
too.Indentation of wrapped right parentheses ) |
See also: | Wrap before right parentheses ) |
Avoid confusing indentations for methods and constructors declarations |
int parameterTwo
is correctly aligned to parameterOne
:
void | set(int parameterOne, | int parameterTwo) { | callAnotherMethod(paramterOne, paramaterTwo); // line is easy to miss } | |
callAnotherMethod(...)
is
easy to miss. It seems it belongs to the method declaration head. Such an indetation is
considered as 'confusing indentation'.
void | set(int parameterOne, | |------|int parameterTwo) { | callAnotherMethod(paramterOne, paramaterTwo); // line is easy to miss } | |
callAnotherMethod(...)
is now separated from the method head and well-defined.See also: | Alternative indentation , Avoid confusing indentations |
Wrap before throw |
throw
.always
and indent by 8 white spaces:
static void method(int args) throw (MyError) { callMethod(); } |
throw
to a new line
even if it would fit into the specified maximal line length.throw
is indented by setting: "Indentation of wrapped throw"never
:
static void method(int args) throw (MyError) { callMethod(); } |
throw
to a new line
even if it does not fit into the specified maximal line length.on demand
and indent by 8 white spaces:
static void method(int args) | throw (MyError) { | callMethod(); | } | |
throw
on demand:throw
fits into the specified maximal line length then it won't be wrapped.
If it exceeds maximal line length it will be wrapped to a new line though. The wrapped token
will be indented by setting: "Indentation of wrapped throw"if line exceeds
works a bit different:throws
belongs to exceeds maximal line length then
throws
will be wrapped.
static void method(int args) throw(overflow, underflow) { callMethod(); | } | |
throws
does not exceed the specified maximal line length,
but another token underflow
does. We consider this case as 'the line exceeds
maximal line length' and therefore token throws
will be wrapped and
indented by setting: "Indentation of wrapped throw"
static void method(int args) | throw (overflow, underflow) { | callMethod(); | } | |
See also: | Indentation of wrapped throw |
Indentation of wrapped throw |
throw
by a specified number of white spaces.See also: | Wrap before throw |
Wrap throw exceptions |
always
:
void method(int parameterOne) throw(overflow, underflow, zero_devide) { ... } |
never
:
void method(int parameterOne) throw(overflow, underflow, zero_devide) { ... } |
on demand
:
void method(int parameterOne) throw(overflow, underflow, | zero_devide) { | ... | } | |
if line exceeds
works a bit different:
void method(int parameterOne) throw(overflow, underflow, zero_devide) { ... | } | |
zero_devide
exceeds the specified maximal line length,
therefore we consider this case as 'the line exceeds maximal line length' and all
exceptions will be wrapped:
void method(int parameterOne) throw(overflow, | underflow, | zero_devide) { | ... | } | |
Do not wrap empty void parameter |
int method | ( | int parameterOne, | int parameterTwo, | int parameterThree | ) | { | ... | } | |
void
parameter declarations like:
int method | ( | void | ) | { | ... | } | |
int method(void) | { | ... | } | |
void
parameter will not be wrapped to a new line.
Wrap before colons of constructor initializers |
always
:
ClassA(int arg1, int arg2) : ClassB(arg1, arg2), ClassC(arg1, arg2), ClassD(arg1, arg2) { // ... |
never
:
ClassA(int arg1, int arg2) : ClassB(arg1, arg2), ClassC(arg1, arg2), ClassD(arg1, arg2) { // ... |
on demand
:
ClassA(int arg1, int arg2) : ClassB(arg1, arg2), ClassC(arg1, arg2), ClassD(arg1, arg2) { | // ... | |
if line exceeds
works a bit different:
ClassA(int arg1, int arg2) : ClassB(arg1, arg2), ClassC(arg1, arg2), ClassD(arg1, arg2) { | // ... | |
ClassC
exceeds the specified maximal line length,
therefore we consider this case as 'the line exceeds maximal line length'
and the colon will be wrapped.
ClassA(int arg1, int arg2) | : ClassB(arg1, arg2), ClassC(arg1, arg2), ClassD(arg1, arg2) { | // ... | |
Indentation of wrapped constructor initializer colons |
ClassA(int arg1, int arg2) : ClassB(arg1, arg2), ClassC(arg1, arg2), ClassD(arg1, arg2) |
ClassA(int arg1, int arg2) : ClassB(arg1, arg2), ClassC(arg1, arg2), ClassD(arg1, arg2) |
Wrap first constructor initializer |
always
:
ClassA(int arg1, int arg2) : ClassB(arg1, arg2), ClassC(arg1, arg2), ClassD(arg1, arg2) { // ... |
never
:
ClassA(int arg1, int arg2) : ClassB(arg1, arg2), ClassC(arg1, arg2), ClassD(arg1, arg2) { // ... |
on demand
:
ClassA(int arg1, int arg2) : ClassB(arg1, arg2), ClassC(arg1, arg2), ClassD(arg1, arg2) { | // ... | |
if line exceeds
works a bit different:
ClassA(int arg1, int arg2) : ClassB(arg1, arg2), ClassC(arg1, arg2), ClassD(arg1, arg2) { | // ... | |
ClassC
exceeds the specified maximal line length,
therefore we consider this case as 'the line exceeds maximal line length'
and first initializer will be wrapped.
ClassA(int arg1, int arg2) : | ClassB(arg1, arg2), ClassC(arg1, arg2), ClassD(arg1, arg2) { | // ... | |
Indentation of wrapped first constructor initializer |
ClassA(int arg1, int arg2) : ClassB(arg1, arg2), ClassC(arg1, arg2), ClassD(arg1, arg2) { // ... |
ClassA(int arg1, int arg2) : ClassB(arg1, arg2), ClassC(arg1, arg2), ClassD(arg1, arg2) { // ... |
Wrap constructor initializers |
always
:
ClassA(int arg1, int arg2) : ClassB(arg1, arg2), ClassC(arg1, arg2), ClassD(arg1, arg2) { // ... |
never
:
ClassA(int arg1, int arg2) : ClassB(arg1, arg2), ClassC(arg1, arg2), ClassD(arg1, arg2) { // ... |
on demand
:
ClassA(int arg1, int arg2) : ClassB(arg1, arg2), ClassC(arg1, arg2), | ClassD(arg1, arg2) | { | // ... | |
if line exceeds
works a bit different:
ClassA(int arg1, int arg2) : ClassB(arg1, arg2), ClassC(arg1, arg2), ClassD(arg1, arg2) { | // ... | |
ClassC
exceeds the specified maximal line length,
therefore we consider this case as 'the line exceeds maximal line length'
and all initializers will be wrapped.
ClassA(int arg1, int arg2) : ClassB(arg1, arg2), | ClassC(arg1, arg2), | ClassD(arg1, arg2) | { | // ... | |
Wrap Enum constants |
on demand
:
enum Counter { | ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, | EIGHT, NINE, TEN | }; | |
always
:
enum Seasons { | SPRING, | SUMMER, | AUTUMN, | WINTER | }; | |
if line exceeds
:
enum Seasons { | SPRING, SUMMER, AUTUMN, WINTER | }; | | enum Counter { | ONE, | TWO, | THREE, | FOUR, | FIVE, | SIX, | SEVEN, | EIGHT, | NINE, | TEN | }; | |
Maximal number of enumeration constants lined up in one line |
enum Enum1 { ONE, TWO, THREE }; enum Enum2 { ONE, TWO, THREE, FOUR, FIVE }; enum Enum3 { ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN }; |
enum Enum1 { ONE, TWO, THREE }; enum Enum2 { ONE, TWO, THREE, FOUR, FIVE }; enum Enum3 { ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN }; |
infinite
.Maximal number of array initializer elements lined up in one line |
int array1[] = { 1, 2, 3 }; int array2[] = { 1, 2, 3, 4, 5 }; int array3[] = { 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 }; |
int array1[] = { 1, 2, 3 }; int array2[] = { 1, 2, 3, 4, 5 }; int array3[] = { 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 }; |
infinite
.