summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-06-30 15:14:56 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-06-30 15:14:56 +0800
commit207f5f7211b5349e203bb30a1209409f52ea5091 (patch)
tree33687316be0d9b425ee5c8375b1f1f24a584a431
parent30f4a6da26f8a96105a00e15c0567a371355186f (diff)
downloadlua-language-server-207f5f7211b5349e203bb30a1209409f52ea5091.zip
cleanup
-rw-r--r--.vscode/launch.json6
-rw-r--r--script/core/infer.lua34
2 files changed, 14 insertions, 26 deletions
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 3ba84cd2..c2dd4704 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -9,12 +9,6 @@
"stopOnEntry": false,
"program": "${workspaceRoot}/test.lua",
"luaexe": "${workspaceFolder}/bin/Windows/lua-language-server.exe",
- "linux": {
- "luaexe": "${workspaceFolder}/bin/Linux/lua-language-server"
- },
- "osx": {
- "luaexe": "${workspaceFolder}/bin/macOS/lua-language-server"
- },
"arg": [
],
"luaVersion": "latest",
diff --git a/script/core/infer.lua b/script/core/infer.lua
index 03bdd440..ce546455 100644
--- a/script/core/infer.lua
+++ b/script/core/infer.lua
@@ -405,6 +405,10 @@ end
---@param mark table
---@return string
local function searchInfer(source, infers, mark)
+ if mark[source] then
+ return
+ end
+ mark[source] = true
if bindClassOrType(source) then
return
end
@@ -489,6 +493,10 @@ local function searchInfer(source, infers, mark)
end
local function searchLiteral(source, literals, mark)
+ if mark[source] then
+ return
+ end
+ mark[source] = true
local value = searcher.getObjectValue(source)
if value then
searchLiteralOfValue(value, literals, mark)
@@ -509,37 +517,28 @@ function m.searchInfers(source, field, mark)
local infers = {}
mark = mark or {}
if not field then
- mark[source] = true
- searchInfer(source, infers)
+ searchInfer(source, infers, mark)
local id = noder.getID(source)
if id then
local node = noder.getNodeByID(source, id)
if node and node.source then
for src in noder.eachSource(node) do
- if not mark[src] then
- mark[src] = true
- searchInfer(src, infers, mark)
- end
+ searchInfer(src, infers, mark)
end
end
end
end
if source.type == 'field' or source.type == 'method' then
- mark[source.parent] = true
searchInfer(source.parent, infers, mark)
end
for _, def in ipairs(defs) do
- if not mark[def] then
- mark[def] = true
- searchInfer(def, infers, mark)
- end
+ searchInfer(def, infers, mark)
end
if source.docParam then
local docType = source.docParam.extends
if docType.type == 'doc.type' then
for _, def in ipairs(docType.types) do
- if def.typeGeneric and not mark[def] then
- mark[def] = true
+ if def.typeGeneric then
searchInfer(def, infers, mark)
end
end
@@ -548,8 +547,7 @@ function m.searchInfers(source, field, mark)
if source.type == 'doc.type' then
if source.type == 'doc.type' then
for _, def in ipairs(source.types) do
- if def.typeGeneric and not mark[def] then
- mark[def] = true
+ if def.typeGeneric then
searchInfer(def, infers, mark)
end
end
@@ -569,14 +567,10 @@ function m.searchLiterals(source, field, mark)
local literals = {}
mark = mark or {}
if not field then
- mark[source] = true
searchLiteral(source, literals, mark)
end
for _, def in ipairs(defs) do
- if not mark[def] then
- mark[def] = true
- searchLiteral(def, literals, mark)
- end
+ searchLiteral(def, literals, mark)
end
return literals
end