forked from qt-creator/qt-creator
Utils: filepathify Link
Change-Id: Ie62500bde139158e776f9698ee0ea00c2a113f93 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
2
src/libs/3rdparty/cplusplus/Symbol.cpp
vendored
2
src/libs/3rdparty/cplusplus/Symbol.cpp
vendored
@@ -450,5 +450,5 @@ Utils::Link Symbol::toLink() const
|
|||||||
if (isGenerated())
|
if (isGenerated())
|
||||||
column = 0;
|
column = 0;
|
||||||
|
|
||||||
return Utils::Link(filename, line, column);
|
return Utils::Link(Utils::FilePath::fromString(filename), line, column);
|
||||||
}
|
}
|
||||||
|
@@ -366,7 +366,9 @@ Utils::Link Location::toLink() const
|
|||||||
// fromPercentEncoding convert %xx encoding to raw values and then interpret
|
// fromPercentEncoding convert %xx encoding to raw values and then interpret
|
||||||
// the result as utf-8, so toUtf8() must be used here.
|
// the result as utf-8, so toUtf8() must be used here.
|
||||||
file = QUrl::fromPercentEncoding(file.toUtf8());
|
file = QUrl::fromPercentEncoding(file.toUtf8());
|
||||||
return Utils::Link(file, range().start().line() + 1, range().start().character());
|
return Utils::Link(Utils::FilePath::fromString(file),
|
||||||
|
range().start().line() + 1,
|
||||||
|
range().start().character());
|
||||||
}
|
}
|
||||||
|
|
||||||
DocumentUri::DocumentUri(const QString &other)
|
DocumentUri::DocumentUri(const QString &other)
|
||||||
|
@@ -25,23 +25,26 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <utils/fileutils.h>
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <qmetatype.h>
|
#include <qmetatype.h>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
|
|
||||||
struct Link
|
struct Link
|
||||||
{
|
{
|
||||||
Link(const QString &fileName = QString(), int line = 0, int column = 0)
|
Link(const Utils::FilePath &filePath = Utils::FilePath(), int line = 0, int column = 0)
|
||||||
: targetFileName(fileName)
|
: targetFilePath(filePath)
|
||||||
, targetLine(line)
|
, targetLine(line)
|
||||||
, targetColumn(column)
|
, targetColumn(column)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool hasValidTarget() const
|
bool hasValidTarget() const
|
||||||
{ return !targetFileName.isEmpty(); }
|
{ return !targetFilePath.isEmpty(); }
|
||||||
|
|
||||||
bool hasValidLinkText() const
|
bool hasValidLinkText() const
|
||||||
{ return linkTextStart != linkTextEnd; }
|
{ return linkTextStart != linkTextEnd; }
|
||||||
@@ -52,7 +55,7 @@ struct Link
|
|||||||
int linkTextStart = -1;
|
int linkTextStart = -1;
|
||||||
int linkTextEnd = -1;
|
int linkTextEnd = -1;
|
||||||
|
|
||||||
QString targetFileName;
|
Utils::FilePath targetFilePath;
|
||||||
int targetLine;
|
int targetLine;
|
||||||
int targetColumn;
|
int targetColumn;
|
||||||
};
|
};
|
||||||
|
@@ -88,7 +88,7 @@ QVariant CTestTreeItem::data(int column, int role) const
|
|||||||
return checked();
|
return checked();
|
||||||
if (role == LinkRole) {
|
if (role == LinkRole) {
|
||||||
QVariant itemLink;
|
QVariant itemLink;
|
||||||
itemLink.setValue(Utils::Link(filePath(), line()));
|
itemLink.setValue(Utils::Link(Utils::FilePath::fromString(filePath()), line()));
|
||||||
return itemLink;
|
return itemLink;
|
||||||
}
|
}
|
||||||
return ITestTreeItem::data(column, role);
|
return ITestTreeItem::data(column, role);
|
||||||
|
@@ -267,7 +267,8 @@ void TestNavigationWidget::onItemActivated(const QModelIndex &index)
|
|||||||
{
|
{
|
||||||
const Utils::Link link = index.data(LinkRole).value<Utils::Link>();
|
const Utils::Link link = index.data(LinkRole).value<Utils::Link>();
|
||||||
if (link.hasValidTarget()) {
|
if (link.hasValidTarget()) {
|
||||||
Core::EditorManager::openEditorAt(link.targetFileName, link.targetLine,
|
Core::EditorManager::openEditorAt(link.targetFilePath,
|
||||||
|
link.targetLine,
|
||||||
link.targetColumn);
|
link.targetColumn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -137,12 +137,12 @@ bool ITestTreeItem::lessThan(const ITestTreeItem *other, ITestTreeItem::SortMode
|
|||||||
|
|
||||||
const Utils::Link &leftLink = data(0, LinkRole).value<Utils::Link>();
|
const Utils::Link &leftLink = data(0, LinkRole).value<Utils::Link>();
|
||||||
const Utils::Link &rightLink = other->data(0, LinkRole).value<Utils::Link>();
|
const Utils::Link &rightLink = other->data(0, LinkRole).value<Utils::Link>();
|
||||||
if (leftLink.targetFileName == rightLink.targetFileName) {
|
if (leftLink.targetFilePath == rightLink.targetFilePath) {
|
||||||
return leftLink.targetLine == rightLink.targetLine
|
return leftLink.targetLine == rightLink.targetLine
|
||||||
? leftLink.targetColumn > rightLink.targetColumn
|
? leftLink.targetColumn > rightLink.targetColumn
|
||||||
: leftLink.targetLine > rightLink.targetLine;
|
: leftLink.targetLine > rightLink.targetLine;
|
||||||
}
|
}
|
||||||
return leftLink.targetFileName > rightLink.targetFileName;
|
return leftLink.targetFilePath > rightLink.targetFilePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -185,7 +185,8 @@ QVariant TestTreeItem::data(int column, int role) const
|
|||||||
if (type() == GroupNode)
|
if (type() == GroupNode)
|
||||||
return QVariant();
|
return QVariant();
|
||||||
QVariant itemLink;
|
QVariant itemLink;
|
||||||
itemLink.setValue(Utils::Link(filePath(), line(), int(m_column)));
|
itemLink.setValue(
|
||||||
|
Utils::Link(Utils::FilePath::fromString(filePath()), line(), int(m_column)));
|
||||||
return itemLink;
|
return itemLink;
|
||||||
}
|
}
|
||||||
return ITestTreeItem::data(column, role);
|
return ITestTreeItem::data(column, role);
|
||||||
|
@@ -117,7 +117,7 @@ static Utils::Link linkAtCursor(const QTextCursor &cursor,
|
|||||||
if (mark.extraInfo.includeDirectivePath && !isValidIncludePathToken(mark))
|
if (mark.extraInfo.includeDirectivePath && !isValidIncludePathToken(mark))
|
||||||
return Link();
|
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.linkTextStart = getMarkPos(cursor, mark);
|
||||||
token.linkTextEnd = token.linkTextStart + mark.length;
|
token.linkTextEnd = token.linkTextStart + mark.length;
|
||||||
|
|
||||||
@@ -155,7 +155,8 @@ static ::Utils::ProcessLinkCallback extendedCallback(::Utils::ProcessLinkCallbac
|
|||||||
// If globalFollowSymbol finds nothing follow to the declaration.
|
// If globalFollowSymbol finds nothing follow to the declaration.
|
||||||
return [original_callback = std::move(callback), result](const ::Utils::Link &link) {
|
return [original_callback = std::move(callback), result](const ::Utils::Link &link) {
|
||||||
if (link.linkTextStart < 0 && result.isResultOnlyForFallBack) {
|
if (link.linkTextStart < 0 && result.isResultOnlyForFallBack) {
|
||||||
return original_callback(::Utils::Link(result.fileName, result.startLine,
|
return original_callback(::Utils::Link(::Utils::FilePath::fromString(result.fileName),
|
||||||
|
result.startLine,
|
||||||
result.startColumn - 1));
|
result.startColumn - 1));
|
||||||
}
|
}
|
||||||
return original_callback(link);
|
return original_callback(link);
|
||||||
@@ -243,7 +244,9 @@ void ClangFollowSymbol::findLink(const CppTools::CursorInEditor &data,
|
|||||||
symbolFinder,
|
symbolFinder,
|
||||||
inNextSplit);
|
inNextSplit);
|
||||||
} else {
|
} else {
|
||||||
callback(Link(result.fileName, result.startLine, result.startColumn - 1));
|
callback(Link(Utils::FilePath::fromString(result.fileName),
|
||||||
|
result.startLine,
|
||||||
|
result.startColumn - 1));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -162,17 +162,19 @@ QList<Core::LocatorFilterEntry> ClangGlobalSymbolFilter::matchesFor(
|
|||||||
QList<Core::LocatorFilterEntry> matches = m_cppFilter->matchesFor(future, entry);
|
QList<Core::LocatorFilterEntry> matches = m_cppFilter->matchesFor(future, entry);
|
||||||
const QList<Core::LocatorFilterEntry> lspMatches = m_lspFilter->matchesFor(future, entry);
|
const QList<Core::LocatorFilterEntry> lspMatches = m_lspFilter->matchesFor(future, entry);
|
||||||
if (!lspMatches.isEmpty()) {
|
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)) {
|
for (const auto &entry : qAsConst(matches)) {
|
||||||
const CppTools::IndexItem::Ptr item
|
const CppTools::IndexItem::Ptr item
|
||||||
= qvariant_cast<CppTools::IndexItem::Ptr>(entry.internalData);
|
= 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) {
|
for (const auto &entry : lspMatches) {
|
||||||
if (!entry.internalData.canConvert<Utils::Link>())
|
if (!entry.internalData.canConvert<Utils::Link>())
|
||||||
continue;
|
continue;
|
||||||
const auto link = qvariant_cast<Utils::Link>(entry.internalData);
|
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()) {
|
link.targetColumn)) == locations.cend()) {
|
||||||
matches << entry; // TODO: Insert sorted?
|
matches << entry; // TODO: Insert sorted?
|
||||||
}
|
}
|
||||||
|
@@ -226,7 +226,7 @@ Link OverviewModel::linkFromIndex(const QModelIndex &sourceIndex) const
|
|||||||
auto item = static_cast<TokenTreeItem *>(itemForIndex(sourceIndex));
|
auto item = static_cast<TokenTreeItem *>(itemForIndex(sourceIndex));
|
||||||
if (!item)
|
if (!item)
|
||||||
return {};
|
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
|
LineColumn OverviewModel::lineColumnFromIndex(const QModelIndex &sourceIndex) const
|
||||||
|
@@ -132,7 +132,7 @@ void RefactoringEngine::globalFollowSymbol(const CppTools::CursorInEditor &data,
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
processLinkCallback(Link(usage.path, usage.line, usage.column - 1));
|
processLinkCallback(Link(Utils::FilePath::fromString(usage.path), usage.line, usage.column - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RefactoringEngine::isRefactoringEngineAvailable() const
|
bool RefactoringEngine::isRefactoringEngineAvailable() const
|
||||||
|
@@ -212,7 +212,7 @@ void CMakeEditorWidget::findLinkAt(const QTextCursor &cursor,
|
|||||||
else
|
else
|
||||||
return processLinkCallback(link);
|
return processLinkCallback(link);
|
||||||
}
|
}
|
||||||
link.targetFileName = fileName;
|
link.targetFilePath = Utils::FilePath::fromString(fileName);
|
||||||
link.linkTextStart = cursor.position() - positionInBlock + beginPos + 1;
|
link.linkTextStart = cursor.position() - positionInBlock + beginPos + 1;
|
||||||
link.linkTextEnd = cursor.position() - positionInBlock + endPos;
|
link.linkTextEnd = cursor.position() - positionInBlock + endPos;
|
||||||
}
|
}
|
||||||
|
@@ -162,7 +162,7 @@ private:
|
|||||||
|
|
||||||
Qt::ItemFlags flags(int) const override
|
Qt::ItemFlags flags(int) const override
|
||||||
{
|
{
|
||||||
Utils::Link link(m_filePath, m_line);
|
const Utils::Link link(Utils::FilePath::fromString(m_filePath), m_line);
|
||||||
if (link.hasValidTarget())
|
if (link.hasValidTarget())
|
||||||
return Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
return Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||||
@@ -199,7 +199,7 @@ QVariant CppIncludeHierarchyItem::data(int column, int role) const
|
|||||||
case Qt::DecorationRole:
|
case Qt::DecorationRole:
|
||||||
return FileIconProvider::icon(QFileInfo(m_filePath));
|
return FileIconProvider::icon(QFileInfo(m_filePath));
|
||||||
case LinkRole:
|
case LinkRole:
|
||||||
return QVariant::fromValue(Utils::Link(m_filePath, m_line));
|
return QVariant::fromValue(Utils::Link(Utils::FilePath::fromString(m_filePath), m_line));
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@@ -282,7 +282,7 @@ QMimeData *CppIncludeHierarchyModel::mimeData(const QModelIndexList &indexes) co
|
|||||||
for (const QModelIndex &index : indexes) {
|
for (const QModelIndex &index : indexes) {
|
||||||
auto link = index.data(LinkRole).value<Utils::Link>();
|
auto link = index.data(LinkRole).value<Utils::Link>();
|
||||||
if (link.hasValidTarget())
|
if (link.hasValidTarget())
|
||||||
data->addFile(link.targetFileName, link.targetLine, link.targetColumn);
|
data->addFile(link.targetFilePath.toString(), link.targetLine, link.targetColumn);
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@@ -434,11 +434,11 @@ void CppIncludeHierarchyWidget::perform()
|
|||||||
if (!m_editor)
|
if (!m_editor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QString document = m_editor->textDocument()->filePath().toString();
|
const Utils::FilePath documentPath = m_editor->textDocument()->filePath();
|
||||||
m_model.buildHierarchy(document);
|
m_model.buildHierarchy(documentPath.toString());
|
||||||
|
|
||||||
m_inspectedFile->setText(m_editor->textDocument()->displayName());
|
m_inspectedFile->setText(m_editor->textDocument()->displayName());
|
||||||
m_inspectedFile->setLink(Utils::Link(document));
|
m_inspectedFile->setLink(Utils::Link(documentPath));
|
||||||
|
|
||||||
// expand "Includes" and "Included by"
|
// expand "Includes" and "Included by"
|
||||||
m_treeView->expand(m_model.index(0, 0));
|
m_treeView->expand(m_model.index(0, 0));
|
||||||
@@ -465,7 +465,7 @@ void CppIncludeHierarchyWidget::onItemActivated(const QModelIndex &index)
|
|||||||
{
|
{
|
||||||
const auto link = index.data(LinkRole).value<Utils::Link>();
|
const auto link = index.data(LinkRole).value<Utils::Link>();
|
||||||
if (link.hasValidTarget())
|
if (link.hasValidTarget())
|
||||||
EditorManager::openEditorAt(link.targetFileName,
|
EditorManager::openEditorAt(link.targetFilePath,
|
||||||
link.targetLine,
|
link.targetLine,
|
||||||
link.targetColumn,
|
link.targetColumn,
|
||||||
Constants::CPPEDITOR_ID);
|
Constants::CPPEDITOR_ID);
|
||||||
|
@@ -332,11 +332,11 @@ void CppTypeHierarchyWidget::onItemActivated(const QModelIndex &index)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
const Link updatedLink = CppElementEvaluator::linkFromExpression(
|
const Link updatedLink = CppElementEvaluator::linkFromExpression(
|
||||||
getExpression(index), link.targetFileName);
|
getExpression(index), link.targetFilePath.toString());
|
||||||
if (updatedLink.hasValidTarget())
|
if (updatedLink.hasValidTarget())
|
||||||
link = updatedLink;
|
link = updatedLink;
|
||||||
|
|
||||||
Core::EditorManager::openEditorAt(link.targetFileName,
|
Core::EditorManager::openEditorAt(link.targetFilePath,
|
||||||
link.targetLine,
|
link.targetLine,
|
||||||
link.targetColumn,
|
link.targetColumn,
|
||||||
Constants::CPPEDITOR_ID);
|
Constants::CPPEDITOR_ID);
|
||||||
@@ -346,7 +346,7 @@ void CppTypeHierarchyWidget::onItemDoubleClicked(const QModelIndex &index)
|
|||||||
{
|
{
|
||||||
const auto link = index.data(LinkRole).value<Link>();
|
const auto link = index.data(LinkRole).value<Link>();
|
||||||
if (link.hasValidTarget())
|
if (link.hasValidTarget())
|
||||||
performFromExpression(getExpression(index), link.targetFileName);
|
performFromExpression(getExpression(index), link.targetFilePath.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// CppTypeHierarchyFactory
|
// CppTypeHierarchyFactory
|
||||||
@@ -390,7 +390,7 @@ QMimeData *CppTypeHierarchyModel::mimeData(const QModelIndexList &indexes) const
|
|||||||
foreach (const QModelIndex &index, indexes) {
|
foreach (const QModelIndex &index, indexes) {
|
||||||
auto link = index.data(LinkRole).value<Link>();
|
auto link = index.data(LinkRole).value<Link>();
|
||||||
if (link.hasValidTarget())
|
if (link.hasValidTarget())
|
||||||
data->addFile(link.targetFileName, link.targetLine, link.targetColumn);
|
data->addFile(link.targetFilePath.toString(), link.targetLine, link.targetColumn);
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@@ -90,7 +90,7 @@ public:
|
|||||||
helpCategory = Core::HelpItem::Brief;
|
helpCategory = Core::HelpItem::Brief;
|
||||||
helpIdCandidates = QStringList(fileName);
|
helpIdCandidates = QStringList(fileName);
|
||||||
helpMark = fileName;
|
helpMark = fileName;
|
||||||
link = Utils::Link(path);
|
link = Utils::Link(Utils::FilePath::fromString(path));
|
||||||
tooltip = path;
|
tooltip = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ public:
|
|||||||
const QString macroName = QString::fromUtf8(macro.name(), macro.name().size());
|
const QString macroName = QString::fromUtf8(macro.name(), macro.name().size());
|
||||||
helpIdCandidates = QStringList(macroName);
|
helpIdCandidates = QStringList(macroName);
|
||||||
helpMark = macroName;
|
helpMark = macroName;
|
||||||
link = Utils::Link(macro.fileName(), macro.line());
|
link = Utils::Link(Utils::FilePath::fromString(macro.fileName()), macro.line());
|
||||||
tooltip = macro.toStringWithLineBreaks();
|
tooltip = macro.toStringWithLineBreaks();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -208,7 +208,7 @@ Link findMacroLink_helper(const QByteArray &name, Document::Ptr doc, const Snaps
|
|||||||
foreach (const Macro ¯o, doc->definedMacros()) {
|
foreach (const Macro ¯o, doc->definedMacros()) {
|
||||||
if (macro.name() == name) {
|
if (macro.name() == name) {
|
||||||
Link link;
|
Link link;
|
||||||
link.targetFileName = macro.fileName();
|
link.targetFilePath = Utils::FilePath::fromString(macro.fileName());
|
||||||
link.targetLine = macro.line();
|
link.targetLine = macro.line();
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
@@ -643,7 +643,7 @@ void FollowSymbolUnderCursor::findLink(
|
|||||||
const int lineno = cursor.blockNumber() + 1;
|
const int lineno = cursor.blockNumber() + 1;
|
||||||
foreach (const Document::Include &incl, doc->resolvedIncludes()) {
|
foreach (const Document::Include &incl, doc->resolvedIncludes()) {
|
||||||
if (incl.line() == lineno) {
|
if (incl.line() == lineno) {
|
||||||
link.targetFileName = incl.resolvedFileName();
|
link.targetFilePath = Utils::FilePath::fromString(incl.resolvedFileName());
|
||||||
link.linkTextStart = beginOfToken + 1;
|
link.linkTextStart = beginOfToken + 1;
|
||||||
link.linkTextEnd = endOfToken - 1;
|
link.linkTextEnd = endOfToken - 1;
|
||||||
processLinkCallback(link);
|
processLinkCallback(link);
|
||||||
@@ -671,7 +671,7 @@ void FollowSymbolUnderCursor::findLink(
|
|||||||
editorWidget->showPreProcessorWidget();
|
editorWidget->showPreProcessorWidget();
|
||||||
} else if (fileName != CppModelManager::configurationFileName()) {
|
} else if (fileName != CppModelManager::configurationFileName()) {
|
||||||
const Macro ¯o = use->macro();
|
const Macro ¯o = use->macro();
|
||||||
link.targetFileName = macro.fileName();
|
link.targetFilePath = Utils::FilePath::fromString(macro.fileName());
|
||||||
link.targetLine = macro.line();
|
link.targetLine = macro.line();
|
||||||
link.linkTextStart = use->utf16charsBegin();
|
link.linkTextStart = use->utf16charsBegin();
|
||||||
link.linkTextEnd = use->utf16charsEnd();
|
link.linkTextEnd = use->utf16charsEnd();
|
||||||
|
@@ -46,7 +46,7 @@ void VirtualFunctionProposalItem::apply(TextEditor::TextDocumentManipulatorInter
|
|||||||
Core::EditorManager::OpenEditorFlags flags = Core::EditorManager::NoFlags;
|
Core::EditorManager::OpenEditorFlags flags = Core::EditorManager::NoFlags;
|
||||||
if (m_openInSplit)
|
if (m_openInSplit)
|
||||||
flags |= Core::EditorManager::OpenInOtherSplit;
|
flags |= Core::EditorManager::OpenInOtherSplit;
|
||||||
Core::EditorManager::openEditorAt(m_link.targetFileName,
|
Core::EditorManager::openEditorAt(m_link.targetFilePath,
|
||||||
m_link.targetLine,
|
m_link.targetLine,
|
||||||
m_link.targetColumn,
|
m_link.targetColumn,
|
||||||
CppEditor::Constants::CPPEDITOR_ID,
|
CppEditor::Constants::CPPEDITOR_ID,
|
||||||
|
@@ -110,7 +110,7 @@ void SymbolSupport::findLinkAt(TextEditor::TextDocument *document,
|
|||||||
if (!resolveTarget) {
|
if (!resolveTarget) {
|
||||||
QTextCursor linkCursor = cursor;
|
QTextCursor linkCursor = cursor;
|
||||||
linkCursor.select(QTextCursor::WordUnderCursor);
|
linkCursor.select(QTextCursor::WordUnderCursor);
|
||||||
Utils::Link link(document->filePath().toString(),
|
Utils::Link link(document->filePath(),
|
||||||
linkCursor.blockNumber() + 1,
|
linkCursor.blockNumber() + 1,
|
||||||
linkCursor.positionInBlock());
|
linkCursor.positionInBlock());
|
||||||
link.linkTextStart = linkCursor.selectionStart();
|
link.linkTextStart = linkCursor.selectionStart();
|
||||||
|
@@ -195,7 +195,7 @@ void DocumentLocatorFilter::accept(Core::LocatorFilterEntry selection,
|
|||||||
lineColumn.column);
|
lineColumn.column);
|
||||||
} else if (selection.internalData.canConvert<Utils::Link>()) {
|
} else if (selection.internalData.canConvert<Utils::Link>()) {
|
||||||
auto link = qvariant_cast<Utils::Link>(selection.internalData);
|
auto link = qvariant_cast<Utils::Link>(selection.internalData);
|
||||||
Core::EditorManager::openEditorAt(link.targetFileName, link.targetLine, link.targetColumn);
|
Core::EditorManager::openEditorAt(link.targetFilePath, link.targetLine, link.targetColumn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,7 +295,7 @@ void WorkspaceLocatorFilter::accept(Core::LocatorFilterEntry selection,
|
|||||||
{
|
{
|
||||||
if (selection.internalData.canConvert<Utils::Link>()) {
|
if (selection.internalData.canConvert<Utils::Link>()) {
|
||||||
auto link = qvariant_cast<Utils::Link>(selection.internalData);
|
auto link = qvariant_cast<Utils::Link>(selection.internalData);
|
||||||
Core::EditorManager::openEditorAt(link.targetFileName, link.targetLine, link.targetColumn);
|
Core::EditorManager::openEditorAt(link.targetFilePath, link.targetLine, link.targetColumn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -105,5 +105,5 @@ void NimTextEditorWidget::onFindLinkFinished()
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Line &line = m_request->lines().front();
|
const Line &line = m_request->lines().front();
|
||||||
m_callback(Utils::Link{line.abs_path, line.row, line.column});
|
m_callback(Utils::Link{Utils::FilePath::fromString(line.abs_path), line.row, line.column});
|
||||||
}
|
}
|
||||||
|
@@ -238,11 +238,11 @@ void ProFileEditorWidget::findLinkAt(const QTextCursor &cursor,
|
|||||||
else
|
else
|
||||||
return processLinkCallback(link);
|
return processLinkCallback(link);
|
||||||
}
|
}
|
||||||
link.targetFileName = QDir::cleanPath(fileName);
|
link.targetFilePath = Utils::FilePath::fromString(QDir::cleanPath(fileName));
|
||||||
} else {
|
} else {
|
||||||
link.targetFileName = checkForPrfFile(buffer);
|
link.targetFilePath = Utils::FilePath::fromString(checkForPrfFile(buffer));
|
||||||
}
|
}
|
||||||
if (!link.targetFileName.isEmpty()) {
|
if (!link.targetFilePath.isEmpty()) {
|
||||||
link.linkTextStart = cursor.position() - positionInBlock + beginPos + 1;
|
link.linkTextStart = cursor.position() - positionInBlock + beginPos + 1;
|
||||||
link.linkTextEnd = cursor.position() - positionInBlock + endPos;
|
link.linkTextEnd = cursor.position() - positionInBlock + endPos;
|
||||||
}
|
}
|
||||||
|
@@ -772,7 +772,7 @@ void QmlJSEditorWidget::findLinkAt(const QTextCursor &cursor,
|
|||||||
// if it's a file import, link to the file
|
// if it's a file import, link to the file
|
||||||
foreach (const ImportInfo &import, semanticInfo.document->bind()->imports()) {
|
foreach (const ImportInfo &import, semanticInfo.document->bind()->imports()) {
|
||||||
if (import.ast() == importAst && import.type() == ImportType::File) {
|
if (import.ast() == importAst && import.type() == ImportType::File) {
|
||||||
Utils::Link link(import.path());
|
Utils::Link link(Utils::FilePath::fromString(import.path()));
|
||||||
link.linkTextStart = importAst->firstSourceLocation().begin();
|
link.linkTextStart = importAst->firstSourceLocation().begin();
|
||||||
link.linkTextEnd = importAst->lastSourceLocation().end();
|
link.linkTextEnd = importAst->lastSourceLocation().end();
|
||||||
processLinkCallback(Utils::Link());
|
processLinkCallback(Utils::Link());
|
||||||
@@ -790,7 +790,7 @@ void QmlJSEditorWidget::findLinkAt(const QTextCursor &cursor,
|
|||||||
link.linkTextStart = literal->literalToken.begin();
|
link.linkTextStart = literal->literalToken.begin();
|
||||||
link.linkTextEnd = literal->literalToken.end();
|
link.linkTextEnd = literal->literalToken.end();
|
||||||
if (semanticInfo.snapshot.document(text)) {
|
if (semanticInfo.snapshot.document(text)) {
|
||||||
link.targetFileName = text;
|
link.targetFilePath = Utils::FilePath::fromString(text);
|
||||||
processLinkCallback(link);
|
processLinkCallback(link);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -798,7 +798,7 @@ void QmlJSEditorWidget::findLinkAt(const QTextCursor &cursor,
|
|||||||
semanticInfo.document->path(),
|
semanticInfo.document->path(),
|
||||||
text);
|
text);
|
||||||
if (QFileInfo::exists(relative)) {
|
if (QFileInfo::exists(relative)) {
|
||||||
link.targetFileName = relative;
|
link.targetFilePath = Utils::FilePath::fromString(relative);
|
||||||
processLinkCallback(link);
|
processLinkCallback(link);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -815,7 +815,7 @@ void QmlJSEditorWidget::findLinkAt(const QTextCursor &cursor,
|
|||||||
return processLinkCallback(Utils::Link());
|
return processLinkCallback(Utils::Link());
|
||||||
|
|
||||||
Utils::Link link;
|
Utils::Link link;
|
||||||
link.targetFileName = fileName;
|
link.targetFilePath = Utils::FilePath::fromString(fileName);
|
||||||
link.targetLine = line;
|
link.targetLine = line;
|
||||||
link.targetColumn = column - 1; // adjust the column
|
link.targetColumn = column - 1; // adjust the column
|
||||||
|
|
||||||
|
@@ -6244,7 +6244,7 @@ bool TextEditorWidget::openLink(const Utils::Link &link, bool inNextSplit)
|
|||||||
if (!link.hasValidTarget())
|
if (!link.hasValidTarget())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!inNextSplit && textDocument()->filePath().toString() == link.targetFileName) {
|
if (!inNextSplit && textDocument()->filePath() == link.targetFilePath) {
|
||||||
EditorManager::addCurrentPositionToNavigationHistory();
|
EditorManager::addCurrentPositionToNavigationHistory();
|
||||||
gotoLine(link.targetLine, link.targetColumn, true, true);
|
gotoLine(link.targetLine, link.targetColumn, true, true);
|
||||||
setFocus();
|
setFocus();
|
||||||
@@ -6254,8 +6254,11 @@ bool TextEditorWidget::openLink(const Utils::Link &link, bool inNextSplit)
|
|||||||
if (inNextSplit)
|
if (inNextSplit)
|
||||||
flags |= EditorManager::OpenInOtherSplit;
|
flags |= EditorManager::OpenInOtherSplit;
|
||||||
|
|
||||||
return EditorManager::openEditorAt(link.targetFileName, link.targetLine, link.targetColumn,
|
return EditorManager::openEditorAt(link.targetFilePath,
|
||||||
Id(), flags);
|
link.targetLine,
|
||||||
|
link.targetColumn,
|
||||||
|
Id(),
|
||||||
|
flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextEditorWidgetPrivate::isMouseNavigationEvent(QMouseEvent *e) const
|
bool TextEditorWidgetPrivate::isMouseNavigationEvent(QMouseEvent *e) const
|
||||||
@@ -8670,7 +8673,7 @@ void TextEditorLinkLabel::mouseMoveEvent(QMouseEvent *event)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
auto data = new DropMimeData;
|
auto data = new DropMimeData;
|
||||||
data->addFile(m_link.targetFileName, m_link.targetLine, m_link.targetColumn);
|
data->addFile(m_link.targetFilePath.toString(), m_link.targetLine, m_link.targetColumn);
|
||||||
auto drag = new QDrag(this);
|
auto drag = new QDrag(this);
|
||||||
drag->setMimeData(data);
|
drag->setMimeData(data);
|
||||||
drag->exec(Qt::CopyAction);
|
drag->exec(Qt::CopyAction);
|
||||||
@@ -8682,7 +8685,9 @@ void TextEditorLinkLabel::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
if (!m_link.hasValidTarget())
|
if (!m_link.hasValidTarget())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
EditorManager::openEditorAt(m_link.targetFileName, m_link.targetLine, m_link.targetColumn);
|
EditorManager::openEditorAt(m_link.targetFilePath.toString(),
|
||||||
|
m_link.targetLine,
|
||||||
|
m_link.targetColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@@ -189,8 +189,8 @@ std::ostream &operator<<(std::ostream &out, const LineColumn &lineColumn)
|
|||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const Link &link)
|
std::ostream &operator<<(std::ostream &out, const Link &link)
|
||||||
{
|
{
|
||||||
return out << "(" << link.targetFileName << ", " << link.targetLine << ", " << link.targetColumn
|
return out << "(" << link.targetFilePath.toString() << ", " << link.targetLine << ", "
|
||||||
<< ", " << link.linkTextStart << ", " << link.linkTextEnd << ")";
|
<< link.targetColumn << ", " << link.linkTextStart << ", " << link.linkTextEnd << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * toText(Utils::Language language)
|
const char * toText(Utils::Language language)
|
||||||
|
@@ -155,7 +155,7 @@ TEST_F(RefactoringEngine, InGlobalFollowSymbol)
|
|||||||
ON_CALL(mockSymbolQuery, declarationsAt(Eq(12), 2, 5)).WillByDefault(Return(usages));
|
ON_CALL(mockSymbolQuery, declarationsAt(Eq(12), 2, 5)).WillByDefault(Return(usages));
|
||||||
|
|
||||||
EXPECT_CALL(mockCallback,
|
EXPECT_CALL(mockCallback,
|
||||||
Call(AllOf(Field(&Link::targetFileName, Eq("/path1")),
|
Call(AllOf(Field(&Link::targetFilePath, Eq(Utils::FilePath::fromString("/path1"))),
|
||||||
Field(&Link::targetLine, Eq(1)),
|
Field(&Link::targetLine, Eq(1)),
|
||||||
Field(&Link::targetColumn, Eq(2)))));
|
Field(&Link::targetColumn, Eq(2)))));
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@ TEST_F(RefactoringEngine, InGlobalFollowSymbolSkipCurrentFile)
|
|||||||
ON_CALL(mockSymbolQuery, declarationsAt(Eq(12), 2, 5)).WillByDefault(Return(usages));
|
ON_CALL(mockSymbolQuery, declarationsAt(Eq(12), 2, 5)).WillByDefault(Return(usages));
|
||||||
|
|
||||||
EXPECT_CALL(mockCallback,
|
EXPECT_CALL(mockCallback,
|
||||||
Call(AllOf(Field(&Link::targetFileName, Eq("/path2")),
|
Call(AllOf(Field(&Link::targetFilePath, Eq(Utils::FilePath::fromString("/path2"))),
|
||||||
Field(&Link::targetLine, Eq(4)),
|
Field(&Link::targetLine, Eq(4)),
|
||||||
Field(&Link::targetColumn, Eq(4)))));
|
Field(&Link::targetColumn, Eq(4)))));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user