diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-05-07 17:10:37 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-05-07 17:10:37 +0800 |
commit | 56e30b07fffee79e6c0612f0f099eb590c7be558 (patch) | |
tree | f636a9d2aa34780eb3967999dce1ad54fcdf386b | |
parent | a8c95b64d7e8a8481cbe961b8b872ef0710d618f (diff) | |
download | lua-language-server-56e30b07fffee79e6c0612f0f099eb590c7be558.zip |
resolve #476 supports multiline comments
-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" +}} |