summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
Diffstat (limited to 'script')
-rw-r--r--script/core/collector.lua13
-rw-r--r--script/core/completion/completion.lua2
-rw-r--r--script/core/diagnostics/undefined-doc-name.lua2
-rw-r--r--script/core/diagnostics/undefined-global.lua2
-rw-r--r--script/progress.lua4
-rw-r--r--script/provider/diagnostic.lua4
-rw-r--r--script/vm/getDocs.lua4
-rw-r--r--script/vm/getGlobals.lua4
8 files changed, 14 insertions, 21 deletions
diff --git a/script/core/collector.lua b/script/core/collector.lua
index 1abfc51b..a2e3ca08 100644
--- a/script/core/collector.lua
+++ b/script/core/collector.lua
@@ -54,18 +54,15 @@ function mt:dropAll()
end
--- 是否包含某个名字的订阅
+---@param uri uri
---@param name string
---@return boolean
-function mt:has(name)
- local nameCollect = self.collect[name]
- if not nameCollect then
- return false
- end
- if next(nameCollect) == nil then
- self.collect[name] = nil
+function mt:has(uri, name)
+ if self:each(uri, name)() then
+ return true
+ else
return false
end
- return true
end
local DUMMY_FUNCTION = function () end
diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua
index 9eb33c2a..b65ee0d8 100644
--- a/script/core/completion/completion.lua
+++ b/script/core/completion/completion.lua
@@ -336,7 +336,7 @@ local function checkModule(state, word, position, results)
local fileName = path:match '[^/\\]*$'
local stemName = fileName:gsub('%..+', '')
if not locals[stemName]
- and not vm.hasGlobalSets(stemName)
+ and not vm.hasGlobalSets(state.uri, stemName)
and not config.get(state.uri, 'Lua.diagnostics.globals')[stemName]
and stemName:match '^[%a_][%w_]*$'
and matchKey(word, stemName) then
diff --git a/script/core/diagnostics/undefined-doc-name.lua b/script/core/diagnostics/undefined-doc-name.lua
index 91d4b90e..a8c75c3c 100644
--- a/script/core/diagnostics/undefined-doc-name.lua
+++ b/script/core/diagnostics/undefined-doc-name.lua
@@ -35,7 +35,7 @@ return function (uri, callback)
if name == '...' then
return
end
- if vm.isDocDefined(name)
+ if vm.isDocDefined(uri, name)
or hasNameOfGeneric(name, source) then
return
end
diff --git a/script/core/diagnostics/undefined-global.lua b/script/core/diagnostics/undefined-global.lua
index 5ac5106d..b570ca65 100644
--- a/script/core/diagnostics/undefined-global.lua
+++ b/script/core/diagnostics/undefined-global.lua
@@ -39,7 +39,7 @@ return function (uri, callback)
end
await.delay()
local id = 'def:' .. noder.getID(src)
- if not collector:has(id) then
+ if not collector:has(uri, id) then
local message = lang.script('DIAG_UNDEF_GLOBAL', key)
if requireLike[key:lower()] then
message = ('%s(%s)'):format(message, lang.script('DIAG_REQUIRE_LIKE', key))
diff --git a/script/progress.lua b/script/progress.lua
index 2e31f753..d5c174ce 100644
--- a/script/progress.lua
+++ b/script/progress.lua
@@ -43,8 +43,6 @@ function mt:remove()
})
--log.info('Remove progress:', token, self._title)
end
-
- log.info('Remove progress:', self._title, self._token)
end
---设置描述
@@ -160,8 +158,6 @@ function m.create(scp, title, delay)
m.map[prog._token] = prog
- log.info('Create progress:', title, prog._token)
-
return prog
end
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua
index 94e69838..0655b1c7 100644
--- a/script/provider/diagnostic.lua
+++ b/script/provider/diagnostic.lua
@@ -282,12 +282,12 @@ function m.refresh(uri)
end
await.close('diag:' .. uri)
await.call(function () ---@async
+ m.diagnosticsScope(uri)
if uri then
await.setID('diag:' .. uri)
await.sleep(0.1)
xpcall(m.doDiagnostic, log.error, uri)
end
- m.diagnosticsScope(uri)
end)
end
@@ -355,7 +355,7 @@ function m.diagnosticsScope(uri, force)
local id = 'diagnosticsScope:' .. scp:getName()
await.close(id)
await.call(function () ---@async
- await.sleep(math.max(delay, 0.1))
+ await.sleep(math.max(delay, 0.2))
while loading.count() > 0 do
await.sleep(1.0)
end
diff --git a/script/vm/getDocs.lua b/script/vm/getDocs.lua
index cfad021c..59651ee9 100644
--- a/script/vm/getDocs.lua
+++ b/script/vm/getDocs.lua
@@ -44,12 +44,12 @@ function vm.getDocDefines(uri, name)
return results
end
-function vm.isDocDefined(name)
+function vm.isDocDefined(uri, name)
if define.BuiltinType[name] then
return true
end
local id = 'def:dn:' .. name
- if collector:has(id) then
+ if collector:has(uri, id) then
return true
end
return false
diff --git a/script/vm/getGlobals.lua b/script/vm/getGlobals.lua
index b9ddedab..8af21d45 100644
--- a/script/vm/getGlobals.lua
+++ b/script/vm/getGlobals.lua
@@ -4,14 +4,14 @@ local guide = require 'parser.guide'
local vm = require 'vm.vm'
local noder = require 'core.noder'
-function vm.hasGlobalSets(name)
+function vm.hasGlobalSets(uri, name)
local id
if type(name) == 'string' then
id = ('def:g:%s%s'):format(noder.STRING_CHAR, name)
else
id = ('def:g:%s'):format(noder.STRING_CHAR, name)
end
- return collector:has(id)
+ return collector:has(uri, id)
end
function vm.getGlobalSets(uri, name)