diff --git a/src/plugins/python/pythonlanguageclient.cpp b/src/plugins/python/pythonlanguageclient.cpp index c4b01462ea9..c49ba404268 100644 --- a/src/plugins/python/pythonlanguageclient.cpp +++ b/src/plugins/python/pythonlanguageclient.cpp @@ -452,17 +452,6 @@ void PyLSSettings::setInterpreter(const QString &interpreterId) m_executable = interpreter.command; } -static PythonProject *projectForFile(const FilePath &pythonFile) -{ - for (ProjectExplorer::Project *project : ProjectExplorer::SessionManager::projects()) { - if (auto pythonProject = qobject_cast(project)) { - if (pythonProject->isKnownFile(pythonFile)) - return pythonProject; - } - } - return nullptr; -} - class PyLSClient : public Client { public: @@ -472,7 +461,7 @@ public: using namespace LanguageServerProtocol; if (reachable()) { const FilePath documentPath = document->filePath(); - if (isSupportedDocument(document) && !projectForFile(documentPath)) { + if (isSupportedDocument(document) && !pythonProjectForFile(documentPath)) { const FilePath workspacePath = documentPath.parentDir(); if (!extraWorkspaceDirs.contains(workspacePath)) { WorkspaceFoldersChangeEvent event; diff --git a/src/plugins/python/pythonutils.cpp b/src/plugins/python/pythonutils.cpp index 5b37cdbf6b5..1ddad5cfcfe 100644 --- a/src/plugins/python/pythonutils.cpp +++ b/src/plugins/python/pythonutils.cpp @@ -146,5 +146,16 @@ QString pythonName(const FilePath &pythonPath) return name; } +PythonProject *pythonProjectForFile(const FilePath &pythonFile) +{ + for (ProjectExplorer::Project *project : ProjectExplorer::SessionManager::projects()) { + if (auto pythonProject = qobject_cast(project)) { + if (pythonProject->isKnownFile(pythonFile)) + return pythonProject; + } + } + return nullptr; +} + } // namespace Internal } // namespace Python diff --git a/src/plugins/python/pythonutils.h b/src/plugins/python/pythonutils.h index c8844d964ea..6493c612a6b 100644 --- a/src/plugins/python/pythonutils.h +++ b/src/plugins/python/pythonutils.h @@ -35,5 +35,8 @@ void openPythonRepl(QObject *parent, const Utils::FilePath &file, ReplType type) Utils::FilePath detectPython(const Utils::FilePath &documentPath); QString pythonName(const Utils::FilePath &pythonPath); +class PythonProject; +PythonProject *pythonProjectForFile(const Utils::FilePath &pythonFile); + } // namespace Internal } // namespace Python