<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/lib/syntax_suggest/code_line.rb, branch v4.0.4</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>[ruby/syntax_suggest] Refactor multi-prism version logic</title>
<updated>2026-01-21T18:11:17+00:00</updated>
<author>
<name>Schneems</name>
<email>richard.schneeman+foo@gmail.com</email>
</author>
<published>2026-01-20T21:32:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=12203963d22a984154c1abb03782c345ba8f5129'/>
<id>12203963d22a984154c1abb03782c345ba8f5129</id>
<content type='text'>
The reason this logic for different methods branches in the class instead of internally was to be eagerly aggressive about runtime performance. This code is currently only used once for the document where it's invoked ~N times (where N is number of lines):

```ruby
module SyntaxSuggest
  class CleanDocument
    # ...
    def join_trailing_slash!
      trailing_groups = @document.select(&amp;:trailing_slash?).map do |code_line|
        take_while_including(code_line.index..) { |x| x.trailing_slash? }
      end
      join_groups(trailing_groups)
      self
    end
```

Since this is not currently a hot-spot I think merging the branches and using a case statement is a reasonable tradeoff and avoids the need to do specific version testing.

An alternative idea was presented in #241 of behavior-based testing for branch logic (which I would prefer), however, calling the code triggered requiring a `DelegateClass` when the `syntax_suggest/api` is being required.

https://github.com/ruby/syntax_suggest/commit/ab122c455f
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The reason this logic for different methods branches in the class instead of internally was to be eagerly aggressive about runtime performance. This code is currently only used once for the document where it's invoked ~N times (where N is number of lines):

```ruby
module SyntaxSuggest
  class CleanDocument
    # ...
    def join_trailing_slash!
      trailing_groups = @document.select(&amp;:trailing_slash?).map do |code_line|
        take_while_including(code_line.index..) { |x| x.trailing_slash? }
      end
      join_groups(trailing_groups)
      self
    end
```

Since this is not currently a hot-spot I think merging the branches and using a case statement is a reasonable tradeoff and avoids the need to do specific version testing.

An alternative idea was presented in #241 of behavior-based testing for branch logic (which I would prefer), however, calling the code triggered requiring a `DelegateClass` when the `syntax_suggest/api` is being required.

https://github.com/ruby/syntax_suggest/commit/ab122c455f
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/syntax_suggest] Handle `on_sp` when using prism</title>
<updated>2026-01-21T18:11:17+00:00</updated>
<author>
<name>Earlopain</name>
<email>14981592+Earlopain@users.noreply.github.com</email>
</author>
<published>2026-01-20T12:38:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=bbba57f22c7eb7279297e03f8124d51135a7e87a'/>
<id>bbba57f22c7eb7279297e03f8124d51135a7e87a</id>
<content type='text'>
It used to not emit this token type, but now it does.
So when a newer version of prism is present, we can fall back
to the same code that ripper uses.

Ref:
* https://github.com/ruby/ruby/pull/15914
* https://github.com/ruby/prism/pull/3859

https://github.com/ruby/syntax_suggest/commit/42a3b8f6cb
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
It used to not emit this token type, but now it does.
So when a newer version of prism is present, we can fall back
to the same code that ripper uses.

Ref:
* https://github.com/ruby/ruby/pull/15914
* https://github.com/ruby/prism/pull/3859

https://github.com/ruby/syntax_suggest/commit/42a3b8f6cb
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/syntax_suggest] Support lexing with Prism</title>
<updated>2023-12-05T17:51:28+00:00</updated>
<author>
<name>Schneems</name>
<email>richard.schneeman+foo@gmail.com</email>
</author>
<published>2023-12-04T21:23:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=62c96959114ea165f7434da9edc42d15e4aaebfa'/>
<id>62c96959114ea165f7434da9edc42d15e4aaebfa</id>
<content type='text'>
https://github.com/ruby/syntax_suggest/commit/7f4176a914
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/syntax_suggest/commit/7f4176a914
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/syntax_suggest] Rollback comment indentation behavior</title>
<updated>2023-04-06T06:45:29+00:00</updated>
<author>
<name>schneems</name>
<email>richard.schneeman+foo@gmail.com</email>
</author>
<published>2023-03-09T20:13:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=63ea6b0cf2b7fd27e22dc7b468fe65ee2c79b23a'/>
<id>63ea6b0cf2b7fd27e22dc7b468fe65ee2c79b23a</id>
<content type='text'>
Originally I fixed https://github.com/ruby/syntax_suggest/pull/177 by making the process of comment removal indentation aware. The next commit is the more general fix and means we don't need to carry that additional logic/overhead.

Also: Update syntax via linter
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Originally I fixed https://github.com/ruby/syntax_suggest/pull/177 by making the process of comment removal indentation aware. The next commit is the more general fix and means we don't need to carry that additional logic/overhead.

Also: Update syntax via linter
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/syntax_suggest] Preserve whitespace in front of comments</title>
<updated>2023-04-06T06:45:28+00:00</updated>
<author>
<name>schneems</name>
<email>richard.schneeman+foo@gmail.com</email>
</author>
<published>2023-03-08T14:51:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=e5236471c3ce194199a6ceb70012eb2ca243407e'/>
<id>e5236471c3ce194199a6ceb70012eb2ca243407e</id>
<content type='text'>
When removing comments I previously replaced them with a newline. This loses some context and may affect the order of the indent search which in turn affects the final result. By preserving whitespace in front of the comment, we preserve the "natural" indentation order of the line while also allowing the parser/lexer to see and join naturally consecutive (method chain) lines.

close https://github.com/ruby/syntax_suggest/pull/177
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When removing comments I previously replaced them with a newline. This loses some context and may affect the order of the indent search which in turn affects the final result. By preserving whitespace in front of the comment, we preserve the "natural" indentation order of the line while also allowing the parser/lexer to see and join naturally consecutive (method chain) lines.

close https://github.com/ruby/syntax_suggest/pull/177
</pre>
</div>
</content>
</entry>
<entry>
<title>Sync SyntaxSuggest</title>
<updated>2022-08-19T01:02:24+00:00</updated>
<author>
<name>schneems</name>
<email>richard.schneeman+foo@gmail.com</email>
</author>
<published>2022-07-26T20:21:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=490af8dbdb66263f29d0b4e43752fbb298b94862'/>
<id>490af8dbdb66263f29d0b4e43752fbb298b94862</id>
<content type='text'>
```
$ tool/sync_default_gems.rb syntax_suggest
```
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
```
$ tool/sync_default_gems.rb syntax_suggest
```
</pre>
</div>
</content>
</entry>
</feed>
