Skip to content

Commit

Permalink
fix(Kotlin): parenthesized types in function declaration (#2107)
Browse files Browse the repository at this point in the history
  • Loading branch information
egor-rogov authored and Marcos Cáceres committed Aug 20, 2019
1 parent 7746a4b commit 15127d2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/languages/kotlin.js
Expand Up @@ -107,6 +107,19 @@ function(hljs) {
'/\\*', '\\*/',
{ contains: [ hljs.C_BLOCK_COMMENT_MODE ] }
);
var KOTLIN_PAREN_TYPE = {
variants: [
{ className: 'type',
begin: hljs.UNDERSCORE_IDENT_RE
},
{ begin: /\(/, end: /\)/,
contains: [] //defined later
}
]
};
var KOTLIN_PAREN_TYPE2 = KOTLIN_PAREN_TYPE;
KOTLIN_PAREN_TYPE2.variants[1].contains = [ KOTLIN_PAREN_TYPE ];
KOTLIN_PAREN_TYPE.variants[1].contains = [ KOTLIN_PAREN_TYPE2 ];

return {
aliases: ['kt'],
Expand Down Expand Up @@ -158,7 +171,7 @@ function(hljs) {
{
begin: /:/, end: /[=,\/]/, endsWithParent: true,
contains: [
{className: 'type', begin: hljs.UNDERSCORE_IDENT_RE},
KOTLIN_PAREN_TYPE,
hljs.C_LINE_COMMENT_MODE,
KOTLIN_NESTED_COMMENT
],
Expand Down
3 changes: 3 additions & 0 deletions test/markup/kotlin/function.expect.txt
Expand Up @@ -11,3 +11,6 @@
b : <span class="hljs-type">String</span> <span class="hljs-comment">//b</span>
)</span></span>
{}


<span class="hljs-function"><span class="hljs-keyword">fun</span> <span class="hljs-type">&lt;OUT&gt;</span> <span class="hljs-title">handle</span><span class="hljs-params">(lambda: (<span class="hljs-type">IN</span>) <span class="hljs-comment">/* parenthesized type */</span> -&gt; <span class="hljs-type">OUT</span>)</span></span> {}
5 changes: 4 additions & 1 deletion test/markup/kotlin/function.txt
Expand Up @@ -10,4 +10,7 @@ fun e(
a : Int, /*a*/
b : String //b
)
{}
{}


fun <OUT> handle(lambda: (IN) /* parenthesized type */ -> OUT) {}

0 comments on commit 15127d2

Please sign in to comment.