mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-16 04:35:45 +02:00
Preserve newline between type and function declarator, related to bug 192764
This commit is contained in:
parent
f022798f69
commit
626f9f736a
2 changed files with 23 additions and 4 deletions
|
@ -1241,9 +1241,15 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
|
||||||
IASTDeclSpecifier declSpec= node.getDeclSpecifier();
|
IASTDeclSpecifier declSpec= node.getDeclSpecifier();
|
||||||
declSpec.accept(this);
|
declSpec.accept(this);
|
||||||
final List<IASTDeclarator> declarators= Arrays.asList(node.getDeclarators());
|
final List<IASTDeclarator> declarators= Arrays.asList(node.getDeclarators());
|
||||||
if (declarators.size() >= 1) {
|
if (!declarators.isEmpty()) {
|
||||||
if (scribe.printComment()) {
|
if (declarators.size() == 1 && declarators.get(0) instanceof IASTFunctionDeclarator) {
|
||||||
scribe.space();
|
if (scribe.preserveNewLine()) {
|
||||||
|
scribe.space();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (scribe.printComment()) {
|
||||||
|
scribe.space();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
final ListAlignment align= new ListAlignment(preferences.alignment_for_declarator_list);
|
final ListAlignment align= new ListAlignment(preferences.alignment_for_declarator_list);
|
||||||
align.fSpaceAfterComma= preferences.insert_space_after_comma_in_declarator_list;
|
align.fSpaceAfterComma= preferences.insert_space_after_comma_in_declarator_list;
|
||||||
|
@ -1309,7 +1315,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
|
||||||
scribe.indent();
|
scribe.indent();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// preserve newline if not explicitely requested
|
// preserve newline if not explicitly requested
|
||||||
scribe.preserveNewLine();
|
scribe.preserveNewLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1167,4 +1167,17 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
public void testFormatterProblemsWithTypename_Bug269590() throws Exception {
|
public void testFormatterProblemsWithTypename_Bug269590() throws Exception {
|
||||||
assertFormatterResult();
|
assertFormatterResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//void
|
||||||
|
//foo();
|
||||||
|
//int*
|
||||||
|
//bar();
|
||||||
|
|
||||||
|
//void
|
||||||
|
//foo();
|
||||||
|
//int*
|
||||||
|
//bar();
|
||||||
|
public void testPreserveNewlineBetweenTypeAndFunctionDeclarator() throws Exception {
|
||||||
|
assertFormatterResult();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue