Lua: Implement lua pluginspec specific version check

Change-Id: I52c496c177c949056ff5e7a4ff7b903a028620b1
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Marcus Tillmanns
2024-06-13 07:39:17 +02:00
parent 20a6a5cd78
commit 39c1d82f46
9 changed files with 26 additions and 13 deletions

View File

@@ -40,7 +40,7 @@ Can contain newlines.
disabledByDefault = false,
dependencies = {
{ name="Core", version = "12.0.0" }
{ name="Core", version = "14.0.0" }
},
} --[[@as QtcPlugin]]
```

View File

@@ -9,6 +9,7 @@
#include <extensionsystem/extensionsystemtr.h>
#include <utils/algorithm.h>
#include <utils/appinfo.h>
#include <utils/expected.h>
#include <QJsonDocument>
@@ -76,6 +77,19 @@ ExtensionSystem::IPlugin *LuaPluginSpec::plugin() const
return nullptr;
}
bool LuaPluginSpec::provides(PluginSpec *spec, const PluginDependency &dependency) const
{
if (QString::compare(dependency.name, spec->name(), Qt::CaseInsensitive) != 0)
return false;
// Since we first released the lua support with Qt Creator 14.0.0, but the internal version
// number was still 13.0.82, we needed to special case this version.
if (versionCompare(dependency.version, "14.0.0") <= 0)
return true;
return (versionCompare(spec->version(), dependency.version) >= 0);
}
// LuaPluginSpec::For internal use {}
bool LuaPluginSpec::loadLibrary()
{

View File

@@ -44,6 +44,9 @@ public:
ExtensionSystem::IPlugin *plugin() const override;
bool provides(
PluginSpec *spec, const ExtensionSystem::PluginDependency &dependency) const override;
// For internal use only
bool loadLibrary() override;
bool initializePlugin() override;

View File

@@ -29,7 +29,7 @@ QtcPlugin = {}
---@class QtcPluginDependency
---@field Name string The name of the dependency.
---@field Version string The version of the dependency. (`major.minor.patch`)
---@field Required boolean Whether the dependency is required or not.
---@field Required? "required"|"optional"|"test" Whether the dependency is required or not. (Default: "required")
QtcPluginDependency = {}

View File

@@ -15,8 +15,7 @@ This plugin provides some functionality.
You can describe it more here.
]],
Dependencies = {
{ Name = "Core", Version = "%{JS: Util.qtCreatorIdeVersion()}", Required = true },
{ Name = "Lua", Version = "%{JS: Util.qtCreatorIdeVersion()}", Required = true },
{ Name = "Lua", Version = "%{JS: Util.qtCreatorIdeVersion()}" },
},
setup = function()
require 'init'.setup()

View File

@@ -14,9 +14,8 @@ This plugin provides the Lua Language Server.
It will try to install it if it is not found.
]],
Dependencies = {
{ Name = "Core", Version = "13.0.82", Required = true },
{ Name = "Lua", Version = "13.0.82", Required = true },
{ Name = "LuaLanguageClient", Version = "13.0.82", Required = true }
{ Name = "Lua", Version = "14.0.0" },
{ Name = "LuaLanguageClient", Version = "14.0.0" }
},
setup = function()
require 'init'.setup()

View File

@@ -13,8 +13,7 @@ return {
It has tests for (almost) all functionality exposed by the API.
]],
Dependencies = {
{ Name = "Core", Version = "13.0.82", Required = true },
{ Name = "Lua", Version = "13.0.82", Required = true }
{ Name = "Lua", Version = "14.0.0" }
},
setup = function() require 'tests'.setup() end,
printToOutputPane = true,

View File

@@ -14,9 +14,8 @@ This plugin provides the Rust Language Server.
It will try to install it if it is not found.
]],
Dependencies = {
{ Name = "Core", Version = "13.0.82", Required = true },
{ Name = "Lua", Version = "13.0.82", Required = true },
{ Name = "LuaLanguageClient", Version = "13.0.82", Required = true }
{ Name = "Lua", Version = "14.0.0" },
{ Name = "LuaLanguageClient", Version = "14.0.0" }
},
setup = function()
require 'init'.setup()

View File

@@ -50,7 +50,7 @@ return {
Category = "Fun",
Description = "This plugin adds an action that tells a joke.",
Dependencies = {
{ Name = "Lua", Version = "13.0.82", Required = true },
{ Name = "Lua", Version = "14.0.0" },
},
setup = setup,
} --[[@as QtcPlugin]]