diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-03-18 16:23:16 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-03-18 16:23:16 +0800 |
commit | 357e62b68d67c4218d95f6bee937e6d5e206d752 (patch) | |
tree | d53917e3e64b7f252fcb54116c9e5609fe380805 /server/src/core/hover/name.lua | |
parent | de4cec30d4befc0de4bd264c16c52c1a575cd5d3 (diff) | |
download | lua-language-server-357e62b68d67c4218d95f6bee937e6d5e206d752.zip |
重构文件符号
Diffstat (limited to 'server/src/core/hover/name.lua')
-rw-r--r-- | server/src/core/hover/name.lua | 69 |
1 files changed, 6 insertions, 63 deletions
diff --git a/server/src/core/hover/name.lua b/server/src/core/hover/name.lua index 52bcfef4..e5880884 100644 --- a/server/src/core/hover/name.lua +++ b/server/src/core/hover/name.lua @@ -1,4 +1,9 @@ +local getName = require 'core.name' + return function (source) + if not source then + return '' + end local value = source:bindValue() if not value then return '' @@ -22,67 +27,5 @@ return function (source) return name or '' end - local key - if declarat:get 'simple' then - local simple = declarat:get 'simple' - local chars = {} - for i, obj in ipairs(simple) do - if obj.type == 'name' then - chars[i] = obj[1] - elseif obj.type == 'index' then - chars[i] = '[?]' - elseif obj.type == 'call' then - chars[i] = '(?)' - elseif obj.type == ':' then - chars[i] = ':' - elseif obj.type == '.' then - chars[i] = '.' - else - chars[i] = '*' .. obj.type - end - if obj == declarat then - break - end - end - key = table.concat(chars) - elseif declarat.type == 'name' then - key = declarat[1] - elseif declarat.type == 'string' then - key = ('%q'):format(declarat[1]) - elseif declarat.type == 'number' or declarat.type == 'boolean' then - key = tostring(declarat[1]) - elseif declarat.type == 'simple' then - local chars = {} - for i, obj in ipairs(declarat) do - if obj.type == 'name' then - chars[i] = obj[1] - elseif obj.type == 'index' then - chars[i] = '[?]' - elseif obj.type == 'call' then - chars[i] = '(?)' - elseif obj.type == ':' then - chars[i] = ':' - elseif obj.type == '.' then - chars[i] = '.' - else - chars[i] = '*' .. obj.type - end - end - -- 这里有个特殊处理 - -- function mt:func() 以 mt.func 的形式调用时 - -- hover 显示为 mt.func(self) - if chars[#chars-1] == ':' then - if not source:get 'object' then - chars[#chars-1] = '.' - end - elseif chars[#chars-1] == '.' then - if source:get 'object' then - chars[#chars-1] = ':' - end - end - key = table.concat(chars) - else - key = '' - end - return key + return getName(declarat, source) end |