diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-11-20 21:57:09 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-11-20 21:57:09 +0800 |
commit | 4ca61ec457822dd14966afa0752340ae8ce180a1 (patch) | |
tree | ae8adb1ad82c717868e551e699fd3cf3bb290089 /script-beta/vm/getLinks.lua | |
parent | c63b2e404d8d2bb984afe3678a5ba2b2836380cc (diff) | |
download | lua-language-server-4ca61ec457822dd14966afa0752340ae8ce180a1.zip |
no longer beta
Diffstat (limited to 'script-beta/vm/getLinks.lua')
-rw-r--r-- | script-beta/vm/getLinks.lua | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/script-beta/vm/getLinks.lua b/script-beta/vm/getLinks.lua deleted file mode 100644 index 0bb1c6ff..00000000 --- a/script-beta/vm/getLinks.lua +++ /dev/null @@ -1,61 +0,0 @@ -local guide = require 'parser.guide' -local vm = require 'vm.vm' -local files = require 'files' - -local function getFileLinks(uri) - local ws = require 'workspace' - local links = {} - local ast = files.getAst(uri) - if not ast then - return links - end - guide.eachSpecialOf(ast.ast, 'require', function (source) - local call = source.parent - if not call or call.type ~= 'call' then - return - end - local args = call.args - if not args[1] or args[1].type ~= 'string' then - return - end - local uris = ws.findUrisByRequirePath(args[1][1]) - for _, u in ipairs(uris) do - u = files.asKey(u) - if not links[u] then - links[u] = {} - end - links[u][#links[u]+1] = call - end - end) - return links -end - -local function getLinksTo(uri) - uri = files.asKey(uri) - local links = {} - for u in files.eachFile() do - local ls = vm.getFileLinks(u) - if ls[uri] then - for _, l in ipairs(ls[uri]) do - links[#links+1] = l - end - end - end - return links -end - -function vm.getLinksTo(uri) - local cache = vm.getCache('getLinksTo')[uri] - if cache ~= nil then - return cache - end - cache = getLinksTo(uri) - vm.getCache('getLinksTo')[uri] = cache - return cache -end - -function vm.getFileLinks(uri) - local cache = files.getCache(uri) - cache.links = cache.links or getFileLinks(uri) - return cache.links -end |