diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-05 17:34:12 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-05 17:34:12 +0800 |
commit | 2d19737aab53701661a41933e12df08edf078bc1 (patch) | |
tree | 8a3c38cafef6f1b8b0493c08c407ef851b7c488c /server/src/matcher/find_result.lua | |
parent | 3fbeac740ba3f2839c6ac62373bfeb1f7b1ea32c (diff) | |
download | lua-language-server-2d19737aab53701661a41933e12df08edf078bc1.zip |
整理代码
Diffstat (limited to 'server/src/matcher/find_result.lua')
-rw-r--r-- | server/src/matcher/find_result.lua | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/server/src/matcher/find_result.lua b/server/src/matcher/find_result.lua new file mode 100644 index 00000000..b9313510 --- /dev/null +++ b/server/src/matcher/find_result.lua @@ -0,0 +1,37 @@ +local function isContainPos(obj, pos) + return obj.start <= pos and obj.finish + 1 >= pos +end + +return function (results, pos) + for _, var in ipairs(results.vars) do + for _, info in ipairs(var) do + if isContainPos(info.source, pos) then + return { + type = 'var', + var = var, + } + end + end + end + for _, dots in ipairs(results.dots) do + for _, info in ipairs(dots) do + if isContainPos(info.source, pos) then + return { + type = 'dots', + dots = dots, + } + end + end + end + for _, label in ipairs(results.labels) do + for _, info in ipairs(label) do + if isContainPos(info.source, pos) then + return { + type = 'label', + label = label, + } + end + end + end + return nil +end |