summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
Diffstat (limited to 'script')
-rw-r--r--script/core/completion/completion.lua8
-rw-r--r--script/files.lua12
-rw-r--r--script/provider/diagnostic.lua2
-rw-r--r--script/vm/getLinks.lua2
-rw-r--r--script/workspace/require-path.lua2
5 files changed, 14 insertions, 12 deletions
diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua
index b65ee0d8..16cecd04 100644
--- a/script/core/completion/completion.lua
+++ b/script/core/completion/completion.lua
@@ -328,7 +328,7 @@ local function checkModule(state, word, position, results)
return
end
local locals = guide.getVisibleLocals(state.ast, position)
- for uri in files.eachFile() do
+ for uri in files.eachFile(state.uri) do
if uri == guide.getUri(state.ast) then
goto CONTINUE
end
@@ -647,7 +647,7 @@ local function checkCommon(state, word, position, results)
end
if config.get(state.uri, 'Lua.completion.workspaceWord') and #word >= 2 then
local myHead = word:sub(1, 2)
- for uri in files.eachFile() do
+ for uri in files.eachFile(state.uri) do
if #results >= 100 then
results.incomplete = true
break
@@ -880,7 +880,7 @@ end
local function collectRequireNames(mode, myUri, literal, source, smark, position, results)
local collect = {}
if mode == 'require' then
- for uri in files.eachFile() do
+ for uri in files.eachFile(myUri) do
if myUri == uri then
goto CONTINUE
end
@@ -934,7 +934,7 @@ local function collectRequireNames(mode, myUri, literal, source, smark, position
end
end
else
- for uri in files.eachFile() do
+ for uri in files.eachFile(myUri) do
if myUri == uri then
goto CONTINUE
end
diff --git a/script/files.lua b/script/files.lua
index 10b02b2d..5cddcf09 100644
--- a/script/files.lua
+++ b/script/files.lua
@@ -362,7 +362,7 @@ end
function m.getChildFiles(uri)
local results = {}
- local uris = m.getAllUris()
+ local uris = m.getAllUris(uri)
for _, curi in ipairs(uris) do
if #curi > #uri
and curi:sub(1, #uri) == uri
@@ -415,9 +415,10 @@ function m.remove(uri)
end
--- 获取一个包含所有文件uri的数组
----@param scp? scope
+---@param suri? uri
---@return uri[]
-function m.getAllUris(scp)
+function m.getAllUris(suri)
+ local scp = suri and scope.getScope(suri) or nil
local files = {}
local i = 0
for uri in pairs(m.fileMap) do
@@ -432,8 +433,9 @@ function m.getAllUris(scp)
end
--- 遍历文件
-function m.eachFile()
- local files = m.getAllUris()
+---@param suri? uri
+function m.eachFile(suri)
+ local files = m.getAllUris(suri)
local i = 0
return function ()
i = i + 1
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua
index 7b5993a2..f0967af2 100644
--- a/script/provider/diagnostic.lua
+++ b/script/provider/diagnostic.lua
@@ -371,7 +371,7 @@ function m.diagnosticsScope(uri, force)
askForDisable(uri)
end)
end)
- local uris = files.getAllUris(scp)
+ local uris = files.getAllUris(uri)
log.info(('diagnostics scope [%s], files count:[%d]'):format(scp:getName(), #uris))
for i, uri in ipairs(uris) do
while loading.count() > 0 do
diff --git a/script/vm/getLinks.lua b/script/vm/getLinks.lua
index 7fe31e5e..8571fb46 100644
--- a/script/vm/getLinks.lua
+++ b/script/vm/getLinks.lua
@@ -40,7 +40,7 @@ end
local function getLinksTo(uri)
local links = {}
- for u in files.eachFile() do
+ for u in files.eachFile(uri) do
local ls = getFileLinksOrCache(u)
if ls[uri] then
for _, l in ipairs(ls[uri]) do
diff --git a/script/workspace/require-path.lua b/script/workspace/require-path.lua
index 915d0c1e..d0d96164 100644
--- a/script/workspace/require-path.lua
+++ b/script/workspace/require-path.lua
@@ -159,7 +159,7 @@ function m.flush(suri)
if clt then
clt:dropAll()
end
- for uri in files.eachFile() do
+ for uri in files.eachFile(suri) do
m.getVisiblePath(scp.uri, furi.decode(uri))
end
end