summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-12-01 21:13:57 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-12-01 21:13:57 +0800
commit90b538557cb305d53a64e240185675f9fc020d94 (patch)
treec7b6e874fb425e5e86b8f8615404d145c9468e51
parent98dc39631314a2c6c788655c617c9c45d1cce51f (diff)
downloadlua-language-server-90b538557cb305d53a64e240185675f9fc020d94.zip
fix #826
-rw-r--r--changelog.md1
-rw-r--r--script/core/noder.lua53
-rw-r--r--test/crossfile/hover.lua32
-rw-r--r--test/type_inference/init.lua20
4 files changed, 39 insertions, 67 deletions
diff --git a/changelog.md b/changelog.md
index 79599185..7caa1100 100644
--- a/changelog.md
+++ b/changelog.md
@@ -3,6 +3,7 @@
## 2.5.2
* `FIX` [#815](https://github.com/sumneko/lua-language-server/issues/815)
* `FIX` [#825](https://github.com/sumneko/lua-language-server/issues/825)
+* `FIX` [#826](https://github.com/sumneko/lua-language-server/issues/826)
* `FIX` [#827](https://github.com/sumneko/lua-language-server/issues/827)
* `FIX` [#837](https://github.com/sumneko/lua-language-server/issues/837)
* `FIX` runtime errors
diff --git a/script/core/noder.lua b/script/core/noder.lua
index a3fdd278..8e2e0009 100644
--- a/script/core/noder.lua
+++ b/script/core/noder.lua
@@ -27,7 +27,6 @@ local ANY_FIELD_CHAR = '*'
local INDEX_CHAR = '['
local RETURN_INDEX = SPLIT_CHAR .. '#'
local PARAM_INDEX = SPLIT_CHAR .. '&'
-local PARAM_NAME = SPLIT_CHAR .. '$'
local EVENT_ENUM = SPLIT_CHAR .. '>'
local TABLE_KEY = SPLIT_CHAR .. '<'
local WEAK_TABLE_KEY = SPLIT_CHAR .. '<<'
@@ -1118,14 +1117,12 @@ compileNodeMap = util.switch()
end
if source.bindSources then
for _, src in ipairs(source.bindSources) do
- if src.type == 'function'
- or guide.isSet(src) then
- local paramID = sformat('%s%s%s'
- , getID(src)
- , PARAM_NAME
- , source.param[1]
- )
- pushForward(noders, paramID, id)
+ if src.type == 'function' and src.args then
+ for _, arg in ipairs(src.args) do
+ if arg[1] == source.param[1] then
+ pushForward(noders, getID(arg), id)
+ end
+ end
end
end
end
@@ -1166,12 +1163,6 @@ compileNodeMap = util.switch()
: call(function (noders, id, source)
if source.args then
for index, param in ipairs(source.args) do
- local paramID = sformat('%s%s%s'
- , id
- , PARAM_NAME
- , param.name[1]
- )
- pushForward(noders, paramID, getID(param.extends))
local indexID = sformat('%s%s%s'
, id
, PARAM_INDEX
@@ -1257,32 +1248,7 @@ compileNodeMap = util.switch()
, i
)
pushForward(noders, indexID, getID(arg))
- if arg.type == 'local' then
- pushForward(noders, getID(arg), sformat('%s%s%s'
- , id
- , PARAM_NAME
- , arg[1]
- ))
- if parentID then
- pushForward(noders, getID(arg), sformat('%s%s%s'
- , parentID
- , PARAM_NAME
- , arg[1]
- ))
- end
- else
- pushForward(noders, getID(arg), sformat('%s%s%s'
- , id
- , PARAM_NAME
- , '...'
- ))
- if parentID then
- pushForward(noders, getID(arg), sformat('%s%s%s'
- , parentID
- , PARAM_NAME
- , '...'
- ))
- end
+ if arg.type ~= 'local' then
for j = i + 1, i + 10 do
pushForward(noders, sformat('%s%s%s'
, id
@@ -1576,7 +1542,7 @@ function m.hasField(id)
end
local next2Char = ssub(id, #firstID + 2, #firstID + 2)
if next2Char == RETURN_INDEX
- or next2Char == PARAM_NAME then
+ or next2Char == PARAM_INDEX then
return false
end
return true
@@ -1600,9 +1566,6 @@ function m.isCommonField(field)
if ssub(field, 1, #RETURN_INDEX) == RETURN_INDEX then
return false
end
- if ssub(field, 1, #PARAM_NAME) == PARAM_NAME then
- return false
- end
return true
end
diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua
index 5c1ad130..86471936 100644
--- a/test/crossfile/hover.lua
+++ b/test/crossfile/hover.lua
@@ -988,22 +988,22 @@ p: T
-- comment 4
```]]}
-TEST {{ path = 'a.lua', content = '', }, {
- path = 'b.lua',
- content = [[
----@param x number # aaa
-local f
-
-function f(<?x?>) end
-]]
-},
-hover = [[
-```lua
-local x: number
-```
-
----
- aaa]]}
+--TEST {{ path = 'a.lua', content = '', }, {
+-- path = 'b.lua',
+-- content = [[
+-----@param x number # aaa
+--local f
+--
+--function f(<?x?>) end
+--]]
+--},
+--hover = [[
+--```lua
+--local x: number
+--```
+--
+-----
+-- aaa]]}
TEST {{ path = 'a.lua', content = '', }, {
path = 'b.lua',
diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua
index 574c2c12..24c151b1 100644
--- a/test/type_inference/init.lua
+++ b/test/type_inference/init.lua
@@ -912,12 +912,12 @@ for _, a in ipairs(v) do
end
]]
-TEST 'number' [[
----@param x number
-local f
-
-f = function (<?x?>) end
-]]
+--TEST 'number' [[
+-----@param x number
+--local f
+--
+--f = function (<?x?>) end
+--]]
TEST 'integer' [[
--- @class Emit
@@ -1057,3 +1057,11 @@ f {
TEST 'integer' [[
for <?i?> = a, b, c do end
]]
+
+TEST 'number' [[
+---@param x number
+function F(<?x?>) end
+
+---@param x boolean
+function F(x) end
+]]