mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-12 10:45: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) {
|
if (node instanceof ICPPASTFunctionDefinition) {
|
||||||
final ICPPASTConstructorChainInitializer[] constructorChain= ((ICPPASTFunctionDefinition) node).getMemberInitializers();
|
final ICPPASTConstructorChainInitializer[] constructorChain=
|
||||||
|
((ICPPASTFunctionDefinition) node).getMemberInitializers();
|
||||||
if (constructorChain != null && constructorChain.length > 0) {
|
if (constructorChain != null && constructorChain.length > 0) {
|
||||||
if (preferences.insert_new_line_before_colon_in_constructor_initializer_list) {
|
if (preferences.insert_new_line_before_colon_in_constructor_initializer_list) {
|
||||||
scribe.printTrailingComment();
|
scribe.printTrailingComment();
|
||||||
scribe.startNewLine();
|
scribe.startNewLine();
|
||||||
|
for (int i= 0; i < preferences.continuation_indentation; i++) {
|
||||||
scribe.indent();
|
scribe.indent();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
scribe.printNextToken(Token.tCOLON, !preferences.insert_new_line_before_colon_in_constructor_initializer_list);
|
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) {
|
if (preferences.insert_new_line_before_colon_in_constructor_initializer_list) {
|
||||||
scribe.space();
|
scribe.space();
|
||||||
} else {
|
} else {
|
||||||
scribe.printTrailingComment();
|
scribe.printTrailingComment();
|
||||||
scribe.startNewLine();
|
scribe.startNewLine();
|
||||||
|
for (int i= 0; i < preferences.continuation_indentation; i++) {
|
||||||
scribe.indent();
|
scribe.indent();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
final ListAlignment align= new ListAlignment(preferences.alignment_for_constructor_initializer_list);
|
final ListAlignment align= new ListAlignment(preferences.alignment_for_constructor_initializer_list);
|
||||||
align.fTieBreakRule = Alignment.R_OUTERMOST;
|
align.fTieBreakRule = Alignment.R_OUTERMOST;
|
||||||
formatList(Arrays.asList(constructorChain), align, false, false);
|
formatList(Arrays.asList(constructorChain), align, false, false);
|
||||||
|
for (int i= 0; i < preferences.continuation_indentation; i++) {
|
||||||
scribe.unIndent();
|
scribe.unIndent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// body
|
// body
|
||||||
IASTStatement bodyStmt= node.getBody();
|
IASTStatement bodyStmt= node.getBody();
|
||||||
|
|
|
@ -552,7 +552,7 @@ public class Scribe {
|
||||||
fSkippedIndentations++;
|
fSkippedIndentations++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
indentationLevel+= indentationSize;
|
indentationLevel += indentationSize;
|
||||||
numberOfIndentations++;
|
numberOfIndentations++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
class Point {
|
class Point {
|
||||||
public:
|
public:
|
||||||
Point(double xc, double yc) :
|
Point(double x, double y) :
|
||||||
x(xc), y(yc) {
|
x(x), y(y) {
|
||||||
}
|
}
|
||||||
double distance(const Point& other) const;
|
double distance(const Point& other) const;
|
||||||
int compareX(const Point& other) const;
|
int compareX(const Point& other) const;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Indentation
|
* Indentation
|
||||||
*/
|
*/
|
||||||
#include <math.h>
|
#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
|
* Line Wrapping
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue