Skip to content

Commit

Permalink
Add basic support for Dart 3 features (#1935)
Browse files Browse the repository at this point in the history
* Support Dart 3 features in Dart lexer

* Remove `interface` under `:class` declaration
  • Loading branch information
parlough committed Apr 2, 2023
1 parent 9608bcc commit 6320e26
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/rouge/lexers/dart.rb
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6320e26

Please sign in to comment.