summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
Diffstat (limited to 'script')
-rw-r--r--script/core/searcher.lua18
-rw-r--r--script/parser/guide.lua2
-rw-r--r--script/parser/luadoc.lua13
3 files changed, 17 insertions, 16 deletions
diff --git a/script/core/searcher.lua b/script/core/searcher.lua
index 75437497..abfcf059 100644
--- a/script/core/searcher.lua
+++ b/script/core/searcher.lua
@@ -254,11 +254,21 @@ function m.searchRefsByID(status, uri, expect, mode)
local generics = source.typeGeneric[key]
if generics then
for _, docName in ipairs(generics) do
- local docType = docName.parent
-- @param T
- if docType.paramIndex then
- local paramID = linker.getID(callinfo.args[docType.paramIndex])
- searchID(paramID, field)
+ local docType = docName.parent
+ local param = callinfo.args[docType.paramIndex]
+ if param then
+ if docName.literal then
+ -- @param `T`
+ if param.type == 'string' and param[1] then
+ local paramID = 'dn:' .. param[1]
+ searchID(paramID, field)
+ end
+ else
+ local paramID = linker.getID(param)
+ searchID(paramID, field)
+ end
+ return
end
end
end
diff --git a/script/parser/guide.lua b/script/parser/guide.lua
index 46c32f3a..f07a966e 100644
--- a/script/parser/guide.lua
+++ b/script/parser/guide.lua
@@ -102,7 +102,7 @@ m.childMap = {
['doc.type.array'] = {'node'},
['doc.type.table'] = {'node', 'key', 'value', 'comment'},
['doc.type.function'] = {'#args', '#returns', 'comment'},
- ['doc.type.typeliteral'] = {'node'},
+ ['doc.type.literal'] = {'node'},
['doc.type.arg'] = {'extends'},
['doc.overload'] = {'overload', 'comment'},
['doc.see'] = {'name', 'field'},
diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua
index 57f3b42a..31a6af48 100644
--- a/script/parser/luadoc.lua
+++ b/script/parser/luadoc.lua
@@ -483,13 +483,7 @@ function parseType(parent)
break
end
-- TypeLiteral,指代类型的字面值。比如,对于类 Cat 来说,它的 TypeLiteral 是 "Cat"
- typeLiteral = {
- type = 'doc.type.typeliteral',
- parent = result,
- start = getStart(),
- finish = nil,
- node = nil,
- }
+ typeLiteral = true
end
if tp == 'name' then
@@ -500,10 +494,7 @@ function parseType(parent)
end
if typeLiteral then
nextToken()
- typeLiteral.finish = getFinish()
- typeLiteral.node = typeUnit
- typeUnit.parent = typeLiteral
- typeUnit = typeLiteral
+ typeUnit.literal = true
end
result.types[#result.types+1] = typeUnit
if not result.start then