forked from qt-creator/qt-creator
CppTools: Use cursor range for better outline navigation
Clang provides cursor range for each declaration in symbol outline. Use that information to search for more accurate correspondence between a cursor position in editor and an entry in symbol outline. For example skip indexes with not matching ranges to prevent pure declarations from automatically become parents of everything coming after them. Change-Id: I0ef95c26772050cd6655e830288c46118aba38bb Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -213,10 +213,20 @@ bool OverviewModel::isGenerated(const QModelIndex &) const
|
||||
TokenTreeItem *item = static_cast<TokenTreeItem *>(itemForIndex(sourceIndex));
|
||||
if (!item)
|
||||
return {};
|
||||
::Utils::LineColumn lineColumn;
|
||||
lineColumn.line = static_cast<int>(item->token.line);
|
||||
lineColumn.column = static_cast<int>(item->token.column);
|
||||
return lineColumn;
|
||||
return ::Utils::LineColumn(static_cast<int>(item->token.line),
|
||||
static_cast<int>(item->token.column));
|
||||
}
|
||||
|
||||
OverviewModel::Range OverviewModel::rangeFromIndex(const QModelIndex &sourceIndex) const
|
||||
{
|
||||
TokenTreeItem *item = static_cast<TokenTreeItem *>(itemForIndex(sourceIndex));
|
||||
if (!item)
|
||||
return {};
|
||||
const ClangBackEnd::SourceRangeContainer &range = item->token.extraInfo.cursorRange;
|
||||
return std::make_pair(::Utils::LineColumn(static_cast<int>(range.start.line),
|
||||
static_cast<int>(range.start.column)),
|
||||
::Utils::LineColumn(static_cast<int>(range.end.line),
|
||||
static_cast<int>(range.end.column)));
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user