1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-01 06:05:24 +02:00

Fix for 197494: Code formatter has problems with macros that contain access keywords

This commit is contained in:
Anton Leherbauer 2007-08-20 11:42:57 +00:00
parent 82cab2f819
commit 6996d6d478
2 changed files with 36 additions and 11 deletions

View file

@ -1082,18 +1082,25 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
if (!preferences.indent_access_specifier_compare_to_type_header) {
scribe.unIndent();
}
switch (node.getVisibility()) {
case ICPPASTVisiblityLabel.v_private:
scribe.printNextToken(Token.t_private, false);
break;
case ICPPASTVisiblityLabel.v_protected:
scribe.printNextToken(Token.t_protected, false);
break;
case ICPPASTVisiblityLabel.v_public:
scribe.printNextToken(Token.t_public, false);
break;
if (node.getNodeLocations()[0] instanceof IASTMacroExpansion) {
skipNode(node);
} else {
switch (node.getVisibility()) {
case ICPPASTVisiblityLabel.v_private:
scribe.printNextToken(Token.t_private, false);
break;
case ICPPASTVisiblityLabel.v_protected:
scribe.printNextToken(Token.t_protected, false);
break;
case ICPPASTVisiblityLabel.v_public:
scribe.printNextToken(Token.t_public, false);
break;
}
if (peekNextToken() != Token.tCOLON) {
scribe.skipToToken(Token.tCOLON);
}
scribe.printNextToken(Token.tCOLON, false/*preferences.insert_space_before_colon_in_visibility_label */);
}
scribe.printNextToken(Token.tCOLON, false/*preferences.insert_space_before_colon_in_visibility_label */);
if (!preferences.indent_access_specifier_compare_to_type_header) {
scribe.indent();
}

View file

@ -179,4 +179,22 @@ public class CodeFormatterTest extends BaseUITestCase {
public void testForWithEmptyExpression_Bug195942() throws Exception {
assertFormatterResult();
}
//#define MY private:
//
//class ClassA
//{
//MY ClassA() {}
//};
//#define MY private:
//
//class ClassA {
//MY
// ClassA() {
// }
//};
public void testAccessSpecifierAsMacro_Bug197494() throws Exception {
assertFormatterResult();
}
}