summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-04-05 03:39:11 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-04-05 03:39:11 +0800
commit6eba8cd590beb5ea52d880bdfe01b79e7828e5b4 (patch)
treec7fe824750c1de203c827bf2ad892376ad306e2c
parent3f56e35738ecc1d8765dfb6fc89522c1a8481095 (diff)
downloadlua-language-server-6eba8cd590beb5ea52d880bdfe01b79e7828e5b4.zip
update
-rw-r--r--script/config/config.lua4
-rw-r--r--script/vm/compiler.lua34
-rw-r--r--test/crossfile/allreferences.lua2
-rw-r--r--test/crossfile/definition.lua2
-rw-r--r--test/hover/init.lua15
-rw-r--r--test/rename/init.lua1
6 files changed, 26 insertions, 32 deletions
diff --git a/script/config/config.lua b/script/config/config.lua
index 6be80cc9..bde214b0 100644
--- a/script/config/config.lua
+++ b/script/config/config.lua
@@ -212,10 +212,6 @@ local Template = {
['Lua.format.enable'] = Type.Boolean >> true,
['Lua.format.defaultConfig'] = Type.Hash(Type.String, Type.String)
>> {},
- ['Lua.IntelliSense.traceLocalSet'] = Type.Boolean >> false,
- ['Lua.IntelliSense.traceReturn'] = Type.Boolean >> false,
- ['Lua.IntelliSense.traceBeSetted'] = Type.Boolean >> false,
- ['Lua.IntelliSense.traceFieldInject'] = Type.Boolean >> false,
['Lua.telemetry.enable'] = Type.Or(Type.Boolean >> false, Type.Nil) >> nil,
['files.associations'] = Type.Hash(Type.String, Type.String),
['files.exclude'] = Type.Hash(Type.String, Type.Boolean),
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index 31713f36..4dc3edef 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -24,14 +24,14 @@ local searchFieldSwitch = util.switch()
for _, field in ipairs(node) do
if field.type == 'tablefield'
or field.type == 'tableindex' then
- if not key
+ if key == nil
or key == guide.getKeyName(field) then
hasFiled = true
pushResult(field)
end
end
if field.type == 'tableexp' then
- if not key
+ if key == nil
or key == field.tindex then
hasFiled = true
pushResult(field)
@@ -39,12 +39,15 @@ local searchFieldSwitch = util.switch()
end
if field.type == 'varargs' then
if not hasFiled
- and key
+ and type(key) == 'number'
and key >= 1
and math.tointeger(key) then
hasFiled = true
pushResult(field)
end
+ if key == nil then
+ pushResult(field)
+ end
end
end
end)
@@ -86,8 +89,11 @@ local searchFieldSwitch = util.switch()
: case 'doc.type.array'
: call(function (node, key, pushResult)
if type(key) == 'number'
- and math.tointeger(key)
- and key >= 1 then
+ and key >= 1
+ and math.tointeger(key) then
+ pushResult(node.node)
+ end
+ if key == nil then
pushResult(node.node)
end
end)
@@ -99,7 +105,7 @@ local searchFieldSwitch = util.switch()
local fieldNode = m.compileNode(fieldKey)
for fn in nodeMgr.eachNode(fieldNode) do
if fn.type == 'global' and fn.cate == 'type' then
- if not key
+ if key == nil
or fn.name == 'any'
or (fn.name == 'boolean' and type(key) == 'boolean')
or (fn.name == 'number' and type(key) == 'number')
@@ -111,7 +117,7 @@ local searchFieldSwitch = util.switch()
end
end
if fieldKey.type == 'doc.field.name' then
- if not key or fieldKey[1] == key then
+ if key == nil or fieldKey[1] == key then
pushResult(field.extends)
end
end
@@ -133,7 +139,7 @@ function m.getClassFields(node, key, pushResult)
-- check ---@field
local hasFounded
for _, field in ipairs(set.fields) do
- if not key
+ if key == nil
or guide.getKeyName(field) == key then
hasFounded = true
pushResult(field)
@@ -359,11 +365,13 @@ local function bindDocs(source)
local hasFounded = false
local isParam = source.parent.type == 'funcargs'
or source.parent.type == 'in'
- for _, doc in ipairs(source.bindDocs) do
+ local docs = source.bindDocs
+ for i = #docs, 1, -1 do
+ local doc = docs[i]
if doc.type == 'doc.type' then
if not isParam then
- hasFounded = true
nodeMgr.setNode(source, m.compileNode(doc))
+ return true
end
end
if doc.type == 'doc.class' then
@@ -371,18 +379,18 @@ local function bindDocs(source)
or (source._globalNode and guide.isSet(source))
or source.type == 'tablefield'
or source.type == 'tableindex' then
- hasFounded = true
nodeMgr.setNode(source, m.compileNode(doc))
+ return true
end
end
if doc.type == 'doc.param' then
if isParam and source[1] == doc.param[1] then
- hasFounded = true
nodeMgr.setNode(source, m.compileNode(doc))
+ return true
end
end
end
- return hasFounded
+ return false
end
local function compileByLocalID(source)
diff --git a/test/crossfile/allreferences.lua b/test/crossfile/allreferences.lua
index 2753d785..3507e094 100644
--- a/test/crossfile/allreferences.lua
+++ b/test/crossfile/allreferences.lua
@@ -68,7 +68,6 @@ TEST {
},
}
-config.set(nil, 'Lua.IntelliSense.traceBeSetted', true)
TEST {
{
path = 'a.lua',
@@ -215,4 +214,3 @@ TEST {
]]
},
}
-config.set(nil, 'Lua.IntelliSense.traceBeSetted', false)
diff --git a/test/crossfile/definition.lua b/test/crossfile/definition.lua
index eaf12b73..945960e9 100644
--- a/test/crossfile/definition.lua
+++ b/test/crossfile/definition.lua
@@ -800,7 +800,6 @@ TEST {
},
}
-config.set(nil, 'Lua.IntelliSense.traceFieldInject', true)
TEST {
{
path = 'a.lua',
@@ -821,7 +820,6 @@ print(b.<?test?>)
]]
}
}
-config.set(nil, 'Lua.IntelliSense.traceFieldInject', false)
TEST {
{
diff --git a/test/hover/init.lua b/test/hover/init.lua
index fc21e630..1fced5b3 100644
--- a/test/hover/init.lua
+++ b/test/hover/init.lua
@@ -829,7 +829,6 @@ local t: {
}
]]
-config.set(nil, 'Lua.IntelliSense.traceLocalSet', true)
TEST [[
local x
x = 1
@@ -840,7 +839,6 @@ print(<?x?>)
[[
local x: number = 1
]]
-config.set(nil, 'Lua.IntelliSense.traceLocalSet', false)
TEST [[
local <?x?> <close> = 1
@@ -1574,7 +1572,7 @@ TEST [[
local <?x?>--测试
]]
[[
-local x: any
+local x: unknown
]]
TEST [[
@@ -1596,7 +1594,7 @@ print(u.x)
]]
[[
local u: number {
- x: any,
+ x: unknown,
}
]]
@@ -1639,7 +1637,7 @@ local f
<?f?>()
]]
[[
-local f: any
+local f: unknown
]]
TEST [[
@@ -1732,10 +1730,9 @@ local t = nil
t.<?x?>()
]]
[[
-field t.x: any
+field t.x: unknown
]]
-config.set(nil, 'Lua.IntelliSense.traceLocalSet', true)
TEST [[
---@class A
local a
@@ -1746,10 +1743,8 @@ b = a
print(b.<?x?>)
]]
[[
-field A.x: any
+field A.x: unknown
]]
-config.set(nil, 'Lua.IntelliSense.traceLocalSet', false)
-
TEST [[
---@class A
---@field x number
diff --git a/test/rename/init.lua b/test/rename/init.lua
index 31421ada..3b386778 100644
--- a/test/rename/init.lua
+++ b/test/rename/init.lua
@@ -90,7 +90,6 @@ local function f(b)
end
]]
---config.set('Lua.IntelliSense.traceBeSetted', true)
TEST ('a', '!!!') [[
t = {
a = 0