Conversation
Rewriter performs character-range replacements on Buffer content using RBS::Location, preserving everything outside the rewritten ranges. Unlike Writer which regenerates entire source from AST, this allows modifying specific parts without losing non-documentation comments. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Split the comment rewriting API into three focused methods: - add_comment(*locations, content:) inserts before the earliest location - replace_comment(comment, content:) rewrites comment content in place - delete_comment(comment) removes comment lines including indentation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace AST mutation + Writer serialization with Rewriter-based comment editing, preserving non-documentation comments and original formatting in annotated RBS files. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Rewriter always preserves formatting, so preserve: is no longer needed. Default it to true and mark the overload with preserve: as deprecated. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Member
Author
|
I plan to implement more APIs on |
Rewriter always preserves formatting, so the flag is no longer needed. Keep the option for backwards compatibility but mark it as deprecated. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RBS::Rewriterclass for targeted character-range replacements onBuffercontentadd_comment,replace_comment,delete_commentmethods for comment manipulationrbs annotateto useRewriterinstead ofWriter, preserving non-documentation comments and original formatting (inline comments, multi-line definitions, etc.)preserve:parameter inannotate_filesinceRewriteralways preserves formattingMotivation
RBS::Writerregenerates the entire file from AST, which loses non-documentation comments (inline comments like# Some comment hereat end of lines).RBS::Rewriteronly modifies the specific locations that need to change, preserving everything else.Test plan
ruby -Ilib -Itest test/rbs/rewriter_test.rb— 20 tests for Rewriterruby -Ilib -Itest test/rbs/annotate/rdoc_annotator_test.rb— 10 tests for annotator integration🤖 Generated with Claude Code