diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-13 22:23:24 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-13 22:23:24 +0800 |
commit | f2ce1195104a9e3939bccc8154664b86b7e2848a (patch) | |
tree | 3a7c7d4385e128bad003593e154383bf4feee39f /server | |
parent | 352b6489551f0fe5b308cfc7de608dcec42a88ee (diff) | |
download | lua-language-server-f2ce1195104a9e3939bccc8154664b86b7e2848a.zip |
显示显性类型
Diffstat (limited to 'server')
-rw-r--r-- | server/src/matcher/hover.lua | 17 | ||||
-rw-r--r-- | server/src/matcher/vm.lua | 4 | ||||
-rw-r--r-- | server/test/hover/init.lua | 5 |
3 files changed, 20 insertions, 6 deletions
diff --git a/server/src/matcher/hover.lua b/server/src/matcher/hover.lua index 2de5d1fc..34137582 100644 --- a/server/src/matcher/hover.lua +++ b/server/src/matcher/hover.lua @@ -143,14 +143,23 @@ local function buildValueName(result, source) else key = '?' end + + local parentName = declarat.parentName + if parentName == '?' then + local parentType = result.parentValue and result.parentValue.type + if parentType == 'table' then + else + parentName = '*' .. parentType + end + end if source.object then - return declarat.parentName .. ':' .. key + return parentName .. ':' .. key else - if declarat.parentName then + if parentName then if declarat.index then - return declarat.parentName .. '[' .. key .. ']' + return parentName .. '[' .. key .. ']' else - return declarat.parentName .. '.' .. key + return parentName .. '.' .. key end else return key diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua index 13232b8b..8997812d 100644 --- a/server/src/matcher/vm.lua +++ b/server/src/matcher/vm.lua @@ -641,14 +641,13 @@ function mt:getSimple(simple, mode) elseif obj.index then local index = self:getIndex(obj) field = self:getField(value, index, obj) + field.parentValue = value value = self:getValue(field) if mode == 'value' or i < #simple then if obj.start then self:addInfo(field, 'get', obj) end end - field.parent = lastField - lastField = field obj.object = object obj.parentName = parentName if obj.type == 'string' then @@ -661,6 +660,7 @@ function mt:getSimple(simple, mode) else if tp == 'name' then field = self:getField(value, obj[1], obj) + field.parentValue = value value = self:getValue(field) if mode == 'value' or i < #simple then self:addInfo(field, 'get', obj) diff --git a/server/test/hover/init.lua b/server/test/hover/init.lua index 6e81a684..55712492 100644 --- a/server/test/hover/init.lua +++ b/server/test/hover/init.lua @@ -143,3 +143,8 @@ local fs = require 'bee.filesystem' local <?root?> = fs.current_path() ]] "*bee::filesystem root" + +TEST[[ +('xx'):<?yy?>() +]] +"function *string:yy()" |