diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-05-29 16:45:03 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-05-29 16:45:03 +0800 |
commit | bf15a6d9e9e3ea5e86596cd84ff4e3b4f12e29f9 (patch) | |
tree | db51d275388a273466190fca6d9e19771507286e /script-beta/parser/guide.lua | |
parent | 59afbeaed024d2610d4f514d9c1255e3394008c9 (diff) | |
download | lua-language-server-bf15a6d9e9e3ea5e86596cd84ff4e3b4f12e29f9.zip |
更新中
Diffstat (limited to 'script-beta/parser/guide.lua')
-rw-r--r-- | script-beta/parser/guide.lua | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua index 033ffde1..8f168543 100644 --- a/script-beta/parser/guide.lua +++ b/script-beta/parser/guide.lua @@ -994,7 +994,7 @@ function m.searchFields(status, obj, key) if not simple then return nil end - simple[2] = key and ('s|' .. key) or '*' + simple[#simple+1] = key and ('s|' .. key) or '*' m.searchSameFields(newStatus, simple, 'def') local results = newStatus.results m.cleanResults(results) @@ -1242,7 +1242,7 @@ end function m.searchSameFields(status, simple, mode) local first = simple.first - local fref = first.ref + local fref = first and first.ref local queue = {} if fref then for i = 1, #fref do @@ -1277,11 +1277,7 @@ function m.searchSameFields(status, simple, mode) end end -function m.searchRefsAsFunctionReturn(status, obj) - -- 只有 function 才搜索返回值引用 - if obj.type ~= 'function' then - return - end +function m.searchRefsAsFunctionReturn(status, obj, mode) status.results[#status.results+1] = obj -- 搜索所在函数 local currentFunc = m.getParentFunction(obj) @@ -1346,6 +1342,32 @@ function m.searchRefsAsFunctionReturn(status, obj) end end +function m.searchRefsAsFunctionSet(status, obj, mode) + local parent = obj.parent + if not parent then + return + end + if parent.type == 'local' + or parent.type == 'setlocal' + or parent.type == 'setglobal' + or parent.type == 'setfield' + or parent.type == 'setmethod' + or parent.type == 'setindex' + or parent.type == 'tableindex' + or parent.type == 'tablefield' then + m.searchRefs(status, parent, mode) + end +end + +function m.searchRefsAsFunction(status, obj, mode) + if obj.type ~= 'function' then + return + end + m.searchRefsAsFunctionSet(status, obj, mode) + -- 检查自己作为返回函数时的引用 + m.searchRefsAsFunctionReturn(status, obj, mode) +end + function m.cleanResults(results) local mark = {} for i = #results, 1, -1 do @@ -1406,8 +1428,7 @@ function m.requestReference(obj) -- 根据 field 搜索引用 m.searchRefs(status, obj, 'ref') - -- 检查自己作为返回函数时的引用 - m.searchRefsAsFunctionReturn(status, obj) + m.searchRefsAsFunction(status, obj, 'ref') return status.results end |