summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--meta/template/debug.lua24
-rw-r--r--script-beta/core/hover/description.lua20
-rw-r--r--script-beta/parser/guide.lua10
-rw-r--r--script-beta/parser/luadoc.lua6
4 files changed, 41 insertions, 19 deletions
diff --git a/meta/template/debug.lua b/meta/template/debug.lua
index 1c3ab867..94b9af49 100644
--- a/meta/template/debug.lua
+++ b/meta/template/debug.lua
@@ -34,14 +34,14 @@ function debug.getfenv(o) end
function debug.gethook(co) end
---@alias infowhat string
----| '"n"' # `name` 和 `namewhat`
----| '"S"' # `source`,`short_src`,`linedefined`,`lastlinedefined`,和 `what`
----| '"l"' # `currentline`
----| '"t"' # `istailcall`
----| '"u"' # `nups`,`nparams` 和 `isvararg`
----| '"f"' # `func`
----| '"r"' # `ftransfer` 和 `ntransfer`
----| '"L"' # `activelines`
+---|+'"n"' # `name` 和 `namewhat`
+---|+'"S"' # `source`,`short_src`,`linedefined`,`lalinedefined`,和 `what`
+---|+'"l"' # `currentline`
+---|+'"t"' # `istailcall`
+---|+'"u"' # `nups`,`nparams` 和 `isvararg`
+---|+'"f"' # `func`
+---|+'"r"' # `ftransfer` 和 `ntransfer`
+---|+'"L"' # `activelines`
---@overload fun(f: integer|function, what: infowhat?):debuginfo
---@param thread thread
@@ -88,10 +88,10 @@ function debug.setcstacklimit(limit) end
---@return T object
function debug.setfenv(object, env) end
----@alias hookmask
----| '"c"'
----| '"r"'
----| '"l"'
+---@alias hookmask string
+---|+'"c"'
+---|+'"r"'
+---|+'"l"'
---@overload fun(hook: function, mask: hookmask, count: integer?)
---@param thread thread
diff --git a/script-beta/core/hover/description.lua b/script-beta/core/hover/description.lua
index 7ba1ca52..39cfb07b 100644
--- a/script-beta/core/hover/description.lua
+++ b/script-beta/core/hover/description.lua
@@ -210,7 +210,9 @@ local function buildEnumChunk(docType, name)
lines[#lines+1] = ('%s: %s'):format(name, table.concat(types))
for _, enum in ipairs(enums) do
lines[#lines+1] = (' %s %s%s'):format(
- enum.default and '->' or ' |',
+ (enum.default and '->')
+ or (enum.additional and '+>')
+ or ' |',
enum[1],
enum.comment and (' -- %s'):format(enum.comment) or ''
)
@@ -219,17 +221,29 @@ local function buildEnumChunk(docType, name)
end
local function getBindEnums(source)
+ local mark = {}
local chunks = {}
local returnIndex = 0
for _, doc in ipairs(source.bindDocs) do
if doc.type == 'doc.param' then
- chunks[#chunks+1] = buildEnumChunk(doc.extends, doc.param[1])
+ local name = doc.param[1]
+ if mark[name] then
+ goto CONTINUE
+ end
+ mark[name] = true
+ chunks[#chunks+1] = buildEnumChunk(doc.extends, name)
elseif doc.type == 'doc.return' then
for _, rtn in ipairs(doc.returns) do
returnIndex = returnIndex + 1
- chunks[#chunks+1] = buildEnumChunk(rtn, rtn.name and rtn.name[1] or ('(return %d)'):format(returnIndex))
+ local name = rtn.name and rtn.name[1] or ('(return %d)'):format(returnIndex)
+ if mark[name] then
+ goto CONTINUE
+ end
+ mark[name] = true
+ chunks[#chunks+1] = buildEnumChunk(rtn, name)
end
end
+ ::CONTINUE::
end
if #chunks == 0 then
return nil
diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua
index f4c226b8..ae71c15f 100644
--- a/script-beta/parser/guide.lua
+++ b/script-beta/parser/guide.lua
@@ -2766,10 +2766,12 @@ function m.getDocTypeNames(status, doc, genericCallback)
}
end
for _, resume in ipairs(doc.resumes) do
- results[#results+1] = {
- type = resume[1],
- source = resume,
- }
+ if not resume.additional then
+ results[#results+1] = {
+ type = resume[1],
+ source = resume,
+ }
+ end
end
return results
end
diff --git a/script-beta/parser/luadoc.lua b/script-beta/parser/luadoc.lua
index f88baa22..74acfaf2 100644
--- a/script-beta/parser/luadoc.lua
+++ b/script-beta/parser/luadoc.lua
@@ -54,6 +54,7 @@ Symbol <- ({} {
/ ')'
/ '?'
/ '...'
+ / '+'
} {})
-> Symbol
]], {
@@ -378,6 +379,11 @@ local function parseResume()
result.default = true
end
+ if checkToken('symbol', '+', 1) then
+ nextToken()
+ result.additional = true
+ end
+
local tp = peekToken()
if tp ~= 'string' then
pushError {