Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix.kotlin.reified #1504

Merged
merged 2 commits into from Apr 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/rouge/lexers/kotlin.rb
Expand Up @@ -105,7 +105,8 @@ class Kotlin < RegexLexer
state :generic_parameters do
rule class_name, Name::Class
rule %r'(<)', Punctuation, :generic_parameters
rule %r'(,)', Punctuation
rule %r'(reified|out|in)', Keyword
rule %r'([,:])', Punctuation
rule %r'(\s+)', Text
rule %r'(>)', Punctuation, :pop!
end
Expand Down
6 changes: 6 additions & 0 deletions spec/lexers/kotlin_spec.rb
Expand Up @@ -31,5 +31,11 @@
it 'recognizes label reference in break statement' do
assert_tokens_equal 'break@label', ["Keyword", "break"], ["Name.Decorator", "@label"]
end

it 'recognizes type modifiers' do
for modifer in ['reified', 'out', 'in'] do
assert_tokens_equal "<#{modifer} T>", ["Punctuation", "<"], ["Keyword", modifer], ["Text", " "], ["Name.Class", "T"], ["Punctuation", ">"]
end
end
end
end
6 changes: 5 additions & 1 deletion spec/visual/samples/kotlin
Expand Up @@ -162,10 +162,14 @@ fun `String`.`backTickedExtensionFunction`() {
return
}

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

inline fun <reified T> membersOf() = T::class.members
public interface List<out E> : Collection<E> {}
public interface Comparable<in T> {}

@Deprecated("This is an annotation")
fun anAnnotatedFunction() = {
}
Expand Down