18 Commits

Author SHA1 Message Date
Yusuke Endoh
e01b4ca1c8 [ruby/error_highlight] Ensure first_line and last_line are set
Fixes https://github.com/ruby/error_highlight/pull/58

https://github.com/ruby/error_highlight/commit/9ddc1f31a9
2025-01-29 08:51:42 +00:00
Luke Gruber
2a0ee408af [ruby/error_highlight] Fix error with prism when method given no arguments
such as:

  p = Proc.new

This now matches the RubyVM::AbstractSyntaxTree behavior, which is
not to highlight anything.

https://github.com/ruby/error_highlight/commit/d5c592a1ba
2024-09-24 13:28:01 +00:00
Adam Hess
4b1e852d3e
[ruby/error_highlight] Prism added node_id and Node#breadth_first_search in the 1.0 release. These methods are required for Prism to be able to find the method from the backtrace.
https://github.com/ruby/prism/blob/main/CHANGELOG.md#100---2024-08-28

In practice you will likely only end up in this situation if you previously had pre-1.0 prism installed and upgrade Ruby to a version with Prism as the default parser.

https://github.com/ruby/error_highlight/commit/cb574daf62
2024-09-24 15:33:31 +09:00
Kevin Newton
c1df15c3e6 [PRISM] Use node ids for error highlight 2024-07-11 14:25:54 -04:00
Kevin Newton
51bb5dcd2e [ruby/error_highlight] Trim trailing spaces in base.rb
https://github.com/ruby/error_highlight/commit/8ce3f6f145
2024-06-07 13:28:23 +00:00
Kevin Newton
40ec860de7 [ruby/error_highlight] Support for the prism compiler
https://github.com/ruby/error_highlight/commit/69fbacfd49
2024-06-07 13:15:14 +00:00
Kevin Newton
82a4c3af16 Add error for iseqs compiled by prism 2024-02-21 11:44:40 -05:00
Yusuke Endoh
94d6d6d93f [ruby/error_highlight] Identify which node in Foo::Bar::Baz causes a NameError
In Ruby 3.2 or later, a nested constant access like `Foo::Bar::Baz` is
compiled to one instruction by the optimization https://github.com/ruby/ruby/pull/6187

We try to spot which sub-node caues a NameError in question based on the
constant name. We will give up if the same constant name is accessed in
a nested access (`Foo::Foo`).

Fixes https://github.com/ruby/error_highlight/pull/31

https://github.com/ruby/error_highlight/commit/0a4db7da0a
2023-01-13 08:25:09 +00:00
eileencodes
350d0aa023 [ruby/error_highlight] Support nodes in spot
Fixes a bug where `spot` was using the wrong local variable.

We want to use error highlight with code that has been eval'd,
specifically ERB templates. We can recover the compiled source code of
the ERB template but we need an API to pass the node into error
highlight's `spot`.

Required Ruby PR: https://github.com/ruby/ruby/pull/6593

https://github.com/ruby/error_highlight/commit/0b1b650a59

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2022-10-31 04:58:38 +00:00
Yusuke Endoh
d9f1b8baa3 [ruby/error_highlight] Add a note about the current limitation of ErrorHighlight.spot
https://github.com/ruby/error_highlight/commit/489ce80a62
2022-08-12 14:04:41 +09:00
Yusuke Endoh
3a58009066 [ruby/error_highlight] Make backtrace_location keyword work
We had to keep backtrace_location before opts is overwritten.

https://github.com/ruby/error_highlight/commit/2735e4681a
2022-08-10 21:19:10 +09:00
Yusuke Endoh
99e7fa5b37 [ruby/error_highlight] Make ErrorHighlight.spot accept Exception (https://github.com/ruby/error_highlight/pull/25)
... and move things from core_ext.rb to base.rb.
This will confine CRuby-dependent things to ErrorHighlight.spot.

https://github.com/ruby/error_highlight/commit/22d1dd7824
2022-08-10 18:37:13 +09:00
Masataka Pocke Kuwabara
242f024bcb [ruby/error_highlight] Keep it work if paren exists after receiver
https://github.com/ruby/error_highlight/commit/b79d679bbd
2021-07-31 22:15:16 +09:00
Yusuke Endoh
5fd5d71a4b [ruby/error_highlight] Support a file that has no final newline
https://github.com/ruby/error_highlight/commit/9d671284cb
2021-07-13 16:54:17 +09:00
Yusuke Endoh
8b01d16ad6 [ruby/error_highlight] Stop showing a code snippet if it has non-ascii characters
See https://github.com/ruby/error_highlight/issues/4

https://github.com/ruby/error_highlight/commit/c20efd3961
2021-07-12 16:48:15 +09:00
Yusuke Endoh
ca4e5b1eb3 [ruby/error_highlight] Reconsider the API of ErrorHighlight.spot
https://github.com/ruby/error_highlight/commit/acb2046a82
2021-06-30 12:49:27 +09:00
Yusuke Endoh
f428ced69c [ruby/error_highlight] Experimentally support a custom formatter
https://github.com/ruby/error_highlight/commit/f40a1de20e
2021-06-30 12:49:18 +09:00
Yusuke Endoh
9438c99590 Rename error_squiggle to error_highlight 2021-06-29 23:45:49 +09:00