summaryrefslogtreecommitdiff
path: root/server-beta/src/core/hover/name.lua
diff options
context:
space:
mode:
Diffstat (limited to 'server-beta/src/core/hover/name.lua')
-rw-r--r--server-beta/src/core/hover/name.lua38
1 files changed, 28 insertions, 10 deletions
diff --git a/server-beta/src/core/hover/name.lua b/server-beta/src/core/hover/name.lua
index ef7fee02..9eb066fc 100644
--- a/server-beta/src/core/hover/name.lua
+++ b/server-beta/src/core/hover/name.lua
@@ -18,18 +18,36 @@ local function asMethod(source)
return ('%s:%s'):format(node, method)
end
-return function (source)
- local parent = source.parent
- if not parent then
- return ''
+local function asField(source)
+ local class = vm.eachField(source.node, function (info)
+ if info.key == 's|type' or info.key == 's|__name' then
+ if info.value and info.value.type == 'string' then
+ return info.value[1]
+ end
+ end
+ end)
+ local node = class or guide.getName(source.node) or '*'
+ local method = guide.getName(source)
+ return ('%s.%s'):format(node, method)
+end
+
+local function buildName(source)
+ if source.type == 'local'
+ or source.type == 'getlocal'
+ or source.type == 'setlocal' then
+ return asLocal(source) or ''
end
- if parent.type == 'local'
- or parent.type == 'getlocal'
- or parent.type == 'setlocal' then
- return asLocal(parent) or ''
+ if source.type == 'setmethod' then
+ return asMethod(source) or ''
end
- if parent.type == 'setmethod' then
- return asMethod(parent) or ''
+ if source.type == 'setfield' then
+ return asField(source) or ''
+ end
+ local parent = source.parent
+ if parent then
+ return buildName(parent)
end
return ''
end
+
+return buildName