mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-16 04:35:45 +02:00
Fix for 197494: Code formatter has problems with macros that contain access keywords
This commit is contained in:
parent
82cab2f819
commit
6996d6d478
2 changed files with 36 additions and 11 deletions
|
@ -1082,18 +1082,25 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
|
||||||
if (!preferences.indent_access_specifier_compare_to_type_header) {
|
if (!preferences.indent_access_specifier_compare_to_type_header) {
|
||||||
scribe.unIndent();
|
scribe.unIndent();
|
||||||
}
|
}
|
||||||
switch (node.getVisibility()) {
|
if (node.getNodeLocations()[0] instanceof IASTMacroExpansion) {
|
||||||
case ICPPASTVisiblityLabel.v_private:
|
skipNode(node);
|
||||||
scribe.printNextToken(Token.t_private, false);
|
} else {
|
||||||
break;
|
switch (node.getVisibility()) {
|
||||||
case ICPPASTVisiblityLabel.v_protected:
|
case ICPPASTVisiblityLabel.v_private:
|
||||||
scribe.printNextToken(Token.t_protected, false);
|
scribe.printNextToken(Token.t_private, false);
|
||||||
break;
|
break;
|
||||||
case ICPPASTVisiblityLabel.v_public:
|
case ICPPASTVisiblityLabel.v_protected:
|
||||||
scribe.printNextToken(Token.t_public, false);
|
scribe.printNextToken(Token.t_protected, false);
|
||||||
break;
|
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) {
|
if (!preferences.indent_access_specifier_compare_to_type_header) {
|
||||||
scribe.indent();
|
scribe.indent();
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,4 +179,22 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
public void testForWithEmptyExpression_Bug195942() throws Exception {
|
public void testForWithEmptyExpression_Bug195942() throws Exception {
|
||||||
assertFormatterResult();
|
assertFormatterResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#define MY private:
|
||||||
|
//
|
||||||
|
//class ClassA
|
||||||
|
//{
|
||||||
|
//MY ClassA() {}
|
||||||
|
//};
|
||||||
|
|
||||||
|
//#define MY private:
|
||||||
|
//
|
||||||
|
//class ClassA {
|
||||||
|
//MY
|
||||||
|
// ClassA() {
|
||||||
|
// }
|
||||||
|
//};
|
||||||
|
public void testAccessSpecifierAsMacro_Bug197494() throws Exception {
|
||||||
|
assertFormatterResult();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue