summaryrefslogtreecommitdiff
path: root/script-beta/parser/guide.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-10-31 17:02:25 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-10-31 17:02:25 +0800
commit02307701cf666dd884b497654b94b0f71f1f812e (patch)
tree84a40135001a825ca5d6f7071df18820f439033a /script-beta/parser/guide.lua
parent09e873bf25f1dbaccd97d4fe7f608dde1fe68028 (diff)
downloadlua-language-server-02307701cf666dd884b497654b94b0f71f1f812e.zip
支持 doc.field
Diffstat (limited to 'script-beta/parser/guide.lua')
-rw-r--r--script-beta/parser/guide.lua49
1 files changed, 39 insertions, 10 deletions
diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua
index 7974f325..77d43e55 100644
--- a/script-beta/parser/guide.lua
+++ b/script-beta/parser/guide.lua
@@ -698,6 +698,8 @@ function m.getName(obj)
return obj.class[1]
elseif tp == 'doc.alias' then
return obj.alias[1]
+ elseif tp == 'doc.field' then
+ return obj.field[1]
end
return m.getNameOfLiteral(obj)
end
@@ -765,6 +767,12 @@ function m.getKeyName(obj)
elseif tp == 'field'
or tp == 'method' then
return 's|' .. obj[1]
+ elseif tp == 'doc.class' then
+ return 's|' .. obj.class[1]
+ elseif tp == 'doc.alias' then
+ return 's|' .. obj.alias[1]
+ elseif tp == 'doc.field' then
+ return 's|' .. obj.field[1]
end
return m.getKeyNameOfLiteral(obj)
end
@@ -1313,8 +1321,10 @@ function m.searchFields(status, obj, key, interface, deep)
return results
elseif obj.type == 'library' then
local results = {}
- for i = 1, #obj.fields do
- results[i] = obj.fields[i]
+ if obj.fields then
+ for i = 1, #obj.fields do
+ results[i] = obj.fields[i]
+ end
end
return results
else
@@ -1464,6 +1474,8 @@ function m.checkSameSimpleByBindDocs(status, obj, start, queue, mode)
end
elseif doc.type == 'doc.overload' then
results[#results+1] = doc.overload
+ elseif doc.type == 'doc.field' then
+ results[#results+1] = doc
end
end
local mark = {}
@@ -1481,11 +1493,18 @@ function m.checkSameSimpleByBindDocs(status, obj, start, queue, mode)
end
end
end
- queue[#queue+1] = {
- obj = res,
- start = start,
- force = true,
- }
+ if res.type == 'doc.type.function' then
+ queue[#queue+1] = {
+ obj = res,
+ start = start,
+ force = true,
+ }
+ elseif res.type == 'doc.field' then
+ queue[#queue+1] = {
+ obj = res,
+ start = start + 1,
+ }
+ end
end
for _, res in ipairs(newStatus.results) do
queue[#queue+1] = {
@@ -1877,7 +1896,8 @@ function m.pushResult(status, mode, ref, simple)
results[#results+1] = ref
elseif ref.type == 'library' then
results[#results+1] = ref
- elseif ref.type == 'doc.type.function' then
+ elseif ref.type == 'doc.type.function'
+ or ref.type == 'doc.field' then
results[#results+1] = ref
end
if ref.parent and ref.parent.type == 'return' then
@@ -1914,7 +1934,8 @@ function m.pushResult(status, mode, ref, simple)
end
elseif ref.type == 'library' then
results[#results+1] = ref
- elseif ref.type == 'doc.type.function' then
+ elseif ref.type == 'doc.type.function'
+ or ref.type == 'doc.field' then
results[#results+1] = ref
end
if ref.parent and ref.parent.type == 'return' then
@@ -1946,7 +1967,8 @@ function m.pushResult(status, mode, ref, simple)
end
elseif ref.type == 'library' then
results[#results+1] = ref
- elseif ref.type == 'doc.type.function' then
+ elseif ref.type == 'doc.type.function'
+ or ref.type == 'doc.field' then
results[#results+1] = ref
end
end
@@ -2614,6 +2636,13 @@ function m.inferCheckDoc(status, source)
end
return true
end
+ if source.type == 'doc.field' then
+ local results = m.getDocTypeNames(source.extends)
+ for _, res in ipairs(results) do
+ status.results[#status.results+1] = res
+ end
+ return true
+ end
end
function m.getVarargDocType(source)