1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 06:02:11 +02:00

Bug 262536 - [formatter] Problems with extern "C"

This commit is contained in:
Anton Leherbauer 2009-01-29 09:16:37 +00:00
parent 86c7af6e76
commit 6e17efadde
2 changed files with 27 additions and 22 deletions

View file

@ -771,11 +771,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
scribe.startNewLine(); scribe.startNewLine();
for (int i = 0; i < memberDecls.length; i++) { for (int i = 0; i < memberDecls.length; i++) {
IASTDeclaration declaration = memberDecls[i]; IASTDeclaration declaration = memberDecls[i];
if (declaration instanceof ICPPASTVisibilityLabel) { declaration.accept(this);
visit((ICPPASTVisibilityLabel)declaration);
} else {
declaration.accept(this);
}
scribe.startNewLine(); scribe.startNewLine();
} }
if (preferences.indent_body_declarations_compare_to_namespace_header) { if (preferences.indent_body_declarations_compare_to_namespace_header) {
@ -799,26 +795,27 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
// member declarations // member declarations
IASTDeclaration[] memberDecls= node.getDeclarations(); IASTDeclaration[] memberDecls= node.getDeclarations();
// TLETODO [formatter] need options for linkage specification if (memberDecls.length == 1 && peekNextToken() != Token.tLBRACE) {
formatLeftCurlyBrace(line, preferences.brace_position_for_namespace_declaration); scribe.space();
formatOpeningBrace(preferences.brace_position_for_namespace_declaration, preferences.insert_space_before_opening_brace_in_namespace_declaration); memberDecls[0].accept(this);
if (preferences.indent_body_declarations_compare_to_namespace_header) { } else {
scribe.indent(); // TLETODO [formatter] need options for linkage specification
} formatLeftCurlyBrace(line, preferences.brace_position_for_namespace_declaration);
scribe.startNewLine(); formatOpeningBrace(preferences.brace_position_for_namespace_declaration, preferences.insert_space_before_opening_brace_in_namespace_declaration);
for (int i = 0; i < memberDecls.length; i++) { if (preferences.indent_body_declarations_compare_to_namespace_header) {
IASTDeclaration declaration = memberDecls[i]; scribe.indent();
if (declaration instanceof ICPPASTVisibilityLabel) {
visit((ICPPASTVisibilityLabel)declaration);
} else {
declaration.accept(this);
} }
scribe.startNewLine(); scribe.startNewLine();
for (int i = 0; i < memberDecls.length; i++) {
IASTDeclaration declaration = memberDecls[i];
declaration.accept(this);
scribe.startNewLine();
}
if (preferences.indent_body_declarations_compare_to_namespace_header) {
scribe.unIndent();
}
formatClosingBrace(preferences.brace_position_for_namespace_declaration);
} }
if (preferences.indent_body_declarations_compare_to_namespace_header) {
scribe.unIndent();
}
formatClosingBrace(preferences.brace_position_for_namespace_declaration);
return PROCESS_SKIP; return PROCESS_SKIP;
} }

View file

@ -1136,4 +1136,12 @@ public class CodeFormatterTest extends BaseUITestCase {
public void testPreserveSpaceBetweenNameAnd__attribute__Bug261967() throws Exception { public void testPreserveSpaceBetweenNameAnd__attribute__Bug261967() throws Exception {
assertFormatterResult(); assertFormatterResult();
} }
//extern "C" void f(int i, char c, float x);
//extern "C" void f(int i, char c, float x);
public void testPreserveSpaceInExternCDeclaration() throws Exception {
assertFormatterResult();
}
} }