summaryrefslogtreecommitdiff
path: root/server-beta
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-11-16 00:00:11 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-11-16 00:00:11 +0800
commit58bd9dd99cf6f927a318085255e4e18b533eab0d (patch)
treef8256cbb562959b8647860c8c961f17a1d5a389c /server-beta
parentf4fcddfa8805848b7ce7c58188cca711fc429c3b (diff)
downloadlua-language-server-58bd9dd99cf6f927a318085255e4e18b533eab0d.zip
修改 getLibrary 的实现
Diffstat (limited to 'server-beta')
-rw-r--r--server-beta/src/searcher/getGlobal.lua6
-rw-r--r--server-beta/src/searcher/getGlobals.lua2
-rw-r--r--server-beta/src/searcher/getLibrary.lua13
-rw-r--r--server-beta/src/searcher/init.lua2
-rw-r--r--server-beta/src/searcher/isGlobal.lua7
-rw-r--r--server-beta/src/searcher/searcher.lua2
6 files changed, 14 insertions, 18 deletions
diff --git a/server-beta/src/searcher/getGlobal.lua b/server-beta/src/searcher/getGlobal.lua
new file mode 100644
index 00000000..226f2473
--- /dev/null
+++ b/server-beta/src/searcher/getGlobal.lua
@@ -0,0 +1,6 @@
+local searcher = require 'searcher.searcher'
+
+function searcher.getGlobal(source)
+ searcher.getGlobals(source)
+ return searcher.cache.getGlobal[source]
+end
diff --git a/server-beta/src/searcher/getGlobals.lua b/server-beta/src/searcher/getGlobals.lua
index ea6a6f6c..13e69e16 100644
--- a/server-beta/src/searcher/getGlobals.lua
+++ b/server-beta/src/searcher/getGlobals.lua
@@ -23,7 +23,7 @@ local function getGlobals(root)
end
cache[name][#cache[name]+1] = info
cache[name].mode[info.mode] = true
- searcher.cache.isGlobal[src] = true
+ searcher.cache.getGlobal[src] = name
end)
return cache
end
diff --git a/server-beta/src/searcher/getLibrary.lua b/server-beta/src/searcher/getLibrary.lua
index 062c8937..afedde64 100644
--- a/server-beta/src/searcher/getLibrary.lua
+++ b/server-beta/src/searcher/getLibrary.lua
@@ -3,16 +3,13 @@ local guide = require 'parser.guide'
local library = require 'library'
local function getLibrary(source)
- local name = guide.getKeyName(source)
- if not name then
+ local globalName = searcher.getGlobal(source)
+ if not globalName then
return nil
end
- local sname = name:match '^s|(.+)$'
- if not sname then
- return nil
- end
- if searcher.isGlobal(source) then
- return library.global[sname]
+ local name = globalName:match '^s|(.+)$'
+ if library.global[name] then
+ return library.global[name]
end
return nil
end
diff --git a/server-beta/src/searcher/init.lua b/server-beta/src/searcher/init.lua
index a0e61999..6ec7bc99 100644
--- a/server-beta/src/searcher/init.lua
+++ b/server-beta/src/searcher/init.lua
@@ -4,6 +4,6 @@ require 'searcher.eachRef'
require 'searcher.eachDef'
require 'searcher.getGlobals'
require 'searcher.getLinks'
-require 'searcher.isGlobal'
+require 'searcher.getGlobal'
require 'searcher.getLibrary'
return searcher
diff --git a/server-beta/src/searcher/isGlobal.lua b/server-beta/src/searcher/isGlobal.lua
deleted file mode 100644
index 8c59dadb..00000000
--- a/server-beta/src/searcher/isGlobal.lua
+++ /dev/null
@@ -1,7 +0,0 @@
-local searcher = require 'searcher.searcher'
-local guide = require 'parser.guide'
-
-function searcher.isGlobal(source)
- local globals = searcher.getGlobals(source)
- return searcher.cache.isGlobal[source] == true
-end
diff --git a/server-beta/src/searcher/searcher.lua b/server-beta/src/searcher/searcher.lua
index c6038f89..19e114d6 100644
--- a/server-beta/src/searcher/searcher.lua
+++ b/server-beta/src/searcher/searcher.lua
@@ -61,7 +61,7 @@ function m.refreshCache()
eachField = {},
getGlobals = {},
getLinks = {},
- isGlobal = {},
+ getGlobal = {},
specialName = {},
getLibrary = {},
specials = nil,