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) {
|
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.indentForContinuation();
|
||||||
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) {
|
||||||
|
@ -1026,16 +1024,12 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
||||||
} else {
|
} else {
|
||||||
scribe.printTrailingComment();
|
scribe.printTrailingComment();
|
||||||
scribe.startNewLine();
|
scribe.startNewLine();
|
||||||
for (int i= 0; i < preferences.continuation_indentation; i++) {
|
scribe.indentForContinuation();
|
||||||
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.unIndentForContinuation();
|
||||||
scribe.unIndent();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1689,10 +1683,8 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
||||||
if (align.fSpaceAfterOpeningParen) {
|
if (align.fSpaceAfterOpeningParen) {
|
||||||
scribe.space();
|
scribe.space();
|
||||||
}
|
}
|
||||||
final int continuationIndentation=
|
final int continuationIndentation= align.fContinuationIndentation >= 0 ?
|
||||||
align.fContinuationIndentation >= 0
|
align.fContinuationIndentation : preferences.continuation_indentation;
|
||||||
? align.fContinuationIndentation
|
|
||||||
: preferences.continuation_indentation;
|
|
||||||
Alignment listAlignment = scribe.createAlignment(
|
Alignment listAlignment = scribe.createAlignment(
|
||||||
"listElements_" + (elements.isEmpty() ? "ellipsis" : elements.get(0).getClass().getSimpleName()), //$NON-NLS-1$ //$NON-NLS-2$
|
"listElements_" + (elements.isEmpty() ? "ellipsis" : elements.get(0).getClass().getSimpleName()), //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
align.fMode,
|
align.fMode,
|
||||||
|
@ -2309,13 +2301,13 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
||||||
scribe.printCommentPreservingNewLines();
|
scribe.printCommentPreservingNewLines();
|
||||||
if (!indented && line != scribe.line) {
|
if (!indented && line != scribe.line) {
|
||||||
indented= true;
|
indented= true;
|
||||||
scribe.indent();
|
scribe.indentForContinuation();
|
||||||
}
|
}
|
||||||
needSpace= true;
|
needSpace= true;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (indented) {
|
if (indented) {
|
||||||
scribe.unIndent();
|
scribe.unIndentForContinuation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -692,9 +692,7 @@ public class Scribe {
|
||||||
++parenLevel;
|
++parenLevel;
|
||||||
print(currentToken.getLength(), hasWhitespace);
|
print(currentToken.getLength(), hasWhitespace);
|
||||||
if (parenLevel > 0) {
|
if (parenLevel > 0) {
|
||||||
for (int i= 0; i < preferences.continuation_indentation; i++) {
|
indentForContinuation();
|
||||||
indent();
|
|
||||||
}
|
|
||||||
if (column <= indentationLevel) {
|
if (column <= indentationLevel) {
|
||||||
// HACK: avoid indent in same line
|
// HACK: avoid indent in same line
|
||||||
column= indentationLevel + 1;
|
column= indentationLevel + 1;
|
||||||
|
@ -704,9 +702,7 @@ public class Scribe {
|
||||||
case Token.tRPAREN:
|
case Token.tRPAREN:
|
||||||
--parenLevel;
|
--parenLevel;
|
||||||
if (parenLevel >= 0) {
|
if (parenLevel >= 0) {
|
||||||
for (int i= 0; i < preferences.continuation_indentation; i++) {
|
unIndentForContinuation();
|
||||||
unIndent();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
print(currentToken.getLength(), hasWhitespace);
|
print(currentToken.getLength(), hasWhitespace);
|
||||||
break;
|
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) {
|
public void formatOpeningBrace(String bracePosition, boolean insertSpaceBeforeBrace) {
|
||||||
if (DefaultCodeFormatterConstants.NEXT_LINE.equals(bracePosition)) {
|
if (DefaultCodeFormatterConstants.NEXT_LINE.equals(bracePosition)) {
|
||||||
printNewLine();
|
printNewLine();
|
||||||
|
|
|
@ -26,7 +26,7 @@ int main(int argc, char **argv) {
|
||||||
// handling of string concat
|
// handling of string concat
|
||||||
char* s1 = "this " "is " "one " "string.";
|
char* s1 = "this " "is " "one " "string.";
|
||||||
char* s2 = "this " "is "
|
char* s2 = "this " "is "
|
||||||
"one " "string.";
|
"one " "string.";
|
||||||
// macro definition with line comment
|
// macro definition with line comment
|
||||||
#define ID(x) x // identity
|
#define ID(x) x // identity
|
||||||
int main() {
|
int main() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue