-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add command spoom srb sigs translate
to translate RBI signatures into RBS comments
#611
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Alexandre Terrasa <[email protected]>
|
||
LINE_BREAK = T.let(0x0A, Integer) | ||
|
||
# After character 0xFFFF, UTF-16 considers characters to have length 2 and we have to account for that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this complexity wrt to UTF-16 codepoints was only about the fact that VS Code only considers UTF-16 but our code is in UTF-8.
I am not sure if we need the same complexity here. We should be able to treat it as a string of codepoints (or even bytes).
Signed-off-by: Alexandre Terrasa <[email protected]>
Signed-off-by: Alexandre Terrasa <[email protected]>
sigs = translator.sigs.sort_by { |sig, _rbs_string| -T.must(sig.loc&.begin_line) } | ||
|
||
sigs.each do |sig, rbs_string| | ||
scanner = Scanner.new(ruby_contents, Encoding::UTF_8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you know that the source is UTF-8?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be:
scanner = Scanner.new(ruby_contents, Encoding::UTF_8) | |
scanner = Scanner.new(ruby_contents, ruby_contents.encoding) |
Consider the following
file.rb
:We can translate the RBI signatures it contains using the introduced Spoom command:
Wich will update the file contents as follows: