forked from qt-creator/qt-creator
C++: Clarify units of a Token
This will avoid confusion when later more length and indices methods are
added.
In Token:
length() --> bytes()
begin() --> bytesBegin()
end() --> bytesEnd()
Change-Id: I244c69b022e239ee762b4114559e707f93ff344f
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
@@ -479,7 +479,8 @@ BaseTextEditorWidget::Link FollowSymbolUnderCursor::findLink(const QTextCursor &
|
||||
for (int i = 0; i < tokens.size(); ++i) {
|
||||
const Token &tk = tokens.at(i);
|
||||
|
||||
if (((unsigned) positionInBlock) >= tk.begin() && ((unsigned) positionInBlock) < tk.end()) {
|
||||
if (((unsigned) positionInBlock) >= tk.bytesBegin()
|
||||
&& ((unsigned) positionInBlock) < tk.bytesEnd()) {
|
||||
int closingParenthesisPos = tokens.size();
|
||||
if (i >= 2 && tokens.at(i).is(T_IDENTIFIER) && tokens.at(i - 1).is(T_LPAREN)
|
||||
&& (tokens.at(i - 2).is(T_SIGNAL) || tokens.at(i - 2).is(T_SLOT))) {
|
||||
@@ -503,10 +504,10 @@ BaseTextEditorWidget::Link FollowSymbolUnderCursor::findLink(const QTextCursor &
|
||||
if (closingParenthesisPos < tokens.size()) {
|
||||
QTextBlock block = cursor.block();
|
||||
|
||||
beginOfToken = block.position() + tokens.at(i).begin();
|
||||
endOfToken = block.position() + tokens.at(i).end();
|
||||
beginOfToken = block.position() + tokens.at(i).bytesBegin();
|
||||
endOfToken = block.position() + tokens.at(i).bytesEnd();
|
||||
|
||||
tc.setPosition(block.position() + tokens.at(closingParenthesisPos).end());
|
||||
tc.setPosition(block.position() + tokens.at(closingParenthesisPos).bytesEnd());
|
||||
recognizedQtMethod = true;
|
||||
}
|
||||
break;
|
||||
@@ -521,7 +522,8 @@ BaseTextEditorWidget::Link FollowSymbolUnderCursor::findLink(const QTextCursor &
|
||||
|
||||
// In this case we want to look at one token before the current position to recognize
|
||||
// an operator if the cursor is inside the actual operator: operator[$]
|
||||
if (unsigned(positionInBlock) >= tk.begin() && unsigned(positionInBlock) <= tk.end()) {
|
||||
if (unsigned(positionInBlock) >= tk.bytesBegin()
|
||||
&& unsigned(positionInBlock) <= tk.bytesEnd()) {
|
||||
cursorRegionReached = true;
|
||||
if (tk.is(T_OPERATOR)) {
|
||||
link = attemptFuncDeclDef(cursor, m_widget, theSnapshot,
|
||||
@@ -531,7 +533,7 @@ BaseTextEditorWidget::Link FollowSymbolUnderCursor::findLink(const QTextCursor &
|
||||
} else if (tk.isOperator() && i > 0 && tokens.at(i - 1).is(T_OPERATOR)) {
|
||||
QTextCursor c = cursor;
|
||||
c.movePosition(QTextCursor::Left, QTextCursor::MoveAnchor,
|
||||
positionInBlock - tokens.at(i - 1).begin());
|
||||
positionInBlock - tokens.at(i - 1).bytesBegin());
|
||||
link = attemptFuncDeclDef(c, m_widget, theSnapshot, documentFromSemanticInfo,
|
||||
symbolFinder);
|
||||
if (link.hasValidLinkText())
|
||||
@@ -560,8 +562,8 @@ BaseTextEditorWidget::Link FollowSymbolUnderCursor::findLink(const QTextCursor &
|
||||
const Token tk = SimpleLexer::tokenAt(block.text(), pos,
|
||||
BackwardsScanner::previousBlockState(block), true);
|
||||
|
||||
beginOfToken = block.position() + tk.begin();
|
||||
endOfToken = block.position() + tk.end();
|
||||
beginOfToken = block.position() + tk.bytesBegin();
|
||||
endOfToken = block.position() + tk.bytesEnd();
|
||||
|
||||
// Handle include directives
|
||||
if (tk.is(T_STRING_LITERAL) || tk.is(T_ANGLE_STRING_LITERAL)) {
|
||||
|
||||
Reference in New Issue
Block a user