diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-11-29 16:55:59 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-11-29 16:55:59 +0800 |
commit | 9992c649cde19d4db8c9a9a7b47eb71bb2eaa283 (patch) | |
tree | 1c85e8f75ad10c9c5febea94d837a5cfce773072 /server/src/matcher | |
parent | b13e39260cc47b90c9b5b095964ea56c1a3d7cd5 (diff) | |
download | lua-language-server-9992c649cde19d4db8c9a9a7b47eb71bb2eaa283.zip |
除了表以外的转到定义能用了
Diffstat (limited to 'server/src/matcher')
-rw-r--r-- | server/src/matcher/definition.lua | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/server/src/matcher/definition.lua b/server/src/matcher/definition.lua index 0a774a25..9897bcbc 100644 --- a/server/src/matcher/definition.lua +++ b/server/src/matcher/definition.lua @@ -35,7 +35,7 @@ end function mt:searchCall(call) for _, exp in ipairs(call) do - searchExp(exp) + self:searchExp(exp) end return nil end @@ -47,15 +47,12 @@ function mt:searchSimple(simple) local tp = obj.type if tp == 'call' then self:searchCall(obj) - elseif tp == ':' then - self:markLocal(obj) else if obj.index then self:searchExp(obj) end end end - return nil end function mt:searchBinary(exp) @@ -94,6 +91,16 @@ function mt:searchReturn(action) end end +function mt:markSimple(simple) + for i = 2, #simple do + local obj = simple[i] + local tp = obj.type + if tp == ':' then + self:createLocal('self', obj) + end + end +end + function mt:markSet(simple) if simple.type == 'name' then local str = simple[1] @@ -114,6 +121,7 @@ function mt:markSet(simple) self:checkName(simple) else self:searchSimple(simple) + self:markSimple(simple) end end @@ -233,6 +241,7 @@ end function mt:searchFunction(func) self.env:push() + self.env:cut 'dots' if func.name then self:markSet(func.name) end @@ -270,6 +279,8 @@ function mt:searchAction(action) self:markSets(action) elseif tp == 'local' then self:markLocals(action) + elseif tp == 'simple' then + self:searchSimple(action) elseif tp == 'if' then self:searchIfs(action) elseif tp == 'loop' then |