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

Refactor coloring in compiler #7252

Closed
wants to merge 14 commits into from
Closed

Conversation

wooster0
Copy link
Contributor

@wooster0 wooster0 commented Jan 2, 2019

This:

  • Resolves unnecessary colorizing complexity in the compiler.
    Originally I just wanted to fix that when you do '', that the did-you-mean in the error is colored in bold yellow (currently it's not) but it turned out to be actually quite difficult to retrieve the @color value from the Compiler (whether --no-color has been passed or not) from this spot in the lexer.
    So now at the beginning of a compilation, Colorize.enabled is simply used to turn colors off when --no-color has been passed. Which is much simpler than having to define a colorize method first and then having to figure out how to even retrieve the color value from the compiler. Now strings can be colored wherever you want just like you would in your own code without colorize helper methods.
  • Removes 2 unnecessary "colorize" requires.
  • Fixes some did-you-means or other helpful hints not being colored in bold yellow in multiple places.
  • For example Time.new(seconds: 0) results in the error
    error
    with the last item not being colored in bold/white (or more specifically with the items after the (trying this one) not being colored in bold/white). That's fixed as well.

src/compiler/crystal/util.cr Outdated Show resolved Hide resolved
@wooster0 wooster0 force-pushed the color branch 2 times, most recently from c6c178c to 06ca67f Compare January 3, 2019 11:28
@wooster0
Copy link
Contributor Author

wooster0 commented Jan 3, 2019

Phew CI finally passes! That took way too long.

spec/compiler/semantic/generic_class_spec.cr Outdated Show resolved Hide resolved
src/compiler/crystal/util.cr Show resolved Hide resolved
src/compiler/crystal/util.cr Outdated Show resolved Hide resolved
src/colorize.cr Show resolved Hide resolved
src/colorize.cr Show resolved Hide resolved
@wooster0
Copy link
Contributor Author

wooster0 commented Aug 4, 2019

#4499 looks much better than this, I'll close this and perhaps do an extra PR someday with some tiny things of this that #4499 doesn't have, after #4499 is merged.

@wooster0 wooster0 closed this Aug 4, 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
Development

Successfully merging this pull request may close these issues.

4 participants