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;
|
||||
IASTDeclSpecifier declSpec= node.getDeclSpecifier();
|
||||
declSpec.accept(this);
|
||||
if (scribe.printComment()) {
|
||||
scribe.space();
|
||||
}
|
||||
IASTFunctionDeclarator decl= node.getDeclarator();
|
||||
decl.accept(this);
|
||||
IASTStatement bodyStmt= node.getBody();
|
||||
|
@ -781,7 +784,9 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
|
|||
declSpec.accept(this);
|
||||
final List declarators= Arrays.asList(node.getDeclarators());
|
||||
if (declarators.size() > 0) {
|
||||
if (scribe.printComment()) {
|
||||
scribe.space();
|
||||
}
|
||||
final ListAlignment align= new ListAlignment(Alignment.M_COMPACT_SPLIT);
|
||||
formatList(declarators, align, false, false);
|
||||
}
|
||||
|
@ -817,13 +822,11 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
|
|||
|
||||
private int visit(IASTSimpleDeclSpecifier node) {
|
||||
formatNode(node);
|
||||
scribe.space();
|
||||
return PROCESS_SKIP;
|
||||
}
|
||||
|
||||
private int visit(IASTNamedTypeSpecifier node) {
|
||||
formatNode(node);
|
||||
scribe.space();
|
||||
return PROCESS_SKIP;
|
||||
}
|
||||
|
||||
|
@ -1557,7 +1560,9 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
|
|||
}
|
||||
|
||||
private void formatNode(IASTNode node) {
|
||||
scribe.printComment();
|
||||
if (scribe.printComment()) {
|
||||
scribe.space();
|
||||
}
|
||||
IASTNodeLocation location= node.getFileLocation();
|
||||
if (location != null) {
|
||||
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() {}
|
|
@ -12,16 +12,16 @@ class Foo {
|
|||
|
||||
// TEMPLATE_STRUCT
|
||||
template<class Key, class Value, class SortAlgorithm=DefaultSort> struct Map {
|
||||
Key * keys;
|
||||
Value * values;
|
||||
SortAlgorithm * sortAlgorithm;
|
||||
Key* keys;
|
||||
Value* values;
|
||||
SortAlgorithm* sortAlgorithm;
|
||||
Map();
|
||||
};
|
||||
|
||||
// TEMPLATE_CLASS
|
||||
template<class T> class nonVector {
|
||||
private:
|
||||
T * head;
|
||||
T* head;
|
||||
|
||||
public:
|
||||
nonVector() {
|
||||
|
@ -30,7 +30,7 @@ public:
|
|||
int length() {
|
||||
return 1;
|
||||
}
|
||||
const T &first() const;
|
||||
const T& first() const;
|
||||
};
|
||||
|
||||
// TEMPLATE_UNION
|
||||
|
@ -52,7 +52,7 @@ class TemplateContainer {
|
|||
};
|
||||
|
||||
// TEMPLATE_FUNCTION
|
||||
template<class T> const T &nonVector<T>::first() const {
|
||||
template<class T> const T& nonVector<T>::first() const {
|
||||
return *head;
|
||||
}
|
||||
|
||||
|
|
|
@ -131,4 +131,7 @@ public class FormatActionTest extends TestCase {
|
|||
assertFormatResult();
|
||||
}
|
||||
|
||||
public void testBugs() throws Exception {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue