mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 14:12:10 +02:00
Bug 460551. C++11 Keyword 'final' not supported in code formatter
Change-Id: I87db78c4b848f2a469c8a0cd53caa6c60aa3adca Signed-off-by: Milivoje Legenovic <duh-sa-sekirom@hotmail.com>
This commit is contained in:
parent
bb4b74b367
commit
52794aa29c
2 changed files with 43 additions and 0 deletions
|
@ -104,6 +104,7 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTVisitor;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTClassVirtSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
|
||||
|
@ -386,6 +387,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
|||
shouldVisitBaseSpecifiers = true;
|
||||
shouldVisitNamespaces = true;
|
||||
shouldVisitTemplateParameters = true;
|
||||
shouldVisitVirtSpecifiers = true;
|
||||
}
|
||||
|
||||
private final Scanner localScanner;
|
||||
|
@ -1828,6 +1830,12 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
|||
name.accept(this);
|
||||
}
|
||||
|
||||
ICPPASTClassVirtSpecifier virtSpecifier = node.getVirtSpecifier();
|
||||
if (virtSpecifier != null) {
|
||||
scribe.space();
|
||||
virtSpecifier.accept(this);
|
||||
}
|
||||
|
||||
// Base specifiers
|
||||
final List<ICPPASTBaseSpecifier> baseSpecifiers= Arrays.asList(node.getBaseSpecifiers());
|
||||
if (baseSpecifiers.size() > 0) {
|
||||
|
@ -3459,6 +3467,14 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
|||
return PROCESS_SKIP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int visit(ICPPASTClassVirtSpecifier node) {
|
||||
if (node.getKind() == ICPPASTClassVirtSpecifier.SpecifierKind.Final) {
|
||||
scribe.printNextToken(Token.t_final);
|
||||
}
|
||||
return PROCESS_SKIP;
|
||||
}
|
||||
|
||||
private int visit(IASTReturnStatement node) {
|
||||
scribe.printNextToken(Token.t_return);
|
||||
final IASTExpression expression = node.getReturnValue();
|
||||
|
|
|
@ -356,6 +356,33 @@ public class CodeFormatterTest extends BaseUITestCase {
|
|||
assertFormatterResult();
|
||||
}
|
||||
|
||||
//class A final {
|
||||
//public:
|
||||
//A();
|
||||
//};
|
||||
|
||||
//class A final {
|
||||
//public:
|
||||
// A();
|
||||
//};
|
||||
public void testKeywordFinal_Bug460551() throws Exception {
|
||||
assertFormatterResult();
|
||||
}
|
||||
|
||||
//class A
|
||||
//final : public B {
|
||||
//public:
|
||||
//A();
|
||||
//};
|
||||
|
||||
//class A final : public B {
|
||||
//public:
|
||||
// A();
|
||||
//};
|
||||
public void testKeywordFinalDerivedClass_Bug460551() throws Exception {
|
||||
assertFormatterResult();
|
||||
}
|
||||
|
||||
//template<typename T> class B {};
|
||||
//template<typename T1,typename T2=B<T1> > class A {};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue