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

Update Scala lexer to output more differentiated token types. #1040

Merged
merged 1 commit into from
May 30, 2019

Conversation

alanqthomas
Copy link
Contributor

Motivation

I decided to write this lexer addition because I felt the tokens being output by the current Scala lexer implementation were too general, usually a Name token. This PR makes the lexer output some more specific token types. This allows the stylesheet to define more specific colors for different tokens while also leaving it open to having these new token types be styled the same way as before.

New Token Types

  • Name::Function for def names
  • Name::Variable for val names
  • Name::Property for anything used after a . e.g. method calls, class fields. I chose Name::Property because calling vals or defs on an instance are more or less interchangeable
  • Name::Function for def/function calls

Before:

chrome_2018-11-25_20-01-30
chrome_2018-11-25_20-02-18

After:

chrome_2018-11-25_19-59-37
chrome_2018-11-25_20-03-25

Adds tokens Function, Variable, Property, and Function where appropriate.
Copy link
Contributor

@pyrmont pyrmont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a nice improvement! Thanks for taking the time to add it and sorry for the delay in getting to the PR. Just one comment below:

lib/rouge/lexers/scala.rb Show resolved Hide resolved
@pyrmont pyrmont added author-action The PR has been reviewed but action by the author is needed and removed needs-review The PR needs to be reviewed labels May 29, 2019
@pyrmont pyrmont merged commit 6c7da8a into rouge-ruby:master May 30, 2019
@pyrmont pyrmont removed the author-action The PR has been reviewed but action by the author is needed label May 30, 2019
@alanqthomas alanqthomas deleted the scala-lexer-update branch May 30, 2019 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants