Skip to content
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

[swift2objc] Support nested declarations #1749

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

[swift2objc] Support nested declarations #1749

wants to merge 3 commits into from

Conversation

liamappelbe
Copy link
Contributor

@liamappelbe liamappelbe commented Nov 26, 2024

  • In the AST, replace pathComponents with a new interface, NestableDeclaration, containing child and parent links.
  • In the symbolgraph, the parent/child relationship is defined by a memberOf relationship. This is the same relationship as methods and properties, so all the declaration parsing infrastructure is already there.
  • Parsing a ReferredType for a nested type is easy too. They look like [Foo, ".", Bar], but Bar's token has its fully qualified globally unique ID. So we can actually just discard Foo and parse Bar normally. See _nestedTypeParselet.
  • Nested declarations are code-genned inside their parent
    • This requires a bit of care when finding unique names for them. These declarations have to be named using the parent's UniqueNamer, not the global one
    • That means we have to make sure (with an assert) that we're only ever transforming the nested declaration in the scope of the parent.
  • Change code-gen pipeline to pass around List<String> instead of String.
    • Previously we were doing indenting by splitting the string, adding indents, then joining. This was happening every time we indented, which is pretty inefficient.
    • Better to pass around lists of lines, and only join them at the end.
    • This caused a bunch of whitespace changes in the integration tests.

@coveralls
Copy link

coveralls commented Nov 26, 2024

Coverage Status

coverage: 88.839% (+0.03%) from 88.809%
when pulling 0f82ecf on nested
into 4ce4816 on main.

@liamappelbe liamappelbe changed the title WIP: [swift2objc] Support nested declarations [swift2objc] Support nested declarations Nov 26, 2024
@liamappelbe liamappelbe marked this pull request as ready for review November 26, 2024 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants