diff options
author | David Schulz <david.schulz@qt.io> | 2021-05-28 12:37:35 +0200 |
---|---|---|
committer | David Schulz <david.schulz@qt.io> | 2021-06-09 06:57:42 +0000 |
commit | 0cfe27a53d6f3ccf231e4c05069c0bbe72286757 (patch) | |
tree | 84a8b4e9f1c782738f3fb4bd4c3b2df732bd2bd8 | |
parent | 27f8e2dbce774410c5443a7f425eb53c2a869f54 (diff) |
Debugger: filepathify DiagnosticLocation
Change-Id: Ibbbf137231b313ec10e3d57c0230217b0c1e0a6c
Reviewed-by: hjk <hjk@qt.io>
19 files changed, 78 insertions, 70 deletions
diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp index 385581ee65..d0ab78eaab 100644 --- a/src/libs/utils/fileutils.cpp +++ b/src/libs/utils/fileutils.cpp @@ -1277,14 +1277,14 @@ FilePath FilePath::onDevice(const FilePath &deviceTemplate) const return res; } -FilePath FilePath::pathAppended(const QString &str) const +FilePath FilePath::pathAppended(const QString &path) const { FilePath fn = *this; - if (str.isEmpty()) + if (path.isEmpty()) return fn; if (!fn.m_data.isEmpty() && !fn.m_data.endsWith(QLatin1Char('/'))) fn.m_data.append('/'); - fn.m_data.append(str); + fn.m_data.append(path); return fn; } diff --git a/src/plugins/clangtools/clangtool.cpp b/src/plugins/clangtools/clangtool.cpp index 668031da21..53eb9b0ca9 100644 --- a/src/plugins/clangtools/clangtool.cpp +++ b/src/plugins/clangtools/clangtool.cpp @@ -209,7 +209,7 @@ public: ApplyFixIts(const QVector<DiagnosticItem *> &diagnosticItems) { for (DiagnosticItem *diagnosticItem : diagnosticItems) { - const QString &filePath = diagnosticItem->diagnostic().location.filePath; + const Utils::FilePath &filePath = diagnosticItem->diagnostic().location.filePath; QTC_ASSERT(!filePath.isEmpty(), continue); // Get or create refactoring file @@ -245,14 +245,14 @@ public: const Debugger::DiagnosticLocation start = step.ranges.first(); const Debugger::DiagnosticLocation end = step.ranges.last(); - const int startPos = file.position(start.filePath, start.line, start.column); - const int endPos = file.position(start.filePath, end.line, end.column); + const int startPos = file.position(start.filePath.toString(), start.line, start.column); + const int endPos = file.position(start.filePath.toString(), end.line, end.column); auto op = new ReplacementOperation; op->pos = startPos; op->length = endPos - startPos; op->text = step.message; - op->fileName = start.filePath; + op->fileName = start.filePath.toString(); op->apply = apply; replacements += op; @@ -322,7 +322,7 @@ public: } private: - QMap<QString, RefactoringFileInfo> m_refactoringFileInfos; + QMap<Utils::FilePath, RefactoringFileInfo> m_refactoringFileInfos; }; static FileInfos sortedFileInfos(const QVector<CppTools::ProjectPart::Ptr> &projectParts) @@ -1119,7 +1119,7 @@ QSet<Diagnostic> ClangTool::diagnostics() const { return Utils::filtered(m_diagnosticModel->diagnostics(), [](const Diagnostic &diagnostic) { using CppTools::ProjectFile; - return ProjectFile::isSource(ProjectFile::classify(diagnostic.location.filePath)); + return ProjectFile::isSource(ProjectFile::classify(diagnostic.location.filePath.toString())); }); } diff --git a/src/plugins/clangtools/clangtoolsdiagnosticmodel.cpp b/src/plugins/clangtools/clangtoolsdiagnosticmodel.cpp index ca84875a3d..081f716bb9 100644 --- a/src/plugins/clangtools/clangtoolsdiagnosticmodel.cpp +++ b/src/plugins/clangtools/clangtoolsdiagnosticmodel.cpp @@ -47,7 +47,7 @@ static Q_LOGGING_CATEGORY(LOG, "qtc.clangtools.model", QtWarningMsg) namespace ClangTools { namespace Internal { -FilePathItem::FilePathItem(const QString &filePath) +FilePathItem::FilePathItem(const Utils::FilePath &filePath) : m_filePath(filePath) {} @@ -56,11 +56,11 @@ QVariant FilePathItem::data(int column, int role) const if (column == DiagnosticView::DiagnosticColumn) { switch (role) { case Qt::DisplayRole: - return m_filePath; + return m_filePath.toUserOutput(); case Qt::DecorationRole: - return Core::FileIconProvider::icon(QFileInfo(m_filePath)); + return Core::FileIconProvider::icon(m_filePath.toFileInfo()); case Debugger::DetailedErrorView::FullTextRole: - return m_filePath; + return m_filePath.toUserOutput(); default: return QVariant(); } @@ -119,12 +119,12 @@ void ClangToolsDiagnosticModel::addDiagnostics(const Diagnostics &diagnostics, b } // Create file path item if necessary - const QString filePath = d.location.filePath; + const Utils::FilePath &filePath = d.location.filePath; FilePathItem *&filePathItem = m_filePathToItem[filePath]; if (!filePathItem) { filePathItem = new FilePathItem(filePath); rootItem()->appendChild(filePathItem); - addWatchedPath(d.location.filePath); + addWatchedPath(filePath.toString()); } // Add to file path item @@ -184,7 +184,7 @@ void ClangToolsDiagnosticModel::clearAndSetupCache() void ClangToolsDiagnosticModel::onFileChanged(const QString &path) { forItemsAtLevel<2>([&](DiagnosticItem *item){ - if (item->diagnostic().location.filePath == path) + if (item->diagnostic().location.filePath == Utils::FilePath::fromString(path)) item->setFixItStatus(FixitStatus::Invalidated); }); removeWatchedPath(path); @@ -238,7 +238,7 @@ static QString createExplainingStepToolTipString(const ExplainingStep &step) static QString createLocationString(const Debugger::DiagnosticLocation &location) { - const QString filePath = location.filePath; + const QString filePath = location.filePath.toUserOutput(); const QString lineNumber = QString::number(location.line); const QString fileAndLine = filePath + QLatin1Char(':') + lineNumber; return QLatin1String("in ") + fileAndLine; @@ -262,7 +262,7 @@ static QString createExplainingStepString(const ExplainingStep &explainingStep, static QString fullText(const Diagnostic &diagnostic) { - QString text = diagnostic.location.filePath + QLatin1Char(':'); + QString text = diagnostic.location.filePath.toUserOutput() + QLatin1Char(':'); text += lineColumnString(diagnostic.location) + QLatin1String(": "); if (!diagnostic.category.isEmpty()) text += diagnostic.category + QLatin1String(": "); @@ -452,7 +452,9 @@ QVariant ExplainingStepItem::data(int column, int role) const return QVariant::fromValue(m_step.location); case Debugger::DetailedErrorView::FullTextRole: { return QString("%1:%2: %3") - .arg(m_step.location.filePath, lineColumnString(m_step.location), m_step.message); + .arg(m_step.location.filePath.toUserOutput(), + lineColumnString(m_step.location), + m_step.message); } case ClangToolsDiagnosticModel::TextRole: return m_step.message; @@ -461,11 +463,12 @@ QVariant ExplainingStepItem::data(int column, int role) const case ClangToolsDiagnosticModel::DocumentationUrlRole: return parent()->data(column, role); case Qt::DisplayRole: { - const QString mainFilePath = static_cast<DiagnosticItem *>(parent())->diagnostic().location.filePath; + const Utils::FilePath mainFilePath + = static_cast<DiagnosticItem *>(parent())->diagnostic().location.filePath; const QString locationString = m_step.location.filePath == mainFilePath ? lineColumnString(m_step.location) - : QString("%1:%2").arg(QFileInfo(m_step.location.filePath).fileName(), + : QString("%1:%2").arg(m_step.location.filePath.fileName(), lineColumnString(m_step.location)); if (m_step.isFixIt) { @@ -645,10 +648,9 @@ bool DiagnosticFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &s foreach (const SuppressedDiagnostic &d, m_suppressedDiagnostics) { if (d.description != diag.description) continue; - QString filePath = d.filePath.toString(); - QFileInfo fi(filePath); - if (fi.isRelative()) - filePath = m_lastProjectDirectory.toString() + QLatin1Char('/') + filePath; + Utils::FilePath filePath = d.filePath; + if (d.filePath.toFileInfo().isRelative()) + filePath = m_lastProjectDirectory.pathAppended(filePath.toString()); if (filePath == diag.location.filePath) { diagnosticItem->setTextMarkVisible(false); return false; diff --git a/src/plugins/clangtools/clangtoolsdiagnosticmodel.h b/src/plugins/clangtools/clangtoolsdiagnosticmodel.h index 095d893835..2acfe330fd 100644 --- a/src/plugins/clangtools/clangtoolsdiagnosticmodel.h +++ b/src/plugins/clangtools/clangtoolsdiagnosticmodel.h @@ -54,11 +54,11 @@ class ClangToolsDiagnosticModel; class FilePathItem : public Utils::TreeItem { public: - FilePathItem(const QString &filePath); + FilePathItem(const Utils::FilePath &filePath); QVariant data(int column, int role) const override; private: - const QString m_filePath; + const Utils::FilePath m_filePath; }; class DiagnosticMark; @@ -139,7 +139,7 @@ private: void clearAndSetupCache(); private: - QHash<QString, FilePathItem *> m_filePathToItem; + QHash<Utils::FilePath, FilePathItem *> m_filePathToItem; QSet<Diagnostic> m_diagnostics; std::map<QVector<ExplainingStep>, QVector<DiagnosticItem *>> stepsToItemsCache; std::unique_ptr<QFileSystemWatcher> m_filesWatcher; diff --git a/src/plugins/clangtools/clangtoolsdiagnosticview.cpp b/src/plugins/clangtools/clangtoolsdiagnosticview.cpp index c73fc7e579..19f86632d0 100644 --- a/src/plugins/clangtools/clangtoolsdiagnosticview.cpp +++ b/src/plugins/clangtools/clangtoolsdiagnosticview.cpp @@ -222,7 +222,7 @@ void DiagnosticView::suppressCurrentDiagnostic() diags << diag; continue; } - Utils::FilePath filePath = Utils::FilePath::fromString(diag.location.filePath); + Utils::FilePath filePath = diag.location.filePath; const Utils::FilePath relativeFilePath = filePath.relativeChildPath(project->projectDirectory()); if (!relativeFilePath.isEmpty()) @@ -402,7 +402,7 @@ void DiagnosticView::openEditorForCurrentIndex() const QVariant v = model()->data(currentIndex(), Debugger::DetailedErrorView::LocationRole); const auto loc = v.value<Debugger::DiagnosticLocation>(); if (loc.isValid()) - Core::EditorManager::openEditorAt(loc.filePath, loc.line, loc.column - 1); + Core::EditorManager::openEditorAt(Utils::Link(loc.filePath, loc.line, loc.column - 1)); } } // namespace Internal diff --git a/src/plugins/clangtools/clangtoolslogfilereader.cpp b/src/plugins/clangtools/clangtoolslogfilereader.cpp index 96ec0da16c..f74884d25a 100644 --- a/src/plugins/clangtools/clangtoolslogfilereader.cpp +++ b/src/plugins/clangtools/clangtoolslogfilereader.cpp @@ -155,16 +155,16 @@ public: int extraOffset = 0) : m_node(node) , m_fileCache(fileCache) - , m_filePath(QDir::cleanPath(asString(node["FilePath"]))) + , m_filePath(Utils::FilePath::fromUserInput(asString(node["FilePath"]))) , m_fileOffsetKey(fileOffsetKey) , m_extraOffset(extraOffset) {} - QString filePath() const { return m_filePath; } + Utils::FilePath filePath() const { return m_filePath; } Debugger::DiagnosticLocation toDiagnosticLocation() const { - FileCache::Item &cacheItem = m_fileCache.item(m_filePath); + FileCache::Item &cacheItem = m_fileCache.item(m_filePath.toString()); const QByteArray fileContents = cacheItem.fileContents(); const char *data = fileContents.data(); @@ -205,7 +205,7 @@ public: private: const YAML::Node &m_node; FileCache &m_fileCache; - QString m_filePath; + Utils::FilePath m_filePath; const char *m_fileOffsetKey = nullptr; int m_extraOffset = 0; }; @@ -232,10 +232,8 @@ Diagnostics readExportedDiagnostics(const Utils::FilePath &logFilePath, Location loc(node, fileCache); if (loc.filePath().isEmpty()) continue; - if (acceptFromFilePath - && !acceptFromFilePath(Utils::FilePath::fromString(loc.filePath()))) { + if (acceptFromFilePath && !acceptFromFilePath(loc.filePath())) continue; - } Diagnostic diag; diag.location = loc.toDiagnosticLocation(); diff --git a/src/plugins/clangtools/clangtoolsprojectsettings.cpp b/src/plugins/clangtools/clangtoolsprojectsettings.cpp index 7cc68a9a87..2953245c3b 100644 --- a/src/plugins/clangtools/clangtoolsprojectsettings.cpp +++ b/src/plugins/clangtools/clangtoolsprojectsettings.cpp @@ -232,7 +232,7 @@ ClangToolsProjectSettings::ClangToolsProjectSettingsPtr } SuppressedDiagnostic::SuppressedDiagnostic(const Diagnostic &diag) - : filePath(Utils::FilePath::fromString(diag.location.filePath)) + : filePath(diag.location.filePath) , description(diag.description) , uniquifier(diag.explainingSteps.count()) { diff --git a/src/plugins/clangtools/clangtoolsutils.cpp b/src/plugins/clangtools/clangtoolsutils.cpp index 1e64403b67..5522fdbb4d 100644 --- a/src/plugins/clangtools/clangtoolsutils.cpp +++ b/src/plugins/clangtools/clangtoolsutils.cpp @@ -115,7 +115,7 @@ QString createDiagnosticToolTipString( if (!steps.second.isEmpty()) steps.second += "<br>"; steps.second += QString("%1:%2: %3") - .arg(step.location.filePath, + .arg(step.location.filePath.toUserOutput(), lineColumnString(step.location), step.message); } @@ -147,7 +147,7 @@ QString createDiagnosticToolTipString( QString createFullLocationString(const Debugger::DiagnosticLocation &location) { - return location.filePath + QLatin1Char(':') + QString::number(location.line) + return location.filePath.toUserOutput() + QLatin1Char(':') + QString::number(location.line) + QLatin1Char(':') + QString::number(location.column); } diff --git a/src/plugins/clangtools/diagnosticconfigswidget.cpp b/src/plugins/clangtools/diagnosticconfigswidget.cpp index a2c7e420b3..96196aa456 100644 --- a/src/plugins/clangtools/diagnosticconfigswidget.cpp +++ b/src/plugins/clangtools/diagnosticconfigswidget.cpp @@ -1162,8 +1162,8 @@ void disableChecks(const QList<Diagnostic> &diagnostics) Utils::Id activeConfigId = settings->runSettings().diagnosticConfigId(); ClangToolsProjectSettings::ClangToolsProjectSettingsPtr projectSettings; - if (ProjectExplorer::Project *project = ProjectExplorer::SessionManager - ::projectForFile(Utils::FilePath::fromString(diagnostics.first().location.filePath))) { + if (ProjectExplorer::Project *project = ProjectExplorer::SessionManager::projectForFile( + diagnostics.first().location.filePath)) { projectSettings = ClangToolsProjectSettings::getSettings(project); if (!projectSettings->useGlobalSettings()) activeConfigId = projectSettings->runSettings().diagnosticConfigId(); diff --git a/src/plugins/clangtools/diagnosticmark.cpp b/src/plugins/clangtools/diagnosticmark.cpp index 68adec147e..0e29a1c731 100644 --- a/src/plugins/clangtools/diagnosticmark.cpp +++ b/src/plugins/clangtools/diagnosticmark.cpp @@ -39,7 +39,7 @@ namespace ClangTools { namespace Internal { DiagnosticMark::DiagnosticMark(const Diagnostic &diagnostic) - : TextEditor::TextMark(Utils::FilePath::fromString(diagnostic.location.filePath), + : TextEditor::TextMark(diagnostic.location.filePath, diagnostic.location.line, Utils::Id(Constants::DIAGNOSTIC_MARK_ID)) , m_diagnostic(diagnostic) diff --git a/src/plugins/clangtools/documentclangtoolrunner.cpp b/src/plugins/clangtools/documentclangtoolrunner.cpp index 0651905f90..89d76e0f55 100644 --- a/src/plugins/clangtools/documentclangtoolrunner.cpp +++ b/src/plugins/clangtools/documentclangtoolrunner.cpp @@ -264,7 +264,7 @@ void DocumentClangToolRunner::runNext() static void updateLocation(Debugger::DiagnosticLocation &location) { - location.filePath = vfso().originalFilePath(Utils::FilePath::fromString(location.filePath)).toString(); + location.filePath = vfso().originalFilePath(location.filePath); } void DocumentClangToolRunner::onSuccess() @@ -364,10 +364,9 @@ bool DocumentClangToolRunner::isSuppressed(const Diagnostic &diagnostic) const auto equalsSuppressed = [this, &diagnostic](const SuppressedDiagnostic &suppressed) { if (suppressed.description != diagnostic.description) return false; - QString filePath = suppressed.filePath.toString(); - QFileInfo fi(filePath); - if (fi.isRelative()) - filePath = m_lastProjectDirectory.toString() + QLatin1Char('/') + filePath; + Utils::FilePath filePath = suppressed.filePath; + if (filePath.toFileInfo().isRelative()) + filePath = m_lastProjectDirectory.pathAppended(filePath.toString()); return filePath == diagnostic.location.filePath; }; return Utils::anyOf(m_suppressed, equalsSuppressed); diff --git a/src/plugins/clangtools/documentquickfixfactory.cpp b/src/plugins/clangtools/documentquickfixfactory.cpp index 2a3dafe8e2..b1283b7f88 100644 --- a/src/plugins/clangtools/documentquickfixfactory.cpp +++ b/src/plugins/clangtools/documentquickfixfactory.cpp @@ -68,9 +68,10 @@ void ClangToolQuickFixOperation::perform() for (const ExplainingStep &step : m_diagnostic.explainingSteps) { if (!step.isFixIt) continue; - TextEditor::RefactoringFilePtr &refactoringFile = refactoringFiles[step.location.filePath]; + TextEditor::RefactoringFilePtr &refactoringFile + = refactoringFiles[step.location.filePath.toString()]; if (refactoringFile.isNull()) - refactoringFile = changes.file(Utils::FilePath::fromString(step.location.filePath)); + refactoringFile = changes.file(step.location.filePath); Utils::ChangeSet changeSet = refactoringFile->changeSet(); Range range = toRange(refactoringFile->document(), {step.ranges.first(), step.ranges.last()}); changeSet.replace(range, step.message); diff --git a/src/plugins/cppcheck/cppcheckdiagnosticsmodel.cpp b/src/plugins/cppcheck/cppcheckdiagnosticsmodel.cpp index a4c4000cb7..49bc745838 100644 --- a/src/plugins/cppcheck/cppcheckdiagnosticsmodel.cpp +++ b/src/plugins/cppcheck/cppcheckdiagnosticsmodel.cpp @@ -79,7 +79,7 @@ QVariant DiagnosticItem::data(int column, int role) const if (column == DiagnosticsModel::DiagnosticColumn) { switch (role) { case DetailedErrorView::LocationRole: { - const auto location = DiagnosticLocation(m_diagnostic.fileName.toString(), + const auto location = DiagnosticLocation(m_diagnostic.fileName, m_diagnostic.lineNumber, 0); return QVariant::fromValue(location); @@ -92,7 +92,7 @@ QVariant DiagnosticItem::data(int column, int role) const return getIcon(m_diagnostic.severity); case Debugger::DetailedErrorView::FullTextRole: return QString("%1:%2: %3") - .arg(m_diagnostic.fileName.toString()) + .arg(m_diagnostic.fileName.toUserOutput()) .arg(m_diagnostic.lineNumber) .arg(m_diagnostic.message); default: diff --git a/src/plugins/cppcheck/cppcheckdiagnosticview.cpp b/src/plugins/cppcheck/cppcheckdiagnosticview.cpp index 1f881e5330..2fda665305 100644 --- a/src/plugins/cppcheck/cppcheckdiagnosticview.cpp +++ b/src/plugins/cppcheck/cppcheckdiagnosticview.cpp @@ -103,7 +103,7 @@ void DiagnosticView::openEditorForCurrentIndex() const QVariant v = model()->data(currentIndex(), Debugger::DetailedErrorView::LocationRole); const auto loc = v.value<Debugger::DiagnosticLocation>(); if (loc.isValid()) - Core::EditorManager::openEditorAt(loc.filePath, loc.line, loc.column - 1); + Core::EditorManager::openEditorAt(Utils::Link(loc.filePath, loc.line, loc.column - 1)); } void DiagnosticView::mouseDoubleClickEvent(QMouseEvent *event) diff --git a/src/plugins/debugger/analyzer/detailederrorview.cpp b/src/plugins/debugger/analyzer/detailederrorview.cpp index cdb5919535..a5fad37821 100644 --- a/src/plugins/debugger/analyzer/detailederrorview.cpp +++ b/src/plugins/debugger/analyzer/detailederrorview.cpp @@ -66,7 +66,7 @@ DetailedErrorView::DetailedErrorView(QWidget *parent) : const auto loc = index.model()->data(index, DetailedErrorView::LocationRole) .value<DiagnosticLocation>(); if (loc.isValid()) - Core::EditorManager::openEditorAt(loc.filePath, loc.line, loc.column - 1); + Core::EditorManager::openEditorAt(Utils::Link(loc.filePath, loc.line, loc.column - 1)); } }); @@ -123,12 +123,12 @@ QVariant DetailedErrorView::locationData(int role, const DiagnosticLocation &loc return QVariant::fromValue(location); case Qt::DisplayRole: return location.isValid() ? QString::fromLatin1("%1:%2:%3") - .arg(QFileInfo(location.filePath).fileName()) + .arg(location.filePath.fileName()) .arg(location.line) .arg(location.column) : QString(); case Qt::ToolTipRole: - return location.filePath.isEmpty() ? QVariant() : QVariant(location.filePath); + return location.filePath.isEmpty() ? QVariant() : QVariant(location.filePath.toUserOutput()); case Qt::FontRole: { QFont font = QApplication::font(); font.setUnderline(true); diff --git a/src/plugins/debugger/analyzer/diagnosticlocation.cpp b/src/plugins/debugger/analyzer/diagnosticlocation.cpp index 417edcab53..e1088e4da3 100644 --- a/src/plugins/debugger/analyzer/diagnosticlocation.cpp +++ b/src/plugins/debugger/analyzer/diagnosticlocation.cpp @@ -29,7 +29,7 @@ namespace Debugger { DiagnosticLocation::DiagnosticLocation() = default; -DiagnosticLocation::DiagnosticLocation(const QString &filePath, int line, int column) +DiagnosticLocation::DiagnosticLocation(const Utils::FilePath &filePath, int line, int column) : filePath(filePath), line(line), column(column) { } diff --git a/src/plugins/debugger/analyzer/diagnosticlocation.h b/src/plugins/debugger/analyzer/diagnosticlocation.h index 69b4ef091a..76459d7661 100644 --- a/src/plugins/debugger/analyzer/diagnosticlocation.h +++ b/src/plugins/debugger/analyzer/diagnosticlocation.h @@ -27,6 +27,8 @@ #include <debugger/debugger_global.h> +#include <utils/fileutils.h> + #include <QDebug> #include <QMetaType> #include <QString> @@ -37,11 +39,11 @@ class DEBUGGER_EXPORT DiagnosticLocation { public: DiagnosticLocation(); - DiagnosticLocation(const QString &filePath, int line, int column); + DiagnosticLocation(const Utils::FilePath &filePath, int line, int column); bool isValid() const; - QString filePath; + Utils::FilePath filePath; // Both values start at 1. int line = 0; diff --git a/src/plugins/valgrind/xmlprotocol/errorlistmodel.cpp b/src/plugins/valgrind/xmlprotocol/errorlistmodel.cpp index 85e5a68ac4..a4d4234d07 100644 --- a/src/plugins/valgrind/xmlprotocol/errorlistmodel.cpp +++ b/src/plugins/valgrind/xmlprotocol/errorlistmodel.cpp @@ -175,7 +175,9 @@ ErrorItem::ErrorItem(const ErrorListModel *model, const Error &error) static QVariant locationData(int role, const Frame &frame) { - const Debugger::DiagnosticLocation location(frame.filePath(), frame.line(), 0); + const Debugger::DiagnosticLocation location(Utils::FilePath::fromString(frame.filePath()), + frame.line(), + 0); return Debugger::DetailedErrorView::locationData(role, location); } diff --git a/tests/unit/unittest/readexporteddiagnostics-test.cpp b/tests/unit/unittest/readexporteddiagnostics-test.cpp index c4fe4572ae..a15191baf2 100644 --- a/tests/unit/unittest/readexporteddiagnostics-test.cpp +++ b/tests/unit/unittest/readexporteddiagnostics-test.cpp @@ -112,19 +112,21 @@ static QString appendYamlSuffix(const char *filePathFragment) TEST_F(ReadExportedDiagnostics, Tidy) { - const QString sourceFile = TESTDATA "tidy.modernize-use-nullptr.cpp"; + const Utils::FilePath sourceFile = Utils::FilePath::fromString( + TESTDATA "tidy.modernize-use-nullptr.cpp"); const QString exportedFile = createFile(appendYamlSuffix(TESTDATA "tidy.modernize-use-nullptr"), - sourceFile); + sourceFile.toString()); Diagnostic expectedDiag; expectedDiag.name = "modernize-use-nullptr"; expectedDiag.location = {sourceFile, 2, 25}; expectedDiag.description = "use nullptr [modernize-use-nullptr]"; expectedDiag.type = "warning"; expectedDiag.hasFixits = true; - expectedDiag.explainingSteps = {ExplainingStep{"nullptr", - expectedDiag.location, - {expectedDiag.location, {sourceFile, 2, 26}}, - true}}; + expectedDiag.explainingSteps = { + ExplainingStep{"nullptr", + expectedDiag.location, + {expectedDiag.location, {sourceFile, 2, 26}}, + true}}; Diagnostics diags = readExportedDiagnostics(Utils::FilePath::fromString(exportedFile), {}, @@ -151,9 +153,10 @@ TEST_F(ReadExportedDiagnostics, AcceptDiagsFromFilePaths_None) // Diagnostics from clang (static) analyzer passed through via clang-tidy TEST_F(ReadExportedDiagnostics, Tidy_ClangAnalyzer) { - const QString sourceFile = TESTDATA "clang-analyzer.dividezero.cpp"; + const Utils::FilePath sourceFile = Utils::FilePath::fromString(TESTDATA + "clang-analyzer.dividezero.cpp"); const QString exportedFile = createFile(appendYamlSuffix(TESTDATA "clang-analyzer.dividezero"), - sourceFile); + sourceFile.toString()); Diagnostic expectedDiag; expectedDiag.name = "clang-analyzer-core.DivideZero"; expectedDiag.location = {sourceFile, 4, 15}; @@ -188,8 +191,9 @@ TEST_F(ReadExportedDiagnostics, Tidy_ClangAnalyzer) TEST_F(ReadExportedDiagnostics, Clazy) { - const QString sourceFile = TESTDATA "clazy.qgetenv.cpp"; - const QString exportedFile = createFile(appendYamlSuffix(TESTDATA "clazy.qgetenv"), sourceFile); + const Utils::FilePath sourceFile = Utils::FilePath::fromString(TESTDATA "clazy.qgetenv.cpp"); + const QString exportedFile = createFile(appendYamlSuffix(TESTDATA "clazy.qgetenv"), + sourceFile.toString()); Diagnostic expectedDiag; expectedDiag.name = "clazy-qgetenv"; expectedDiag.location = {sourceFile, 7, 5}; |