mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 257700 - Wrong formatting of C++ class when using value of function pointer
This commit is contained in:
parent
78b78b4812
commit
4eea923bc7
3 changed files with 73 additions and 64 deletions
|
@ -2094,6 +2094,10 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
|
|||
boolean forceSpace= Character.isJavaIdentifierStart(peekNextChar());
|
||||
|
||||
switch (node.getOperator()) {
|
||||
case IASTBinaryExpression.op_pmdot:
|
||||
case IASTBinaryExpression.op_pmarrow:
|
||||
scribe.printNextToken(nextToken, false);
|
||||
break;
|
||||
case IASTBinaryExpression.op_assign:
|
||||
case IASTBinaryExpression.op_binaryAndAssign:
|
||||
case IASTBinaryExpression.op_binaryOrAssign:
|
||||
|
|
|
@ -306,72 +306,66 @@ public class SimpleScanner {
|
|||
++digits;
|
||||
c = getChar();
|
||||
}
|
||||
|
||||
if (!hex && c == '.') {
|
||||
if (floatingPoint && digits == 0) {
|
||||
// encountered ..
|
||||
if ((c= getChar()) == '.') {
|
||||
return newToken(Token.tELIPSE);
|
||||
} else {
|
||||
ungetChar(c);
|
||||
ungetChar('.');
|
||||
return newToken(Token.tDOT);
|
||||
}
|
||||
}
|
||||
|
||||
floatingPoint = true;
|
||||
c = getChar();
|
||||
while ((c >= '0' && c <= '9')) {
|
||||
++digits;
|
||||
c = getChar();
|
||||
}
|
||||
}
|
||||
|
||||
if (!hex && digits > 0 && (c == 'e' || c == 'E')) {
|
||||
if (!floatingPoint) {
|
||||
floatingPoint = true;
|
||||
}
|
||||
|
||||
// exponent type for floating point
|
||||
c = getChar();
|
||||
|
||||
// optional + or -
|
||||
if (c == '+' || c == '-') {
|
||||
c = getChar();
|
||||
}
|
||||
|
||||
// digit sequence of exponent part
|
||||
while ((c >= '0' && c <= '9')) {
|
||||
c = getChar();
|
||||
}
|
||||
|
||||
// optional suffix
|
||||
if (c == 'l' || c == 'L' || c == 'f' || c == 'F') {
|
||||
c = getChar();
|
||||
}
|
||||
if (!hex) {
|
||||
if (c == '*') {
|
||||
return newToken(Token.tDOTSTAR);
|
||||
} else if (c == '.') {
|
||||
if (floatingPoint && digits == 0) {
|
||||
// encountered ..
|
||||
if ((c= getChar()) == '.') {
|
||||
return newToken(Token.tELIPSE);
|
||||
} else {
|
||||
ungetChar(c);
|
||||
ungetChar('.');
|
||||
return newToken(Token.tDOT);
|
||||
}
|
||||
}
|
||||
|
||||
floatingPoint = true;
|
||||
c = getChar();
|
||||
while ((c >= '0' && c <= '9')) {
|
||||
++digits;
|
||||
c = getChar();
|
||||
}
|
||||
} else if (digits > 0 && (c == 'e' || c == 'E')) {
|
||||
floatingPoint = true;
|
||||
|
||||
// exponent type for floating point
|
||||
c = getChar();
|
||||
|
||||
// optional + or -
|
||||
if (c == '+' || c == '-') {
|
||||
c = getChar();
|
||||
}
|
||||
|
||||
// digit sequence of exponent part
|
||||
while ((c >= '0' && c <= '9')) {
|
||||
c = getChar();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (floatingPoint) {
|
||||
if (digits > 0) {
|
||||
//floating-suffix
|
||||
if (c == 'l' || c == 'L' || c == 'f' || c == 'F') {
|
||||
c = getChar();
|
||||
}
|
||||
} else {
|
||||
ungetChar(c);
|
||||
return newToken(Token.tDOT);
|
||||
}
|
||||
} else {
|
||||
if (floatingPoint) {
|
||||
if (digits > 0) {
|
||||
//floating-suffix
|
||||
if (c == 'l' || c == 'L' || c == 'f' || c == 'F') {
|
||||
c = getChar();
|
||||
}
|
||||
} else {
|
||||
ungetChar(c);
|
||||
return newToken(Token.tDOT);
|
||||
}
|
||||
} else {
|
||||
//integer suffix
|
||||
if (c == 'u' || c == 'U') {
|
||||
c = getChar();
|
||||
if (c == 'l' || c == 'L')
|
||||
c = getChar();
|
||||
} else if (c == 'l' || c == 'L') {
|
||||
c = getChar();
|
||||
if (c == 'u' || c == 'U')
|
||||
c = getChar();
|
||||
}
|
||||
}
|
||||
//integer suffix
|
||||
if (c == 'u' || c == 'U') {
|
||||
c = getChar();
|
||||
if (c == 'l' || c == 'L')
|
||||
c = getChar();
|
||||
} else if (c == 'l' || c == 'L') {
|
||||
c = getChar();
|
||||
if (c == 'u' || c == 'U')
|
||||
c = getChar();
|
||||
}
|
||||
}
|
||||
|
||||
ungetChar(c);
|
||||
|
|
|
@ -1080,4 +1080,15 @@ public class CodeFormatterTest extends BaseUITestCase {
|
|||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_EXCEPTION_SPECIFICATION, CCorePlugin.INSERT);
|
||||
assertFormatterResult();
|
||||
}
|
||||
|
||||
//void Foo::bar() {
|
||||
//*this.*FncPointer () ; this->*FncPointer( ); }
|
||||
|
||||
//void Foo::bar() {
|
||||
// *this.*FncPointer();
|
||||
// this->*FncPointer();
|
||||
//}
|
||||
public void testDotStarAndArrowStarOperators_Bug257700() throws Exception {
|
||||
assertFormatterResult();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue