summaryrefslogtreecommitdiff
path: root/server-beta/src/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-10-17 19:30:38 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-10-17 19:30:38 +0800
commitc8175c13c19cb6be4d2690d0a8fde6f04210ba51 (patch)
treec2e297b4d62e19a92625edf6bfadfb58dfcb2787 /server-beta/src/core
parent9cfe34795e2cb31b7b1e7f30cf9988ae360857c7 (diff)
downloadlua-language-server-c8175c13c19cb6be4d2690d0a8fde6f04210ba51.zip
整理代码
Diffstat (limited to 'server-beta/src/core')
-rw-r--r--server-beta/src/core/field.lua8
-rw-r--r--server-beta/src/core/getindex.lua2
-rw-r--r--server-beta/src/core/method.lua7
-rw-r--r--server-beta/src/core/setfield.lua30
-rw-r--r--server-beta/src/core/setindex.lua22
-rw-r--r--server-beta/src/core/setmethod.lua26
-rw-r--r--server-beta/src/core/tablefield.lua6
7 files changed, 58 insertions, 43 deletions
diff --git a/server-beta/src/core/field.lua b/server-beta/src/core/field.lua
index e1e67c08..12c13632 100644
--- a/server-beta/src/core/field.lua
+++ b/server-beta/src/core/field.lua
@@ -28,13 +28,7 @@ function m:field(source, key, callback)
end
function m:value(source, callback)
- local parent = source.parent
- if parent.type == 'setfield'
- or parent.type == 'tablefield' then
- if parent.value then
- self:eachValue(parent.value, callback)
- end
- end
+ self:eachValue(source.parent, callback)
end
return m
diff --git a/server-beta/src/core/getindex.lua b/server-beta/src/core/getindex.lua
index 0c0913dc..c0b3e517 100644
--- a/server-beta/src/core/getindex.lua
+++ b/server-beta/src/core/getindex.lua
@@ -13,7 +13,7 @@ function m:field(source, key, callback)
local myKey = guide.getKeyName(source)
if key == myKey then
- callback(source, 'set')
+ callback(source, 'get')
end
self:eachField(node, myKey, function (src, mode)
diff --git a/server-beta/src/core/method.lua b/server-beta/src/core/method.lua
index c8ea61e1..a5005587 100644
--- a/server-beta/src/core/method.lua
+++ b/server-beta/src/core/method.lua
@@ -27,12 +27,7 @@ function m:field(source, key, callback)
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
+ self:eachValue(source.parent, callback)
end
return m
diff --git a/server-beta/src/core/setfield.lua b/server-beta/src/core/setfield.lua
index 3736663b..6f629d55 100644
--- a/server-beta/src/core/setfield.lua
+++ b/server-beta/src/core/setfield.lua
@@ -9,22 +9,26 @@ function m:field(source, key, callback)
used[source] = true
local node = source.node
- used[node] = true
+ self:eachDef(node, function (src)
+ used[src] = true
+ end)
local myKey = guide.getKeyName(source)
if key == myKey then
callback(source, 'set')
end
- self:eachField(node, key, function (src, mode)
- if used[src] then
- return
- end
- used[src] = true
- if mode == 'set' then
- callback(src, mode)
- found = true
- end
+ self:eachField(node, myKey, function (src, mode)
+ self:eachField(src, key, function (src, mode)
+ if used[src] then
+ return
+ end
+ used[src] = true
+ if mode == 'set' then
+ callback(src, mode)
+ found = true
+ end
+ end)
end)
self:eachValue(node, function (src)
@@ -43,4 +47,10 @@ function m:field(source, key, callback)
checkSMT(self, key, used, found, callback)
end
+function m:value(source, callback)
+ if source.value then
+ self:eachValue(source.value, callback)
+ end
+end
+
return m
diff --git a/server-beta/src/core/setindex.lua b/server-beta/src/core/setindex.lua
index 60813166..0c0913dc 100644
--- a/server-beta/src/core/setindex.lua
+++ b/server-beta/src/core/setindex.lua
@@ -13,18 +13,20 @@ function m:field(source, key, callback)
local myKey = guide.getKeyName(source)
if key == myKey then
- callback(source, 'get')
+ callback(source, 'set')
end
- self:eachField(node, key, function (src, mode)
- if used[src] then
- return
- end
- used[src] = true
- if mode == 'set' then
- callback(src, mode)
- found = true
- end
+ self:eachField(node, myKey, function (src, mode)
+ self:eachField(src, key, function (src, mode)
+ if used[src] then
+ return
+ end
+ used[src] = true
+ if mode == 'set' then
+ callback(src, mode)
+ found = true
+ end
+ end)
end)
self:eachValue(node, function (src)
diff --git a/server-beta/src/core/setmethod.lua b/server-beta/src/core/setmethod.lua
index 3736663b..881b5083 100644
--- a/server-beta/src/core/setmethod.lua
+++ b/server-beta/src/core/setmethod.lua
@@ -16,15 +16,17 @@ function m:field(source, key, callback)
callback(source, 'set')
end
- self:eachField(node, key, function (src, mode)
- if used[src] then
- return
- end
- used[src] = true
- if mode == 'set' then
- callback(src, mode)
- found = true
- end
+ self:eachField(node, myKey, function (src, mode)
+ self:eachField(src, key, function (src, mode)
+ if used[src] then
+ return
+ end
+ used[src] = true
+ if mode == 'set' then
+ callback(src, mode)
+ found = true
+ end
+ end)
end)
self:eachValue(node, function (src)
@@ -43,4 +45,10 @@ function m:field(source, key, callback)
checkSMT(self, key, used, found, callback)
end
+function m:value(source, callback)
+ if source.value then
+ self:eachValue(source.value, callback)
+ end
+end
+
return m
diff --git a/server-beta/src/core/tablefield.lua b/server-beta/src/core/tablefield.lua
index a5447e3f..cfc6bace 100644
--- a/server-beta/src/core/tablefield.lua
+++ b/server-beta/src/core/tablefield.lua
@@ -6,4 +6,10 @@ function m:field(source, key, callback)
end
end
+function m:value(source, callback)
+ if source.value then
+ self:eachValue(source.value, callback)
+ end
+end
+
return m