summaryrefslogtreecommitdiff
path: root/script-beta
diff options
context:
space:
mode:
Diffstat (limited to 'script-beta')
-rw-r--r--script-beta/core/hover/label.lua24
-rw-r--r--script-beta/core/hover/name.lua7
2 files changed, 31 insertions, 0 deletions
diff --git a/script-beta/core/hover/label.lua b/script-beta/core/hover/label.lua
index 29db67fa..1933adfe 100644
--- a/script-beta/core/hover/label.lua
+++ b/script-beta/core/hover/label.lua
@@ -121,6 +121,28 @@ local function asField(source)
return asValue(source, 'field')
end
+local function asDocField(source)
+ local name = source.field[1]
+ local class
+ for _, doc in ipairs(source.bindGroup) do
+ if doc.type == 'doc.class' then
+ class = doc
+ break
+ end
+ end
+ if not class then
+ return ('field ?.%s: %s'):format(
+ name,
+ vm.getInferType(source.extends)
+ )
+ end
+ return ('field %s.%s: %s'):format(
+ class.class[1],
+ name,
+ vm.getInferType(source.extends)
+ )
+end
+
local function asString(source)
local str = source[1]
if type(str) ~= 'string' then
@@ -189,5 +211,7 @@ return function (source, oop)
return asDocFunction(source)
elseif source.type == 'doc.type.name' then
return asDocTypeName(source)
+ elseif source.type == 'doc.field' then
+ return asDocField(source)
end
end
diff --git a/script-beta/core/hover/name.lua b/script-beta/core/hover/name.lua
index e5bd6f66..ee8b3961 100644
--- a/script-beta/core/hover/name.lua
+++ b/script-beta/core/hover/name.lua
@@ -84,6 +84,10 @@ local function asDocFunction(source)
return ''
end
+local function asDocField(source)
+ return source.field[1]
+end
+
function buildName(source, oop)
if oop == nil then
oop = source.type == 'setmethod'
@@ -117,6 +121,9 @@ function buildName(source, oop)
if source.type == 'doc.type.function' then
return asDocFunction(source)
end
+ if source.type == 'doc.field' then
+ return asDocField(source)
+ end
local parent = source.parent
if parent then
return buildName(parent, oop)