diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-11-17 18:32:11 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-11-17 18:32:11 +0800 |
commit | 2b434ab4f4a078773a27e205a60b63a9ae4efe1b (patch) | |
tree | c63f76d3fa15d5f5994759e3e3bc8aa6575d3a8b /script-beta | |
parent | 54a97c8ebd12bee141eb5d0d0a3b92f9d411d0d5 (diff) | |
download | lua-language-server-2b434ab4f4a078773a27e205a60b63a9ae4efe1b.zip |
过所有测试
Diffstat (limited to 'script-beta')
-rw-r--r-- | script-beta/core/completion.lua | 64 | ||||
-rw-r--r-- | script-beta/parser/guide.lua | 1 |
2 files changed, 51 insertions, 14 deletions
diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua index 6c8d9040..a1a35a92 100644 --- a/script-beta/core/completion.lua +++ b/script-beta/core/completion.lua @@ -352,6 +352,21 @@ local function checkFieldFromFieldToIndex(name, parent, word, start, offset) return textEdit, additionalTextEdits end +local function isDeprecated(value) + if value.deprecated then + return true + end + if not value.bindDocs then + return false + end + for _, doc in ipairs(value.bindDocs) do + if doc.type == 'doc.deprecated' then + return true + end + end + return false +end + local function checkFieldThen(name, src, word, start, offset, parent, oop, results) local value = guide.getObjectValue(src) or src local kind = define.CompletionItemKind.Field @@ -364,7 +379,7 @@ local function checkFieldThen(name, src, word, start, offset, parent, oop, resul buildFunction(results, src, oop, { label = name, kind = kind, - deprecated = value.deprecated, + deprecated = isDeprecated(value) or nil, id = stack(function () return { detail = buildDetail(src), @@ -680,6 +695,9 @@ local function checkUri(ast, text, offset, results) if files.eq(myUri, uri) then goto CONTINUE end + if vm.isMetaFile(uri) then + goto CONTINUE + end local path = workspace.getRelativePath(uri) local infos = rpath.getVisiblePath(path, config.config.runtime.path) for _, info in ipairs(infos) do @@ -692,17 +710,11 @@ local function checkUri(ast, text, offset, results) } } end - if vm.isMetaFile(uri) then - collect[info.expect][#collect[info.expect]+1] = ([=[* [[meta]](%s)]=]):format( - uri - ) - else - collect[info.expect][#collect[info.expect]+1] = ([=[* [%s](%s) %s]=]):format( - path, - uri, - lang.script('HOVER_USE_LUA_PATH', info.searcher) - ) - end + collect[info.expect][#collect[info.expect]+1] = ([=[* [%s](%s) %s]=]):format( + path, + uri, + lang.script('HOVER_USE_LUA_PATH', info.searcher) + ) end end ::CONTINUE:: @@ -714,6 +726,9 @@ local function checkUri(ast, text, offset, results) if files.eq(myUri, uri) then goto CONTINUE end + if vm.isMetaFile(uri) then + goto CONTINUE + end local path = workspace.getRelativePath(uri) if matchKey(literal, path) then if not collect[path] then @@ -918,10 +933,20 @@ local function getCallEnums(source, index) return enums end if source.type == 'function' and source.bindDocs then - local arg = source.args and source.args[index] - if not arg then + if not source.args then return end + local arg + if index <= #source.args then + arg = source.args[index] + else + local lastArg = source.args[#source.args] + if lastArg.type == '...' then + arg = lastArg + else + return + end + end for _, doc in ipairs(source.bindDocs) do if doc.type == 'doc.param' and doc.param[1] == arg[1] then @@ -934,6 +959,17 @@ local function getCallEnums(source, index) } end return enums + elseif doc.type == 'doc.vararg' + and arg.type == '...' then + local enums = {} + for _, enum in ipairs(vm.getDocEnums(doc.vararg)) do + enums[#enums+1] = { + label = enum[1], + description = enum.comment, + kind = define.CompletionItemKind.EnumMember, + } + end + return enums end end end diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua index 8324cfd0..e633cfaf 100644 --- a/script-beta/parser/guide.lua +++ b/script-beta/parser/guide.lua @@ -1161,6 +1161,7 @@ function m.getSimple(obj, max) or obj.type == 'tableindex' or obj.type == 'select' or obj.type == 'table' + or obj.type == 'string' or obj.type == 'doc.class.name' or obj.type == 'doc.class' or obj.type == 'doc.type.name' then |