summaryrefslogtreecommitdiff
path: root/script/parser/luadoc.lua
diff options
context:
space:
mode:
Diffstat (limited to 'script/parser/luadoc.lua')
-rw-r--r--script/parser/luadoc.lua36
1 files changed, 14 insertions, 22 deletions
diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua
index ae8e3f34..5f70a9e5 100644
--- a/script/parser/luadoc.lua
+++ b/script/parser/luadoc.lua
@@ -1,7 +1,7 @@
local m = require 'lpeglabel'
local re = require 'parser.relabel'
local lines = require 'parser.lines'
-local guide = require 'core.guide'
+local guide = require 'parser.guide'
local grammar = require 'parser.grammar'
local TokenTypes, TokenStarts, TokenFinishs, TokenContents
@@ -484,13 +484,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
@@ -501,10 +495,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
@@ -1152,21 +1143,22 @@ local function bindParamAndReturnIndex(binded)
if not func then
return
end
- if not func.args then
- return
- end
- local paramIndex = 0
- local paramMap = {}
- for _, param in ipairs(func.args) do
- paramIndex = paramIndex + 1
- if param[1] then
- paramMap[param[1]] = paramIndex
+ local paramMap
+ if func.args then
+ local paramIndex = 0
+ paramMap = {}
+ for _, param in ipairs(func.args) do
+ paramIndex = paramIndex + 1
+ if param[1] then
+ paramMap[param[1]] = paramIndex
+ end
end
+ func.docParamMap = paramMap
end
local returnIndex = 0
for _, doc in ipairs(binded) do
if doc.type == 'doc.param' then
- if doc.extends then
+ if paramMap and doc.extends then
doc.extends.paramIndex = paramMap[doc.param[1]]
end
elseif doc.type == 'doc.return' then