diff options
-rw-r--r-- | server-beta/src/core/definition.lua | 12 | ||||
-rw-r--r-- | server-beta/src/core/engineer.lua | 28 | ||||
-rw-r--r-- | server-beta/src/core/getfield.lua | 22 | ||||
-rw-r--r-- | server-beta/src/core/getglobal.lua | 8 | ||||
-rw-r--r-- | server-beta/src/core/getindex.lua | 22 | ||||
-rw-r--r-- | server-beta/src/core/getmethod.lua | 22 | ||||
-rw-r--r-- | server-beta/src/core/local.lua | 12 | ||||
-rw-r--r-- | server-beta/src/core/setfield.lua | 2 | ||||
-rw-r--r-- | server-beta/src/core/setindex.lua | 2 | ||||
-rw-r--r-- | server-beta/src/core/setmethod.lua | 2 | ||||
-rw-r--r-- | server-beta/src/core/table.lua | 4 |
11 files changed, 65 insertions, 71 deletions
diff --git a/server-beta/src/core/definition.lua b/server-beta/src/core/definition.lua index 4d1d1288..c6596268 100644 --- a/server-beta/src/core/definition.lua +++ b/server-beta/src/core/definition.lua @@ -6,6 +6,18 @@ return function (ast, text, offset) guide.eachSourceContain(ast.ast, offset, function (source) local searcher = engineer(ast) searcher:eachDef(source, function (src) + if src.type == 'setfield' + or src.type == 'getfield' + or src.type == 'tablefield' then + src = src.field + elseif src.type == 'setindex' + or src.type == 'getindex' + or src.type == 'tableindex' then + src = src.index + elseif src.type == 'getmethod' + or src.type == 'setmethod' then + src = src.method + end results[#results+1] = { uri = ast.uri, source = source, diff --git a/server-beta/src/core/engineer.lua b/server-beta/src/core/engineer.lua index 099d934f..0553df9c 100644 --- a/server-beta/src/core/engineer.lua +++ b/server-beta/src/core/engineer.lua @@ -261,34 +261,6 @@ function mt:eachValue(source, callback) self.step = self.step - 1 end -function mt:childDef(source, callback) - local tp = source.type - if tp == 'setfield' then - callback(source.field, 'set') - elseif tp == 'setmethod' then - callback(source.method, 'set') - elseif tp == 'setindex' then - callback(source.index, 'set') - end -end - -function mt:childRef(source, callback) - local tp = source.type - if tp == 'setfield' then - callback(source.field, 'set') - elseif tp == 'setmethod' then - callback(source.method, 'set') - elseif tp == 'setindex' then - callback(source.index, 'set') - elseif tp == 'getfield' then - callback(source.field, 'get') - elseif tp == 'getmethod' then - callback(source.method, 'get') - elseif tp == 'getindex' then - callback(source.index, 'get') - end -end - function mt:callArgOf(source) if not source or source.type ~= 'call' then return diff --git a/server-beta/src/core/getfield.lua b/server-beta/src/core/getfield.lua index 77a132ca..03aa7854 100644 --- a/server-beta/src/core/getfield.lua +++ b/server-beta/src/core/getfield.lua @@ -15,18 +15,20 @@ function m:field(source, key, callback) local myKey = guide.getKeyName(source) if key == myKey then - callback(source.field, 'get') + callback(source, 'get') 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/getglobal.lua b/server-beta/src/core/getglobal.lua index 2c48ca76..72d208a5 100644 --- a/server-beta/src/core/getglobal.lua +++ b/server-beta/src/core/getglobal.lua @@ -15,7 +15,7 @@ function m:def(source, callback) if name == '_G' then local parent = src.parent if guide.getKeyName(parent) == key then - self:childDef(parent, callback) + callback(parent, 'set') end elseif name == 'rawset' then local t, k = self:callArgOf(src.parent) @@ -39,7 +39,11 @@ function m:ref(source, callback) if name == '_G' then local parent = src.parent if guide.getKeyName(parent) == key then - self:childRef(parent, callback) + if parent.type:sub(1, 3) == 'set' then + callback(parent, 'set') + else + callback(parent, 'get') + end end elseif name == 'rawset' then local t, k = self:callArgOf(src.parent) diff --git a/server-beta/src/core/getindex.lua b/server-beta/src/core/getindex.lua index 28706589..0c0913dc 100644 --- a/server-beta/src/core/getindex.lua +++ b/server-beta/src/core/getindex.lua @@ -13,18 +13,20 @@ function m:field(source, key, callback) local myKey = guide.getKeyName(source) if key == myKey then - callback(source.index, 'set') + 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/getmethod.lua b/server-beta/src/core/getmethod.lua index b743d384..c0b3e517 100644 --- a/server-beta/src/core/getmethod.lua +++ b/server-beta/src/core/getmethod.lua @@ -13,18 +13,20 @@ function m:field(source, key, callback) local myKey = guide.getKeyName(source) if key == myKey then - callback(source.method, 'get') + callback(source, 'get') 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/local.lua b/server-beta/src/core/local.lua index eb0c8900..6c9488f4 100644 --- a/server-beta/src/core/local.lua +++ b/server-beta/src/core/local.lua @@ -53,12 +53,12 @@ function m:field(source, key, callback) used[ref] = true local parent = ref.parent if key == guide.getKeyName(parent) then - self:childRef(parent, function (src, mode) - callback(src, mode) - if mode == 'set' then - found = true - end - end) + if parent.type:sub(1, 3) == 'set' then + callback(parent, 'set') + found = true + else + callback(parent, 'get') + end end elseif ref.type == 'getglobal' then used[ref] = true diff --git a/server-beta/src/core/setfield.lua b/server-beta/src/core/setfield.lua index a9f76280..3736663b 100644 --- a/server-beta/src/core/setfield.lua +++ b/server-beta/src/core/setfield.lua @@ -13,7 +13,7 @@ function m:field(source, key, callback) local myKey = guide.getKeyName(source) if key == myKey then - callback(source.field, 'set') + callback(source, 'set') end self:eachField(node, key, function (src, mode) diff --git a/server-beta/src/core/setindex.lua b/server-beta/src/core/setindex.lua index 87fe18de..60813166 100644 --- a/server-beta/src/core/setindex.lua +++ b/server-beta/src/core/setindex.lua @@ -13,7 +13,7 @@ function m:field(source, key, callback) local myKey = guide.getKeyName(source) if key == myKey then - callback(source.index, 'get') + callback(source, 'get') end self:eachField(node, key, function (src, mode) diff --git a/server-beta/src/core/setmethod.lua b/server-beta/src/core/setmethod.lua index e48cd6d1..3736663b 100644 --- a/server-beta/src/core/setmethod.lua +++ b/server-beta/src/core/setmethod.lua @@ -13,7 +13,7 @@ function m:field(source, key, callback) local myKey = guide.getKeyName(source) if key == myKey then - callback(source.method, 'set') + callback(source, 'set') end self:eachField(node, key, function (src, mode) diff --git a/server-beta/src/core/table.lua b/server-beta/src/core/table.lua index 3c3ae0f3..7b7b7a78 100644 --- a/server-beta/src/core/table.lua +++ b/server-beta/src/core/table.lua @@ -7,9 +7,9 @@ function m:field(source, key, callback) local src = source[i] if key == guide.getKeyName(src) then if src.type == 'tablefield' then - callback(src.field, 'set') + callback(src, 'set') elseif src.type == 'tableindex' then - callback(src.index, 'set') + callback(src, 'set') end end end |