Skip to content

Support multiline sig#428

Open
st0012 wants to merge 2 commits intomasterfrom
multiline-sig-2
Open

Support multiline sig#428
st0012 wants to merge 2 commits intomasterfrom
multiline-sig-2

Conversation

@st0012
Copy link
Copy Markdown
Member

@st0012 st0012 commented Apr 6, 2025

Motivation

I added the new RBSDeclaration class to one or multiple comments as in many context, especially type translation, we won't know which exact comment to pass down beforehand. With RBSDeclaration::typeLocFromRange, we should be able to convert the rbs token range into a Sorbet location.

With RBSDeclaration, supporting multiline helpers, assertions, or attribute signatures will be easier too.

Test plan

See included automated tests.

const rbs::Comment &assertion) {
rbs_string_t rbsString = makeRBSString(assertion.string);
const rbs::RBSDeclaration &assertion) {
string signatureString = assertion.string();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to hold the string value here to make sure it has the same lifecycle as this entire function.

Comment thread rbs/SigsRewriter.cc
uint32_t continueIndex = index + line.size();

// Look downwards (later lines) for continuation lines starting with "#|"
auto forwardIt = all_lines.begin() + 1 + distance(it, all_lines.rend()) -
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To read consequent lines, I used another iterator to continue moving down.

@Hassan222-ux

This comment was marked as spam.

st0012 and others added 2 commits April 10, 2025 16:33
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants