Skip to content

Remove leading and trailing space from & #1116

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
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
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public let SYNTAX_TOKENS: [TokenSpec] = [
PunctuatorSpec(name: "Equal", kind: "equal", text: "=", requiresLeadingSpace: true, requiresTrailingSpace: true),
PunctuatorSpec(name: "AtSign", kind: "at_sign", text: "@", classification: "Attribute"),
PunctuatorSpec(name: "Pound", kind: "pound", text: "#"),
PunctuatorSpec(name: "PrefixAmpersand", kind: "amp_prefix", text: "&", requiresLeadingSpace: true, requiresTrailingSpace: true),
PunctuatorSpec(name: "PrefixAmpersand", kind: "amp_prefix", text: "&"),
PunctuatorSpec(name: "Arrow", kind: "arrow", text: "->", requiresLeadingSpace: true, requiresTrailingSpace: true),
PunctuatorSpec(name: "Backtick", kind: "backtick", text: "`"),
PunctuatorSpec(name: "Backslash", kind: "backslash", text: "\\"),
Expand Down
4 changes: 0 additions & 4 deletions Sources/SwiftBasicFormat/generated/BasicFormat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ open class BasicFormat: SyntaxRewriter {
return true
case .equal:
return true
case .prefixAmpersand:
return true
case .arrow:
return true
case .spacedBinaryOperator:
Expand Down Expand Up @@ -238,8 +236,6 @@ open class BasicFormat: SyntaxRewriter {
return true
case .equal:
return true
case .prefixAmpersand:
return true
case .arrow:
return true
case .poundKeyPathKeyword:
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftSyntax/gyb_generated/SyntaxFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9852,8 +9852,8 @@ public enum SyntaxFactory {
}
@available(*, deprecated, message: "Use TokenSyntax.prefixAmpersandToken instead")
public static func makePrefixAmpersandToken(
leadingTrivia: Trivia = .space,
trailingTrivia: Trivia = .space
leadingTrivia: Trivia = [],
trailingTrivia: Trivia = []
) -> TokenSyntax {
return makeToken(.prefixAmpersand, presence: .present,
leadingTrivia: leadingTrivia,
Expand Down
27 changes: 27 additions & 0 deletions Tests/SwiftSyntaxBuilderTest/ReturnStmsTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

import XCTest
import SwiftSyntax
import SwiftSyntaxBuilder

final class ReturnStmtTests: XCTestCase {

func testReturnStmt() {
let buildable = ReturnStmt("return Self.parse(from: &parser)")

AssertBuildResult(buildable, """
return Self.parse(from: &parser)
""")
}

}
3 changes: 1 addition & 2 deletions gyb_syntax_support/Token.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,7 @@ def macro_name(self):
Punctuator('AtSign', 'at_sign', text='@', classification='Attribute'),
Punctuator('Pound', 'pound', text='#'),

Punctuator('PrefixAmpersand', 'amp_prefix', text='&',
requires_leading_space=True, requires_trailing_space=True),
Punctuator('PrefixAmpersand', 'amp_prefix', text='&'),
Punctuator('Arrow', 'arrow', text='->', requires_leading_space=True,
requires_trailing_space=True),

Expand Down