aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/python/pythonlanguageclient.h
diff options
context:
space:
mode:
authorDavid Schulz <[email protected]>2022-05-25 15:24:09 +0200
committerDavid Schulz <[email protected]>2022-06-02 09:09:22 +0000
commitb9627ddba75ebf46d2d12b0fccac9cfb35554ac7 (patch)
treebd8866fff98f0865defb370d3a4f1fe5b10ae7ce /src/plugins/python/pythonlanguageclient.h
parentd8b404a1a3d96bdfb1d97f1575f91f2dad4e1747 (diff)
Python: add pyside uic extra compiler
To be able to autocomplete code from .ui forms we need to feed the python language server the compiled form. The uic extra compiler generates a temporary ui_name.py file for uncompiled or unsaved ui files. These files are inside a folder that gets appended to the python path environment variable for the python language server. Change-Id: I9f48d2012162f33986639315189c41e0a7e0dad2 Reviewed-by: Christian Stenger <[email protected]>
Diffstat (limited to 'src/plugins/python/pythonlanguageclient.h')
-rw-r--r--src/plugins/python/pythonlanguageclient.h35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/plugins/python/pythonlanguageclient.h b/src/plugins/python/pythonlanguageclient.h
index 4109fd4a8cd..42319377412 100644
--- a/src/plugins/python/pythonlanguageclient.h
+++ b/src/plugins/python/pythonlanguageclient.h
@@ -26,18 +26,46 @@
#pragma once
#include <utils/fileutils.h>
+#include <utils/temporarydirectory.h>
#include <languageclient/client.h>
#include <languageclient/languageclientsettings.h>
namespace Core { class IDocument; }
-namespace LanguageClient { class Client; }
+namespace ProjectExplorer { class ExtraCompiler; }
namespace TextEditor { class TextDocument; }
namespace Python {
namespace Internal {
-struct PythonLanguageServerState;
+class PySideUicExtraCompiler;
+class PythonLanguageServerState;
+
+class PyLSClient : public LanguageClient::Client
+{
+ Q_OBJECT
+public:
+ explicit PyLSClient(LanguageClient::BaseClientInterface *interface);
+
+ 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);
+
+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;
+};
class PyLSSettings : public LanguageClient::StdIOSettings
{
@@ -56,6 +84,9 @@ public:
LanguageClient::Client *createClient(LanguageClient::BaseClientInterface *interface) const final;
private:
+ LanguageClient::BaseClientInterface *createInterfaceWithProject(
+ ProjectExplorer::Project *project) const override;
+
static QJsonObject defaultConfiguration();
QString m_interpreterId;