diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-10-10 19:34:12 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-10-10 19:34:12 +0800 |
commit | 8535713d22d4bfc1d02dea1b6fdc31324c61b760 (patch) | |
tree | 30b6cb52d464bd9acd43a365944f0a61f9f3ee47 /server-beta/src | |
parent | f8ae93feb7be0faba81ce72795b74bc4ec4dfe03 (diff) | |
download | lua-language-server-8535713d22d4bfc1d02dea1b6fdc31324c61b760.zip |
防止重复触发
Diffstat (limited to 'server-beta/src')
-rw-r--r-- | server-beta/src/core/engineer.lua | 40 | ||||
-rw-r--r-- | server-beta/src/core/field.lua | 2 | ||||
-rw-r--r-- | server-beta/src/core/local.lua | 2 | ||||
-rw-r--r-- | server-beta/src/core/method.lua | 9 |
4 files changed, 42 insertions, 11 deletions
diff --git a/server-beta/src/core/engineer.lua b/server-beta/src/core/engineer.lua index bfb9c98b..0d55479c 100644 --- a/server-beta/src/core/engineer.lua +++ b/server-beta/src/core/engineer.lua @@ -74,7 +74,14 @@ function mt:eachField(source, key, callback) if not f then return end - f(self, source, key, callback) + local mark = {} + f(self, source, key, function (src, ...) + if mark[src] then + return + end + mark[src] = true + callback(src, ...) + end) end function mt:eachRef(source, callback) @@ -87,7 +94,14 @@ function mt:eachRef(source, callback) if not f then return end - f(self, source, callback) + local mark = {} + f(self, source, function (src, ...) + if mark[src] then + return + end + mark[src] = true + callback(src, ...) + end) end function mt:eachDef(source, callback) @@ -100,7 +114,14 @@ function mt:eachDef(source, callback) if not f then return end - f(self, source, callback) + local mark = {} + f(self, source, function (src, ...) + if mark[src] then + return + end + mark[src] = true + callback(src, ...) + end) end function mt:eachValue(source, callback) @@ -113,7 +134,14 @@ function mt:eachValue(source, callback) if not f then return end - f(self, source, callback) + local mark = {} + f(self, source, function (src, ...) + if mark[src] then + return + end + mark[src] = true + callback(src, ...) + end) end function mt:childDef(source, callback) @@ -155,10 +183,6 @@ function mt:callArgOf(source) return tableUnpack(args) end -function mt:callReturnOf(source) - -end - return function (ast) local self = setmetatable({ step = 0, diff --git a/server-beta/src/core/field.lua b/server-beta/src/core/field.lua index 72845956..30613582 100644 --- a/server-beta/src/core/field.lua +++ b/server-beta/src/core/field.lua @@ -10,8 +10,6 @@ function m:def(source, callback) callback(src, mode) end end) - -- 尝试 __index - end function m:ref(source, callback) diff --git a/server-beta/src/core/local.lua b/server-beta/src/core/local.lua index a68b41f8..33a25899 100644 --- a/server-beta/src/core/local.lua +++ b/server-beta/src/core/local.lua @@ -69,7 +69,7 @@ function m:field(source, key, callback) self:eachField(node, key, callback) end self:eachValue(source, function (src) - if src ~= source then + if source ~= src then self:eachField(src, key, callback) end end) diff --git a/server-beta/src/core/method.lua b/server-beta/src/core/method.lua index 78f74e7a..071e231a 100644 --- a/server-beta/src/core/method.lua +++ b/server-beta/src/core/method.lua @@ -22,4 +22,13 @@ function m:ref(source, callback) end) end +function m:value(source, callback) + local parent = source.parent + if parent.type == 'setmethod' then + if parent.value then + self:eachValue(parent.value, callback) + end + end +end + return m |