summaryrefslogtreecommitdiff
path: root/server-beta/src/searcher/getLibrary.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-11-20 11:00:32 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-11-20 11:00:32 +0800
commit03a56a63e1c943e985b73082be34749a3bd5533b (patch)
tree543dcf81e70b0ff429dcd7415f811ae803f994ab /server-beta/src/searcher/getLibrary.lua
parent2c90cf1b7b1fce9095f95bc54ed33680c848bfbe (diff)
downloadlua-language-server-03a56a63e1c943e985b73082be34749a3bd5533b.zip
searcher太难拼了,我们还是叫vm吧
Diffstat (limited to 'server-beta/src/searcher/getLibrary.lua')
-rw-r--r--server-beta/src/searcher/getLibrary.lua60
1 files changed, 0 insertions, 60 deletions
diff --git a/server-beta/src/searcher/getLibrary.lua b/server-beta/src/searcher/getLibrary.lua
deleted file mode 100644
index a2620295..00000000
--- a/server-beta/src/searcher/getLibrary.lua
+++ /dev/null
@@ -1,60 +0,0 @@
-local searcher = require 'searcher.searcher'
-local library = require 'library'
-local guide = require 'parser.guide'
-
-local function checkStdLibrary(source)
- local globalName = searcher.getGlobal(source)
- if not globalName then
- return nil
- end
- local name = globalName:match '^s|(.+)$'
- if library.global[name] then
- return library.global[name]
- end
-end
-
-local function getLibrary(source)
- local lib = checkStdLibrary(source)
- if lib then
- return lib
- end
- return searcher.eachRef(source, function (info)
- local src = info.source
- if src.type ~= 'getfield'
- and src.type ~= 'getmethod'
- and src.type ~= 'getindex' then
- return
- end
- local node = src.node
- local nodeGlobalName = searcher.getGlobal(node)
- if not nodeGlobalName then
- return
- end
- local nodeName = nodeGlobalName:match '^s|(.+)$'
- local nodeLib = library.global[nodeName]
- if not nodeLib then
- return
- end
- if not nodeLib.child then
- return
- end
- local key = guide.getKeyString(src)
- local defLib = nodeLib.child[key]
- return defLib
- end)
-end
-
-function searcher.getLibrary(source)
- local cache = searcher.cache.getLibrary[source]
- if cache ~= nil then
- return cache
- end
- local unlock = searcher.lock('getLibrary', source)
- if not unlock then
- return
- end
- cache = getLibrary(source) or false
- searcher.cache.getLibrary[source] = cache
- unlock()
- return cache
-end