Age | Commit message (Collapse) | Author |
|
0c459af7c233adb5f44022350bfe8fa132d8053e changed the meaning of
`detect_compile_error`, and this commit lets it follow the change.
|
|
This was needed before 0c459af7c233adb5f44022350bfe8fa132d8053e but it
could be actually useless now. But I added this anyway just in case.
|
|
* lib/irb/color.rb (IRB::Color.scan): ignore "incomplete end of
input" error only, to colorize invalid characters, e.g., control
characters, and invalid symbols, as errors.
|
|
Becausee the current irb support reline and have many of changes.
|
|
|
|
Let's say we are in progress to write `"foo"`:
```
irb> "fo
```
at this moment, nothing is wrong.
It would be just a normal way to write `"foo"`.
Prior to this commit, the `fo` part was warned because of
5b64d7ac6e7cbf759b859428f125539e58bac0bd. But I think warning such a
normal input is not valuable for users.
However, we'd like to warn `:@1` or `@@1` which is also a syntax error.
Then this commit switches the syntax highlight based on whether the
input text is finished or not. When it's not finished yet, it does not
warn compile_error.
|
|
because 5b64d7ac6e7cbf759b859428f125539e58bac0bd made it hard to
understand #colorize_code for me and this change is needed for my next
commit.
|
|
so that we can colorize binding.irb source lines.
|
|
|
|
* lib/irb/color.rb (IRB::Color.colorize_code): colorize
`compile_error` part as same as `on_parse_error`.
|
|
* lib/irb/color.rb (IRB::Color.colorize): get rid of nesting string
interpolations not to confuse ruby-mode.el
|
|
* ext/ripper/lib/ripper/lexer.rb (Ripper::Lexer#scan): parses the
code and returns the result elements including errors.
[EXPERIMENTAL]
|
|
|
|
|
|
This reverts commit c7f3c222c9b82736c993419daa6bfb643e5c0793.
|
|
Colorize `compile_error` parts as well as `on_parse_error` parts.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* lib/irb/context.rb (IRB::Context#evaluate): separate the code
from wrapping lines to propagate the given exception, not to show
the wrapping lines when SyntaxError.
|
|
|
|
|
|
|
|
for improving readability of the condition. It may be slightly faster, or may not.
|
|
The reason why we were checking lexer state in addition to token was
that we do not want to colorize local variable, method call, etc., while
they share the :on_ident token with a name of method definition which
should be colored as blue.
It means that we're concerned about the lexer state only for :on_ident.
Thus we can skip checking lexer state for non-:on_ident tokens. This
refactoring is based on that idea.
Also, now we manage Ripper's lexer state as Integer (use `|` if you
need to check multiple states). It should be faster than using Array of
Integer because #any? block call is not needed.
|
|
|
|
|
|
and sorted the token names alphabetically.
|
|
|
|
|
|
|
|
|
|
Please refer to the tests again.
|
|
See tests for what kind of things are fixed.
|
|
Symbol color was made blue as a workaround because it was hard to
distinguish `foo`s in `:foo` and `def foo; end` (both are :on_ident).
But I wanted to make it yellow like pry.
`:Struct` had the same problem in :on_const. Because the :on_const was
also blue (but underlined and bold), it was not a big issue.
While they're not so problematic since we got a workaround, we also had
a more serious issue for highlighting a symbol like `:"a#{b}c"`.
The first half was considered as Symbol and the last half was considered
as String, because the colorizer did not have a state like a parser.
To approach the last issue, I introduced `IRB::Color::SymbolState` which
is a thin state manager knowing only "the token is Symbol or not". Having
this module magically solves the first two problems as well. So now we
can highlight Symbol as yellow in the perfect manner.
|
|
|
|
Heredoc, %i, :Foo, { 'a': ... }, ...
:'a' is still half-broken.
|
|
because otherwise prompt and other things could be polluted.
|
|
|
|
|
|
Closes: https://github.com/ruby/ruby/pull/2202
|
|
pp Ripper.lex('{ "a": 3 }')
=>
[[[1, 0], :on_lbrace, "{", EXPR_BEG|EXPR_LABEL],
[[1, 1], :on_sp, " ", EXPR_BEG|EXPR_LABEL],
[[1, 2], :on_tstring_beg, "\"", EXPR_BEG|EXPR_LABEL],
[[1, 3], :on_tstring_content, "a", EXPR_BEG|EXPR_LABEL],
[[1, 4], :on_label_end, "\":", EXPR_BEG|EXPR_LABEL],
[[1, 6], :on_sp, " ", EXPR_BEG|EXPR_LABEL],
[[1, 7], :on_int, "3", EXPR_END],
[[1, 8], :on_sp, " ", EXPR_END],
[[1, 9], :on_rbrace, "}", EXPR_END]]
|
|
|
|
|
|
|