diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-09-02 16:07:27 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-09-02 16:07:27 +0800 |
commit | c3f6547cc5c9eeec715138614469ca9c32f77730 (patch) | |
tree | 20758f5159bef535f12dfa96fa7ce5665dd3fb14 /script/doctor.lua | |
parent | ec0ce17b00e04cfae2409e3143f2dab377863160 (diff) | |
download | lua-language-server-c3f6547cc5c9eeec715138614469ca9c32f77730.zip |
update doctor
Diffstat (limited to 'script/doctor.lua')
-rw-r--r-- | script/doctor.lua | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/script/doctor.lua b/script/doctor.lua index e1044689..914706a8 100644 --- a/script/doctor.lua +++ b/script/doctor.lua @@ -161,6 +161,9 @@ local function private(o) end local m = private {} + +m._ignoreMainThread = true + --- 获取内存快照,生成一个内部数据结构。 --- 一般不用这个API,改用 report 或 catch。 ---@return table @@ -191,7 +194,6 @@ m.snapshot = private(function () local find local mark = private {} - local function findTable(t, result) result = result or {} local mt = getmetatable(t) @@ -211,21 +213,45 @@ m.snapshot = private(function () if not wk then local keyInfo = find(k) if keyInfo then - result[#result+1] = private { - type = 'key', - name = formatName(k), - info = keyInfo, - } + if wv then + find(v) + local valueResults = mark[v] + if valueResults then + valueResults[#valueResults+1] = private { + type = 'weakvalue-key', + name = formatName(t) .. '|' .. formatName(v), + info = keyInfo, + } + end + else + result[#result+1] = private { + type = 'key', + name = formatName(k), + info = keyInfo, + } + end end end if not wv then local valueInfo = find(v) if valueInfo then - result[#result+1] = private { - type = 'field', - name = formatName(k) .. '|' .. formatName(v), - info = valueInfo, - } + if wk then + find(k) + local keyResults = mark[k] + if keyResults then + keyResults[#keyResults+1] = private { + type = 'weakkey-field', + name = formatName(t) .. '|' .. formatName(k), + info = valueInfo, + } + end + else + result[#result+1] = private { + type = 'field', + name = formatName(k) .. '|' .. formatName(v), + info = valueInfo, + } + end end end end |