diff --git a/src/plugins/clangtools/clangselectablefilesdialog.cpp b/src/plugins/clangtools/clangselectablefilesdialog.cpp index 414c320b8bc..3ae08067f41 100644 --- a/src/plugins/clangtools/clangselectablefilesdialog.cpp +++ b/src/plugins/clangtools/clangselectablefilesdialog.cpp @@ -61,7 +61,7 @@ static Tree *createDirNode(const QString &name, const FilePath &filePath = FileP static Tree *createFileNode(const FileInfo &fileInfo, bool displayFullPath = false) { auto node = new TreeWithFileInfo; - node->name = displayFullPath ? fileInfo.file.toString() : fileInfo.file.fileName(); + node->name = displayFullPath ? fileInfo.file.toUserOutput() : fileInfo.file.fileName(); node->fullPath = fileInfo.file; node->info = fileInfo; diff --git a/src/plugins/clangtools/clangtool.cpp b/src/plugins/clangtools/clangtool.cpp index 2622f3c7d9f..d7d945c6403 100644 --- a/src/plugins/clangtools/clangtool.cpp +++ b/src/plugins/clangtools/clangtool.cpp @@ -1250,7 +1250,7 @@ void ClangTool::setState(State state) QSet ClangTool::diagnostics() const { return Utils::filtered(m_diagnosticModel->diagnostics(), [](const Diagnostic &diagnostic) { - return ProjectFile::isSource(ProjectFile::classify(diagnostic.location.filePath.toString())); + return ProjectFile::isSource(ProjectFile::classify(diagnostic.location.filePath)); }); } diff --git a/src/plugins/clangtools/clangtoolsdiagnosticmodel.cpp b/src/plugins/clangtools/clangtoolsdiagnosticmodel.cpp index f4d03bed48b..dc4cc690cc4 100644 --- a/src/plugins/clangtools/clangtoolsdiagnosticmodel.cpp +++ b/src/plugins/clangtools/clangtoolsdiagnosticmodel.cpp @@ -653,7 +653,7 @@ bool DiagnosticFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &s continue; Utils::FilePath filePath = d.filePath; if (d.filePath.toFileInfo().isRelative()) - filePath = m_lastProjectDirectory.pathAppended(filePath.toString()); + filePath = m_lastProjectDirectory.resolvePath(filePath); if (filePath == diag.location.filePath) { diagnosticItem->setTextMarkVisible(false); return false; diff --git a/src/plugins/clangtools/clangtoolslogfilereader.cpp b/src/plugins/clangtools/clangtoolslogfilereader.cpp index a68b3c4d82a..21f34f35c10 100644 --- a/src/plugins/clangtools/clangtoolslogfilereader.cpp +++ b/src/plugins/clangtools/clangtoolslogfilereader.cpp @@ -129,7 +129,7 @@ public: Debugger::DiagnosticLocation toDiagnosticLocation() const { - FileCache::Item &cacheItem = m_fileCache.item(m_filePath.toString()); + FileCache::Item &cacheItem = m_fileCache.item(m_filePath.toUserOutput()); const QByteArray fileContents = cacheItem.fileContents(); const char *data = fileContents.data(); diff --git a/src/plugins/clangtools/clangtoolsprojectsettings.cpp b/src/plugins/clangtools/clangtoolsprojectsettings.cpp index 224cfab1a8c..3b5d7da0375 100644 --- a/src/plugins/clangtools/clangtoolsprojectsettings.cpp +++ b/src/plugins/clangtools/clangtoolsprojectsettings.cpp @@ -139,31 +139,27 @@ void ClangToolsProjectSettings::load() // Read map m_useGlobalSettings = map.value(SETTINGS_KEY_USE_GLOBAL_SETTINGS).toBool(); - auto toFileName = [](const QString &s) { return Utils::FilePath::fromString(s); }; - const QStringList dirs = map.value(SETTINGS_KEY_SELECTED_DIRS).toStringList(); - m_selectedDirs = Utils::transform(dirs, toFileName); + const QVariantList dirs = map.value(SETTINGS_KEY_SELECTED_DIRS).toList(); + m_selectedDirs = Utils::transform(dirs, Utils::FilePath::fromSettings); - const QStringList files = map.value(SETTINGS_KEY_SELECTED_FILES).toStringList(); - m_selectedFiles = Utils::transform(files, toFileName); + const QVariantList files = map.value(SETTINGS_KEY_SELECTED_FILES).toList(); + m_selectedFiles = Utils::transform(files, Utils::FilePath::fromSettings); const QVariantList list = map.value(SETTINGS_KEY_SUPPRESSED_DIAGS).toList(); for (const QVariant &v : list) { const Store diag = storeFromVariant(v); - const QString fp = diag.value(SETTINGS_KEY_SUPPRESSED_DIAGS_FILEPATH).toString(); + const auto fp = Utils::FilePath::fromSettings( + diag.value(SETTINGS_KEY_SUPPRESSED_DIAGS_FILEPATH)); if (fp.isEmpty()) continue; const QString message = diag.value(SETTINGS_KEY_SUPPRESSED_DIAGS_MESSAGE).toString(); if (message.isEmpty()) continue; - Utils::FilePath fullPath = Utils::FilePath::fromString(fp); - if (fullPath.toFileInfo().isRelative()) - fullPath = m_project->projectDirectory().pathAppended(fp); + const Utils::FilePath fullPath = m_project->projectDirectory().resolvePath(fp); if (!fullPath.exists()) continue; const int uniquifier = diag.value(SETTINGS_KEY_SUPPRESSED_DIAGS_UNIQIFIER).toInt(); - m_suppressedDiagnostics << SuppressedDiagnostic(Utils::FilePath::fromString(fp), - message, - uniquifier); + m_suppressedDiagnostics << SuppressedDiagnostic(fp, message, uniquifier); } emit suppressedDiagnosticsChanged(); @@ -178,16 +174,17 @@ void ClangToolsProjectSettings::store() Store map; map.insert(SETTINGS_KEY_USE_GLOBAL_SETTINGS, m_useGlobalSettings); - const QStringList dirs = Utils::transform(m_selectedDirs, &Utils::FilePath::toString); + const QVariantList dirs = Utils::transform(m_selectedDirs, &Utils::FilePath::toSettings); map.insert(SETTINGS_KEY_SELECTED_DIRS, dirs); - const QStringList files = Utils::transform(m_selectedFiles, &Utils::FilePath::toString); + const QVariantList files + = Utils::transform(m_selectedFiles, &Utils::FilePath::toSettings); map.insert(SETTINGS_KEY_SELECTED_FILES, files); QVariantList list; for (const SuppressedDiagnostic &diag : std::as_const(m_suppressedDiagnostics)) { Store diagMap; - diagMap.insert(SETTINGS_KEY_SUPPRESSED_DIAGS_FILEPATH, diag.filePath.toString()); + diagMap.insert(SETTINGS_KEY_SUPPRESSED_DIAGS_FILEPATH, diag.filePath.toSettings()); diagMap.insert(SETTINGS_KEY_SUPPRESSED_DIAGS_MESSAGE, diag.description); diagMap.insert(SETTINGS_KEY_SUPPRESSED_DIAGS_UNIQIFIER, diag.uniquifier); list << variantFromStore(diagMap); diff --git a/src/plugins/clangtools/clangtoolsutils.cpp b/src/plugins/clangtools/clangtoolsutils.cpp index 1b65e1db1f0..e7b42a21b4a 100644 --- a/src/plugins/clangtools/clangtoolsutils.cpp +++ b/src/plugins/clangtools/clangtoolsutils.cpp @@ -154,7 +154,7 @@ FilePath fullPath(const FilePath &executable) candidate = candidate.withExecutableSuffix(); } else { const Environment environment = Environment::systemEnvironment(); - const FilePath expandedPath = environment.searchInPath(candidate.toString()); + const FilePath expandedPath = environment.searchInPath(candidate.fileName()); if (!expandedPath.isEmpty()) candidate = expandedPath; } diff --git a/src/plugins/clangtools/diagnosticconfigswidget.cpp b/src/plugins/clangtools/diagnosticconfigswidget.cpp index 69369803645..a17334c4ce9 100644 --- a/src/plugins/clangtools/diagnosticconfigswidget.cpp +++ b/src/plugins/clangtools/diagnosticconfigswidget.cpp @@ -401,8 +401,7 @@ static void buildTree(ProjectExplorer::Tree *parent, current->name = node.name; current->isDir = node.children.size(); if (parent) { - current->fullPath = Utils::FilePath::fromString(parent->fullPath.toString() - + current->name); + current->fullPath = parent->fullPath.pathAppended(current->name); parent->childDirectories.push_back(current); } else { current->fullPath = Utils::FilePath::fromString(current->name); @@ -413,9 +412,9 @@ static void buildTree(ProjectExplorer::Tree *parent, } static bool needsLink(ProjectExplorer::Tree *node) { - if (node->fullPath.toString() == "clang-analyzer-") + if (node->fullPath.path() == "clang-analyzer-") return true; - return !node->isDir && !node->fullPath.toString().startsWith("clang-analyzer-"); + return !node->isDir && !node->fullPath.startsWith("clang-analyzer-"); } class BaseChecksTreeModel : public ProjectExplorer::SelectableFilesModel // FIXME: This isn't about files. @@ -591,7 +590,7 @@ public: // 'clang-analyzer-' group if (node->isDir) return CppEditor::Constants::CLANG_STATIC_ANALYZER_DOCUMENTATION_URL; - return clangTidyDocUrl(node->fullPath.toString()); + return clangTidyDocUrl(node->fullPath.path()); } return BaseChecksTreeModel::data(fullIndex, role); @@ -629,7 +628,7 @@ private: return false; auto *node = static_cast(index.internalPointer()); - const QString nodeName = node->fullPath.toString(); + const QString nodeName = node->fullPath.path(); if ((check.endsWith("*") && nodeName.startsWith(check.left(check.length() - 1))) || (!node->isDir && nodeName == check)) { result = index; @@ -646,7 +645,7 @@ private: if (root->checked == Qt::Unchecked) return; if (root->checked == Qt::Checked) { - checks += "," + root->fullPath.toString(); + checks += "," + root->fullPath.path(); if (root->isDir) checks += "*"; return; diff --git a/src/plugins/clangtools/documentclangtoolrunner.cpp b/src/plugins/clangtools/documentclangtoolrunner.cpp index 827cacb3dfc..3cab2f986da 100644 --- a/src/plugins/clangtools/documentclangtoolrunner.cpp +++ b/src/plugins/clangtools/documentclangtoolrunner.cpp @@ -208,13 +208,14 @@ void DocumentClangToolRunner::run() const AnalyzeUnits units{{m_fileInfo, tool}}; const auto diagnosticFilter = [mappedPath = vfso().autoSavedFilePath(m_document)]( const FilePath &path) { return path == mappedPath; }; - const AnalyzeInputData input{tool, - runSettings, - config, - m_temporaryDir.path(), - env, - vfso().overlayFilePath().toString(), - diagnosticFilter}; + const AnalyzeInputData input{ + tool, + runSettings, + config, + m_temporaryDir.path(), + env, + vfso().overlayFilePath().nativePath(), + diagnosticFilter}; const auto setupHandler = [this, executable](const AnalyzeUnit &) { return !m_document->isModified() || isVFSOverlaySupported(executable); }; @@ -317,7 +318,7 @@ bool DocumentClangToolRunner::isSuppressed(const Diagnostic &diagnostic) const return false; FilePath filePath = suppressed.filePath; if (filePath.toFileInfo().isRelative()) - filePath = m_lastProjectDirectory.pathAppended(filePath.toString()); + filePath = m_lastProjectDirectory.resolvePath(filePath); 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 864f0c9ee20..1344325882c 100644 --- a/src/plugins/clangtools/documentquickfixfactory.cpp +++ b/src/plugins/clangtools/documentquickfixfactory.cpp @@ -42,13 +42,12 @@ static Range toRange(const QTextDocument *doc, DiagnosticRange locations) void ClangToolQuickFixOperation::perform() { TextEditor::PlainRefactoringFileFactory changes; - QMap refactoringFiles; + QMap refactoringFiles; for (const ExplainingStep &step : m_diagnostic.explainingSteps) { if (!step.isFixIt) continue; - TextEditor::RefactoringFilePtr &refactoringFile - = refactoringFiles[step.location.filePath.toString()]; + TextEditor::RefactoringFilePtr &refactoringFile = refactoringFiles[step.location.filePath]; if (refactoringFile.isNull()) refactoringFile = changes.file(step.location.filePath); Utils::ChangeSet changeSet = refactoringFile->changeSet(); diff --git a/src/plugins/clangtools/executableinfo.cpp b/src/plugins/clangtools/executableinfo.cpp index b3d4f9eb790..2f4be6d6702 100644 --- a/src/plugins/clangtools/executableinfo.cpp +++ b/src/plugins/clangtools/executableinfo.cpp @@ -164,9 +164,8 @@ static FilePath queryResourceDir(const FilePath &clangToolPath) [&clangToolPath](const QString &stdOut, const QString &) -> std::optional { QString output = stdOut; QTextStream stream(&output); - const QString path = clangToolPath.parentDir().parentDir() - .pathAppended(stream.readLine()).toString(); - const auto filePath = FilePath::fromUserInput(QDir::cleanPath(path)); + const FilePath filePath + = clangToolPath.parentDir().parentDir().pathAppended(stream.readLine()).cleanPath(); if (filePath.exists()) return filePath; return {}; diff --git a/src/plugins/clangtools/virtualfilesystemoverlay.cpp b/src/plugins/clangtools/virtualfilesystemoverlay.cpp index 6db85f52aac..1c26f59a2d9 100644 --- a/src/plugins/clangtools/virtualfilesystemoverlay.cpp +++ b/src/plugins/clangtools/virtualfilesystemoverlay.cpp @@ -26,9 +26,6 @@ VirtualFileSystemOverlay::VirtualFileSystemOverlay(const QString &rootPattern) void VirtualFileSystemOverlay::update() { overlayFilePath().removeRecursively(); - QFile overlayFile(m_overlayFilePath.toString()); - if (!overlayFile.open(QFile::ReadWrite)) - return; std::map> documentRoots; const QList &modifiedDocuments = Core::DocumentManager::modifiedDocuments(); QHash newSaved; @@ -87,9 +84,10 @@ void VirtualFileSystemOverlay::update() main["roots"] = jsonRoots; QJsonDocument overlay(main); - if (!overlayFile.write(overlay.toJson(QJsonDocument::Compact))) + const Utils::expected_str res = m_overlayFilePath.writeFileContents( + overlay.toJson(QJsonDocument::Compact)); + if (!res) qCDebug(LOG) << "failed to write vfso to " << m_overlayFilePath; - overlayFile.close(); } Utils::FilePath VirtualFileSystemOverlay::overlayFilePath() const { return m_overlayFilePath; }