diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-11-18 01:15:20 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-11-18 01:15:20 +0800 |
commit | 7ade261608ef3649be5c6ee2961e926527e2f03d (patch) | |
tree | 4cb3991079061384962de3bf1905c9b5374d65bf /server-beta/src/parser | |
parent | e9fcf13480ed98af15201911cad542fe6e84dc1e (diff) | |
download | lua-language-server-7ade261608ef3649be5c6ee2961e926527e2f03d.zip |
暂存
Diffstat (limited to 'server-beta/src/parser')
-rw-r--r-- | server-beta/src/parser/guide.lua | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/server-beta/src/parser/guide.lua b/server-beta/src/parser/guide.lua index 80f9d160..f91c677e 100644 --- a/server-beta/src/parser/guide.lua +++ b/server-beta/src/parser/guide.lua @@ -299,7 +299,10 @@ function m.eachSourceContain(ast, offset, callback) list[len] = nil if m.isInRange(obj, offset) then if m.isContain(obj, offset) then - callback(obj) + local res = callback(obj) + if res ~= nil then + return res + end end m.addChilds(list, obj, m.childMap) end @@ -476,19 +479,23 @@ function m.getKeyName(obj) elseif tp == 'getfield' or tp == 'setfield' or tp == 'tablefield' then - return 's|' .. obj.field[1] + if obj.field then + return 's|' .. obj.field[1] + end elseif tp == 'getmethod' or tp == 'setmethod' then - return 's|' .. obj.method[1] + if obj.method then + return 's|' .. obj.method[1] + end elseif tp == 'getindex' or tp == 'setindex' or tp == 'tableindex' then - return m.getKeyName(obj.index) + if obj.index then + return m.getKeyName(obj.index) + end elseif tp == 'field' or tp == 'method' then return 's|' .. obj[1] - elseif tp == 'index' then - return m.getKeyName(obj.index) elseif tp == 'string' then local s = obj[1] if s then |