diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-07-08 22:06:25 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-07-08 22:06:25 +0800 |
commit | ece524b44c93ed49504b6e0ec86934f2d1ec408d (patch) | |
tree | 6d32ae5197507470d91f2e33834d6fd202fa61e8 /script | |
parent | 6ba79a338298881b5cd23610eb470c54ab590388 (diff) | |
download | lua-language-server-ece524b44c93ed49504b6e0ec86934f2d1ec408d.zip |
stash
Diffstat (limited to 'script')
-rw-r--r-- | script/core/infer.lua | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/script/core/infer.lua b/script/core/infer.lua index c4af5122..4feba41c 100644 --- a/script/core/infer.lua +++ b/script/core/infer.lua @@ -609,19 +609,34 @@ function m.isTrue(source, mark) if not source then return false end - local literals = m.searchLiterals(source, nil, mark) - for literal in pairs(literals) do - if literal ~= false then - return true + mark = mark or {} + if not mark.isTrue then + mark.isTrue = {} + end + if mark.isTrue[source] == nil then + local literals = m.searchLiterals(source, nil, mark) + for literal in pairs(literals) do + if literal ~= false then + mark.isTrue[source] = true + break + end end + mark.isTrue[source] = false end - return false + return mark.isTrue[source] end ---判断对象的推断类型是否包含某个类型 function m.hasType(source, tp, mark) - local infers = m.searchInfers(source, nil, mark) - return infers[tp] or false + mark = mark or {} + if not mark.hasType then + mark.hasType = {} + end + if mark.hasType[source] == nil then + local infers = m.searchInfers(source, nil, mark) + mark.hasType[source] = infers[tp] or false + end + return mark.hasType[source] end ---搜索并显示推断类型 |