Skip to content

Regnerate gyb-files to support 'any' types #369

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
Mar 15, 2022
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
10 changes: 5 additions & 5 deletions Sources/SwiftSyntax/gyb_generated/Misc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1297,10 +1297,10 @@ extension SyntaxNode {
return OptionalTypeSyntax(asSyntaxData)
}

public var isSomeType: Bool { return raw.kind == .someType }
public var asSomeType: SomeTypeSyntax? {
guard isSomeType else { return nil }
return SomeTypeSyntax(asSyntaxData)
public var isConstrainedSugarType: Bool { return raw.kind == .constrainedSugarType }
public var asConstrainedSugarType: ConstrainedSugarTypeSyntax? {
guard isConstrainedSugarType else { return nil }
return ConstrainedSugarTypeSyntax(asSyntaxData)
}

public var isImplicitlyUnwrappedOptionalType: Bool { return raw.kind == .implicitlyUnwrappedOptionalType }
Expand Down Expand Up @@ -1931,7 +1931,7 @@ extension Syntax {
return node
case .optionalType(let node):
return node
case .someType(let node):
case .constrainedSugarType(let node):
return node
case .implicitlyUnwrappedOptionalType(let node):
return node
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftSyntax/gyb_generated/SyntaxAnyVisitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1555,11 +1555,11 @@ open class SyntaxAnyVisitor: SyntaxVisitor {
override open func visitPost(_ node: OptionalTypeSyntax) {
visitAnyPost(node._syntaxNode)
}
override open func visit(_ node: SomeTypeSyntax) -> SyntaxVisitorContinueKind {
override open func visit(_ node: ConstrainedSugarTypeSyntax) -> SyntaxVisitorContinueKind {
return visitAny(node._syntaxNode)
}

override open func visitPost(_ node: SomeTypeSyntax) {
override open func visitPost(_ node: ConstrainedSugarTypeSyntax) {
visitAnyPost(node._syntaxNode)
}
override open func visit(_ node: ImplicitlyUnwrappedOptionalTypeSyntax) -> SyntaxVisitorContinueKind {
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftSyntax/gyb_generated/SyntaxBaseNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public struct TypeSyntax: TypeSyntaxProtocol, SyntaxHashable {
/// `nil` if the conversion is not possible.
public init?(_ syntax: Syntax) {
switch syntax.raw.kind {
case .unknownType, .simpleTypeIdentifier, .memberTypeIdentifier, .classRestrictionType, .arrayType, .dictionaryType, .metatypeType, .optionalType, .someType, .implicitlyUnwrappedOptionalType, .compositionType, .tupleType, .functionType, .attributedType:
case .unknownType, .simpleTypeIdentifier, .memberTypeIdentifier, .classRestrictionType, .arrayType, .dictionaryType, .metatypeType, .optionalType, .constrainedSugarType, .implicitlyUnwrappedOptionalType, .compositionType, .tupleType, .functionType, .attributedType:
self._syntaxNode = syntax
default:
return nil
Expand All @@ -394,7 +394,7 @@ public struct TypeSyntax: TypeSyntaxProtocol, SyntaxHashable {
// Assert that the kind of the given data matches in debug builds.
#if DEBUG
switch data.raw.kind {
case .unknownType, .simpleTypeIdentifier, .memberTypeIdentifier, .classRestrictionType, .arrayType, .dictionaryType, .metatypeType, .optionalType, .someType, .implicitlyUnwrappedOptionalType, .compositionType, .tupleType, .functionType, .attributedType:
case .unknownType, .simpleTypeIdentifier, .memberTypeIdentifier, .classRestrictionType, .arrayType, .dictionaryType, .metatypeType, .optionalType, .constrainedSugarType, .implicitlyUnwrappedOptionalType, .compositionType, .tupleType, .functionType, .attributedType:
break
default:
fatalError("Unable to create TypeSyntax from \(data.raw.kind)")
Expand Down
22 changes: 11 additions & 11 deletions Sources/SwiftSyntax/gyb_generated/SyntaxBuilders.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9613,19 +9613,19 @@ extension OptionalTypeSyntax {
}
}

public struct SomeTypeSyntaxBuilder {
public struct ConstrainedSugarTypeSyntaxBuilder {
private var layout =
Array<RawSyntax?>(repeating: nil, count: 2)

internal init() {}

public mutating func useSomeSpecifier(_ node: TokenSyntax) {
let idx = SomeTypeSyntax.Cursor.someSpecifier.rawValue
public mutating func useSomeOrAnySpecifier(_ node: TokenSyntax) {
let idx = ConstrainedSugarTypeSyntax.Cursor.someOrAnySpecifier.rawValue
layout[idx] = node.raw
}

public mutating func useBaseType(_ node: TypeSyntax) {
let idx = SomeTypeSyntax.Cursor.baseType.rawValue
let idx = ConstrainedSugarTypeSyntax.Cursor.baseType.rawValue
layout[idx] = node.raw
}

Expand All @@ -9637,22 +9637,22 @@ public struct SomeTypeSyntaxBuilder {
layout[1] = RawSyntax.missing(SyntaxKind.type)
}

return .forRoot(RawSyntax.createAndCalcLength(kind: .someType,
return .forRoot(RawSyntax.createAndCalcLength(kind: .constrainedSugarType,
layout: layout, presence: .present))
}
}

extension SomeTypeSyntax {
/// Creates a `SomeTypeSyntax` using the provided build function.
extension ConstrainedSugarTypeSyntax {
/// Creates a `ConstrainedSugarTypeSyntax` using the provided build function.
/// - Parameter:
/// - build: A closure that will be invoked in order to initialize
/// the fields of the syntax node.
/// This closure is passed a `SomeTypeSyntaxBuilder` which you can use to
/// This closure is passed a `ConstrainedSugarTypeSyntaxBuilder` which you can use to
/// incrementally build the structure of the node.
/// - Returns: A `SomeTypeSyntax` with all the fields populated in the builder
/// - Returns: A `ConstrainedSugarTypeSyntax` with all the fields populated in the builder
/// closure.
public init(_ build: (inout SomeTypeSyntaxBuilder) -> Void) {
var builder = SomeTypeSyntaxBuilder()
public init(_ build: (inout ConstrainedSugarTypeSyntaxBuilder) -> Void) {
var builder = ConstrainedSugarTypeSyntaxBuilder()
build(&builder)
let data = builder.buildData()
self.init(data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ extension SyntaxClassification {
return (.typeIdentifier, false)
case (.memberTypeIdentifier, 2):
return (.typeIdentifier, false)
case (.someType, 0):
case (.constrainedSugarType, 0):
return (.keyword, false)
case (.functionType, 3):
return (.keyword, false)
Expand Down
6 changes: 3 additions & 3 deletions Sources/SwiftSyntax/gyb_generated/SyntaxEnum.swift
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public enum SyntaxEnum {
case dictionaryType(DictionaryTypeSyntax)
case metatypeType(MetatypeTypeSyntax)
case optionalType(OptionalTypeSyntax)
case someType(SomeTypeSyntax)
case constrainedSugarType(ConstrainedSugarTypeSyntax)
case implicitlyUnwrappedOptionalType(ImplicitlyUnwrappedOptionalTypeSyntax)
case compositionTypeElement(CompositionTypeElementSyntax)
case compositionTypeElementList(CompositionTypeElementListSyntax)
Expand Down Expand Up @@ -710,8 +710,8 @@ public extension Syntax {
return .metatypeType(MetatypeTypeSyntax(self)!)
case .optionalType:
return .optionalType(OptionalTypeSyntax(self)!)
case .someType:
return .someType(SomeTypeSyntax(self)!)
case .constrainedSugarType:
return .constrainedSugarType(ConstrainedSugarTypeSyntax(self)!)
case .implicitlyUnwrappedOptionalType:
return .implicitlyUnwrappedOptionalType(ImplicitlyUnwrappedOptionalTypeSyntax(self)!)
case .compositionTypeElement:
Expand Down
14 changes: 7 additions & 7 deletions Sources/SwiftSyntax/gyb_generated/SyntaxFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4322,24 +4322,24 @@ public enum SyntaxFactory {
], length: .zero, presence: .present))
return OptionalTypeSyntax(data)
}
public static func makeSomeType(someSpecifier: TokenSyntax, baseType: TypeSyntax) -> SomeTypeSyntax {
public static func makeConstrainedSugarType(someOrAnySpecifier: TokenSyntax, baseType: TypeSyntax) -> ConstrainedSugarTypeSyntax {
let layout: [RawSyntax?] = [
someSpecifier.raw,
someOrAnySpecifier.raw,
baseType.raw,
]
let raw = RawSyntax.createAndCalcLength(kind: SyntaxKind.someType,
let raw = RawSyntax.createAndCalcLength(kind: SyntaxKind.constrainedSugarType,
layout: layout, presence: SourcePresence.present)
let data = SyntaxData.forRoot(raw)
return SomeTypeSyntax(data)
return ConstrainedSugarTypeSyntax(data)
}

public static func makeBlankSomeType() -> SomeTypeSyntax {
let data = SyntaxData.forRoot(RawSyntax.create(kind: .someType,
public static func makeBlankConstrainedSugarType() -> ConstrainedSugarTypeSyntax {
let data = SyntaxData.forRoot(RawSyntax.create(kind: .constrainedSugarType,
layout: [
RawSyntax.missingToken(TokenKind.identifier("")),
RawSyntax.missing(SyntaxKind.type),
], length: .zero, presence: .present))
return SomeTypeSyntax(data)
return ConstrainedSugarTypeSyntax(data)
}
public static func makeImplicitlyUnwrappedOptionalType(wrappedType: TypeSyntax, exclamationMark: TokenSyntax) -> ImplicitlyUnwrappedOptionalTypeSyntax {
let layout: [RawSyntax?] = [
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftSyntax/gyb_generated/SyntaxKind.swift
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ internal enum SyntaxKind: CSyntaxKind {
case dictionaryType = 216
case metatypeType = 217
case optionalType = 218
case someType = 230
case constrainedSugarType = 230
case implicitlyUnwrappedOptionalType = 219
case compositionTypeElement = 153
case compositionTypeElementList = 196
Expand Down
16 changes: 8 additions & 8 deletions Sources/SwiftSyntax/gyb_generated/SyntaxRewriter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1514,10 +1514,10 @@ open class SyntaxRewriter {
return TypeSyntax(visitChildren(node))
}

/// Visit a `SomeTypeSyntax`.
/// Visit a `ConstrainedSugarTypeSyntax`.
/// - Parameter node: the node that is being visited
/// - Returns: the rewritten node
open func visit(_ node: SomeTypeSyntax) -> TypeSyntax {
open func visit(_ node: ConstrainedSugarTypeSyntax) -> TypeSyntax {
return TypeSyntax(visitChildren(node))
}

Expand Down Expand Up @@ -3946,8 +3946,8 @@ open class SyntaxRewriter {
}

/// Implementation detail of visit(_:). Do not call directly.
private func visitImplSomeTypeSyntax(_ data: SyntaxData) -> Syntax {
let node = SomeTypeSyntax(data)
private func visitImplConstrainedSugarTypeSyntax(_ data: SyntaxData) -> Syntax {
let node = ConstrainedSugarTypeSyntax(data)
// Accessing _syntaxNode directly is faster than calling Syntax(node)
visitPre(node._syntaxNode)
defer { visitPost(node._syntaxNode) }
Expand Down Expand Up @@ -4733,8 +4733,8 @@ open class SyntaxRewriter {
return visitImplMetatypeTypeSyntax
case .optionalType:
return visitImplOptionalTypeSyntax
case .someType:
return visitImplSomeTypeSyntax
case .constrainedSugarType:
return visitImplConstrainedSugarTypeSyntax
case .implicitlyUnwrappedOptionalType:
return visitImplImplicitlyUnwrappedOptionalTypeSyntax
case .compositionTypeElement:
Expand Down Expand Up @@ -5244,8 +5244,8 @@ open class SyntaxRewriter {
return visitImplMetatypeTypeSyntax(data)
case .optionalType:
return visitImplOptionalTypeSyntax(data)
case .someType:
return visitImplSomeTypeSyntax(data)
case .constrainedSugarType:
return visitImplConstrainedSugarTypeSyntax(data)
case .implicitlyUnwrappedOptionalType:
return visitImplImplicitlyUnwrappedOptionalTypeSyntax(data)
case .compositionTypeElement:
Expand Down
16 changes: 8 additions & 8 deletions Sources/SwiftSyntax/gyb_generated/SyntaxVisitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2162,16 +2162,16 @@ open class SyntaxVisitor {
/// The function called after visiting `OptionalTypeSyntax` and its descendents.
/// - node: the node we just finished visiting.
open func visitPost(_ node: OptionalTypeSyntax) {}
/// Visiting `SomeTypeSyntax` specifically.
/// Visiting `ConstrainedSugarTypeSyntax` specifically.
/// - Parameter node: the node we are visiting.
/// - Returns: how should we continue visiting.
open func visit(_ node: SomeTypeSyntax) -> SyntaxVisitorContinueKind {
open func visit(_ node: ConstrainedSugarTypeSyntax) -> SyntaxVisitorContinueKind {
return .visitChildren
}

/// The function called after visiting `SomeTypeSyntax` and its descendents.
/// The function called after visiting `ConstrainedSugarTypeSyntax` and its descendents.
/// - node: the node we just finished visiting.
open func visitPost(_ node: SomeTypeSyntax) {}
open func visitPost(_ node: ConstrainedSugarTypeSyntax) {}
/// Visiting `ImplicitlyUnwrappedOptionalTypeSyntax` specifically.
/// - Parameter node: the node we are visiting.
/// - Returns: how should we continue visiting.
Expand Down Expand Up @@ -4884,8 +4884,8 @@ open class SyntaxVisitor {
}

/// Implementation detail of doVisit(_:_:). Do not call directly.
private func visitImplSomeTypeSyntax(_ data: SyntaxData) {
let node = SomeTypeSyntax(data)
private func visitImplConstrainedSugarTypeSyntax(_ data: SyntaxData) {
let node = ConstrainedSugarTypeSyntax(data)
let needsChildren = (visit(node) == .visitChildren)
// Avoid calling into visitChildren if possible.
if needsChildren && node.raw.numberOfChildren > 0 {
Expand Down Expand Up @@ -5669,8 +5669,8 @@ open class SyntaxVisitor {
visitImplMetatypeTypeSyntax(data)
case .optionalType:
visitImplOptionalTypeSyntax(data)
case .someType:
visitImplSomeTypeSyntax(data)
case .constrainedSugarType:
visitImplConstrainedSugarTypeSyntax(data)
case .implicitlyUnwrappedOptionalType:
visitImplImplicitlyUnwrappedOptionalTypeSyntax(data)
case .compositionTypeElement:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -979,54 +979,54 @@ extension OptionalTypeSyntax: CustomReflectable {
}
}

// MARK: - SomeTypeSyntax
// MARK: - ConstrainedSugarTypeSyntax

public struct SomeTypeSyntax: TypeSyntaxProtocol, SyntaxHashable {
public struct ConstrainedSugarTypeSyntax: TypeSyntaxProtocol, SyntaxHashable {
enum Cursor: Int {
case someSpecifier
case someOrAnySpecifier
case baseType
}

public let _syntaxNode: Syntax

/// Converts the given `Syntax` node to a `SomeTypeSyntax` if possible. Returns
/// Converts the given `Syntax` node to a `ConstrainedSugarTypeSyntax` if possible. Returns
/// `nil` if the conversion is not possible.
public init?(_ syntax: Syntax) {
guard syntax.raw.kind == .someType else { return nil }
guard syntax.raw.kind == .constrainedSugarType else { return nil }
self._syntaxNode = syntax
}

/// Creates a `SomeTypeSyntax` node from the given `SyntaxData`. This assumes
/// Creates a `ConstrainedSugarTypeSyntax` node from the given `SyntaxData`. This assumes
/// that the `SyntaxData` is of the correct kind. If it is not, the behaviour
/// is undefined.
internal init(_ data: SyntaxData) {
assert(data.raw.kind == .someType)
assert(data.raw.kind == .constrainedSugarType)
self._syntaxNode = Syntax(data)
}

public var syntaxNodeType: SyntaxProtocol.Type {
return Swift.type(of: self)
}

public var someSpecifier: TokenSyntax {
public var someOrAnySpecifier: TokenSyntax {
get {
let childData = data.child(at: Cursor.someSpecifier,
let childData = data.child(at: Cursor.someOrAnySpecifier,
parent: Syntax(self))
return TokenSyntax(childData!)
}
set(value) {
self = withSomeSpecifier(value)
self = withSomeOrAnySpecifier(value)
}
}

/// Returns a copy of the receiver with its `someSpecifier` replaced.
/// - param newChild: The new `someSpecifier` to replace the node's
/// current `someSpecifier`, if present.
public func withSomeSpecifier(
_ newChild: TokenSyntax?) -> SomeTypeSyntax {
/// Returns a copy of the receiver with its `someOrAnySpecifier` replaced.
/// - param newChild: The new `someOrAnySpecifier` to replace the node's
/// current `someOrAnySpecifier`, if present.
public func withSomeOrAnySpecifier(
_ newChild: TokenSyntax?) -> ConstrainedSugarTypeSyntax {
let raw = newChild?.raw ?? RawSyntax.missingToken(TokenKind.identifier(""))
let newData = data.replacingChild(raw, at: Cursor.someSpecifier)
return SomeTypeSyntax(newData)
let newData = data.replacingChild(raw, at: Cursor.someOrAnySpecifier)
return ConstrainedSugarTypeSyntax(newData)
}

public var baseType: TypeSyntax {
Expand All @@ -1044,10 +1044,10 @@ public struct SomeTypeSyntax: TypeSyntaxProtocol, SyntaxHashable {
/// - param newChild: The new `baseType` to replace the node's
/// current `baseType`, if present.
public func withBaseType(
_ newChild: TypeSyntax?) -> SomeTypeSyntax {
_ newChild: TypeSyntax?) -> ConstrainedSugarTypeSyntax {
let raw = newChild?.raw ?? RawSyntax.missing(SyntaxKind.type)
let newData = data.replacingChild(raw, at: Cursor.baseType)
return SomeTypeSyntax(newData)
return ConstrainedSugarTypeSyntax(newData)
}


Expand Down Expand Up @@ -1075,10 +1075,10 @@ public struct SomeTypeSyntax: TypeSyntaxProtocol, SyntaxHashable {
}
}

extension SomeTypeSyntax: CustomReflectable {
extension ConstrainedSugarTypeSyntax: CustomReflectable {
public var customMirror: Mirror {
return Mirror(self, children: [
"someSpecifier": Syntax(someSpecifier).asProtocol(SyntaxProtocol.self),
"someOrAnySpecifier": Syntax(someOrAnySpecifier).asProtocol(SyntaxProtocol.self),
"baseType": Syntax(baseType).asProtocol(SyntaxProtocol.self),
])
}
Expand Down
Loading