mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 12:03:16 +02:00
Split string literals have to be indented using continuation line indent.
This commit is contained in:
parent
caccc14ee8
commit
569c4f47ea
3 changed files with 22 additions and 22 deletions
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue