Python: extract pythonProjectForFile function to utils

Change-Id: I4055527302cab09f55cd4b06bfd3896accb4832a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2022-03-23 07:40:20 +01:00
parent ff686f5679
commit 64170a788a
3 changed files with 15 additions and 12 deletions

View File

@@ -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<PythonProject *>(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;