diff --git a/.gitmodules b/.gitmodules index e97868e0..fda68b55 100644 --- a/.gitmodules +++ b/.gitmodules @@ -67,9 +67,6 @@ [submodule "assets/syntaxes/JavaScript (Babel)"] path = assets/syntaxes/02_Extra/JavaScript (Babel) url = https://github.com/babel/babel-sublime -[submodule "assets/syntaxes/Dart"] - path = assets/syntaxes/02_Extra/Dart - url = https://github.com/guillermooo/dart-sublime-bundle [submodule "assets/syntaxes/FSharp"] path = assets/syntaxes/02_Extra/FSharp url = https://github.com/hoest/sublimetext-fsharp @@ -236,3 +233,6 @@ [submodule "assets/syntaxes/02_Extra/MediaWiki"] path = assets/syntaxes/02_Extra/MediaWiki url = https://github.com/tosher/Mediawiker.git +[submodule "assets/syntaxes/02_Extra/Dart"] + path = assets/syntaxes/02_Extra/Dart + url = https://github.com/elMuso/Dartlight.git diff --git a/CHANGELOG.md b/CHANGELOG.md index c91be472..439cb112 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ - LiveScript, see #1915 (@Enselic) - MediaWiki, see #1925 (@sorairolake) - The `requirements.txt` syntax has been removed due to incompatible license requirements. +- Dart, new highlighter, see #1959 (@Ersikan) ## New themes diff --git a/assets/syntaxes/02_Extra/Dart b/assets/syntaxes/02_Extra/Dart index d891fb36..2734901b 160000 --- a/assets/syntaxes/02_Extra/Dart +++ b/assets/syntaxes/02_Extra/Dart @@ -1 +1 @@ -Subproject commit d891fb36c98ca0b111a35cba109b05a16b6c4b83 +Subproject commit 2734901b014191f5a7f71c3f48678adf31239098 diff --git a/assets/syntaxes/02_Extra/Dart.sublime-syntax b/assets/syntaxes/02_Extra/Dart.sublime-syntax index 34ed01e9..1b0fb2db 100644 --- a/assets/syntaxes/02_Extra/Dart.sublime-syntax +++ b/assets/syntaxes/02_Extra/Dart.sublime-syntax @@ -1,6 +1,6 @@ %YAML 1.2 --- -# http://www.sublimetext.com/docs/3/syntax.html +# http://www.sublimetext.com/docs/syntax.html name: Dart file_extensions: - dart @@ -9,7 +9,7 @@ contexts: main: - match: ^(#!.*)$ scope: meta.preprocessor.script.dart - - match: ^\s*\b(library|import|export|part of|part)\b + - match: ^\w*\b(library|import|part of|part|export)\b captures: 0: keyword.other.import.dart push: @@ -19,242 +19,114 @@ contexts: 0: punctuation.terminator.dart pop: true - include: strings - - match: \b(as|show|hide|deferred)\b + - include: comments + - match: \b(as|show|hide)\b scope: keyword.other.import.dart - include: comments - - include: constants-and-special-vars + - include: punctuation - include: annotations - - include: decl-typedef - - include: decl-class - - include: decl-enum - - include: decl-function - include: keywords + - include: constants-and-special-vars - include: strings annotations: - - match: '^(?:\s*)((@)([a-zA-Z0-9_]+))' - captures: - 1: annotation.dart - 2: entity.name.function.annotation.dart - 3: support.type.dart + - match: '@[a-zA-Z]+' + scope: storage.type.annotation.dart comments: - match: /\*\*/ scope: comment.block.empty.dart captures: 0: punctuation.definition.comment.dart + - include: comments-doc-oldschool + - include: comments-doc - include: comments-inline - comments-inline: + comments-block: - match: /\* push: - meta_scope: comment.block.dart - match: \*/ pop: true - - include: scope:text.dart-doccomments - - match: (///) - captures: - 1: marker.dart + - include: comments-block + comments-doc: + - match: /// push: - - meta_scope: comment.line.triple-slash.dart - - match: $ + - meta_scope: comment.block.documentation.dart + - match: .* pop: true - - include: scope:text.dart-doccomments - - match: (//) - captures: - 1: marker.dart + - include: dartdoc + comments-doc-oldschool: + - match: /\*\* push: - - meta_scope: comment.line.double-slash.dart - - match: $ + - meta_scope: comment.block.documentation.dart + - match: \*/ pop: true - - include: scope:text.dart-doccomments + - include: comments-doc-oldschool + - include: comments-block + - include: dartdoc + comments-inline: + - include: comments-block + - match: ((//).*)$ + captures: + 1: comment.line.double-slash.dart constants-and-special-vars: - - match: \b(true|false|null)\b + - match: (?)' captures: - 0: keyword.control.new.dart + 1: entity.name.function.dart + dartdoc: + - match: '(\[.*?\])' + captures: + 0: variable.name.source.dart + - match: '^ {4,}(?![ \*]).*' + captures: + 0: variable.name.source.dart + - match: '```.*?$' push: - - meta_scope: meta.declaration.class.dart - - match: "(?={)" + - meta_content_scope: variable.other.source.dart + - match: '```' pop: true - - include: keywords - - match: "[A-Za-z_][A-Za-z0-9_]*" - scope: class.name.dart - decl-enum: - - match: \benum\b + - match: (`.*?`) captures: - 0: keyword.declaration.dart - push: - - meta_scope: meta.declaration.enum.dart - - match: "(?={)" - pop: true - - include: keywords - - match: "[A-Za-z_][A-Za-z0-9_]*" - scope: enum.name.dart - decl-function: - - match: ^\s*(?:\b(void|bool|num|int|double|dynamic|var|String|List|Map)\b)\s+(get)\s+(\w+)\s+(?==>) - comment: A getter with a primitive return type. - scope: meta.declaration.function.dart + 0: variable.other.source.dart + - match: (`.*?`) captures: - 1: storage.type.primitive.dart - 2: keyword.declaration.dart - 3: function.name.dart - - match: ^\s*(?:\b(\w+)\b\s+)?(get)\s+(\w+)\s+(?==>) - comment: A getter with a user-defined return type or no return type. - scope: meta.declaration.function.dart + 0: variable.other.source.dart + - match: (\* (( ).*))$ captures: - 1: type.user-defined.dart - 2: keyword.declaration.dart - 3: function.name.dart - - match: ^\s*(set)\s+(\w+)(?=\() - comment: A setter. - captures: - 1: keyword.declaration.dart - 2: function.name.dart - push: - - meta_scope: meta.declaration.function.dart - - match: \) - pop: true - - include: comments-inline - - include: decl-function-parameter - - include: strings - - include: keywords - - match: ^\s*(?:\b(void|bool|num|int|double|dynamic|var|String|List|Map)\b)\s+(\w+)(?=\() - comment: A function with a primitive return type. - captures: - 1: storage.type.primitive.dart - 2: function.name.dart - push: - - meta_scope: meta.declaration.function.dart - - match: \) - pop: true - - include: comments-inline - - include: decl-function-parameter - - include: strings - - include: keywords - - match: ^\s*(?:\b(return)\b)\s+(\w+)(?=\() - comment: A function invocation after 'return' - captures: - 1: keyword.control.dart - 2: function.name.dart - push: - - meta_scope: meta.invocation.function.dart - - match: \) - pop: true - - include: comments-inline - - include: decl-function-parameter - - include: strings - - include: keywords - - match: ^\s*\b(new)\b\s+(\w+)(?=\() - comment: A class instantiation after 'new' - captures: - 1: keyword.declaration.dart - 2: function.name.dart - push: - - meta_scope: meta.invocation.function.dart - - match: \) - pop: true - - include: comments-inline - - include: decl-function-parameter - - include: strings - - include: keywords - decl-function-parameter: - - include: constants-and-special-vars - - match: (?:\b(void|bool|num|int|double|dynamic|var|String|List|Map)\b)\s+(\w+)(?=\() - comment: A function with a primitive return type. - captures: - 1: storage.type.primitive.dart - 2: function.name.dart - push: - - meta_scope: meta.parameter.function.dart - - match: \) - pop: true - - include: decl-function-parameter - - include: strings - - include: keywords - - match: \b(new)\b\s+(\w+)(?=\() - comment: A class instantiation after 'new' - captures: - 1: keyword.declaration.dart - 2: function.name.dart - push: - - meta_scope: meta.invocation.function.dart - - match: \) - pop: true - - include: decl-function-parameter - - include: strings - - include: keywords - - match: (?:\b(\w+)\b)\s+(\w+)(?=\() - comment: A function with a user-defined return type. - captures: - 1: type.user-defined.dart - 2: function.name.dart - push: - - meta_scope: meta.parameter.function.dart - - match: \) - pop: true - - include: decl-function-parameter - - include: strings - - include: keywords - - match: (\w+)(?=\() - comment: A function with no return type. - captures: - 1: function.name.dart - push: - - meta_scope: meta.parameter.function.dart - - match: \) - pop: true - - include: decl-function-parameter - - include: strings - - include: keywords - decl-typedef: - - match: typedef - captures: - 0: keyword.control.new.dart - push: - - meta_scope: meta.declaration.typedef.dart - - match: ; - captures: - 0: punctuation.terminator.dart - pop: true - - match: '(?:\b(void|bool|num|int|double|dynamic|var|String|List|Map)\b|([a-zA-Z_][a-zA-Z0-9_]*))\s+([a-zA-Z_][a-zA-Z0-9_]+)' - captures: - 1: storage.type.primitive.dart - 2: typedef.return.dart - 3: typedef.name.dart - - match: \( - push: - - meta_scope: typedef.params.dart - - match: \) - pop: true - - include: keywords + 2: variable.other.source.dart + - match: (\* .*)$ keywords: - - match: \bassert\b - scope: keyword.control.assert.dart - - match: \bas\b + - match: (?>>?|~|\^|\||&) scope: keyword.operator.bitwise.dart - match: ((&|\^|\||<<|>>>?)=) scope: keyword.operator.assignment.bitwise.dart - - match: (===?|!==?|<=?|>=?) + - match: (=>) + scope: keyword.operator.closure.dart + - match: (==|!=|<=?|>=?) scope: keyword.operator.comparison.dart - match: '(([+*/%-]|\~)=)' scope: keyword.operator.assignment.arithmetic.dart @@ -266,56 +138,22 @@ contexts: scope: keyword.operator.arithmetic.dart - match: (!|&&|\|\|) scope: keyword.operator.logical.dart + - match: (? launchDate?.year; + int get launchYear => launchDate?.year; - void describe() { - print('Spacecraft: $name'); + void describe() { + print('Spacecraft: $name');  if (launchDate != null) { - int years = DateTime.now().difference(launchDate).inDays ~/ 365; - print('Launched: $launchYear ($years years ago)'); + int years = DateTime.now().difference(launchDate).inDays ~/ 365; + print('Launched: $launchYear ($years years ago)');  } else { - print('Unlaunched'); + print('Unlaunched');  }  } } /* Mixins */ -class PilotedCraft extends Spacecraft with Piloted { - // ยทยทยท +class PilotedCraft extends Spacecraft with Piloted { + // ยทยทยท } /* Interfaces and abstract classes */ -class MockSpaceship implements Spacecraft { - // ยทยทยท +class MockSpaceship implements Spacecraft { + // ยทยทยท } /* async */ -Future<void> printWithDelay(String message) { - return Future.delayed(const Duration(seconds: 2)).then((_) { - print(message); +Future<void> printWithDelay(String message) { + return Future.delayed(const Duration(seconds: 2)).then((_) { + print(message);  }); } -Stream<String> report(Spacecraft craft, Iterable<String> objects) async* { +Stream<String> report(Spacecraft craft, Iterable<String> objects) async* {  for (var object in objects) { - await Future.delayed(const Duration(seconds: 2)); - yield '${craft.name} flies by $object'; + await Future.delayed(const Duration(seconds: 2)); + yield '${craft.name} flies by $object';  } } diff --git a/tests/syntax-tests/source/Dart/inner_comment.dart b/tests/syntax-tests/source/Dart/inner_comment.dart new file mode 100644 index 00000000..b7aa3481 --- /dev/null +++ b/tests/syntax-tests/source/Dart/inner_comment.dart @@ -0,0 +1,5 @@ +return Object( + Object( + // Not highlighted as a comment + ) +)