From 0617cddc170ddb0070591a74f55a1eb8cea4b961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 28 Sep 2020 01:44:10 +0800 Subject: =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-beta/core/completion.lua | 20 ++++++++++---------- script-beta/core/hover/label.lua | 6 ++++++ 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 [[ ---@$ -- cgit v1.2.3