summaryrefslogtreecommitdiff
path: root/lib/syntax_suggest/code_line.rb
AgeCommit message (Collapse)Author
2026-01-21[ruby/syntax_suggest] Refactor multi-prism version logicSchneems
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(&: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
2026-01-21[ruby/syntax_suggest] Handle `on_sp` when using prismEarlopain
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
2023-12-05[ruby/syntax_suggest] Support lexing with PrismSchneems
https://github.com/ruby/syntax_suggest/commit/7f4176a914
2023-04-06[ruby/syntax_suggest] Rollback comment indentation behaviorschneems
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
2023-04-06[ruby/syntax_suggest] Preserve whitespace in front of commentsschneems
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
2022-08-19Sync SyntaxSuggestschneems
``` $ tool/sync_default_gems.rb syntax_suggest ``` Notes: Merged: https://github.com/ruby/ruby/pull/5859