Skip to content

Eliminate SyntaxNode #684

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

Merged
merged 1 commit into from
Sep 6, 2022
Merged

Eliminate SyntaxNode #684

merged 1 commit into from
Sep 6, 2022

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Sep 1, 2022

SyntaxNode was introduced as a lighter Syntax when existentials were needed for creating Syntax instance.

Now that Syntax/SyntaxData is just a struct that holds one class (SyntaxBox). So it's not that heavy.
More importantly SyntaxNode was not safe to escape because it didn't retain the SyntaxArena of the AbsoluteRawSyntax

SyntaxNode was only used in SyntaxCursor for IncrementalParseLookup. Use SyntaxData instead.

(Conflicts with #659 . Will rebase after merging it)

(No noticeable performance regression with a test case in rdar://48511326)

@rintaro
Copy link
Member Author

rintaro commented Sep 1, 2022

@swift-ci Please test

@rintaro rintaro force-pushed the syntaxnode-remove branch 2 times, most recently from b2f9466 to dff8f69 Compare September 2, 2022 21:08
@rintaro
Copy link
Member Author

rintaro commented Sep 2, 2022

@swift-ci Please test

@rintaro
Copy link
Member Author

rintaro commented Sep 2, 2022

@swift-ci Please test

@rintaro rintaro marked this pull request as ready for review September 2, 2022 23:01
@rintaro rintaro requested a review from ahoppen as a code owner September 2, 2022 23:01
`SyntaxNode` was introduced as a lighter `Syntax` when existentials were
needed for creating `Syntax` instance.

Now that `Syntax`/`SyntaxData` is just a struct that holds one class
(`SyntaxBox`). So it's not that heavy.
More importantly `SyntaxNode` was not safe to escape because it didn't
retain the `SyntaxArena` of the `AbsoluteRawSyntax`

`SyntaxNode` was only used in `SyntaxCursor` for `IncrementalParseLookup`.
Use `SyntaxData` instead.
@rintaro
Copy link
Member Author

rintaro commented Sep 2, 2022

@swift-ci Please test

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

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

A great simplification. Thank you.

@@ -766,3 +663,6 @@ extension RawSyntaxNodeProtocol {
return Syntax(raw: raw).recursiveDescription
}
}

@available(*, unavailable, message: "use 'Syntax' instead")
public struct SyntaxNode {}
Copy link
Member

Choose a reason for hiding this comment

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

Is this useful in any way or just an artifact from your local development?

Copy link
Member Author

Choose a reason for hiding this comment

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

I left this only because SyntaxNode was a public type. Since the initializer was not public, I don't anticipate anyone is using this. But still.

@rintaro rintaro merged commit ec7f015 into swiftlang:main Sep 6, 2022
@rintaro rintaro deleted the syntaxnode-remove branch September 6, 2022 16:59
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.

2 participants