QtSupport: Some FilePathification in the OutputParser

Change-Id: I618bb47608593b5a60636c5e740f4d19e68e4f5a
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
hjk
2023-01-12 14:12:20 +01:00
parent a661dc5db4
commit b3bc499ebd

View File

@@ -29,8 +29,7 @@
using namespace ProjectExplorer;
using namespace Utils;
namespace QtSupport {
namespace Internal {
namespace QtSupport::Internal {
class QtOutputFormatterPrivate
{
@@ -65,10 +64,10 @@ public:
~QtOutputLineParser() override;
protected:
virtual void openEditor(const QString &fileName, int line, int column = -1);
virtual void openEditor(const FilePath &filePath, int line, int column = -1);
private:
Result handleLine(const QString &text, Utils::OutputFormat format) override;
Result handleLine(const QString &text, OutputFormat format) override;
bool handleLink(const QString &href) override;
void updateProjectFileList();
@@ -148,7 +147,7 @@ bool QtOutputLineParser::handleLink(const QString &href)
const QRegularExpressionMatch qmlLineColumnMatch = qmlLineColumnLink.match(href);
const auto getFileToOpen = [this](const QUrl &fileUrl) {
return chooseFileFromList(d->projectFinder.findFile(fileUrl)).toString();
return chooseFileFromList(d->projectFinder.findFile(fileUrl));
};
if (qmlLineColumnMatch.hasMatch()) {
const QUrl fileUrl = QUrl(qmlLineColumnMatch.captured(1));
@@ -198,16 +197,16 @@ bool QtOutputLineParser::handleLink(const QString &href)
}
if (!fileName.isEmpty()) {
fileName = getFileToOpen(QUrl::fromLocalFile(fileName));
openEditor(fileName, line);
const FilePath filePath = getFileToOpen(QUrl::fromLocalFile(fileName));
openEditor(filePath, line);
return true;
}
return false;
}
void QtOutputLineParser::openEditor(const QString &fileName, int line, int column)
void QtOutputLineParser::openEditor(const FilePath &filePath, int line, int column)
{
Core::EditorManager::openEditorAt({FilePath::fromString(fileName), line, column});
Core::EditorManager::openEditorAt({filePath, line, column});
}
void QtOutputLineParser::updateProjectFileList()
@@ -227,8 +226,7 @@ QtOutputFormatterFactory::QtOutputFormatterFactory()
});
}
} // namespace Internal
} // namespace QtSupport
} // QtSupport::Internal
// Unit tests:
@@ -252,9 +250,9 @@ public:
{
}
void openEditor(const QString &fileName, int line, int column = -1)
void openEditor(const FilePath &filePath, int line, int column = -1) override
{
this->fileName = fileName;
this->fileName = filePath.toString();
this->line = line;
this->column = column;
}