@@ -1958,7 +1958,7 @@ local function bindDocs(state)
1958
1958
binded = {}
1959
1959
state .ast .docs .groups [# state .ast .docs .groups + 1 ] = binded
1960
1960
end
1961
- binded [# binded + 1 ] = doc
1961
+ binded [# binded + 1 ] = doc
1962
1962
if isTailComment (text , doc ) then
1963
1963
bindDocWithSources (sources , binded )
1964
1964
binded = nil
@@ -1994,105 +1994,107 @@ local function findTouch(state, doc)
1994
1994
end
1995
1995
end
1996
1996
1997
- return {
1998
- buildAndBindDoc = function (ast , src , comment )
1999
- local doc = buildLuaDoc (comment )
2000
- if doc then
2001
- local pluginDocs = ast .state .pluginDocs or {}
2002
- pluginDocs [# pluginDocs + 1 ] = doc
2003
- doc .special = src
2004
- doc .originalComment = comment
2005
- ast .state .pluginDocs = pluginDocs
2006
- return true
2007
- end
2008
- return false
2009
- end ,
2010
- luadoc = function (state )
2011
- local ast = state .ast
2012
- local comments = state .comms
2013
- table.sort (comments , function (a , b )
2014
- return a .start < b .start
2015
- end )
2016
- ast .docs = {
2017
- type = ' doc' ,
2018
- parent = ast ,
2019
- groups = {},
2020
- }
1997
+ local function luadoc (state )
1998
+ local ast = state .ast
1999
+ local comments = state .comms
2000
+ table.sort (comments , function (a , b )
2001
+ return a .start < b .start
2002
+ end )
2003
+ ast .docs = {
2004
+ type = ' doc' ,
2005
+ parent = ast ,
2006
+ groups = {},
2007
+ }
2021
2008
2022
- pushWarning = function (err )
2023
- local errs = state .errs
2024
- if err .finish < err .start then
2025
- err .finish = err .start
2026
- end
2027
- local last = errs [# errs ]
2028
- if last then
2029
- if last .start <= err .start and last .finish >= err .finish then
2030
- return
2031
- end
2009
+ pushWarning = function (err )
2010
+ local errs = state .errs
2011
+ if err .finish < err .start then
2012
+ err .finish = err .start
2013
+ end
2014
+ local last = errs [# errs ]
2015
+ if last then
2016
+ if last .start <= err .start and last .finish >= err .finish then
2017
+ return
2032
2018
end
2033
- err .level = err .level or ' Warning'
2034
- errs [# errs + 1 ] = err
2035
- return err
2036
2019
end
2037
- Lines = state .lines
2020
+ err .level = err .level or ' Warning'
2021
+ errs [# errs + 1 ] = err
2022
+ return err
2023
+ end
2024
+ Lines = state .lines
2038
2025
2039
- local ci = 1
2040
- NextComment = function (offset , peek )
2041
- local comment = comments [ci + (offset or 0 )]
2042
- if not peek then
2043
- ci = ci + 1 + (offset or 0 )
2044
- end
2045
- return comment
2026
+ local ci = 1
2027
+ NextComment = function (offset , peek )
2028
+ local comment = comments [ci + (offset or 0 )]
2029
+ if not peek then
2030
+ ci = ci + 1 + (offset or 0 )
2046
2031
end
2032
+ return comment
2033
+ end
2047
2034
2048
- local function insertDoc (doc , comment )
2049
- ast .docs [# ast .docs + 1 ] = doc
2050
- doc .parent = ast .docs
2051
- if ast .start > doc .start then
2052
- ast .start = doc .start
2053
- end
2054
- if ast .finish < doc .finish then
2055
- ast .finish = doc .finish
2056
- end
2057
- doc .originalComment = comment
2058
- if comment .type == ' comment.long' then
2059
- findTouch (state , doc )
2060
- end
2035
+ local function insertDoc (doc , comment )
2036
+ ast .docs [# ast .docs + 1 ] = doc
2037
+ doc .parent = ast .docs
2038
+ if ast .start > doc .start then
2039
+ ast .start = doc .start
2040
+ end
2041
+ if ast .finish < doc .finish then
2042
+ ast .finish = doc .finish
2043
+ end
2044
+ doc .originalComment = comment
2045
+ if comment .type == ' comment.long' then
2046
+ findTouch (state , doc )
2061
2047
end
2048
+ end
2062
2049
2063
- while true do
2064
- local comment = NextComment ()
2065
- if not comment then
2066
- break
2067
- end
2068
- lockResume = false
2069
- local doc , rests = buildLuaDoc (comment )
2070
- if doc then
2071
- insertDoc (doc , comment )
2072
- if rests then
2073
- for _ , rest in ipairs (rests ) do
2074
- insertDoc (rest , comment )
2075
- end
2050
+ while true do
2051
+ local comment = NextComment ()
2052
+ if not comment then
2053
+ break
2054
+ end
2055
+ lockResume = false
2056
+ local doc , rests = buildLuaDoc (comment )
2057
+ if doc then
2058
+ insertDoc (doc , comment )
2059
+ if rests then
2060
+ for _ , rest in ipairs (rests ) do
2061
+ insertDoc (rest , comment )
2076
2062
end
2077
2063
end
2078
2064
end
2079
-
2080
- if ast .state .pluginDocs then
2081
- for i , doc in ipairs (ast .state .pluginDocs ) do
2082
- insertDoc (doc , doc .originalComment )
2083
- end
2084
- table.sort (ast .docs , function (a , b )
2085
- return a .start < b .start
2086
- end )
2065
+ end
2066
+
2067
+ if ast .state .pluginDocs then
2068
+ for i , doc in ipairs (ast .state .pluginDocs ) do
2069
+ insertDoc (doc , doc .originalComment )
2087
2070
end
2071
+ table.sort (ast .docs , function (a , b )
2072
+ return a .start < b .start
2073
+ end )
2074
+ end
2088
2075
2089
- ast .docs .start = ast .start
2090
- ast .docs .finish = ast .finish
2091
-
2092
- if # ast .docs == 0 then
2093
- return
2094
- end
2076
+ ast .docs .start = ast .start
2077
+ ast .docs .finish = ast .finish
2095
2078
2096
- bindDocs (state )
2079
+ if # ast .docs == 0 then
2080
+ return
2097
2081
end
2082
+
2083
+ bindDocs (state )
2084
+ end
2085
+
2086
+ return {
2087
+ buildAndBindDoc = function (ast , src , comment )
2088
+ local doc = buildLuaDoc (comment )
2089
+ if doc then
2090
+ local pluginDocs = ast .state .pluginDocs or {}
2091
+ pluginDocs [# pluginDocs + 1 ] = doc
2092
+ doc .special = src
2093
+ doc .originalComment = comment
2094
+ ast .state .pluginDocs = pluginDocs
2095
+ return true
2096
+ end
2097
+ return false
2098
+ end ,
2099
+ luadoc = luadoc
2098
2100
}
0 commit comments