Skip to content

Commit

Permalink
Kotlin: Added support for backticks in function names (#2489)
Browse files Browse the repository at this point in the history
  • Loading branch information
osipxd committed Nov 15, 2020
1 parent f217ab7 commit a5107d5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
10 changes: 7 additions & 3 deletions components/prism-kotlin.js
Expand Up @@ -6,10 +6,14 @@
lookbehind: true
},
'function': [
/\w+(?=\s*\()/,
{
pattern: /(\.)\w+(?=\s*\{)/,
lookbehind: true
pattern: /(?:`[^\r\n`]+`|\w+)(?=\s*\()/,
greedy: true
},
{
pattern: /(\.)(?:`[^\r\n`]+`|\w+)(?=\s*\{)/,
lookbehind: true,
greedy: true
}
],
'number': /\b(?:0[xX][\da-fA-F]+(?:_[\da-fA-F]+)*|0[bB][01]+(?:_[01]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?(?:[eE][+-]?\d+(?:_\d+)*)?[fFL]?)\b/,
Expand Down
2 changes: 1 addition & 1 deletion components/prism-kotlin.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion tests/languages/kotlin/function_feature.test
@@ -1,14 +1,23 @@
foo()
foo_Bar_42()
list.filter {}
`function 1`()
` !"#$%^&()*+,=?@{|}~-_`()
list.`take 1` {}
`make fun`()

----------------------------------------------------

[
["function", "foo"], ["punctuation", "("], ["punctuation", ")"],
["function", "foo_Bar_42"], ["punctuation", "("], ["punctuation", ")"],
"\r\nlist", ["punctuation", "."],
["function", "filter"], ["punctuation", "{"], ["punctuation", "}"]
["function", "filter"], ["punctuation", "{"], ["punctuation", "}"],
["function", "`function 1`"], ["punctuation", "("], ["punctuation", ")"],
["function", "` !\"#$%^&()*+,=?@{|}~-_`"], ["punctuation", "("], ["punctuation", ")"],
"\r\nlist", ["punctuation", "."],
["function", "`take 1`"], ["punctuation", "{"], ["punctuation", "}"],
["function", "`make fun`"], ["punctuation", "("], ["punctuation", ")"]
]

----------------------------------------------------
Expand Down

0 comments on commit a5107d5

Please sign in to comment.