Conversation
vinistock
left a comment
There was a problem hiding this comment.
It would be nice to run a quick benchmark against rbs core and stdlib to understand if there's significant performance impact of trying to split the comments.
| } | ||
|
|
||
| #[test] | ||
| fn split_multiline_comments() { |
There was a problem hiding this comment.
Let's add a test with an escaped line break as part of the comment's content. It's easy for this to get confused.
# splits strings at the \\n char
def foo; end|
|
||
| #[test] | ||
| fn split_multiline_comments() { | ||
| let source = "# First line\n# Second line\n# Third line\nclass Foo\nend"; |
There was a problem hiding this comment.
Can't we use index_source and nicely indent the example like we do in other tests?
There was a problem hiding this comment.
Should we also have a test that shows how it behaves with an initial indent?
module Outer
# First line
# Second line
class Inner
end
end|
I run a quick benchmark with RBS files in DetailsBeforeAfter |
rust/rubydex/src/model/graph.rs
Outdated
| if has_docs { | ||
| declarations_with_docs += 1; | ||
| let doc_size: usize = definitions.iter().map(|def| def.comments().len()).sum(); | ||
| let doc_size: usize = definitions.iter().map(|def| def.comments().iter().map(|c| c.string().len()).sum::<usize>()).sum(); |
There was a problem hiding this comment.
It says bytes, but it actually was lines. (lines would also make sense, but this is a fix to make it bytes.)
| let line_text = if i == 0 { | ||
| line.to_string() | ||
| } else { | ||
| line[indent_len..].to_string() | ||
| }; |
There was a problem hiding this comment.
Is this assuming that all comment lines are indented the same? What happens in this case? Let's add a test to document the behaviour.
class Foo
# my first comment starts out great
# now I mess up the indent
def bar: () -> void
# this one is the opposite
# I fix it later
def baz: () -> void
endThere was a problem hiding this comment.
My bad. 🙇♂️
I was thinking the RBS parser rejects the differently indented comments, but it actually accepts. I need to fix the implementation.
#87
An RBS
CommentNodeobject represents sequence of comment lines, but the RubydexCommentobject represents a line of comment. This PR implements the conversion from oneCommentNodeto list ofCommentobjects.