Commit 42c676d1 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Added BackwardsScanner::mid(tokenIndex). Mid() returns a substring starting...

Added BackwardsScanner::mid(tokenIndex). Mid() returns a substring starting from the position of the given token.
parent 41118d91
...@@ -99,6 +99,12 @@ int BackwardsScanner::startPosition() const ...@@ -99,6 +99,12 @@ int BackwardsScanner::startPosition() const
QString BackwardsScanner::text() const QString BackwardsScanner::text() const
{ return _text; } { return _text; }
QString BackwardsScanner::mid(int index) const
{
const SimpleToken &firstToken = _tokens.at(index + _offset);
return _text.mid(firstToken.begin());
}
QString BackwardsScanner::text(int index) const QString BackwardsScanner::text(int index) const
{ {
const SimpleToken &firstToken = _tokens.at(index + _offset); const SimpleToken &firstToken = _tokens.at(index + _offset);
......
...@@ -51,9 +51,10 @@ public: ...@@ -51,9 +51,10 @@ public:
int startPosition() const; int startPosition() const;
QString text() const; QString text() const;
QString mid(int index) const;
QString text(int index) const; QString text(int index) const;
QStringRef textRef(int index) const; QStringRef textRef(int index) const;
// 1-based // 1-based
SimpleToken LA(int index) const; SimpleToken LA(int index) const;
......
...@@ -150,7 +150,7 @@ QString ExpressionUnderCursor::operator()(const QTextCursor &cursor) ...@@ -150,7 +150,7 @@ QString ExpressionUnderCursor::operator()(const QTextCursor &cursor)
if (i == initialSize) if (i == initialSize)
return QString(); return QString();
return scanner.text(i); return scanner.mid(i);
} }
int ExpressionUnderCursor::startOfFunctionCall(const QTextCursor &cursor) const int ExpressionUnderCursor::startOfFunctionCall(const QTextCursor &cursor) const
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment