diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-09-28 01:44:10 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-09-28 01:44:10 +0800 |
commit | 0617cddc170ddb0070591a74f55a1eb8cea4b961 (patch) | |
tree | 4de86ab3f0a97306f9b4071083564752c78e1eb3 | |
parent | 3252e1f4820bbbe6568c3be09fd6fa6dc436adde (diff) | |
download | lua-language-server-0617cddc170ddb0070591a74f55a1eb8cea4b961.zip |
整理代码
-rw-r--r-- | script-beta/core/completion.lua | 20 | ||||
-rw-r--r-- | script-beta/core/hover/label.lua | 6 | ||||
-rw-r--r-- | test-beta/completion/init.lua | 5 |
3 files changed, 21 insertions, 10 deletions
diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua index c46e49e1..fd27f535 100644 --- a/script-beta/core/completion.lua +++ b/script-beta/core/completion.lua @@ -313,11 +313,7 @@ local function checkFieldFromFieldToIndex(name, parent, word, start, offset) return textEdit, additionalTextEdits end -local function checkFieldThen(ast, key, src, word, start, offset, parent, oop, results) - local name = key:sub(3) - if not matchKey(word, name) then - return - end +local function checkFieldThen(name, src, word, start, offset, parent, oop, results) local value = guide.getObjectValue(src) or src local kind = ckind.Field if value.type == 'function' then @@ -385,9 +381,13 @@ local function checkField(ast, word, start, offset, parent, oop, results) if isSameSource(ast, src, start) then return end - local last = fields[key] + local name = key:sub(3) + if not matchKey(word, name) then + return + end + local last = fields[name] if not last then - fields[key] = src + fields[name] = src return end if src.type == 'tablefield' @@ -395,12 +395,12 @@ local function checkField(ast, word, start, offset, parent, oop, results) or src.type == 'tableindex' or src.type == 'setindex' or src.type == 'setmethod' then - fields[key] = src + fields[name] = src return end end) - for key, src in util.sortPairs(fields) do - checkFieldThen(ast, key, src, word, start, offset, parent, oop, results) + for name, src in util.sortPairs(fields) do + checkFieldThen(name, src, word, start, offset, parent, oop, results) end end diff --git a/script-beta/core/hover/label.lua b/script-beta/core/hover/label.lua index 5798317f..4fd569b2 100644 --- a/script-beta/core/hover/label.lua +++ b/script-beta/core/hover/label.lua @@ -55,6 +55,10 @@ local function asGlobal(source) return asValue(source, 'global') end +local function asLibrary(source) + +end + local function isGlobalField(source) if source.type == 'field' or source.type == 'method' then @@ -124,5 +128,7 @@ return function (source, oop) return asField(source) elseif source.type == 'string' then return asString(source) + elseif source.type == 'library' then + return asLibrary(source) end end diff --git a/test-beta/completion/init.lua b/test-beta/completion/init.lua index 6e350ed6..8fae0bd3 100644 --- a/test-beta/completion/init.lua +++ b/test-beta/completion/init.lua @@ -1136,6 +1136,11 @@ io.close(1, $) ]] (nil) +TEST [[ +io$ +]] +(EXISTS) + do return end TEST [[ ---@$ |