Skip to content

Remove all remaining use of raw: interpolations #2086

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 2 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CodeGeneration/Sources/SyntaxSupport/Node.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class Node {

/// If the syntax node can be constructed by parsing a string, the parser
/// function that should be invoked to create this node.
public let parserFunction: String?
public let parserFunction: TokenSyntax?

/// A name for this node that is suitable to be used as a variables or enum
/// case's name.
Expand Down Expand Up @@ -110,7 +110,7 @@ public class Node {
isExperimental: Bool = false,
nameForDiagnostics: String?,
documentation: String? = nil,
parserFunction: String? = nil,
parserFunction: TokenSyntax? = nil,
traits: [String] = [],
children: [Child] = []
) {
Expand Down Expand Up @@ -229,7 +229,7 @@ public class Node {
isExperimental: Bool = false,
nameForDiagnostics: String?,
documentation: String? = nil,
parserFunction: String? = nil,
parserFunction: TokenSyntax? = nil,
elementChoices: [SyntaxNodeKind]
) {
self.kind = kind
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let parserEntryFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
// incremental parse and would then live in a different arena than
// `parser.arena`.
defer { withExtendedLifetime(parser) {} }
let node = parser.\(raw: parserFunction)()
let node = parser.\(parserFunction)()
let raw = RawSyntax(parser.parseRemainder(into: node))
return Syntax(raw: raw, rawNodeArena: raw.arena).cast(Self.self)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ let rawSyntaxNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
}

if let node = node.collectionNode {
let element = node.elementChoices.only != nil ? "\(node.elementChoices.only!.rawType)" : "Element"
let element = node.elementChoices.only != nil ? node.elementChoices.only!.rawType : "Element"
DeclSyntax(
"""
public init(elements: [\(raw: element)], arena: __shared SyntaxArena) {
public init(elements: [\(element)], arena: __shared SyntaxArena) {
let raw = RawSyntax.makeLayout(
kind: .\(node.varOrCaseName), uninitializedCount: elements.count, arena: arena) { layout in
guard var ptr = layout.baseAddress else { return }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func syntaxNode(emitKind: SyntaxNodeKind) -> SourceFileSyntax {
/// - returns: A copy of the receiver with the provided `\(raw: childElt)`
/// appended to its `\(child.varOrCaseName)` collection.
@available(*, deprecated, message: "Use node.\(child.varOrCaseName).append(newElement) instead")
public func add\(raw: childElt)(_ element: \(raw: childEltType)) -> \(node.kind.syntaxType) {
public func add\(raw: childElt)(_ element: \(childEltType)) -> \(node.kind.syntaxType) {
var collection: RawSyntax
let arena = SyntaxArena()
if let col = raw.layoutView!.children[\(raw: index)] {
Expand Down