diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-09-25 17:42:54 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-09-25 17:42:54 +0800 |
commit | 3036d9d81a5771665e27b1bfe06662d163155b22 (patch) | |
tree | 48062c66c0f7eff3660461d76a0e140ad8bccedc /server-beta/src/core | |
parent | c08ce9af7a35be058aafabcb5dd88748aae75282 (diff) | |
download | lua-language-server-3036d9d81a5771665e27b1bfe06662d163155b22.zip |
暂存
Diffstat (limited to 'server-beta/src/core')
-rw-r--r-- | server-beta/src/core/definition.lua | 12 | ||||
-rw-r--r-- | server-beta/src/core/engineer.lua | 21 |
2 files changed, 31 insertions, 2 deletions
diff --git a/server-beta/src/core/definition.lua b/server-beta/src/core/definition.lua index b15519bd..6724ca89 100644 --- a/server-beta/src/core/definition.lua +++ b/server-beta/src/core/definition.lua @@ -19,18 +19,23 @@ function m.search(state, ast, source) end function m.aslocal(state, ast, source) - engineer(ast):eachLocalRef(source, function (src, mode) + local searcher = engineer(ast) + searcher:eachLocalRef(source, function (src, mode) if mode == 'local' or mode == 'set' then state.callback(src) end end) + searcher:eachClass(source, function (src) + state.callback(src) + end) end m.asgetlocal = m.aslocal m.assetlocal = m.aslocal function m.globals(state, ast, source) - engineer(ast):eachGloablOfName(source[1], function (src, mode) + local searcher = engineer(ast) + searcher:eachGloablOfName(source[1], function (src, mode) if mode == 'set' then state.callback(src) end @@ -47,6 +52,9 @@ return function (ast, text, offset) cache = {}, } function state.callback(target, uri) + if target.start == 0 then + return + end results[#results+1] = { uri = uri or ast.uri, source = state.source, diff --git a/server-beta/src/core/engineer.lua b/server-beta/src/core/engineer.lua index c82efa6d..a093a90a 100644 --- a/server-beta/src/core/engineer.lua +++ b/server-beta/src/core/engineer.lua @@ -87,6 +87,10 @@ function mt:isGlobal(obj) if obj.type == 'getfield' then return self:call('isGlobalField', obj) end + if obj.type == 'call' then + local d = self:call('asRawGet', obj) + return not not d + end return false end @@ -218,6 +222,23 @@ function mt:eachLocalRef(obj, callback) end end +--- 遍历class +function mt:eachClass(obj, callback) + local root = self.ast.root + if obj.type == 'setlocal' or obj.type == 'getlocal' then + local loc = root[obj.loc] + local setmethod = root[loc.method] + if setmethod then + local node = root[setmethod.node] + self:call('eachLocalRef', node, function (src, mode) + if mode == 'local' or mode == 'set' then + callback(src) + end + end) + end + end +end + return function (ast) local self = setmetatable({ step = 0, |