summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/parser/luadoc.lua10
-rw-r--r--test/crossfile/hover.lua22
2 files changed, 8 insertions, 24 deletions
diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua
index 0463d7d2..4a431e68 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 guide = require 'parser.guide'
-local grammar = require 'parser.grammar'
+local parser = require 'parser.newparser'
local TokenTypes, TokenStarts, TokenFinishs, TokenContents
local Ci, Offset, pushError, NextComment, Lines
@@ -1121,9 +1121,9 @@ local function trimTailComment(text)
comment = text:sub(3)
end
if comment:find '^%s*[\'"[]' then
- local result = grammar(nil, comment:gsub('^%s+', ''), 'string')
- if result and result[1] then
- comment = result[1][1]
+ local state = parser(comment:gsub('^%s+', ''), 'String')
+ if state and state.ast then
+ comment = state.ast[1]
end
end
return comment
@@ -1148,7 +1148,7 @@ local function buildLuaDoc(comment)
local result = convertTokens()
if result then
result.range = comment.finish
- local cstart = text:find('%S', (result.firstFinish or result.finish) - comment.start + 2)
+ local cstart = text:find('%S', (result.firstFinish or result.finish) - comment.start)
if cstart and cstart < comment.finish then
result.comment = {
type = 'doc.tailcomment',
diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua
index a877d226..1c46214c 100644
--- a/test/crossfile/hover.lua
+++ b/test/crossfile/hover.lua
@@ -2,6 +2,7 @@ local files = require 'files'
local furi = require 'file-uri'
local core = require 'core.hover'
local config = require 'config'
+local catch = require 'catch'
rawset(_G, 'TEST', true)
@@ -36,36 +37,19 @@ local function eq(a, b)
return a == b
end
-local function catch_target(script, sep)
- local list = {}
- local cur = 1
- local cut = 0
- while true do
- local start, finish = script:find(('<%%%s.-%%%s>'):format(sep, sep), cur)
- if not start then
- break
- end
- list[#list+1] = { start - cut, finish - 4 - cut }
- cur = finish + 1
- cut = cut + 4
- end
- local new_script = script:gsub(('<%%%s(.-)%%%s>'):format(sep, sep), '%1')
- return new_script, list
-end
-
function TEST(expect)
files.removeAll()
local targetScript = expect[1].content
local targetUri = furi.encode(expect[1].path)
- local sourceScript, sourceList = catch_target(expect[2].content, '?')
+ local sourceScript, sourceList = catch(expect[2].content, '?')
local sourceUri = furi.encode(expect[2].path)
files.setText(targetUri, targetScript)
files.setText(sourceUri, sourceScript)
- local sourcePos = (sourceList[1][1] + sourceList[1][2]) // 2
+ local sourcePos = (sourceList['?'][1][1] + sourceList['?'][1][2]) // 2
local hover = core.byUri(sourceUri, sourcePos)
assert(hover)
hover = tostring(hover):gsub('\r\n', '\n')