summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-09-29 20:04:17 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-09-29 20:04:17 +0800
commit170f587b41b01911f49250b0acc011d00c4e4008 (patch)
treecaa0b10ae66ce97f41997c2219a8015617291457
parent1721f5c185547b8074060a95f526f2f4b630969b (diff)
downloadlua-language-server-170f587b41b01911f49250b0acc011d00c4e4008.zip
hover: shows method
-rw-r--r--changelog.md1
-rw-r--r--script/core/hover/label.lua2
-rw-r--r--test/crossfile/hover.lua2
-rw-r--r--test/hover/init.lua12
-rw-r--r--test/signature/init.lua4
5 files changed, 11 insertions, 10 deletions
diff --git a/changelog.md b/changelog.md
index 2462cb06..eaa3e8ed 100644
--- a/changelog.md
+++ b/changelog.md
@@ -30,6 +30,7 @@
```
* `CHG` hover: improve showing multi defines
* `CHG` hover: improve showing multi comments at enums
+* `CHG` hover: shows method
* `CHG` hint: `Lua.hint.paramName` now supports `Disable`, `Literal` and `All`
* `CHG` only search first file by `require`
* `CHG` no longer infer by usage
diff --git a/script/core/hover/label.lua b/script/core/hover/label.lua
index 3322e0d3..8906d54d 100644
--- a/script/core/hover/label.lua
+++ b/script/core/hover/label.lua
@@ -16,7 +16,7 @@ local function asFunction(source, oop)
local arg = buildArg(source, oop)
local rtn = buildReturn(source)
local lines = {}
- lines[1] = ('function %s(%s)'):format(name or '', arg)
+ lines[1] = ('%s %s(%s)'):format(oop and 'method' or 'function', name or '', arg)
lines[2] = rtn
return table.concat(lines, '\n')
end
diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua
index 97e6218d..d341fa29 100644
--- a/test/crossfile/hover.lua
+++ b/test/crossfile/hover.lua
@@ -216,7 +216,7 @@ TEST {
},
hover = [[
```lua
-function mt:add(a: any, b: any)
+method mt:add(a: any, b: any)
```]]
}
diff --git a/test/hover/init.lua b/test/hover/init.lua
index 8058317d..a09f8583 100644
--- a/test/hover/init.lua
+++ b/test/hover/init.lua
@@ -64,7 +64,7 @@ local obj = setmetatable({}, mt)
obj:<?init?>(1, '测试')
]]
[[
-function mt:init(a: any, b: any, c: any)
+method mt:init(a: any, b: any, c: any)
]]
--TEST [[
@@ -114,7 +114,7 @@ local obj = setmetatable({}, mt)
obj:<?init?>(1, '测试')
]]
[[
-function mt:init(a: any, b: any, c: any)
+method mt:init(a: any, b: any, c: any)
-> table
]]
@@ -132,7 +132,7 @@ obj:init(1, '测试')
obj.<?init?>(obj, 1, '测试')
]]
[[
-function mt:init(a: any, b: any, c: any)
+method mt:init(a: any, b: any, c: any)
-> table
]]
@@ -327,7 +327,7 @@ local t = init()
t:<?add?>()
]]
[[
-function mt:add(a: any, b: any)
+method mt:add(a: any, b: any)
]]
TEST [[
@@ -345,7 +345,7 @@ local t = init()
t:<?add?>()
]]
[[
-function mt:add(a: any, b: any)
+method mt:add(a: any, b: any)
]]
TEST [[
@@ -485,7 +485,7 @@ function mt:test(a, b)
end
]]
[[
-function mt:test(a: any, b: any)
+method mt:test(a: any, b: any)
]]
TEST[[
diff --git a/test/signature/init.lua b/test/signature/init.lua
index f1057ae0..1dbe61e8 100644
--- a/test/signature/init.lua
+++ b/test/signature/init.lua
@@ -64,7 +64,7 @@ end
mt:f(<??>
]]
-'function mt:f(<!a: any!>)'
+'method mt:f(<!a: any!>)'
TEST [[
local function x(a, b)
@@ -87,7 +87,7 @@ x(1, 2, 3, <??>
TEST [[
(''):sub(<??>
]]
-'function string:sub(<!i: integer!>, j?: integer)'
+'method string:sub(<!i: integer!>, j?: integer)'
TEST [[
(''):sub(1)<??>