Skip to content

Support multiline sig #428

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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Support multiline sig #428

wants to merge 11 commits into from

Conversation

st0012
Copy link
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
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.

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
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.

jez and others added 11 commits April 8, 2025 15:25
In 5865c505bdb30e80b1a1861a92b6a62d751d8827, Trevor made it so that
`getFiles` returns a span instead of a const vector, which means that we
now have access to the `subspan` method, and we can avoid doing some
branches inside a loop.

Slight performance improvement, but really just a nice to have.
* Compute, don't store, fullTestPkgName

This was only ever used in error messages, so it does not need to live
forever in the PackageDB.

* Remove operator== from PackageName

* Factor VisibleTo struct from a `pair`

* Use LocOffsets in FullyQualifiedName

* Remove redundant PackageName::loc

* whoops
* Inline commitFileUpdates into the fast-path

* Inline commitFileUpdates into the slow path

* Remove commitFileUpdates
This comment was added in 
ba2dcca when a call to a method named `isPackagerMaterializedConstantRef` was added to the following `if` condition.

In 49b02c3 that method was deleted and removed from the condition, but the comment was not removed.

This comment references the old implementation of package visibility which worked based on syntactic rewrites instead of first-class visibility checking.
* Stop populating updatedFileIndexes

* Feedback from code review

* Name change: cacheOpenFiles -> cacheUpdatedFiles
We don't actually need this `_Package` suffix.

I'm working on some changes which will completely replace `MangledName`
with `PackageRef` IDs. Eventually, nothing will operate on
`MangledName`.

I also thought that we might have an optimization that meant that the
strings backing two names like `Opus_Foo` and `Opus_Foo_Bar` could
overlap in the string table, but I don't actually know if that's the
case now that I'm looking at the code—it looks like if a name doesn't
exist we unconditionally copy the whole string into the string table.

Regardless, this should save memory because we're not storing `8 *
num_packages` extra bytes in the name table.
Signed-off-by: Alexandre Terrasa <[email protected]>
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.

6 participants