summaryrefslogtreecommitdiff
path: root/server/src/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-07-08 20:31:53 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-07-08 20:31:53 +0800
commitdc67d2357ef43e9f3c1f4d78ef5e141c475b9dcb (patch)
tree76d0d5e06bb44c0401522a206adefad167ee049e /server/src/core
parentdd792e6924572117905f7f58574ac38bb361c236 (diff)
downloadlua-language-server-dc67d2357ef43e9f3c1f4d78ef5e141c475b9dcb.zip
修正优先级识别的bug
Diffstat (limited to 'server/src/core')
-rw-r--r--server/src/core/diagnostics.lua31
1 files changed, 24 insertions, 7 deletions
diff --git a/server/src/core/diagnostics.lua b/server/src/core/diagnostics.lua
index 77898b17..1a72d504 100644
--- a/server/src/core/diagnostics.lua
+++ b/server/src/core/diagnostics.lua
@@ -271,19 +271,36 @@ local opMap = {
['..'] = true,
}
+local literalMap = {
+ ['number'] = true,
+ ['boolean'] = true,
+ ['string'] = true,
+ ['table'] = true,
+}
+
function mt:searchAmbiguity1(callback)
self.vm:eachSource(function (source)
if source.op ~= 'or' then
return
end
- -- (a or 0) + c --> a or (0 + c)
+ local first = source[1]
+ local second = source[2]
-- a + (b or 0) --> (a + b) or 0
- for x = 1, 2 do
- local y = x % 2 + 1
- local exp = source[x]
- local other = source[y]
- if opMap[exp.op] and not opMap[other.op] then
- callback(source.start, source.finish, exp.start, exp.finish)
+ do
+ if opMap[first.op]
+ and not second.op
+ and literalMap[second.type]
+ then
+ callback(source.start, source.finish, first.start, first.finish)
+ end
+ end
+ -- (a or 0) + c --> a or (0 + c)
+ do
+ if opMap[second.op]
+ and not first.op
+ and literalMap[second[1].type]
+ then
+ callback(source.start, source.finish, second.start, second.finish)
end
end
end)