diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-11-30 16:24:15 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-11-30 16:24:15 +0800 |
commit | e44d4b79e08cccd0f8c83c5bf564ce571395acc1 (patch) | |
tree | 4113cddd6e84574b6ae8276207c120a07011f684 /server/src | |
parent | 931ec71a8cdf6e5c6f80cf3d90a1c3be494028ee (diff) | |
download | lua-language-server-e44d4b79e08cccd0f8c83c5bf564ce571395acc1.zip |
用一个额外字段来记录meta
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/matcher/definition.lua | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/server/src/matcher/definition.lua b/server/src/matcher/definition.lua index 2a816cf0..045f8171 100644 --- a/server/src/matcher/definition.lua +++ b/server/src/matcher/definition.lua @@ -15,6 +15,9 @@ function mt:getVar(key, source) if not var then var = self:addField(self:getVar '_ENV', key, source) end + while var and var.meta do + var = var.meta + end return var end @@ -38,8 +41,8 @@ function mt:createLocal(key, source) return var end -function mt:bindLocal(key, other_key, source) - self.env.var[key] = self:getVar(other_key, source) +function mt:setMeta(var, meta_var) + var.meta = meta_var end function mt:addField(parent, key, source) @@ -218,7 +221,9 @@ function mt:markSimple(simple) local obj = simple[i] local tp = obj.type if tp == ':' then - self:bindLocal('self', simple[i-1][1], simple[i-1]) + local var = self:createLocal('self', simple[i-1]) + local meta_var = self:getVar(simple[i-1][1]) + self:setMeta(var, meta_var) elseif tp == 'name' then if not obj.index then var = self:addField(var, obj[1], obj) |