summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-10-14 20:46:44 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-10-14 20:46:44 +0800
commit64bcf0979e681f8c2f521642cf648dbf88f360a9 (patch)
tree9b07d7577573add1851f22f959040b3f370a378f
parentb735bbc94ce68bd1a7b66f2f2b195e4951508d42 (diff)
downloadlua-language-server-64bcf0979e681f8c2f521642cf648dbf88f360a9.zip
修正bug
-rw-r--r--server-beta/src/core/engineer.lua4
-rw-r--r--server-beta/src/core/getfield.lua5
-rw-r--r--server-beta/src/core/getindex.lua52
-rw-r--r--server-beta/src/core/getmethod.lua52
-rw-r--r--server-beta/src/core/setfield.lua5
-rw-r--r--server-beta/src/core/setindex.lua52
-rw-r--r--server-beta/src/core/setmethod.lua52
7 files changed, 220 insertions, 2 deletions
diff --git a/server-beta/src/core/engineer.lua b/server-beta/src/core/engineer.lua
index 1afdd153..099d934f 100644
--- a/server-beta/src/core/engineer.lua
+++ b/server-beta/src/core/engineer.lua
@@ -19,6 +19,10 @@ mt['setglobal'] = mt['getglobal']
mt['getfield'] = require 'core.getfield'
mt['setfield'] = require 'core.setfield'
mt['tablefield'] = require 'core.tablefield'
+mt['getmethod'] = require 'core.getmethod'
+mt['setmethod'] = require 'core.setmethod'
+mt['getindex'] = require 'core.getindex'
+mt['setindex'] = require 'core.setindex'
mt['field'] = require 'core.field'
mt['method'] = require 'core.method'
mt['index'] = require 'core.index'
diff --git a/server-beta/src/core/getfield.lua b/server-beta/src/core/getfield.lua
index 328de34a..69c8a675 100644
--- a/server-beta/src/core/getfield.lua
+++ b/server-beta/src/core/getfield.lua
@@ -11,8 +11,11 @@ function m:field(source, key, callback)
local node = source.node
used[node] = true
- callback(source.field, 'get')
local myKey = guide.getKeyName(source)
+ if key == myKey then
+ callback(source.field, 'get')
+ end
+
self:eachField(node, myKey, function (src, mode)
if used[src] then
return
diff --git a/server-beta/src/core/getindex.lua b/server-beta/src/core/getindex.lua
new file mode 100644
index 00000000..d66d06fe
--- /dev/null
+++ b/server-beta/src/core/getindex.lua
@@ -0,0 +1,52 @@
+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
+
+ local myKey = guide.getKeyName(source)
+ if key == myKey then
+ callback(source.index, 'set')
+ end
+
+ 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
diff --git a/server-beta/src/core/getmethod.lua b/server-beta/src/core/getmethod.lua
new file mode 100644
index 00000000..fd5855c1
--- /dev/null
+++ b/server-beta/src/core/getmethod.lua
@@ -0,0 +1,52 @@
+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
+
+ local myKey = guide.getKeyName(source)
+ if key == myKey then
+ callback(source.method, 'get')
+ end
+
+ 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
diff --git a/server-beta/src/core/setfield.lua b/server-beta/src/core/setfield.lua
index bf18842d..356b5eee 100644
--- a/server-beta/src/core/setfield.lua
+++ b/server-beta/src/core/setfield.lua
@@ -11,8 +11,11 @@ function m:field(source, key, callback)
local node = source.node
used[node] = true
- callback(source.field, 'set')
local myKey = guide.getKeyName(source)
+ if key == myKey then
+ callback(source.field, 'set')
+ end
+
self:eachField(node, myKey, function (src, mode)
if used[src] then
return
diff --git a/server-beta/src/core/setindex.lua b/server-beta/src/core/setindex.lua
new file mode 100644
index 00000000..895d48f5
--- /dev/null
+++ b/server-beta/src/core/setindex.lua
@@ -0,0 +1,52 @@
+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
+
+ local myKey = guide.getKeyName(source)
+ if key == myKey then
+ callback(source.index, 'get')
+ end
+
+ 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
diff --git a/server-beta/src/core/setmethod.lua b/server-beta/src/core/setmethod.lua
new file mode 100644
index 00000000..4140c2d5
--- /dev/null
+++ b/server-beta/src/core/setmethod.lua
@@ -0,0 +1,52 @@
+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
+
+ local myKey = guide.getKeyName(source)
+ if key == myKey then
+ callback(source.method, 'set')
+ end
+
+ 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