diff options
author | hjk <[email protected]> | 2025-01-09 11:58:40 +0100 |
---|---|---|
committer | hjk <[email protected]> | 2025-01-10 13:05:29 +0000 |
commit | 2d9d6aa315976dc8937381e453f57263950d8841 (patch) | |
tree | 7ccb860763e95ad24272b158ead690afb79e9c3b /src/plugins/nim | |
parent | 0986822d44c80ee1fc8fef0289a05ccc2d4d3668 (diff) |
Utils: Rename FilePath::toString() into toUrlishString()
toString() is almost always the wrong conversion, but unfortunately
too easy to find and often even working at least for local setup.
This here raises the bar as the non-availability of the "obvious"
toString() hopefully helps people to think about the semantics of
the needed conversion and choose the right toXXX() function.
The chosen new name is intentional ugly to reduce the likelihood
that this (still almost always wrong) function is used out of
convenience.
Change-Id: I57f1618dd95ef2629d7d978688d130275e096c0f
Reviewed-by: Eike Ziller <[email protected]>
Diffstat (limited to 'src/plugins/nim')
-rw-r--r-- | src/plugins/nim/editor/nimcompletionassistprovider.cpp | 2 | ||||
-rw-r--r-- | src/plugins/nim/editor/nimtexteditorwidget.cpp | 2 | ||||
-rw-r--r-- | src/plugins/nim/project/nimblebuildsystem.cpp | 10 | ||||
-rw-r--r-- | src/plugins/nim/project/nimbuildsystem.cpp | 8 | ||||
-rw-r--r-- | src/plugins/nim/project/nimcompilerbuildstep.cpp | 12 | ||||
-rw-r--r-- | src/plugins/nim/project/nimcompilercleanstep.cpp | 2 |
6 files changed, 18 insertions, 18 deletions
diff --git a/src/plugins/nim/editor/nimcompletionassistprovider.cpp b/src/plugins/nim/editor/nimcompletionassistprovider.cpp index e290c8fb84d..c266e645f19 100644 --- a/src/plugins/nim/editor/nimcompletionassistprovider.cpp +++ b/src/plugins/nim/editor/nimcompletionassistprovider.cpp @@ -141,7 +141,7 @@ private: int line = 0, column = 0; Utils::Text::convertPosition(interface->textDocument(), pos, &line, &column); QTC_ASSERT(column >= 0, return nullptr); - return suggest->sug(interface->filePath().toString(), line, column, dirtyFile); + return suggest->sug(interface->filePath().toUrlishString(), line, column, dirtyFile); } static std::unique_ptr<QTemporaryFile> writeDirtyFile(const TextEditor::AssistInterface *interface) diff --git a/src/plugins/nim/editor/nimtexteditorwidget.cpp b/src/plugins/nim/editor/nimtexteditorwidget.cpp index f7ca080dace..8bc6c5749e8 100644 --- a/src/plugins/nim/editor/nimtexteditorwidget.cpp +++ b/src/plugins/nim/editor/nimtexteditorwidget.cpp @@ -48,7 +48,7 @@ void NimTextEditorWidget::findLinkAt(const QTextCursor &c, const Utils::LinkHand int line = 0, column = 0; Utils::Text::convertPosition(document(), c.position(), &line, &column); - std::shared_ptr<NimSuggestClientRequest> request = suggest->def(path.toString(), + std::shared_ptr<NimSuggestClientRequest> request = suggest->def(path.toUrlishString(), line, column, dirtyFile->fileName()); diff --git a/src/plugins/nim/project/nimblebuildsystem.cpp b/src/plugins/nim/project/nimblebuildsystem.cpp index b08a3f6dc04..f7b6fb4a7d0 100644 --- a/src/plugins/nim/project/nimblebuildsystem.cpp +++ b/src/plugins/nim/project/nimblebuildsystem.cpp @@ -104,7 +104,7 @@ NimbleBuildSystem::NimbleBuildSystem(Target *target) m_projectScanner.watchProjectFilePath(); connect(&m_projectScanner, &NimProjectScanner::fileChanged, this, [this](const QString &path) { - if (path == projectFilePath().toString()) + if (path == projectFilePath().toUrlishString()) requestDelayedParse(); }); @@ -117,7 +117,7 @@ NimbleBuildSystem::NimbleBuildSystem(Target *target) // Workaround for nimble creating temporary files in project root directory // when querying the list of tasks. // See https://github.com/nim-lang/nimble/issues/720 - if (directory != projectDirectory().toString()) + if (directory != projectDirectory().toUrlishString()) requestDelayedParse(); }); @@ -219,14 +219,14 @@ bool NimbleBuildSystem::supportsAction(Node *context, ProjectAction action, cons bool NimbleBuildSystem::addFiles(Node *, const FilePaths &filePaths, FilePaths *) { - return m_projectScanner.addFiles(Utils::transform(filePaths, &FilePath::toString)); + return m_projectScanner.addFiles(Utils::transform(filePaths, &FilePath::toUrlishString)); } RemovedFilesFromProject NimbleBuildSystem::removeFiles(Node *, const FilePaths &filePaths, FilePaths *) { - return m_projectScanner.removeFiles(Utils::transform(filePaths, &FilePath::toString)); + return m_projectScanner.removeFiles(Utils::transform(filePaths, &FilePath::toUrlishString)); } bool NimbleBuildSystem::deleteFiles(Node *, const FilePaths &) @@ -238,7 +238,7 @@ bool NimbleBuildSystem::renameFiles(Node *, const FilePairs &filesToRename, File { bool success = true; for (const auto &[oldFilePath, newFilePath] : filesToRename) { - if (!m_projectScanner.renameFile(oldFilePath.toString(), newFilePath.toString())) { + if (!m_projectScanner.renameFile(oldFilePath.toUrlishString(), newFilePath.toUrlishString())) { success = false; if (notRenamed) *notRenamed << oldFilePath; diff --git a/src/plugins/nim/project/nimbuildsystem.cpp b/src/plugins/nim/project/nimbuildsystem.cpp index b8425df69a2..91862171a2a 100644 --- a/src/plugins/nim/project/nimbuildsystem.cpp +++ b/src/plugins/nim/project/nimbuildsystem.cpp @@ -85,7 +85,7 @@ void NimProjectScanner::startScan() { m_scanner.setFilter( [excludedFiles = excludedFiles()](const Utils::MimeType &, const FilePath &fp) { - const QString path = fp.toString(); + const QString path = fp.toUrlishString(); return excludedFiles.contains(path) || path.endsWith(".nimproject") || path.contains(".nimproject.user") || path.contains(".nimble.user"); }); @@ -225,14 +225,14 @@ bool NimBuildSystem::supportsAction(Node *context, ProjectAction action, const N bool NimBuildSystem::addFiles(Node *, const FilePaths &filePaths, FilePaths *) { - return m_projectScanner.addFiles(Utils::transform(filePaths, &FilePath::toString)); + return m_projectScanner.addFiles(Utils::transform(filePaths, &FilePath::toUrlishString)); } RemovedFilesFromProject NimBuildSystem::removeFiles(Node *, const FilePaths &filePaths, FilePaths *) { - return m_projectScanner.removeFiles(Utils::transform(filePaths, &FilePath::toString)); + return m_projectScanner.removeFiles(Utils::transform(filePaths, &FilePath::toUrlishString)); } bool NimBuildSystem::deleteFiles(Node *, const FilePaths &) @@ -244,7 +244,7 @@ bool NimBuildSystem::renameFiles(Node *, const FilePairs &filesToRename, FilePat { bool success = true; for (const auto &[oldFilePath, newFilePath] : filesToRename) { - if (!m_projectScanner.renameFile(oldFilePath.toString(), newFilePath.toString())) { + if (!m_projectScanner.renameFile(oldFilePath.toUrlishString(), newFilePath.toUrlishString())) { success = false; if (notRenamed) *notRenamed << oldFilePath; diff --git a/src/plugins/nim/project/nimcompilerbuildstep.cpp b/src/plugins/nim/project/nimcompilerbuildstep.cpp index ce820926bed..9b724ecf058 100644 --- a/src/plugins/nim/project/nimcompilerbuildstep.cpp +++ b/src/plugins/nim/project/nimcompilerbuildstep.cpp @@ -86,10 +86,10 @@ QWidget *NimCompilerBuildStep::createConfigWidget() const FilePaths files = project()->files(Project::AllFiles); for (const FilePath &file : files) { if (file.endsWith(".nim")) - targetComboBox->addItem(file.fileName(), file.toString()); + targetComboBox->addItem(file.fileName(), file.toUrlishString()); } - const int index = targetComboBox->findData(m_targetNimFile.toString()); + const int index = targetComboBox->findData(m_targetNimFile.toUrlishString()); targetComboBox->setCurrentIndex(index); const QString text = m_userCompilerOptions.join(QChar::Space); @@ -135,7 +135,7 @@ void NimCompilerBuildStep::toMap(Store &map) const AbstractProcessStep::toMap(map); map[Constants::C_NIMCOMPILERBUILDSTEP_USERCOMPILEROPTIONS] = m_userCompilerOptions.join('|'); map[Constants::C_NIMCOMPILERBUILDSTEP_DEFAULTBUILDOPTIONS] = m_defaultOptions; - map[Constants::C_NIMCOMPILERBUILDSTEP_TARGETNIMFILE] = m_targetNimFile.toString(); + map[Constants::C_NIMCOMPILERBUILDSTEP_TARGETNIMFILE] = m_targetNimFile.toUrlishString(); } void NimCompilerBuildStep::setBuildType(BuildConfiguration::BuildType buildType) @@ -172,8 +172,8 @@ CommandLine NimCompilerBuildStep::commandLine() else if (m_defaultOptions == Debug) cmd.addArgs({"--debugInfo", "--lineDir:on"}); - cmd.addArg("--out:" + outFilePath().toString()); - cmd.addArg("--nimCache:" + bc->cacheDirectory().toString()); + cmd.addArg("--out:" + outFilePath().toUrlishString()); + cmd.addArg("--nimCache:" + bc->cacheDirectory().toUrlishString()); for (const QString &arg : std::as_const(m_userCompilerOptions)) { if (!arg.isEmpty()) @@ -181,7 +181,7 @@ CommandLine NimCompilerBuildStep::commandLine() } if (!m_targetNimFile.isEmpty()) - cmd.addArg(m_targetNimFile.toString()); + cmd.addArg(m_targetNimFile.toUrlishString()); return cmd; } diff --git a/src/plugins/nim/project/nimcompilercleanstep.cpp b/src/plugins/nim/project/nimcompilercleanstep.cpp index cb497638b57..5de8a0b96de 100644 --- a/src/plugins/nim/project/nimcompilercleanstep.cpp +++ b/src/plugins/nim/project/nimcompilercleanstep.cpp @@ -86,7 +86,7 @@ bool NimCompilerCleanStep::removeCacheDirectory() QTC_ASSERT(bc, return false); if (!bc->cacheDirectory().exists()) return true; - QDir dir = QDir::fromNativeSeparators(bc->cacheDirectory().toString()); + QDir dir = QDir::fromNativeSeparators(bc->cacheDirectory().toUrlishString()); const QString dirName = dir.dirName(); if (!dir.cdUp()) return false; |