diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-11-20 19:10:30 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-11-20 19:10:30 +0800 |
commit | 9cd44e1b61fa8f002b211224e0141812a8fc97e6 (patch) | |
tree | ea40fba54f00d294e25803e6fb82bcefcd0419df | |
parent | 1dfeaffc5df3a8e1c4585374fa8f6ab252221b40 (diff) | |
download | lua-language-server-9cd44e1b61fa8f002b211224e0141812a8fc97e6.zip |
stage
-rw-r--r-- | script-beta/core/hover/label.lua | 24 | ||||
-rw-r--r-- | script-beta/core/hover/name.lua | 7 | ||||
-rw-r--r-- | test-beta/completion/init.lua | 12 |
3 files changed, 43 insertions, 0 deletions
diff --git a/script-beta/core/hover/label.lua b/script-beta/core/hover/label.lua index 29db67fa..1933adfe 100644 --- a/script-beta/core/hover/label.lua +++ b/script-beta/core/hover/label.lua @@ -121,6 +121,28 @@ local function asField(source) return asValue(source, 'field') end +local function asDocField(source) + local name = source.field[1] + local class + for _, doc in ipairs(source.bindGroup) do + if doc.type == 'doc.class' then + class = doc + break + end + end + if not class then + return ('field ?.%s: %s'):format( + name, + vm.getInferType(source.extends) + ) + end + return ('field %s.%s: %s'):format( + class.class[1], + name, + vm.getInferType(source.extends) + ) +end + local function asString(source) local str = source[1] if type(str) ~= 'string' then @@ -189,5 +211,7 @@ return function (source, oop) return asDocFunction(source) elseif source.type == 'doc.type.name' then return asDocTypeName(source) + elseif source.type == 'doc.field' then + return asDocField(source) end end diff --git a/script-beta/core/hover/name.lua b/script-beta/core/hover/name.lua index e5bd6f66..ee8b3961 100644 --- a/script-beta/core/hover/name.lua +++ b/script-beta/core/hover/name.lua @@ -84,6 +84,10 @@ local function asDocFunction(source) return '' end +local function asDocField(source) + return source.field[1] +end + function buildName(source, oop) if oop == nil then oop = source.type == 'setmethod' @@ -117,6 +121,9 @@ function buildName(source, oop) if source.type == 'doc.type.function' then return asDocFunction(source) end + if source.type == 'doc.field' then + return asDocField(source) + end local parent = source.parent if parent then return buildName(parent, oop) diff --git a/test-beta/completion/init.lua b/test-beta/completion/init.lua index 381ce84e..49f08e85 100644 --- a/test-beta/completion/init.lua +++ b/test-beta/completion/init.lua @@ -1761,3 +1761,15 @@ f($) description = '注释2', }, } + +TEST [[ +utf8.charpatter$ +]] +{ + { + label = 'charpattern', + detail = 'string', + kind = define.CompletionItemKind.Field, + description = EXISTS, + } +} |