summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/src/core/hover/hover.lua9
-rw-r--r--server/test/hover/init.lua44
2 files changed, 47 insertions, 6 deletions
diff --git a/server/src/core/hover/hover.lua b/server/src/core/hover/hover.lua
index dfaeed35..a7fcca19 100644
--- a/server/src/core/hover/hover.lua
+++ b/server/src/core/hover/hover.lua
@@ -122,9 +122,10 @@ end
local function getValueHover(source, name, value, lib)
local valueType = value:getType()
+ local class
if not lib then
- local class = findClass(value)
+ class = findClass(value)
if class then
valueType = class
end
@@ -164,7 +165,11 @@ local function getValueHover(source, name, value, lib)
text = ('%s %s: %s'):format(tp, name, unpackTable(value))
else
if literal == nil then
- text = ('%s %s: %s'):format(tp, name, valueType)
+ if class then
+ text = ('%s %s: %s %s'):format(tp, name, valueType, unpackTable(value))
+ else
+ text = ('%s %s: %s'):format(tp, name, valueType)
+ end
else
text = ('%s %s: %s = %s'):format(tp, name, valueType, literal)
end
diff --git a/server/test/hover/init.lua b/server/test/hover/init.lua
index 8187f7d3..9e1d6ada 100644
--- a/server/test/hover/init.lua
+++ b/server/test/hover/init.lua
@@ -117,7 +117,7 @@ mt.__name = 'class'
local <?obj?> = setmetatable({}, mt)
]]
-"local obj: *class"
+"local obj: *class {}"
TEST [[
local mt = {}
@@ -126,7 +126,12 @@ mt.__index = mt
local <?obj?> = setmetatable({}, mt)
]]
-"local obj: *class"
+[[
+local obj: *class {
+ __index: table,
+ name: string = "class",
+}
+]]
TEST [[
local mt = {}
@@ -135,7 +140,12 @@ mt.__index = mt
local <?obj?> = setmetatable({}, mt)
]]
-"local obj: *class"
+[[
+local obj: *class {
+ TYPE: string = "class",
+ __index: table,
+}
+]]
TEST [[
local mt = {}
@@ -144,7 +154,12 @@ mt.__index = mt
local <?obj?> = setmetatable({}, mt)
]]
-"local obj: *class"
+[[
+local obj: *class {
+ Class: string = "class",
+ __index: table,
+}
+]]
TEST[[
local fs = require 'bee.filesystem'
@@ -351,3 +366,24 @@ end
[[
function mt:test(a: any, b: any)
]]
+
+TEST[[
+local mt = {}
+mt.__index = mt
+mt.__name = 'obj'
+
+function mt:remove()
+end
+
+local <?self?> = setmetatable({
+ id = 1,
+}, mt)
+]]
+[[
+local self: *obj {
+ __index: table,
+ __name: string = "obj",
+ id: number = 1,
+ remove: function,
+}
+]]