mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-12 02:35:37 +02:00
Corrected indentation of constructor initializer lists.
This commit is contained in:
parent
d034f60b19
commit
7ce55b165b
7 changed files with 21 additions and 14 deletions
|
@ -1010,27 +1010,34 @@ 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();
|
||||
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) {
|
||||
scribe.space();
|
||||
} else {
|
||||
scribe.printTrailingComment();
|
||||
scribe.startNewLine();
|
||||
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);
|
||||
for (int i= 0; i < preferences.continuation_indentation; i++) {
|
||||
scribe.unIndent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// body
|
||||
IASTStatement bodyStmt= node.getBody();
|
||||
|
|
|
@ -552,7 +552,7 @@ public class Scribe {
|
|||
fSkippedIndentations++;
|
||||
return;
|
||||
}
|
||||
indentationLevel+= indentationSize;
|
||||
indentationLevel += indentationSize;
|
||||
numberOfIndentations++;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue