diff options
-rw-r--r-- | changelog.md | 1 | ||||
-rw-r--r-- | script/parser/ast.lua | 6 | ||||
-rw-r--r-- | script/parser/grammar.lua | 6 | ||||
-rw-r--r-- | test/crossfile/hover.lua | 15 |
4 files changed, 22 insertions, 6 deletions
diff --git a/changelog.md b/changelog.md index f7a1ae3d..3ce84910 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,7 @@ ## 1.21.0 * `NEW` setting: `completion.showParams` +* `NEW` `LuaDoc`: supports multiline comments ## 1.20.5 `2021-4-30` diff --git a/script/parser/ast.lua b/script/parser/ast.lua index 38c4e51b..3ac4d27f 100644 --- a/script/parser/ast.lua +++ b/script/parser/ast.lua @@ -277,7 +277,7 @@ local Defs = { type = 'comment.long', start = start, finish = finish - 1, - text = '', + text = str, } if not close then local endSymbol = ']' .. ('='):rep(afterEq-beforeEq) .. ']' @@ -318,7 +318,7 @@ local Defs = { } end end, - CLongComment = function (start1, finish1, start2, finish2) + CLongComment = function (start1, finish1, str, start2, finish2) if State.options.nonstandardSymbol and State.options.nonstandardSymbol['/**/'] then else PushError { @@ -344,7 +344,7 @@ local Defs = { type = 'comment.clong', start = start1, finish = finish2 - 1, - text = '', + text = str, } end, CCommentPrefix = function (start, finish, commentFinish) diff --git a/script/parser/grammar.lua b/script/parser/grammar.lua index ea9a25e0..01756c2a 100644 --- a/script/parser/grammar.lua +++ b/script/parser/grammar.lua @@ -88,13 +88,13 @@ end grammar 'Comment' [[ Comment <- LongComment / '--' ShortComment -LongComment <- ({} '--[' {} {:eq: '='* :} {} '[' +LongComment <- ({} '--[' {} {:eq: '='* :} {} '[' %nl? {(!CommentClose .)*} ((CommentClose / %nil) {})) -> LongComment / ( - {} '/*' {} - (!'*/' .)* + {} '/*' {} %nl? + {(!'*/' .)*} {} '*/' {} ) -> CLongComment diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua index 521f5a49..dacf1ab2 100644 --- a/test/crossfile/hover.lua +++ b/test/crossfile/hover.lua @@ -731,3 +731,18 @@ hover = { label = 'field Food.firstField: integer = 0', name = 'food.firstField', }} + +TEST {{ path = 'a.lua', content = '', }, { + path = 'b.lua', + content = [[ +--[=[ +I'm a multiline comment +]=] +local <?food?> +]] +}, +hover = { + label = 'local food: any', + name = 'food', + description = "I'm a multiline comment\n" +}} |