mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for Bug 169382 - default formatter can't format "struct xxx get(){}"
This commit is contained in:
parent
095910e7bf
commit
b27b8766ae
5 changed files with 26 additions and 10 deletions
|
@ -650,6 +650,9 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
|
||||||
final int line= scribe.line;
|
final int line= scribe.line;
|
||||||
IASTDeclSpecifier declSpec= node.getDeclSpecifier();
|
IASTDeclSpecifier declSpec= node.getDeclSpecifier();
|
||||||
declSpec.accept(this);
|
declSpec.accept(this);
|
||||||
|
if (scribe.printComment()) {
|
||||||
|
scribe.space();
|
||||||
|
}
|
||||||
IASTFunctionDeclarator decl= node.getDeclarator();
|
IASTFunctionDeclarator decl= node.getDeclarator();
|
||||||
decl.accept(this);
|
decl.accept(this);
|
||||||
IASTStatement bodyStmt= node.getBody();
|
IASTStatement bodyStmt= node.getBody();
|
||||||
|
@ -781,7 +784,9 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
|
||||||
declSpec.accept(this);
|
declSpec.accept(this);
|
||||||
final List declarators= Arrays.asList(node.getDeclarators());
|
final List declarators= Arrays.asList(node.getDeclarators());
|
||||||
if (declarators.size() > 0) {
|
if (declarators.size() > 0) {
|
||||||
|
if (scribe.printComment()) {
|
||||||
scribe.space();
|
scribe.space();
|
||||||
|
}
|
||||||
final ListAlignment align= new ListAlignment(Alignment.M_COMPACT_SPLIT);
|
final ListAlignment align= new ListAlignment(Alignment.M_COMPACT_SPLIT);
|
||||||
formatList(declarators, align, false, false);
|
formatList(declarators, align, false, false);
|
||||||
}
|
}
|
||||||
|
@ -817,13 +822,11 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
|
||||||
|
|
||||||
private int visit(IASTSimpleDeclSpecifier node) {
|
private int visit(IASTSimpleDeclSpecifier node) {
|
||||||
formatNode(node);
|
formatNode(node);
|
||||||
scribe.space();
|
|
||||||
return PROCESS_SKIP;
|
return PROCESS_SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int visit(IASTNamedTypeSpecifier node) {
|
private int visit(IASTNamedTypeSpecifier node) {
|
||||||
formatNode(node);
|
formatNode(node);
|
||||||
scribe.space();
|
|
||||||
return PROCESS_SKIP;
|
return PROCESS_SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1557,7 +1560,9 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void formatNode(IASTNode node) {
|
private void formatNode(IASTNode node) {
|
||||||
scribe.printComment();
|
if (scribe.printComment()) {
|
||||||
|
scribe.space();
|
||||||
|
}
|
||||||
IASTNodeLocation location= node.getFileLocation();
|
IASTNodeLocation location= node.getFileLocation();
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
scribe.printRaw(location.getNodeOffset(), location.getNodeLength());
|
scribe.printRaw(location.getNodeOffset(), location.getNodeLength());
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=169382
|
||||||
|
struct x {
|
||||||
|
};
|
||||||
|
struct x getX() {
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=169382
|
||||||
|
struct x {};
|
||||||
|
struct x getX() {}
|
|
@ -131,4 +131,7 @@ public class FormatActionTest extends TestCase {
|
||||||
assertFormatResult();
|
assertFormatResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testBugs() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue