summaryrefslogtreecommitdiff
path: root/script/core/hover
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-03-01 21:10:46 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-03-01 21:10:46 +0800
commit80f7dd1d8ea9c575aa9b26916c3eeccb58251cfc (patch)
treebea676f33761c7fcbba05a52b009acf86be0ed96 /script/core/hover
parent007c58d43c6171cba5da72f8b6595fa1986d598e (diff)
downloadlua-language-server-80f7dd1d8ea9c575aa9b26916c3eeccb58251cfc.zip
dont infer `x()` as function
Diffstat (limited to 'script/core/hover')
-rw-r--r--script/core/hover/init.lua48
1 files changed, 26 insertions, 22 deletions
diff --git a/script/core/hover/init.lua b/script/core/hover/init.lua
index 80c4db1e..f0315bd8 100644
--- a/script/core/hover/init.lua
+++ b/script/core/hover/init.lua
@@ -20,6 +20,28 @@ local function eachFunctionAndOverload(value, callback)
end
end
+local function getHoverAsValue(source)
+ local oop = source.type == 'method'
+ or source.type == 'getmethod'
+ or source.type == 'setmethod'
+ local label = getLabel(source, oop)
+ local desc = getDesc(source)
+ if not desc then
+ local values = vm.getDefs(source, 0)
+ for _, def in ipairs(values) do
+ desc = getDesc(def)
+ if desc then
+ break
+ end
+ end
+ end
+ return {
+ label = label,
+ source = source,
+ description = desc,
+ }
+end
+
local function getHoverAsFunction(source)
local values = vm.getDefs(source, 0)
local desc = getDesc(source)
@@ -59,6 +81,10 @@ local function getHoverAsFunction(source)
end
end
+ if defs == 0 then
+ return getHoverAsValue(source)
+ end
+
if defs == 1 and other == 0 then
return {
label = next(labels),
@@ -89,28 +115,6 @@ local function getHoverAsFunction(source)
}
end
-local function getHoverAsValue(source)
- local oop = source.type == 'method'
- or source.type == 'getmethod'
- or source.type == 'setmethod'
- local label = getLabel(source, oop)
- local desc = getDesc(source)
- if not desc then
- local values = vm.getDefs(source, 0)
- for _, def in ipairs(values) do
- desc = getDesc(def)
- if desc then
- break
- end
- end
- end
- return {
- label = label,
- source = source,
- description = desc,
- }
-end
-
local function getHoverAsDocName(source)
local label = getLabel(source)
local desc = getDesc(source)