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

Kotlin - Function names (including generics and extensions) #996

Merged
merged 7 commits into from
Oct 1, 2018
Merged

Kotlin - Function names (including generics and extensions) #996

merged 7 commits into from
Oct 1, 2018

Conversation

lordcodes
Copy link
Contributor

@lordcodes lordcodes commented Sep 21, 2018

Recognize Kotlin function names (declarations).

This includes handling extension functions, generic functions and generic extension functions.

The solution uses state to avoid long regexes.

  • Function names mapped to Name.Function.
  • Class name when it is an extension function mapped to Name.Class.
  • Each generic parameter mapped to Name.Class.
  • Less than (<), greater than (>) and comma (,) mapped to Punctuation.

Includes unit tests for each type.

Fixes #792.
Fixes #791.
Fixes #906.

- Regular function
- Extension function
- Generic function
- Generic Extension function
Put back previous recognition of fun keyword.
Using state to recognize instead of long regexes.
Generic and non-generic extension functions
Rather than mapping it to punctuation containing plain text. Map each generic parameter to Name.Class and the less than, greater than and internal commas to punctuation.
@lordcodes
Copy link
Contributor Author

CC @dblessing

@lordcodes
Copy link
Contributor Author

@jneen Sorry to bump this PR, but would be really keen to get these Kotlin PRs I have put forward included, as currently Rouge is almost unusable for Kotlin as it doesn't really highlight anything other than certain keywords.

spec/lexers/kotlin_spec.rb Outdated Show resolved Hide resolved
@dblessing dblessing added the author-action The PR has been reviewed but action by the author is needed label Oct 1, 2018
@lordcodes
Copy link
Contributor Author

@dblessing Removed the tests and added missing samples. Thanks for review.

@dblessing dblessing merged commit d4a2bb6 into rouge-ruby:master Oct 1, 2018
@lordcodes lordcodes deleted the kotlin-function-names branch October 1, 2018 15:41
@pyrmont pyrmont removed the author-action The PR has been reviewed but action by the author is needed label Aug 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants