diff options
-rw-r--r-- | script/provider/build-meta.lua | 56 | ||||
-rw-r--r-- | script/provider/provider.lua | 3 | ||||
-rw-r--r-- | script/vm/memoryAPI.lua | 34 | ||||
-rw-r--r-- | test/example/meta.json (renamed from test/example/memoryAPI.json) | 0 | ||||
-rw-r--r-- | test/tclient/init.lua | 1 | ||||
-rw-r--r-- | test/tclient/tests/build-meta.lua | 18 |
6 files changed, 76 insertions, 36 deletions
diff --git a/script/provider/build-meta.lua b/script/provider/build-meta.lua new file mode 100644 index 00000000..0da5d05c --- /dev/null +++ b/script/provider/build-meta.lua @@ -0,0 +1,56 @@ +local fs = require 'bee.filesystem' +local config = require 'config' +local util = require 'utility' + +local m = {} + +---@class meta +---@field root string +---@field classes meta.class[] + +---@class meta.class +---@field namespace string +---@field baseClass string +---@field attribute string +---@field integerface string[] +---@field fields meta.field[] +---@field methods meta.method[] + +---@class meta.field +---@field name string +---@field typeName string +---@field comment string +---@field location string + +---@class meta.method +---@field name string +---@field comment string +---@field location string +---@field isStatic boolean +---@field returnTypeName string +---@field params {name: string, typeName: string}[] + +---@param api meta +---@return string +local function buildText(api) + local lines = {} + for _, class in ipairs(api.classes) do + + end + + lines[#lines+1] = '' + return table.concat(lines, '\n') +end + +---@param name string +---@param api meta +function m.build(name, api) + local encoding = config.get(nil, 'Lua.runtime.fileEncoding') + local filePath = fs.path(METAPATH) / (name .. ' ' .. encoding .. '.lua') + + local text = buildText(api) + + util.saveFile(filePath:string(), text) +end + +return m diff --git a/script/provider/provider.lua b/script/provider/provider.lua index 57346dcc..11b713bc 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -21,7 +21,6 @@ local furi = require 'file-uri' local inspect = require 'inspect' local markdown = require 'provider.markdown' local guide = require 'parser.guide' -local vm = require 'vm.vm' ---@async local function updateConfig(uri) @@ -1342,7 +1341,7 @@ m.register 'workspace/diagnostic' { m.register '$/api/report' { ---@async function (params) - vm.saveMemoryAPI(params) + require 'provider.build-meta'.build('reported', params) end } diff --git a/script/vm/memoryAPI.lua b/script/vm/memoryAPI.lua deleted file mode 100644 index 079687d7..00000000 --- a/script/vm/memoryAPI.lua +++ /dev/null @@ -1,34 +0,0 @@ ----@class vm ----@field memoryAPI? table -local vm = require 'vm.vm' - ----@class vm.memoryAPI ----@field root string ----@field classes vm.memoryAPI.class[] - ----@class vm.memoryAPI.class ----@field namespace string ----@field baseClass string ----@field attribute string ----@field integerface string[] ----@field fields vm.memoryAPI.field[] ----@field methods vm.memoryAPI.method[] - ----@class vm.memoryAPI.field ----@field name string ----@field typeName string ----@field comment string ----@field location string - ----@class vm.memoryAPI.method ----@field name string ----@field comment string ----@field location string ----@field isStatic boolean ----@field returnTypeName string ----@field params {name: string, typeName: string}[] - ----@param api vm.memoryAPI -function vm.saveMemoryAPI(api) - vm.memoryAPI = api -end diff --git a/test/example/memoryAPI.json b/test/example/meta.json index 658618e2..658618e2 100644 --- a/test/example/memoryAPI.json +++ b/test/example/meta.json diff --git a/test/tclient/init.lua b/test/tclient/init.lua index 2b470887..070cf337 100644 --- a/test/tclient/init.lua +++ b/test/tclient/init.lua @@ -8,3 +8,4 @@ require 'tclient.tests.resolve-completion' require 'tclient.tests.performance-jass-common' require 'tclient.tests.hover-pairs' require 'tclient.tests.change-workspace-folder' +require 'tclient.tests.build-meta' diff --git a/test/tclient/tests/build-meta.lua b/test/tclient/tests/build-meta.lua new file mode 100644 index 00000000..13f41a7a --- /dev/null +++ b/test/tclient/tests/build-meta.lua @@ -0,0 +1,18 @@ +local lclient = require 'lclient' +local util = require 'utility' +local ws = require 'workspace' +local json = require 'json' + +---@async +lclient():start(function (client) + client:registerFakers() + + client:initialize() + + local text = util.loadFile((ROOT / 'test' / 'example' / 'meta.json'):string()) + local meta = json.decode(text) + + client:notify('$/api/report', meta) + + ws.awaitReady() +end) |