diff --git a/src/libs/cplusplus/ExpressionUnderCursor.cpp b/src/libs/cplusplus/ExpressionUnderCursor.cpp index 8016f537bb2de71be26d4f2688005784700971e4..d95982b881ca0c852471c690682cf782a27966d6 100644 --- a/src/libs/cplusplus/ExpressionUnderCursor.cpp +++ b/src/libs/cplusplus/ExpressionUnderCursor.cpp @@ -45,8 +45,33 @@ ExpressionUnderCursor::~ExpressionUnderCursor() int ExpressionUnderCursor::startOfExpression(BackwardsScanner &tk, int index) { - // tk is a reference to a const QList. So, don't worry about [] access. - // ### TODO implement multiline support. It should be pretty easy. + index = startOfExpression_helper(tk, index); + + if (_jumpedComma) { + const SimpleToken &tok = tk[index - 1]; + + switch (tok.kind()) { + case T_LPAREN: + case T_LBRACKET: + case T_LBRACE: + case T_SEMICOLON: + case T_COLON: + case T_QUESTION: + break; + + default: + if (tok.isOperator()) + return startOfExpression(tk, index - 1); + + break; + } + } + + return index; +} + +int ExpressionUnderCursor::startOfExpression_helper(BackwardsScanner &tk, int index) +{ if (tk[index - 1].isLiteral()) { return index - 1; } else if (tk[index - 1].is(T_THIS)) { diff --git a/src/libs/cplusplus/ExpressionUnderCursor.h b/src/libs/cplusplus/ExpressionUnderCursor.h index 35be67214df15603e3e2672e1b2456c7800ca58d..b72f790f977c850cc9ab1560984f60e392c7c89f 100644 --- a/src/libs/cplusplus/ExpressionUnderCursor.h +++ b/src/libs/cplusplus/ExpressionUnderCursor.h @@ -55,6 +55,7 @@ public: private: int startOfExpression(BackwardsScanner &tk, int index); + int startOfExpression_helper(BackwardsScanner &tk, int index); int previousBlockState(const QTextBlock &block); bool isAccessToken(const SimpleToken &tk);