diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-10-14 20:31:55 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-10-14 20:31:55 +0800 |
commit | b735bbc94ce68bd1a7b66f2f2b195e4951508d42 (patch) | |
tree | ed408652a912cc98768ffa8fadc6798e8e718272 /server-beta/src/core/setfield.lua | |
parent | 94e9133d7b25050212bbda323ef83f30142352e8 (diff) | |
download | lua-language-server-b735bbc94ce68bd1a7b66f2f2b195e4951508d42.zip |
整理代码
Diffstat (limited to 'server-beta/src/core/setfield.lua')
-rw-r--r-- | server-beta/src/core/setfield.lua | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/server-beta/src/core/setfield.lua b/server-beta/src/core/setfield.lua new file mode 100644 index 00000000..bf18842d --- /dev/null +++ b/server-beta/src/core/setfield.lua @@ -0,0 +1,49 @@ +local guide = require 'parser.guide' +local checkSMT = require 'core.setmetatable' + +local m = {} + +function m:field(source, key, callback) + local used = {} + local found = false + used[source] = true + + local node = source.node + used[node] = true + + callback(source.field, 'set') + local myKey = guide.getKeyName(source) + self:eachField(node, myKey, function (src, mode) + if used[src] then + return + end + used[src] = true + self:eachField(src, key, function (src, mode) + used[src] = true + if mode == 'set' then + callback(src, mode) + found = true + end + end) + end) + + self:eachValue(node, function (src) + self:eachField(src, myKey, function (src, mode) + if used[src] then + return + end + used[src] = true + self:eachField(src, key, function (src, mode) + used[src] = true + if mode == 'set' then + callback(src, mode) + found = true + end + end) + end) + end) + + checkSMT(self, key, used, found, callback) +end + +return m |