diff options
-rw-r--r-- | .vscode/settings.json | 2 | ||||
-rw-r--r-- | script-beta/core/completion.lua | 19 | ||||
-rw-r--r-- | script-beta/parser/guide.lua | 3 | ||||
-rw-r--r-- | test-beta/completion/init.lua | 10 |
4 files changed, 20 insertions, 14 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json index 55ca2cb5..e857db9b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -33,7 +33,7 @@ "script/meta" : true, }, "Lua.plugin.enable": true, - //"Lua.zzzzzz.cat": true, + "Lua.zzzzzz.cat": true, "Lua.develop.enable": true, "Lua.develop.debuggerPort": 11413 } diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua index c68a2317..71d34a06 100644 --- a/script-beta/core/completion.lua +++ b/script-beta/core/completion.lua @@ -135,16 +135,17 @@ local function findParent(ast, text, offset) return nil, nil end -local function buildFunctionSnip(source) +local function buildFunctionSnip(source, oop) local name = getName(source):gsub('^.-[$.:]', '') - local args = vm.eachDef(source, function (src) - if src.type == 'function' then - local args = getArg(src) - if args ~= '' then - return args - end + local defs = vm.getDefs(source) + local args = '' + for _, def in ipairs(defs) do + local defArgs = getArg(def) + if defArgs ~= '' then + args = defArgs + break end - end) or '' + end local id = 0 args = args:gsub('[^,]+', function (arg) id = id + 1 @@ -182,7 +183,7 @@ local function buildFunction(results, source, oop, data) local snipData = util.deepCopy(data) snipData.kind = ckind.Snippet snipData.label = snipData.label .. '()' - snipData.insertText = buildFunctionSnip(source) + snipData.insertText = buildFunctionSnip(source, oop) snipData.insertTextFormat = 2 snipData.id = stack(function () return { diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua index 34d36106..84878f4d 100644 --- a/script-beta/parser/guide.lua +++ b/script-beta/parser/guide.lua @@ -817,6 +817,9 @@ function m.getStepRef(obj, mode) or obj.type == 'setglobal' then return stepRefOfGlobal(obj, mode) end + if obj.type == 'library' then + return { obj } + end return nil end diff --git a/test-beta/completion/init.lua b/test-beta/completion/init.lua index add0125c..76aa6c2c 100644 --- a/test-beta/completion/init.lua +++ b/test-beta/completion/init.lua @@ -33,7 +33,7 @@ end rawset(_G, 'TEST', true) -local cared = { +local Cared = { ['label'] = true, ['kind'] = true, ['textEdit'] = true, @@ -58,7 +58,7 @@ function TEST(script) item[k] = v end for k in pairs(item) do - if not cared[k] then + if not Cared[k] then item[k] = nil end end @@ -912,8 +912,7 @@ else$ }, } --- TODO -do return end +Cared['insertText'] = true TEST [[ local xpcal @@ -935,6 +934,9 @@ xpcal$ }, } +-- TODO +do return end + TEST [[ function mt:f(a, b, c) end |