From 82e718114a22193d586f9aaca30777bae20708e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 8 Jan 2019 13:58:50 +0800 Subject: =?UTF-8?q?=E5=8F=AA=E6=9C=89function=E4=BC=9A=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=97=B6=E7=9A=84=E5=90=8D=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/core/hover_name.lua | 80 ++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 38 deletions(-) (limited to 'server/src') diff --git a/server/src/core/hover_name.lua b/server/src/core/hover_name.lua index d8e7b043..d8afe2fc 100644 --- a/server/src/core/hover_name.lua +++ b/server/src/core/hover_name.lua @@ -1,49 +1,53 @@ - return function (result, source) local func = result.value - local declarat = func.declarat or source - if declarat then - local key - if 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 func.type == 'function' then - key = '' - elseif type(result.key) == 'string' then - key = result.key - else - key = '' - end + local declarat + if func.type == 'function' then + declarat = func.declarat or source + else + declarat = source + end + if not declarat then + return result.key or '' + end + local key + if 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 func.type == 'function' then + key = '' + elseif type(result.key) == 'string' then + key = result.key + else + key = '' + end - local parentName = declarat.parentName + local parentName = declarat.parentName - if not parentName then - return key or '' - end + if not parentName then + return key or '' + end - 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 parentName .. ':' .. key + if parentName == '?' then + local parentType = result.parentValue and result.parentValue.type + if parentType == 'table' then else - if parentName then - if declarat.index then - return parentName .. '[' .. key .. ']' - else - return parentName .. '.' .. key - end + parentName = '*' .. parentType + end + end + if source.object then + return parentName .. ':' .. key + else + if parentName then + if declarat.index then + return parentName .. '[' .. key .. ']' else - return key + return parentName .. '.' .. key end + else + return key end end - return result.key or '' end -- cgit v1.2.3