summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-04-27 15:51:51 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-04-27 15:51:51 +0800
commitc88ea6274f90bad38db2383e67121c2ae48c7970 (patch)
tree604b0cdaf00153a79f920dd67d504a0d43951b7b /script
parentb8ec5ae4fa6eed01bd093f39cd76f01d315f330a (diff)
downloadlua-language-server-c88ea6274f90bad38db2383e67121c2ae48c7970.zip
support `T`
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