Skip to content

Move SwiftSyntaxParser related code to its own module #614

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
Aug 23, 2022

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Aug 19, 2022

  • Remove _SyntaxParserInterop.swift
  • Use RawSyntax.toOpaque()/RawSyntax.fromOpaque(:_) to interop
  • Move RawSyntax.createFromCSyntaxNode() to the module
  • Move SyntaxKind/RawTokenKind/RawTriviaPiece creation from C serialization code to the module
  • Tweak some RawSyntax API visibility
  • Refactor materialized token creation API to efficiently create a token from SyntaxParser modules
  • Introduce Syntax.withUnsafeRawSyntax(_:) API

@rintaro rintaro requested a review from ahoppen as a code owner August 19, 2022 22:40
@rintaro rintaro force-pushed the syntaxparser-move branch 3 times, most recently from 705acf9 to 8eeb394 Compare August 19, 2022 22:49
@@ -286,6 +287,3 @@ extension Diagnostic {
}
}

fileprivate func verifyCNodeLayoutHash() -> Bool {
return cNodeLayoutHash() == SwiftSyntax.cNodeLayoutHash()
Copy link
Member Author

Choose a reason for hiding this comment

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

Now that SwiftSyntax doesn't know anything about CNodes, so this is not needed anymore.

@rintaro
Copy link
Member Author

rintaro commented Aug 20, 2022

@swift-ci Please test

@rintaro rintaro force-pushed the syntaxparser-move branch 4 times, most recently from 105fcc8 to 9ecba2b Compare August 20, 2022 04:47
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.

Nice. This is great work, making the SwiftSyntax module smaller.

guard var ptr = buffer.baseAddress else { return }
for cnode in cnodes {
let element: RawSyntax? = cnode.map {
// 'CClinentNode' is a node created with `toOpaque()`
Copy link
Member

Choose a reason for hiding this comment

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

Typo

Suggested change
// 'CClinentNode' is a node created with `toOpaque()`
// 'CClientNode' is a node created with `toOpaque()`

let syntaxKind = SyntaxKind(serializationCode: cnode.kind)
assert(syntaxKind != .token)

let cnodes = UnsafeBufferPointer<CClientNode?>(
Copy link
Member

Choose a reason for hiding this comment

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

Maybe call cnodes children instead?

* Remove `_SyntaxParserInterop.swift`
* Use `RawSyntax.toOpaque()`/`RawSyntax.fromOpaque(:_)` to interop
* Move `RawSyntax.createFromCSyntaxNode()` to the module
* Move SyntaxKind/RawTokenKind/RawTriviaPiece creation from C
  serialization code to the module
* Tweak some RawSyntax API visibility
* Refactor materialized token creation API to efficiently create a
  them from the parser modules
* Introduce `Syntax.withUnsafeRawSyntax(_:)` API
@rintaro rintaro force-pushed the syntaxparser-move branch from 9ecba2b to 6bcf9fd Compare August 22, 2022 16:49
@rintaro
Copy link
Member Author

rintaro commented Aug 22, 2022

@swift-ci Please test

@rintaro rintaro merged commit 101bbc6 into swiftlang:main Aug 23, 2022
@rintaro rintaro deleted the syntaxparser-move branch August 23, 2022 02:24
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