diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-10-10 14:16:20 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-10-10 14:16:20 +0800 |
commit | be391ed25a3c560bac363c9ead702c1ad41e7488 (patch) | |
tree | 4bf1056a240b9283ca4c33dcf712b9ee25b9830f | |
parent | 8ea5794f59f4608faacc727cf11a41f0f751ddd1 (diff) | |
download | lua-language-server-be391ed25a3c560bac363c9ead702c1ad41e7488.zip |
还是先不支持特殊API了
-rw-r--r-- | server-beta/src/core/local.lua | 47 | ||||
-rw-r--r-- | server-beta/test/definition/set.lua | 18 |
2 files changed, 30 insertions, 35 deletions
diff --git a/server-beta/src/core/local.lua b/server-beta/src/core/local.lua index 1a9c1644..113637a9 100644 --- a/server-beta/src/core/local.lua +++ b/server-beta/src/core/local.lua @@ -1,3 +1,5 @@ +local guide = require 'parser.guide' + local m = {} function m:def(source, callback) @@ -43,23 +45,7 @@ function m:field(source, key, callback) for _, ref in ipairs(source.ref) do if ref.type == 'getlocal' then local parent = ref.parent - local tp = parent.type - if tp == 'setfield' - or tp == 'setmethod' - or tp == 'setindex' then - callback(parent, 'set') - elseif tp == 'getfield' - or tp == 'getmethod' - or tp == 'getindex' then - callback(parent, 'get') - end - elseif ref.type == 'setlocal' then - self:eachRef(ref.value, 'field', callback) - elseif ref.type == 'getglobal' then - -- _ENV.XXX - callback(ref, 'get') - if self:getSpecial(ref) == 's|_G' then - local parent = ref.parent + if key == guide.getKeyName(parent) then local tp = parent.type if tp == 'setfield' or tp == 'setmethod' @@ -71,20 +57,29 @@ function m:field(source, key, callback) callback(parent, 'get') end end + elseif ref.type == 'setlocal' then + self:eachRef(ref.value, 'field', callback) + elseif ref.type == 'getglobal' then + -- _ENV.XXX + if key == guide.getKeyName(ref) then + callback(ref, 'get') + end elseif ref.type == 'setglobal' then -- _ENV.XXX = XXX - callback(ref, 'set') + if key == guide.getKeyName(ref) then + callback(ref, 'set') + end end end end - if source.tag == 'self' then - local method = source.method - local node = method.node - self:eachRef(node, 'field', callback) - end - if source.value then - self:eachField(source.value, nil, 'ref', callback) - end + --if source.tag == 'self' then + -- local method = source.method + -- local node = method.node + -- self:eachRef(node, 'field', callback) + --end + --if source.value then + -- self:eachField(source.value, nil, 'ref', callback) + --end end return m diff --git a/server-beta/test/definition/set.lua b/server-beta/test/definition/set.lua index be653baa..ca2c0828 100644 --- a/server-beta/test/definition/set.lua +++ b/server-beta/test/definition/set.lua @@ -44,12 +44,12 @@ TEST [[ print(<?x?>) ]] -TEST [[ -<!_G.x!> = 1 -print(<?x?>) -]] - -TEST [[ -<!rawset(_G, 'x', 1)!> -print(<?x?>) -]] +--TEST [[ +--<!_G.x!> = 1 +--print(<?x?>) +--]] +-- +--TEST [[ +--<!rawset(_G, 'x', 1)!> +--print(<?x?>) +--]] |