1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-15 20:25:46 +02:00

Preserve newline between type and function declarator, related to bug 192764

This commit is contained in:
Anton Leherbauer 2009-04-23 15:16:35 +00:00
parent f022798f69
commit 626f9f736a
2 changed files with 23 additions and 4 deletions

View file

@ -1241,9 +1241,15 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
IASTDeclSpecifier declSpec= node.getDeclSpecifier();
declSpec.accept(this);
final List<IASTDeclarator> declarators= Arrays.asList(node.getDeclarators());
if (declarators.size() >= 1) {
if (scribe.printComment()) {
scribe.space();
if (!declarators.isEmpty()) {
if (declarators.size() == 1 && declarators.get(0) instanceof IASTFunctionDeclarator) {
if (scribe.preserveNewLine()) {
scribe.space();
}
} else {
if (scribe.printComment()) {
scribe.space();
}
}
final ListAlignment align= new ListAlignment(preferences.alignment_for_declarator_list);
align.fSpaceAfterComma= preferences.insert_space_after_comma_in_declarator_list;
@ -1309,7 +1315,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
scribe.indent();
}
} else {
// preserve newline if not explicitely requested
// preserve newline if not explicitly requested
scribe.preserveNewLine();
}

View file

@ -1167,4 +1167,17 @@ public class CodeFormatterTest extends BaseUITestCase {
public void testFormatterProblemsWithTypename_Bug269590() throws Exception {
assertFormatterResult();
}
//void
//foo();
//int*
//bar();
//void
//foo();
//int*
//bar();
public void testPreserveNewlineBetweenTypeAndFunctionDeclarator() throws Exception {
assertFormatterResult();
}
}