From 0061555213a491a407307cfbf16d1618426a234b Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 31 Aug 2021 13:34:20 +0200 Subject: [PATCH] LanguangeClient: Use more FilePath Change-Id: Ic849da11da646feb804717550d2a8a60d61f332d Reviewed-by: David Schulz --- src/plugins/android/javalanguageserver.cpp | 9 ++++----- .../languageclient/languageclientsettings.cpp | 14 ++++++-------- .../languageclient/languageclientsettings.h | 4 ++-- src/plugins/python/pythonutils.cpp | 2 +- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/plugins/android/javalanguageserver.cpp b/src/plugins/android/javalanguageserver.cpp index 1de0411cbb3..bdfa164a8e2 100644 --- a/src/plugins/android/javalanguageserver.cpp +++ b/src/plugins/android/javalanguageserver.cpp @@ -59,7 +59,7 @@ public: JLSSettingsWidget(const JLSSettings *settings, QWidget *parent); QString name() const { return m_name->text(); } - QString java() const { return m_java->filePath().toString(); } + FilePath java() const { return m_java->filePath(); } QString languageServer() const { return m_ls->filePath().toString(); } QString workspace() const { return m_workspace->filePath().toString(); } @@ -85,7 +85,7 @@ JLSSettingsWidget::JLSSettingsWidget(const JLSSettings *settings, QWidget *paren mainLayout->addWidget(new QLabel(tr("Java:")), ++row, 0); m_java->setExpectedKind(Utils::PathChooser::ExistingCommand); - m_java->setPath(QDir::toNativeSeparators(settings->m_executable)); + m_java->setFilePath(settings->m_executable); mainLayout->addWidget(m_java, row, 1); mainLayout->addWidget(new QLabel(tr("Java Language Server:")), ++row, 0); @@ -106,7 +106,7 @@ JLSSettings::JLSSettings() m_languageFilter.mimeTypes = QStringList(Constants::JAVA_MIMETYPE); const FilePath &javaPath = Utils::Environment::systemEnvironment().searchInPath("java"); if (javaPath.exists()) - m_executable = javaPath.toString(); + m_executable = javaPath; } bool JLSSettings::applyFromSettingsWidget(QWidget *widget) @@ -192,8 +192,7 @@ private: LanguageClient::BaseClientInterface *JLSSettings::createInterface() const { auto interface = new JLSInterface(); - CommandLine cmd{FilePath::fromString(m_executable)}; - cmd.addArgs(arguments(), CommandLine::Raw); + CommandLine cmd{m_executable, arguments(), CommandLine::Raw}; cmd.addArgs({"-data", interface->workspaceDir()}); interface->setCommandLine(cmd); return interface; diff --git a/src/plugins/languageclient/languageclientsettings.cpp b/src/plugins/languageclient/languageclientsettings.cpp index 0745d6f1732..b2c49af5015 100644 --- a/src/plugins/languageclient/languageclientsettings.cpp +++ b/src/plugins/languageclient/languageclientsettings.cpp @@ -715,7 +715,7 @@ bool StdIOSettings::isValid() const QVariantMap StdIOSettings::toMap() const { QVariantMap map = BaseSettings::toMap(); - map.insert(executableKey, m_executable); + map.insert(executableKey, m_executable.toVariant()); map.insert(argumentsKey, m_arguments); return map; } @@ -723,7 +723,7 @@ QVariantMap StdIOSettings::toMap() const void StdIOSettings::fromMap(const QVariantMap &map) { BaseSettings::fromMap(map); - m_executable = map[executableKey].toString(); + m_executable = Utils::FilePath::fromVariant(map[executableKey]); m_arguments = map[argumentsKey].toString(); } @@ -734,9 +734,7 @@ QString StdIOSettings::arguments() const Utils::CommandLine StdIOSettings::command() const { - return Utils::CommandLine(Utils::FilePath::fromUserInput(m_executable), - arguments(), - Utils::CommandLine::Raw); + return Utils::CommandLine(m_executable, arguments(), Utils::CommandLine::Raw); } BaseClientInterface *StdIOSettings::createInterfaceWithProject(ProjectExplorer::Project *project) const @@ -975,16 +973,16 @@ StdIOSettingsWidget::StdIOSettingsWidget(const StdIOSettings *settings, QWidget mainLayout->addWidget(m_executable, baseRows, 1); mainLayout->addWidget(new QLabel(tr("Arguments:")), baseRows + 1, 0); m_executable->setExpectedKind(Utils::PathChooser::ExistingCommand); - m_executable->setPath(QDir::toNativeSeparators(settings->m_executable)); + m_executable->setFilePath(settings->m_executable); mainLayout->addWidget(m_arguments, baseRows + 1, 1); auto chooser = new Utils::VariableChooser(this); chooser->addSupportedWidget(m_arguments); } -QString StdIOSettingsWidget::executable() const +Utils::FilePath StdIOSettingsWidget::executable() const { - return m_executable->filePath().toString(); + return m_executable->filePath(); } QString StdIOSettingsWidget::arguments() const diff --git a/src/plugins/languageclient/languageclientsettings.h b/src/plugins/languageclient/languageclientsettings.h index b964fbca5d7..03a9cf9f84a 100644 --- a/src/plugins/languageclient/languageclientsettings.h +++ b/src/plugins/languageclient/languageclientsettings.h @@ -124,7 +124,7 @@ public: StdIOSettings() = default; ~StdIOSettings() override = default; - QString m_executable; + Utils::FilePath m_executable; QString m_arguments; bool applyFromSettingsWidget(QWidget *widget) override; @@ -204,7 +204,7 @@ public: explicit StdIOSettingsWidget(const StdIOSettings* settings, QWidget *parent = nullptr); ~StdIOSettingsWidget() override = default; - QString executable() const; + Utils::FilePath executable() const; QString arguments() const; private: diff --git a/src/plugins/python/pythonutils.cpp b/src/plugins/python/pythonutils.cpp index 4340da3bacb..b570b26a1ae 100644 --- a/src/plugins/python/pythonutils.cpp +++ b/src/plugins/python/pythonutils.cpp @@ -225,7 +225,7 @@ const StdIOSettings *PyLSConfigureAssistant::languageServerForPython(const FileP static Client *registerLanguageServer(const FilePath &python) { auto *settings = new StdIOSettings(); - settings->m_executable = python.toString(); + settings->m_executable = python; settings->m_arguments = "-m pyls"; settings->m_name = PyLSConfigureAssistant::tr("Python Language Server (%1)") .arg(pythonName(python));