diff --git a/CHANGELOG.md b/CHANGELOG.md index 6070319..658e7b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,3 @@ -## 1.4.0 (2024-11-14) - -- Removed use of 'while' in the grammar to avoid some differences in implementations between GitHub and VS Code -- Improved handling of unclosed code blocks in dartdoc comments - ## 1.3.0 (2024-07-31) - Added support for digit separators (`_`). diff --git a/grammars/dart.json b/grammars/dart.json index 7f63686..6a4877b 100644 --- a/grammars/dart.json +++ b/grammars/dart.json @@ -1,6 +1,6 @@ { "name": "Dart", - "version": "1.4.0", + "version": "1.3.0", "fileTypes": [ "dart" ], @@ -69,16 +69,6 @@ ], "repository": { - "dartdoc-codeblock-triple": { - "begin": "^\\s*///\\s*(?!\\s*```)", - "end": "\n", - "contentName": "variable.other.source.dart" - }, - "dartdoc-codeblock-block": { - "begin": "^\\s*\\*\\s*(?!(\\s*```|\/))", - "end": "\n", - "contentName": "variable.other.source.dart" - }, "dartdoc": { "patterns": [ { @@ -90,31 +80,30 @@ } }, { - "begin": "^\\s*///\\s*(```)", - "end": "^\\s*///\\s*(```)|^(?!\\s*///)", - "patterns": [ - { - "include": "#dartdoc-codeblock-triple" + "match": "^ {4,}(?![ \\*]).*", + "captures": { + "0": { + "name": "variable.name.source.dart" } - ] + } }, { - "begin": "^\\s*\\*\\s*(```)", - "end": "^\\s*\\*\\s*(```)|^(?=\\s*\\*\/)", - "patterns": [ - { - "include": "#dartdoc-codeblock-block" - } - ] + "contentName": "variable.other.source.dart", + "begin": "```.*?$", + "end": "```" }, { - "match": "`[^`\n]+`", - "name": "variable.other.source.dart" + "match": "(`[^`]+?`)", + "captures": { + "0": { + "name": "variable.other.source.dart" + } + } }, { - "match": "\\s{4,}(.*)$", + "match": "(\\* (( ).*))$", "captures": { - "1": { + "2": { "name": "variable.other.source.dart" } } @@ -168,7 +157,7 @@ { "name": "comment.block.documentation.dart", "begin": "///", - "end": "^(?!\\s*///)", + "while": "^\\s*///", "patterns": [ { "include": "#dartdoc" diff --git a/pubspec.yaml b/pubspec.yaml index 6606d5f..893846e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,8 +4,8 @@ environment: sdk: ^3.2.0 dev_dependencies: - collection: ^1.19.0 - dart_flutter_team_lints: ^3.2.1 + collection: ^1.18.0 + dart_flutter_team_lints: ^2.1.1 path: ^1.9.0 - string_scanner: ^1.4.0 - test: ^1.25.8 + string_scanner: ^1.2.0 + test: ^1.25.2 diff --git a/test/goldens/comments.dart.golden b/test/goldens/comments.dart.golden index bc00a3f..05b2729 100644 --- a/test/goldens/comments.dart.golden +++ b/test/goldens/comments.dart.golden @@ -5,143 +5,26 @@ >// found in the LICENSE file. #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.double-slash.dart > ->/// Multiline dartdoc comment with triple backticks. -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.block.documentation.dart +>/// Multiline dartdoc comment. +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.block.documentation.dart >/// #^^^ comment.block.documentation.dart >/// ``` #^^^^^^^ comment.block.documentation.dart ->/// code -#^^^^ comment.block.documentation.dart -# ^^^^ comment.block.documentation.dart variable.other.source.dart ->/// ``` -#^^^^^^^ comment.block.documentation.dart ->/// -#^^^ comment.block.documentation.dart ->/// ... -#^^^^^^^ comment.block.documentation.dart ->var doc1; -#^^^ storage.type.primitive.dart -# ^ punctuation.terminator.dart -> ->/// Multiline dartdoc comment with unclosed triple backticks. -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.block.documentation.dart ->/// +>/// doc #^^^ comment.block.documentation.dart +# ^^^^ comment.block.documentation.dart variable.other.source.dart >/// ``` -#^^^^^^^ comment.block.documentation.dart ->/// code -#^^^^ comment.block.documentation.dart -# ^^^^ comment.block.documentation.dart variable.other.source.dart ->var doc2; -#^^^ storage.type.primitive.dart -# ^ punctuation.terminator.dart -> ->/// Multiline dartdoc comment with unclosed backticks. -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.block.documentation.dart ->/// #^^^ comment.block.documentation.dart ->/// `code -#^^^^^^^^^ comment.block.documentation.dart ->var doc3; -#^^^ storage.type.primitive.dart -# ^ punctuation.terminator.dart -> ->/// Multiline dartdoc comment with indented code. -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.block.documentation.dart ->/// -#^^^ comment.block.documentation.dart ->/// code1 -#^^^^^^^^ comment.block.documentation.dart -# ^^^^^ comment.block.documentation.dart variable.other.source.dart ->/// code2 -#^^^^^^^^ comment.block.documentation.dart -# ^^^^^ comment.block.documentation.dart variable.other.source.dart ->/// -#^^^ comment.block.documentation.dart ->/// code3 -#^^^^^^^^ comment.block.documentation.dart -# ^^^^^ comment.block.documentation.dart variable.other.source.dart +# ^ comment.block.documentation.dart variable.other.source.dart +# ^^^ comment.block.documentation.dart >/// #^^^ comment.block.documentation.dart >/// ... #^^^^^^^ comment.block.documentation.dart ->var doc4; +>var a; #^^^ storage.type.primitive.dart -# ^ punctuation.terminator.dart -> ->/** Block dartdoc comment with triple backticks. -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.block.documentation.dart -> * -#^^ comment.block.documentation.dart -> * ``` -#^^^^^^ comment.block.documentation.dart -> * code -#^^^ comment.block.documentation.dart -# ^^^^ comment.block.documentation.dart variable.other.source.dart -> * ``` -#^^^^^^ comment.block.documentation.dart -> * -#^^ comment.block.documentation.dart -> * ... -#^^^^^^ comment.block.documentation.dart -> */ -#^^^ comment.block.documentation.dart ->var blockDoc1; -#^^^ storage.type.primitive.dart -# ^ punctuation.terminator.dart -> ->/** Block dartdoc comment with unclosed triple backticks. -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.block.documentation.dart -> * -#^^ comment.block.documentation.dart -> * ``` -#^^^^^^ comment.block.documentation.dart -> * code -#^^^ comment.block.documentation.dart -# ^^^^ comment.block.documentation.dart variable.other.source.dart -> */ -#^^^ comment.block.documentation.dart ->var blockDoc2; -#^^^ storage.type.primitive.dart -# ^ punctuation.terminator.dart -> ->/** Block dartdoc comment with unclosed backticks. -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.block.documentation.dart -> * -#^^ comment.block.documentation.dart -> * `code -#^^^^^^^^ comment.block.documentation.dart -> */ -#^^^ comment.block.documentation.dart ->var blockDoc3; -#^^^ storage.type.primitive.dart -# ^ punctuation.terminator.dart -> ->/** Block dartdoc comment with indented code. -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.block.documentation.dart -> * -#^^ comment.block.documentation.dart -> * code1 -#^^^^^^^ comment.block.documentation.dart -# ^^^^^ comment.block.documentation.dart variable.other.source.dart -> * code2 -#^^^^^^^ comment.block.documentation.dart -# ^^^^^ comment.block.documentation.dart variable.other.source.dart -> * -#^^ comment.block.documentation.dart -> * code3 -#^^^^^^^ comment.block.documentation.dart -# ^^^^^ comment.block.documentation.dart variable.other.source.dart -> * -#^^ comment.block.documentation.dart -> * ... -#^^^^^^ comment.block.documentation.dart -> */ -#^^^ comment.block.documentation.dart ->var blockDoc4; -#^^^ storage.type.primitive.dart -# ^ punctuation.terminator.dart +# ^ punctuation.terminator.dart > >/// `` #^^^^^^ comment.block.documentation.dart @@ -240,24 +123,24 @@ #^^^ storage.type.primitive.dart # ^ punctuation.terminator.dart > ->class A { +>class A { #^^^^^ keyword.declaration.dart # ^ support.class.dart # ^ other.source.dart -# ^ support.class.dart -# ^^^^^^^^^^^^^ comment.block.dart -# ^ other.source.dart -> void b() {} +# ^^^^^^^ support.class.dart +# ^^^^^^^^^^^^^ comment.block.dart +# ^ other.source.dart +> void b() {} # ^^^^ storage.type.primitive.dart # ^ keyword.operator.comparison.dart -# ^ support.class.dart -# ^^^^^^^^^^^^^ comment.block.dart -# ^ keyword.operator.comparison.dart -> Future c() {} +# ^^^^^^^ support.class.dart +# ^^^^^^^^^^^^^ comment.block.dart +# ^ keyword.operator.comparison.dart +> Future c() {} # ^^^^^^ support.class.dart # ^ other.source.dart -# ^ support.class.dart -# ^^^^^^^^^^^^^ comment.block.dart -# ^ other.source.dart -# ^ entity.name.function.dart +# ^^^^^^^ support.class.dart +# ^^^^^^^^^^^^^ comment.block.dart +# ^ other.source.dart +# ^ entity.name.function.dart >} diff --git a/test/test_files/comments.dart b/test/test_files/comments.dart index a41d817..31ff0b6 100644 --- a/test/test_files/comments.dart +++ b/test/test_files/comments.dart @@ -2,69 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -/// Multiline dartdoc comment with triple backticks. +/// Multiline dartdoc comment. /// /// ``` -/// code +/// doc /// ``` /// /// ... -var doc1; - -/// Multiline dartdoc comment with unclosed triple backticks. -/// -/// ``` -/// code -var doc2; - -/// Multiline dartdoc comment with unclosed backticks. -/// -/// `code -var doc3; - -/// Multiline dartdoc comment with indented code. -/// -/// code1 -/// code2 -/// -/// code3 -/// -/// ... -var doc4; - -/** Block dartdoc comment with triple backticks. - * - * ``` - * code - * ``` - * - * ... - */ -var blockDoc1; - -/** Block dartdoc comment with unclosed triple backticks. - * - * ``` - * code - */ -var blockDoc2; - -/** Block dartdoc comment with unclosed backticks. - * - * `code - */ -var blockDoc3; - -/** Block dartdoc comment with indented code. - * - * code1 - * code2 - * - * code3 - * - * ... - */ -var blockDoc4; +var a; /// `` var noInlineCode; @@ -111,7 +56,7 @@ var g; /// And a link to [example.org](http://example.org/). var h; -class A { - void b() {} - Future c() {} +class A { + void b() {} + Future c() {} }