summaryrefslogtreecommitdiff
path: root/server-beta/src
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-10-14 21:03:49 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-10-14 21:03:49 +0800
commit9c18872bc69a713c038eb9626d42a81615b80d97 (patch)
treefc87529a26f2f1ab7f101809b0581e01662cfb0c /server-beta/src
parent64bcf0979e681f8c2f521642cf648dbf88f360a9 (diff)
downloadlua-language-server-9c18872bc69a713c038eb9626d42a81615b80d97.zip
整理代码
Diffstat (limited to 'server-beta/src')
-rw-r--r--server-beta/src/core/field.lua34
-rw-r--r--server-beta/src/core/getfield.lua26
-rw-r--r--server-beta/src/core/getindex.lua26
-rw-r--r--server-beta/src/core/getmethod.lua26
-rw-r--r--server-beta/src/core/method.lua4
-rw-r--r--server-beta/src/core/setfield.lua26
-rw-r--r--server-beta/src/core/setindex.lua26
-rw-r--r--server-beta/src/core/setmethod.lua26
8 files changed, 76 insertions, 118 deletions
diff --git a/server-beta/src/core/field.lua b/server-beta/src/core/field.lua
index 4d48bd93..e1e67c08 100644
--- a/server-beta/src/core/field.lua
+++ b/server-beta/src/core/field.lua
@@ -5,32 +5,22 @@ local m = {}
function m:def(source, callback)
local parent = source.parent
- if parent.type == 'setfield' or parent.type == 'getfield' then
- local node = parent.node
- local key = guide.getKeyName(source)
- self:eachField(node, key, function (src, mode)
- if mode == 'set' then
- callback(src, mode)
- end
- end)
- elseif parent.type == 'tablefield' then
- self:eachDef(parent.value, callback)
- end
+ local key = guide.getKeyName(source)
+ self:eachField(parent, key, function (src, mode)
+ if mode == 'set' then
+ callback(src, mode)
+ end
+ end)
end
function m:ref(source, callback)
local parent = source.parent
- if parent.type == 'setfield' or parent.type == 'getfield' then
- local node = parent.node
- local key = guide.getKeyName(source)
- self:eachField(node, key, function (src, mode)
- if mode == 'set' or mode == 'get' then
- callback(src, mode)
- end
- end)
- elseif parent.type == 'tablefield' then
- self:eachDef(parent.value, callback)
- end
+ local key = guide.getKeyName(source)
+ self:eachField(parent, key, function (src, mode)
+ if mode == 'set' or mode == 'set' then
+ callback(src, mode)
+ end
+ end)
end
function m:field(source, key, callback)
diff --git a/server-beta/src/core/getfield.lua b/server-beta/src/core/getfield.lua
index 69c8a675..c76df24e 100644
--- a/server-beta/src/core/getfield.lua
+++ b/server-beta/src/core/getfield.lua
@@ -16,33 +16,27 @@ function m:field(source, key, callback)
callback(source.field, 'get')
end
- self:eachField(node, myKey, function (src, mode)
+ self:eachField(node, key, 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)
+ if mode == 'set' then
+ callback(src, mode)
+ found = true
+ end
end)
self:eachValue(node, function (src)
- self:eachField(src, myKey, function (src, mode)
+ self:eachField(src, key, 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)
+ if mode == 'set' then
+ callback(src, mode)
+ found = true
+ end
end)
end)
diff --git a/server-beta/src/core/getindex.lua b/server-beta/src/core/getindex.lua
index d66d06fe..28706589 100644
--- a/server-beta/src/core/getindex.lua
+++ b/server-beta/src/core/getindex.lua
@@ -16,33 +16,27 @@ function m:field(source, key, callback)
callback(source.index, 'set')
end
- self:eachField(node, myKey, function (src, mode)
+ self:eachField(node, key, 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)
+ if mode == 'set' then
+ callback(src, mode)
+ found = true
+ end
end)
self:eachValue(node, function (src)
- self:eachField(src, myKey, function (src, mode)
+ self:eachField(src, key, 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)
+ if mode == 'set' then
+ callback(src, mode)
+ found = true
+ end
end)
end)
diff --git a/server-beta/src/core/getmethod.lua b/server-beta/src/core/getmethod.lua
index fd5855c1..b743d384 100644
--- a/server-beta/src/core/getmethod.lua
+++ b/server-beta/src/core/getmethod.lua
@@ -16,33 +16,27 @@ function m:field(source, key, callback)
callback(source.method, 'get')
end
- self:eachField(node, myKey, function (src, mode)
+ self:eachField(node, key, 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)
+ if mode == 'set' then
+ callback(src, mode)
+ found = true
+ end
end)
self:eachValue(node, function (src)
- self:eachField(src, myKey, function (src, mode)
+ self:eachField(src, key, 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)
+ if mode == 'set' then
+ callback(src, mode)
+ found = true
+ end
end)
end)
diff --git a/server-beta/src/core/method.lua b/server-beta/src/core/method.lua
index 071e231a..c8ea61e1 100644
--- a/server-beta/src/core/method.lua
+++ b/server-beta/src/core/method.lua
@@ -22,6 +22,10 @@ function m:ref(source, callback)
end)
end
+function m:field(source, key, callback)
+ self:eachField(source.parent, key, callback)
+end
+
function m:value(source, callback)
local parent = source.parent
if parent.type == 'setmethod' then
diff --git a/server-beta/src/core/setfield.lua b/server-beta/src/core/setfield.lua
index 356b5eee..a9f76280 100644
--- a/server-beta/src/core/setfield.lua
+++ b/server-beta/src/core/setfield.lua
@@ -16,33 +16,27 @@ function m:field(source, key, callback)
callback(source.field, 'set')
end
- self:eachField(node, myKey, function (src, mode)
+ self:eachField(node, key, 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)
+ if mode == 'set' then
+ callback(src, mode)
+ found = true
+ end
end)
self:eachValue(node, function (src)
- self:eachField(src, myKey, function (src, mode)
+ self:eachField(src, key, 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)
+ if mode == 'set' then
+ callback(src, mode)
+ found = true
+ end
end)
end)
diff --git a/server-beta/src/core/setindex.lua b/server-beta/src/core/setindex.lua
index 895d48f5..87fe18de 100644
--- a/server-beta/src/core/setindex.lua
+++ b/server-beta/src/core/setindex.lua
@@ -16,33 +16,27 @@ function m:field(source, key, callback)
callback(source.index, 'get')
end
- self:eachField(node, myKey, function (src, mode)
+ self:eachField(node, key, 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)
+ if mode == 'set' then
+ callback(src, mode)
+ found = true
+ end
end)
self:eachValue(node, function (src)
- self:eachField(src, myKey, function (src, mode)
+ self:eachField(src, key, 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)
+ if mode == 'set' then
+ callback(src, mode)
+ found = true
+ end
end)
end)
diff --git a/server-beta/src/core/setmethod.lua b/server-beta/src/core/setmethod.lua
index 4140c2d5..e48cd6d1 100644
--- a/server-beta/src/core/setmethod.lua
+++ b/server-beta/src/core/setmethod.lua
@@ -16,33 +16,27 @@ function m:field(source, key, callback)
callback(source.method, 'set')
end
- self:eachField(node, myKey, function (src, mode)
+ self:eachField(node, key, 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)
+ if mode == 'set' then
+ callback(src, mode)
+ found = true
+ end
end)
self:eachValue(node, function (src)
- self:eachField(src, myKey, function (src, mode)
+ self:eachField(src, key, 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)
+ if mode == 'set' then
+ callback(src, mode)
+ found = true
+ end
end)
end)