2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2021 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2021-12-13 14:19:30 +01:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <utils/fileutils.h>
|
2022-05-25 15:24:09 +02:00
|
|
|
#include <utils/temporarydirectory.h>
|
2021-12-13 14:19:30 +01:00
|
|
|
|
2021-12-13 15:30:21 +01:00
|
|
|
#include <languageclient/client.h>
|
|
|
|
|
#include <languageclient/languageclientsettings.h>
|
|
|
|
|
|
2021-12-13 14:19:30 +01:00
|
|
|
namespace Core { class IDocument; }
|
2022-05-25 15:24:09 +02:00
|
|
|
namespace ProjectExplorer { class ExtraCompiler; }
|
2021-12-13 14:19:30 +01:00
|
|
|
namespace TextEditor { class TextDocument; }
|
|
|
|
|
|
2022-07-15 11:49:34 +02:00
|
|
|
namespace Python::Internal {
|
2021-12-13 14:19:30 +01:00
|
|
|
|
2022-05-25 15:24:09 +02:00
|
|
|
class PySideUicExtraCompiler;
|
|
|
|
|
class PythonLanguageServerState;
|
2022-06-15 12:44:44 +02:00
|
|
|
class PyLSInterface;
|
2022-05-25 15:24:09 +02:00
|
|
|
|
|
|
|
|
class PyLSClient : public LanguageClient::Client
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2022-06-15 12:44:44 +02:00
|
|
|
explicit PyLSClient(PyLSInterface *interface);
|
2022-06-09 13:41:41 +02:00
|
|
|
~PyLSClient();
|
2022-05-25 15:24:09 +02:00
|
|
|
|
|
|
|
|
void openDocument(TextEditor::TextDocument *document) override;
|
|
|
|
|
void projectClosed(ProjectExplorer::Project *project) override;
|
|
|
|
|
|
|
|
|
|
void updateExtraCompilers(ProjectExplorer::Project *project,
|
|
|
|
|
const QList<PySideUicExtraCompiler *> &extraCompilers);
|
|
|
|
|
|
|
|
|
|
static PyLSClient *clientForPython(const Utils::FilePath &python);
|
2022-06-09 13:41:41 +02:00
|
|
|
void updateConfiguration();
|
2022-05-25 15:24:09 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void updateExtraCompilerContents(ProjectExplorer::ExtraCompiler *compiler,
|
|
|
|
|
const Utils::FilePath &file);
|
|
|
|
|
void closeExtraDoc(const Utils::FilePath &file);
|
|
|
|
|
void closeExtraCompiler(ProjectExplorer::ExtraCompiler *compiler);
|
|
|
|
|
|
|
|
|
|
Utils::FilePaths m_extraWorkspaceDirs;
|
|
|
|
|
Utils::FilePath m_extraCompilerOutputDir;
|
|
|
|
|
|
|
|
|
|
QHash<ProjectExplorer::Project *, QList<ProjectExplorer::ExtraCompiler *>> m_extraCompilers;
|
|
|
|
|
};
|
2021-12-13 14:19:30 +01:00
|
|
|
|
|
|
|
|
class PyLSConfigureAssistant : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
static PyLSConfigureAssistant *instance();
|
|
|
|
|
|
2022-04-26 10:21:12 +02:00
|
|
|
static void updateEditorInfoBars(const Utils::FilePath &python,
|
|
|
|
|
LanguageClient::Client *client);
|
|
|
|
|
static void openDocumentWithPython(const Utils::FilePath &python,
|
|
|
|
|
TextEditor::TextDocument *document);
|
2021-12-13 14:19:30 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
explicit PyLSConfigureAssistant(QObject *parent);
|
|
|
|
|
|
|
|
|
|
void handlePyLSState(const Utils::FilePath &python,
|
|
|
|
|
const PythonLanguageServerState &state,
|
|
|
|
|
TextEditor::TextDocument *document);
|
|
|
|
|
void resetEditorInfoBar(TextEditor::TextDocument *document);
|
|
|
|
|
void installPythonLanguageServer(const Utils::FilePath &python,
|
|
|
|
|
QPointer<TextEditor::TextDocument> document);
|
|
|
|
|
|
|
|
|
|
QHash<Utils::FilePath, QList<TextEditor::TextDocument *>> m_infoBarEntries;
|
|
|
|
|
};
|
|
|
|
|
|
2022-07-15 11:49:34 +02:00
|
|
|
} // Python::Internal
|