Utils: filepathify Link

Change-Id: Ie62500bde139158e776f9698ee0ea00c2a113f93
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
David Schulz
2021-05-25 10:11:31 +02:00
parent dbd4a10d6f
commit 356bfcc9fd
24 changed files with 76 additions and 59 deletions

View File

@@ -117,7 +117,7 @@ static Utils::Link linkAtCursor(const QTextCursor &cursor,
if (mark.extraInfo.includeDirectivePath && !isValidIncludePathToken(mark))
return Link();
Link token(filePath, mark.line, mark.column);
Link token(Utils::FilePath::fromString(filePath), mark.line, mark.column);
token.linkTextStart = getMarkPos(cursor, mark);
token.linkTextEnd = token.linkTextStart + mark.length;
@@ -155,8 +155,9 @@ static ::Utils::ProcessLinkCallback extendedCallback(::Utils::ProcessLinkCallbac
// If globalFollowSymbol finds nothing follow to the declaration.
return [original_callback = std::move(callback), result](const ::Utils::Link &link) {
if (link.linkTextStart < 0 && result.isResultOnlyForFallBack) {
return original_callback(::Utils::Link(result.fileName, result.startLine,
result.startColumn - 1));
return original_callback(::Utils::Link(::Utils::FilePath::fromString(result.fileName),
result.startLine,
result.startColumn - 1));
}
return original_callback(link);
};
@@ -243,7 +244,9 @@ void ClangFollowSymbol::findLink(const CppTools::CursorInEditor &data,
symbolFinder,
inNextSplit);
} else {
callback(Link(result.fileName, result.startLine, result.startColumn - 1));
callback(Link(Utils::FilePath::fromString(result.fileName),
result.startLine,
result.startColumn - 1));
}
});

View File

@@ -162,17 +162,19 @@ QList<Core::LocatorFilterEntry> ClangGlobalSymbolFilter::matchesFor(
QList<Core::LocatorFilterEntry> matches = m_cppFilter->matchesFor(future, entry);
const QList<Core::LocatorFilterEntry> lspMatches = m_lspFilter->matchesFor(future, entry);
if (!lspMatches.isEmpty()) {
std::set<std::tuple<QString, int, int>> locations;
std::set<std::tuple<Utils::FilePath, int, int>> locations;
for (const auto &entry : qAsConst(matches)) {
const CppTools::IndexItem::Ptr item
= qvariant_cast<CppTools::IndexItem::Ptr>(entry.internalData);
locations.insert(std::make_tuple(item->fileName(), item->line(), item->column()));
locations.insert(std::make_tuple(Utils::FilePath::fromString(item->fileName()),
item->line(),
item->column()));
}
for (const auto &entry : lspMatches) {
if (!entry.internalData.canConvert<Utils::Link>())
continue;
const auto link = qvariant_cast<Utils::Link>(entry.internalData);
if (locations.find(std::make_tuple(link.targetFileName, link.targetLine,
if (locations.find(std::make_tuple(link.targetFilePath, link.targetLine,
link.targetColumn)) == locations.cend()) {
matches << entry; // TODO: Insert sorted?
}

View File

@@ -226,7 +226,7 @@ Link OverviewModel::linkFromIndex(const QModelIndex &sourceIndex) const
auto item = static_cast<TokenTreeItem *>(itemForIndex(sourceIndex));
if (!item)
return {};
return Link(m_filePath, item->token.line, item->token.column - 1);
return Link(FilePath::fromString(m_filePath), item->token.line, item->token.column - 1);
}
LineColumn OverviewModel::lineColumnFromIndex(const QModelIndex &sourceIndex) const