diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-11-15 23:47:39 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-11-15 23:47:39 +0800 |
commit | f4fcddfa8805848b7ce7c58188cca711fc429c3b (patch) | |
tree | 8e8b1947a40d274e7237dddab30c195bfb0ad1ae /server-beta/src/parser | |
parent | 2862282e18315a6474001a994e385fee132753a6 (diff) | |
download | lua-language-server-f4fcddfa8805848b7ce7c58188cca711fc429c3b.zip |
诊断:未使用的函数 只检查局部函数与全局函数
Diffstat (limited to 'server-beta/src/parser')
-rw-r--r-- | server-beta/src/parser/ast.lua | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/server-beta/src/parser/ast.lua b/server-beta/src/parser/ast.lua index f3fec01b..ded42891 100644 --- a/server-beta/src/parser/ast.lua +++ b/server-beta/src/parser/ast.lua @@ -697,6 +697,7 @@ local Defs = { return lv1 < lv2 end end) + local final for i = #ops, 1, -1 do local n = ops[i] local op = list[n] @@ -710,17 +711,28 @@ local Defs = { [1] = left, [2] = right, } - list[n-1] = exp - list[n+1] = exp - local lastN = ops[i+1] - if lastN then - list[lastN-1] = exp - list[lastN+1] = exp + local leftIndex, rightIndex + if list[left] then + leftIndex = list[left[1]] + else + leftIndex = n - 1 + end + if list[right] then + rightIndex = list[right[2]] + else + rightIndex = n + 1 end + + list[leftIndex] = exp + list[rightIndex] = exp + list[left] = leftIndex + list[right] = rightIndex + list[exp] = n + final = exp + checkOpVersion(op) end - local final = ops[1] - return list[final-1] + return final end, Paren = function (start, exp, finish) if exp and exp.type == 'paren' then |