diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java index d745249f888..6ca492a816e 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java @@ -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: diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/scanner/SimpleScanner.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/scanner/SimpleScanner.java index 675c7b4f341..d7482b19713 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/scanner/SimpleScanner.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/scanner/SimpleScanner.java @@ -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); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java index 76f242a17b4..e58a3b80f4d 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java @@ -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(); + } }