Skip to content

Commit

Permalink
Fix errors from new empty regex requirements (#1606)
Browse files Browse the repository at this point in the history
The merging of #1548 caused issues with two lexers that had been added after the
PR was originally submitted. This commit fixes those errors.

It also reduces the number of calls to `String#upcase` and `String#downcase` in
the Apex lexer (this lexer was updated in #1548).
  • Loading branch information
pyrmont committed Oct 13, 2020
1 parent 6fdc78c commit 9c8c092
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
14 changes: 8 additions & 6 deletions lib/rouge/lexers/apex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,19 @@ def self.constants
rule %r/import\b/, Keyword::Namespace, :import

rule %r/([@$.]?)(#{id})([:(]?)/io do |m|
if self.class.keywords.include? m[0].downcase
lowercased = m[0].downcase
uppercased = m[0].upcase
if self.class.keywords.include? lowercased
token Keyword
elsif self.class.soql.include? m[0].upcase
elsif self.class.soql.include? uppercased
token Keyword
elsif self.class.declarations.include? m[0].downcase
elsif self.class.declarations.include? lowercased
token Keyword::Declaration
elsif self.class.types.include? m[0].downcase
elsif self.class.types.include? lowercased
token Keyword::Type
elsif self.class.constants.include? m[0].downcase
elsif self.class.constants.include? lowercased
token Keyword::Constant
elsif m[0].downcase == 'package'
elsif lowercased == 'package'
token Keyword::Namespace
elsif m[1] == "@"
token Name::Decorator
Expand Down
2 changes: 1 addition & 1 deletion lib/rouge/lexers/email.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Email < RegexLexer
state :root do
rule %r/\n/, Text
rule %r/^>.*/, Comment
rule %r/.*/, Text
rule %r/.+/, Text
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/rouge/lexers/j.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,12 @@ def self.control_words_id

state :note do
mixin :delimiter
rule %r/.*\n?/, Comment::Multiline
rule %r/.+\n?/, Comment::Multiline
end

state :noun do
mixin :delimiter
rule %r/.*\n?/, Str::Heredoc
rule %r/.+\n?/, Str::Heredoc
end

state :code do
Expand Down

0 comments on commit 9c8c092

Please sign in to comment.