From 6320e260e3c418715f510247f80542a8de6249d6 Mon Sep 17 00:00:00 2001 From: Parker Lougheed Date: Sun, 2 Apr 2023 00:03:52 -0500 Subject: [PATCH] Add basic support for Dart 3 features (#1935) * Support Dart 3 features in Dart lexer * Remove `interface` under `:class` declaration --- lib/rouge/lexers/dart.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/rouge/lexers/dart.rb b/lib/rouge/lexers/dart.rb index 1bb991b4a0..ea74d9165d 100644 --- a/lib/rouge/lexers/dart.rb +++ b/lib/rouge/lexers/dart.rb @@ -12,16 +12,16 @@ class Dart < RegexLexer mimetypes 'text/x-dart' keywords = %w( - as assert await break case catch continue default do else finally for - if in is new rethrow return super switch this throw try while with yield + as assert await break case catch continue default do else finally for if + in is new rethrow return super switch this throw try while when with yield ) declarations = %w( - abstract async dynamic const covariant external extends factory final get - implements late native on operator required set static sync typedef var + abstract base async dynamic const covariant external extends factory final get implements + inline interface late native on operator required sealed set static sync typedef var ) - types = %w(bool Comparable double Dynamic enum Function int List Map Never Null num Object Pattern Set String Symbol Type Uri void) + types = %w(bool Comparable double Dynamic enum Function int List Map Never Null num Object Pattern Record Set String Symbol Type Uri void) imports = %w(import deferred export library part\s*of part source) @@ -53,7 +53,7 @@ class Dart < RegexLexer rule %r/(?:#{declarations.join('|')})\b/, Keyword::Declaration rule %r/(?:#{types.join('|')})\b/, Keyword::Type rule %r/(?:true|false|null)\b/, Keyword::Constant - rule %r/(?:class|interface|mixin)\b/, Keyword::Declaration, :class + rule %r/(?:class|mixin)\b/, Keyword::Declaration, :class rule %r/(?:#{imports.join('|')})\b/, Keyword::Namespace, :import rule %r/(\.)(#{id})/ do groups Operator, Name::Attribute