summaryrefslogtreecommitdiff
path: root/script/core/diagnostics/undefined-field.lua
diff options
context:
space:
mode:
Diffstat (limited to 'script/core/diagnostics/undefined-field.lua')
-rw-r--r--script/core/diagnostics/undefined-field.lua17
1 files changed, 14 insertions, 3 deletions
diff --git a/script/core/diagnostics/undefined-field.lua b/script/core/diagnostics/undefined-field.lua
index 31bd9008..ffa70364 100644
--- a/script/core/diagnostics/undefined-field.lua
+++ b/script/core/diagnostics/undefined-field.lua
@@ -11,10 +11,19 @@ return function (uri, callback)
return
end
+ local cache = vm.getCache 'undefined-field'
+
local function getAllDocClassFromInfer(src)
- tracy.ZoneBeginN('undefined-field getInfers')
- local infers = vm.getInfers(src, 0)
- tracy.ZoneEnd()
+ local infers = cache[src]
+ if cache[src] == nil then
+ tracy.ZoneBeginN('undefined-field getInfers')
+ infers = vm.getInfers(src, 0) or false
+ local refs = vm.getRefs(src, 0)
+ for _, ref in ipairs(refs) do
+ cache[ref] = infers
+ end
+ tracy.ZoneEnd()
+ end
if not infers then
return nil
@@ -55,7 +64,9 @@ return function (uri, callback)
local fields = {}
local empty = true
for _, docClass in ipairs(allDocClass) do
+ tracy.ZoneBeginN('undefined-field getDefFields')
local refs = vm.getDefFields(docClass)
+ tracy.ZoneEnd()
for _, ref in ipairs(refs) do
local name = vm.getKeyName(ref)