1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 01:15:29 +02:00

Corrected indentation of constructor initializer lists.

This commit is contained in:
Sergey Prigogin 2011-02-05 20:33:05 +00:00
parent d034f60b19
commit 7ce55b165b
7 changed files with 21 additions and 14 deletions

View file

@ -1010,12 +1010,15 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
}
if (node instanceof ICPPASTFunctionDefinition) {
final ICPPASTConstructorChainInitializer[] constructorChain= ((ICPPASTFunctionDefinition) node).getMemberInitializers();
final ICPPASTConstructorChainInitializer[] constructorChain=
((ICPPASTFunctionDefinition) node).getMemberInitializers();
if (constructorChain != null && constructorChain.length > 0) {
if (preferences.insert_new_line_before_colon_in_constructor_initializer_list) {
scribe.printTrailingComment();
scribe.startNewLine();
scribe.indent();
for (int i= 0; i < preferences.continuation_indentation; i++) {
scribe.indent();
}
}
scribe.printNextToken(Token.tCOLON, !preferences.insert_new_line_before_colon_in_constructor_initializer_list);
if (preferences.insert_new_line_before_colon_in_constructor_initializer_list) {
@ -1023,12 +1026,16 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
} else {
scribe.printTrailingComment();
scribe.startNewLine();
scribe.indent();
for (int i= 0; i < preferences.continuation_indentation; i++) {
scribe.indent();
}
}
final ListAlignment align= new ListAlignment(preferences.alignment_for_constructor_initializer_list);
align.fTieBreakRule = Alignment.R_OUTERMOST;
formatList(Arrays.asList(constructorChain), align, false, false);
scribe.unIndent();
for (int i= 0; i < preferences.continuation_indentation; i++) {
scribe.unIndent();
}
}
}

View file

@ -552,7 +552,7 @@ public class Scribe {
fSkippedIndentations++;
return;
}
indentationLevel+= indentationSize;
indentationLevel += indentationSize;
numberOfIndentations++;
}

View file

@ -16,7 +16,7 @@ class AClass: public ABaseClass {
void test2() throw ();
};
AClass::AClass(int x) throw (int) :
ABaseClass(x) {
ABaseClass(x) {
for (int i = 0; i < 12; i++) {
}
}

View file

@ -15,8 +15,8 @@ private:
public:
// comment
Complex(float re, float im) :
// comment
re(re), im(im) {
// comment
re(re), im(im) {
}
// comment
float GetRe() {

View file

@ -4,8 +4,8 @@
#include <math.h>
class Point {
public:
Point(double xc, double yc) :
x(xc), y(yc) {
Point(double x, double y) :
x(x), y(y) {
}
double distance(const Point& other) const;
int compareX(const Point& other) const;

View file

@ -2,7 +2,7 @@
* Indentation
*/
#include <math.h>
class Point {public:Point(double xc, double yc) : x(xc), y(yc) {}double distance(const Point& other) const;int compareX(const Point& other) const;double x;double y;};double Point::distance(const Point& other) const {double dx = x - other.x;double dy = y - other.y;return sqrt(dx * dx + dy * dy);}int Point::compareX(const Point& other) const {if (x < other.x) {return -1;} else if (x > other.x) {return 1;} else {return 0;}}namespace FOO {int foo(int bar) const {switch (bar) {case 0:++bar;break;case 1:--bar;default: {bar += bar;break;}}}} // end namespace FOO
class Point {public:Point(double x, double y) : x(x), y(y) {}double distance(const Point& other) const;int compareX(const Point& other) const;double x;double y;};double Point::distance(const Point& other) const {double dx = x - other.x;double dy = y - other.y;return sqrt(dx * dx + dy * dy);}int Point::compareX(const Point& other) const {if (x < other.x) {return -1;} else if (x > other.x) {return 1;} else {return 0;}}namespace FOO {int foo(int bar) const {switch (bar) {case 0:++bar;break;case 1:--bar;default: {bar += bar;break;}}}} // end namespace FOO
/*
* Line Wrapping
*/

View file

@ -1120,7 +1120,7 @@ public class CodeFormatterTest extends BaseUITestCase {
//class Point {
//public:
// Point(int x, int y) :
// x(x), y(y) {
// x(x), y(y) {
// }
//
//private:
@ -1144,8 +1144,8 @@ public class CodeFormatterTest extends BaseUITestCase {
//class Point {
//public:
// Point(int x, int y)
// : x(x),
// y(y) {
// : x(x),
// y(y) {
// }
//
//private: