summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-06-07 21:27:45 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-06-07 21:27:45 +0800
commit680e6c9848a6e5f43ccce11561ec98839822bdea (patch)
tree829e587428002e9fdd3f82364c39490d2c3f0c24 /script/core
parent5762f1bdc412a128489f0ad27124193fedfb13e9 (diff)
downloadlua-language-server-680e6c9848a6e5f43ccce11561ec98839822bdea.zip
cleanup
Diffstat (limited to 'script/core')
-rw-r--r--script/core/completion/completion.lua3
-rw-r--r--script/core/diagnostics/deprecated.lua2
-rw-r--r--script/core/diagnostics/init.lua4
-rw-r--r--script/core/diagnostics/lowercase-global.lua6
-rw-r--r--script/core/diagnostics/undefined-global.lua3
5 files changed, 10 insertions, 8 deletions
diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua
index d4c20c60..d2d0a040 100644
--- a/script/core/completion/completion.lua
+++ b/script/core/completion/completion.lua
@@ -356,6 +356,7 @@ local function checkModule(state, word, position, results)
if not config.get(state.uri, 'Lua.completion.autoRequire') then
return
end
+ local globals = util.arrayToHash(config.get(state.uri, 'Lua.diagnostics.globals'))
local locals = guide.getVisibleLocals(state.ast, position)
for uri in files.eachFile(state.uri) do
if uri == guide.getUri(state.ast) then
@@ -366,7 +367,7 @@ local function checkModule(state, word, position, results)
local stemName = fileName:gsub('%..+', '')
if not locals[stemName]
and not vm.hasGlobalSets(state.uri, 'variable', stemName)
- and not config.get(state.uri, 'Lua.diagnostics.globals')[stemName]
+ and not globals[stemName]
and stemName:match '^[%a_][%w_]*$'
and matchKey(word, stemName) then
local targetState = files.getState(uri)
diff --git a/script/core/diagnostics/deprecated.lua b/script/core/diagnostics/deprecated.lua
index 27920c43..85ae2d19 100644
--- a/script/core/diagnostics/deprecated.lua
+++ b/script/core/diagnostics/deprecated.lua
@@ -15,7 +15,7 @@ return function (uri, callback)
return
end
- local dglobals = config.get(uri, 'Lua.diagnostics.globals')
+ local dglobals = util.arrayToHash(config.get(uri, 'Lua.diagnostics.globals'))
local rspecial = config.get(uri, 'Lua.runtime.special')
guide.eachSourceTypes(ast.ast, types, function (src) ---@async
diff --git a/script/core/diagnostics/init.lua b/script/core/diagnostics/init.lua
index b4ae3715..a2eb2482 100644
--- a/script/core/diagnostics/init.lua
+++ b/script/core/diagnostics/init.lua
@@ -3,6 +3,7 @@ local define = require 'proto.define'
local config = require 'config'
local await = require 'await'
local vm = require "vm.vm"
+local util = require 'utility'
-- 把耗时最长的诊断放到最后面
local diagSort = {
@@ -52,7 +53,8 @@ end
---@param isScopeDiag boolean
---@param response async fun(result: any)
local function check(uri, name, isScopeDiag, response)
- if config.get(uri, 'Lua.diagnostics.disable')[name] then
+ local disables = config.get(uri, 'Lua.diagnostics.disable')
+ if util.arrayHas(disables, name) then
return
end
local level = config.get(uri, 'Lua.diagnostics.severity')[name]
diff --git a/script/core/diagnostics/lowercase-global.lua b/script/core/diagnostics/lowercase-global.lua
index d03e8c70..68bec234 100644
--- a/script/core/diagnostics/lowercase-global.lua
+++ b/script/core/diagnostics/lowercase-global.lua
@@ -3,6 +3,7 @@ local guide = require 'parser.guide'
local lang = require 'language'
local config = require 'config'
local vm = require 'vm'
+local util = require 'utility'
local function isDocClass(source)
if not source.bindDocs then
@@ -23,10 +24,7 @@ return function (uri, callback)
return
end
- local definedGlobal = {}
- for name in pairs(config.get(uri, 'Lua.diagnostics.globals')) do
- definedGlobal[name] = true
- end
+ local definedGlobal = util.arrayToHash(config.get(uri, 'Lua.diagnostics.globals'))
guide.eachSourceType(ast.ast, 'setglobal', function (source)
local name = guide.getKeyName(source)
diff --git a/script/core/diagnostics/undefined-global.lua b/script/core/diagnostics/undefined-global.lua
index bd0aae69..7804aeee 100644
--- a/script/core/diagnostics/undefined-global.lua
+++ b/script/core/diagnostics/undefined-global.lua
@@ -4,6 +4,7 @@ local lang = require 'language'
local config = require 'config'
local guide = require 'parser.guide'
local await = require 'await'
+local util = require 'utility'
local requireLike = {
['include'] = true,
@@ -19,7 +20,7 @@ return function (uri, callback)
return
end
- local dglobals = config.get(uri, 'Lua.diagnostics.globals')
+ local dglobals = util.arrayToHash(config.get(uri, 'Lua.diagnostics.globals'))
local rspecial = config.get(uri, 'Lua.runtime.special')
local cache = {}