Skip to content
This repository has been archived by the owner on Sep 8, 2023. It is now read-only.

Commit

Permalink
Ensure word break follows keywords in Kotlin lexer (rouge-ruby#1621)
Browse files Browse the repository at this point in the history
Rouge will currently match identifiers in the Kotlin lexer that begin
with certain keywords (such as `super`). This is because of a change in
rouge-ruby#1496 that added a rule to support labels. That change should have
updated the rule to end with a `\b` so as to ensure that identifiers
that begin with the listed keywords are followed by a word break.
This commit fixes that error.
  • Loading branch information
pyrmont authored and mattt committed May 19, 2021
1 parent 8069683 commit ed307b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/rouge/lexers/kotlin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Kotlin < RegexLexer
groups Keyword::Declaration, Text
push :property
end
rule %r'(return|continue|break|this|super)(@#{name})?' do
rule %r'(return|continue|break|this|super)(@#{name})?\b' do
groups Keyword, Name::Decorator
end
rule %r'\bfun\b', Keyword
Expand Down
10 changes: 7 additions & 3 deletions spec/visual/samples/kotlin
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,19 @@ fun <T, V> genericFunction() {
}

fun String.extensionFunction() {
return
return
}

fun `String`.`backTickedExtensionFunction`() {
return
return
}

fun <T, V : Comparable> String.genericExtensionFunction() {
return
return
}

fun foo(supersedingStuff: List<String>): List<String> {
return supersedingStuff.map { it }
}

inline fun <reified T> membersOf() = T::class.members
Expand Down

0 comments on commit ed307b6

Please sign in to comment.