diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-01-05 15:15:23 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-01-05 15:15:23 +0800 |
commit | 586953c48638abf79c1855d9ba82f22bbcd6d448 (patch) | |
tree | bb912e0cfe74488d80439cfe64e53954a1e34979 /script/workspace/workspace.lua | |
parent | 8dc74fe9232e08f5263bbaab659dd1a8ab84ae50 (diff) | |
download | lua-language-server-586953c48638abf79c1855d9ba82f22bbcd6d448.zip |
improve getLinks
Diffstat (limited to 'script/workspace/workspace.lua')
-rw-r--r-- | script/workspace/workspace.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua index cb033582..f99092bc 100644 --- a/script/workspace/workspace.lua +++ b/script/workspace/workspace.lua @@ -300,9 +300,19 @@ function m.findUrisByFilePath(path) if type(path) ~= 'string' then return {} end + local lpath = path:lower():gsub('[/\\]+', '/') + local vm = require 'vm' + local resultCache = vm.getCache 'findUrisByRequirePath.result' + if resultCache[path] then + return resultCache[path].results, resultCache[path].posts + end + tracy.ZoneBeginN('findUrisByFilePath #1') local results = {} local posts = {} for uri in files.eachFile() do + if not uri:find(lpath, 1, true) then + goto CONTINUE + end local pathLen = #path local curPath = furi.decode(files.getOriginUri(uri)) local curLen = #curPath @@ -315,7 +325,13 @@ function m.findUrisByFilePath(path) posts[uri] = post:gsub('^[/\\]+', '') end end + ::CONTINUE:: end + tracy.ZoneEnd() + resultCache[path] = { + results = results, + posts = posts, + } return results, posts end @@ -325,6 +341,12 @@ function m.findUrisByRequirePath(path) if type(path) ~= 'string' then return {} end + local vm = require 'vm' + local cache = vm.getCache 'findUrisByRequirePath' + if cache[path] then + return cache[path].results, cache[path].searchers + end + tracy.ZoneBeginN('findUrisByRequirePath') local results = {} local mark = {} local searchers = {} @@ -350,6 +372,11 @@ function m.findUrisByRequirePath(path) end end end + tracy.ZoneEnd() + cache[path] = { + results = results, + searchers = searchers, + } return results, searchers end |