Skip to content
Snippets Groups Projects
Commit 67ae2be2 authored by 最萌小汐's avatar 最萌小汐
Browse files

更新 hover

parent c29bbc64
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@ local fs = require 'bee.filesystem'
ROOT = fs.path(rootPath)
LANG = LANG or 'en-US'
collectgarbage('generational', 5, 20)
collectgarbage('generational', 10, 50)
log = require 'log'
log.init(ROOT, ROOT / 'log' / 'service.log')
......
......@@ -6,7 +6,10 @@ local function asFunction(source)
local name = buildName(source)
local arg = buildArg(source)
local rtn = buildReturn(source)
return ('function %s(%s)'):format(name, arg)
local lines = {}
lines[1] = ('function %s(%s)'):format(name, arg)
lines[2] = rtn
return table.concat(lines, '\n')
end
return function (source)
......
......@@ -5,6 +5,26 @@ local function asFunction(source)
if not source.returns then
return nil
end
local returns = {}
for _, rtn in ipairs(source.returns) do
for i = 1, #rtn do
local values = vm.getValue(rtn[i])
returns[#returns+1] = values
end
break
end
if #returns == 0 then
return nil
end
local lines = {}
for i = 1, #returns do
if i == 1 then
lines[i] = (' -> %s'):format(vm.viewType(returns[i]))
else
lines[i] = ('% 3d. %s'):format(i, returns[i])
end
end
return table.concat(lines, '\n')
end
return function (source)
......
......@@ -812,8 +812,7 @@ function vm.hasType(source, type)
return false
end
function vm.getType(source)
local values = vm.getValue(source)
function vm.viewType(values)
if not values then
return 'any'
end
......@@ -851,6 +850,11 @@ function vm.getType(source)
return table.concat(types, '|')
end
function vm.getType(source)
local values = vm.getValue(source)
return vm.viewType(values)
end
function vm.getValue(source)
if not source then
return
......
......@@ -113,7 +113,7 @@ obj:init(1, '测试')
obj.<?init?>(obj, 1, '测试')
]]
[[
function mt.init(self: table, a: number, b: string, c: any)
function mt:init(a: any, b: any, c: any)
-> table
]]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment