1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-10 03:53:21 +02:00

Split string literals have to be indented using continuation line indent.

This commit is contained in:
Sergey Prigogin 2011-02-09 22:13:21 +00:00
parent caccc14ee8
commit 569c4f47ea
3 changed files with 22 additions and 22 deletions

View file

@ -1016,9 +1016,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
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.indentForContinuation();
}
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) {
@ -1026,16 +1024,12 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
} else {
scribe.printTrailingComment();
scribe.startNewLine();
for (int i= 0; i < preferences.continuation_indentation; i++) {
scribe.indent();
}
scribe.indentForContinuation();
}
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();
}
scribe.unIndentForContinuation();
}
}
@ -1689,10 +1683,8 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
if (align.fSpaceAfterOpeningParen) {
scribe.space();
}
final int continuationIndentation=
align.fContinuationIndentation >= 0
? align.fContinuationIndentation
: preferences.continuation_indentation;
final int continuationIndentation= align.fContinuationIndentation >= 0 ?
align.fContinuationIndentation : preferences.continuation_indentation;
Alignment listAlignment = scribe.createAlignment(
"listElements_" + (elements.isEmpty() ? "ellipsis" : elements.get(0).getClass().getSimpleName()), //$NON-NLS-1$ //$NON-NLS-2$
align.fMode,
@ -2309,13 +2301,13 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
scribe.printCommentPreservingNewLines();
if (!indented && line != scribe.line) {
indented= true;
scribe.indent();
scribe.indentForContinuation();
}
needSpace= true;
}
} finally {
if (indented) {
scribe.unIndent();
scribe.unIndentForContinuation();
}
}
} else {

View file

@ -692,9 +692,7 @@ public class Scribe {
++parenLevel;
print(currentToken.getLength(), hasWhitespace);
if (parenLevel > 0) {
for (int i= 0; i < preferences.continuation_indentation; i++) {
indent();
}
indentForContinuation();
if (column <= indentationLevel) {
// HACK: avoid indent in same line
column= indentationLevel + 1;
@ -704,9 +702,7 @@ public class Scribe {
case Token.tRPAREN:
--parenLevel;
if (parenLevel >= 0) {
for (int i= 0; i < preferences.continuation_indentation; i++) {
unIndent();
}
unIndentForContinuation();
}
print(currentToken.getLength(), hasWhitespace);
break;
@ -746,6 +742,18 @@ public class Scribe {
}
}
public void indentForContinuation() {
for (int i= 0; i < preferences.continuation_indentation; i++) {
indent();
}
}
public void unIndentForContinuation() {
for (int i= 0; i < preferences.continuation_indentation; i++) {
unIndent();
}
}
public void formatOpeningBrace(String bracePosition, boolean insertSpaceBeforeBrace) {
if (DefaultCodeFormatterConstants.NEXT_LINE.equals(bracePosition)) {
printNewLine();

View file

@ -26,7 +26,7 @@ int main(int argc, char **argv) {
// handling of string concat
char* s1 = "this " "is " "one " "string.";
char* s2 = "this " "is "
"one " "string.";
"one " "string.";
// macro definition with line comment
#define ID(x) x // identity
int main() {