diff options
Diffstat (limited to 'server-beta')
-rw-r--r-- | server-beta/src/searcher/eachRef.lua | 26 | ||||
-rw-r--r-- | server-beta/test/crossfile/definition.lua | 70 |
2 files changed, 45 insertions, 51 deletions
diff --git a/server-beta/src/searcher/eachRef.lua b/server-beta/src/searcher/eachRef.lua index d4c1192f..48c266bc 100644 --- a/server-beta/src/searcher/eachRef.lua +++ b/server-beta/src/searcher/eachRef.lua @@ -49,10 +49,13 @@ local function ofSpecialCall(call, func, index, callback) local literal = guide.getLiteral(args[1]) if type(literal) == 'string' then local result = workspace.findUrisByRequirePath(literal, true) + local myUri = guide.getRoot(call).uri for _, uri in ipairs(result) do - local ast = files.getAst(uri) - if ast then - searcher.eachRef(ast.ast, callback) + if uri ~= myUri then + local ast = files.getAst(uri) + if ast then + searcher.eachRef(ast.ast, callback) + end end end end @@ -212,13 +215,14 @@ local function ofLocal(loc, callback) end end -local function eachGlobalInWorkSpace(name, callback) +local function ofGlobal(source, callback) + local key = guide.getKeyName(source) for uri in files.eachFile() do local globals = files.getGlobals(uri) local ast = files.getAst(uri) - if ast and globals and globals[name] then + if ast and globals and globals[key] then searcher.eachGlobal(ast.ast, function (info) - if name == info.key then + if key == info.key then callback(info) if info.value then ofValue(info.value, callback) @@ -229,16 +233,6 @@ local function eachGlobalInWorkSpace(name, callback) end end -local function ofGlobal(source, callback) - local key = guide.getKeyName(source) - eachGlobalInWorkSpace(key, function (info) - callback(info) - if info.value then - ofValue(info.value, callback) - end - end) -end - local function ofField(source, callback) local parent = source.parent local node = parent.node diff --git a/server-beta/test/crossfile/definition.lua b/server-beta/test/crossfile/definition.lua index d09f22af..f218bf69 100644 --- a/server-beta/test/crossfile/definition.lua +++ b/server-beta/test/crossfile/definition.lua @@ -345,7 +345,7 @@ TEST { content = [[ local function <!f!>() end - return f + return <!f!> ]] }, { @@ -380,38 +380,38 @@ TEST { } } -TEST { - { - path = 'a.lua', - content = [[ - ---@class Class - local <!obj!> - ]] - }, - { - path = 'b.lua', - content = [[ - ---@type Class - local <!obj!> - <?obj?> - ]] - }, -} +--TEST { +-- { +-- path = 'a.lua', +-- content = [[ +-- ---@class Class +-- local <!obj!> +-- ]] +-- }, +-- { +-- path = 'b.lua', +-- content = [[ +-- ---@type Class +-- local <!obj!> +-- <?obj?> +-- ]] +-- }, +--} -TEST { - { - path = 'a.lua', - content = [[ - ---@type Class - local <!obj!> - <?obj?> - ]] - }, - { - path = 'b.lua', - content = [[ - ---@class Class - local <!obj!> - ]] - }, -} +--TEST { +-- { +-- path = 'a.lua', +-- content = [[ +-- ---@type Class +-- local <!obj!> +-- <?obj?> +-- ]] +-- }, +-- { +-- path = 'b.lua', +-- content = [[ +-- ---@class Class +-- local <!obj!> +-- ]] +-- }, +--} |