Skip to content

Commit 7cbed94

Browse files
authored
Merge pull request #1116 from kimdv/kimdv/remove-leading-and-trailing-space
Remove leading and trailing space from `&`
2 parents aeb2ff5 + 6c25007 commit 7cbed94

File tree

5 files changed

+31
-9
lines changed

5 files changed

+31
-9
lines changed

CodeGeneration/Sources/SyntaxSupport/gyb_generated/TokenSpec.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ public let SYNTAX_TOKENS: [TokenSpec] = [
277277
PunctuatorSpec(name: "Equal", kind: "equal", text: "=", requiresLeadingSpace: true, requiresTrailingSpace: true),
278278
PunctuatorSpec(name: "AtSign", kind: "at_sign", text: "@", classification: "Attribute"),
279279
PunctuatorSpec(name: "Pound", kind: "pound", text: "#"),
280-
PunctuatorSpec(name: "PrefixAmpersand", kind: "amp_prefix", text: "&", requiresLeadingSpace: true, requiresTrailingSpace: true),
280+
PunctuatorSpec(name: "PrefixAmpersand", kind: "amp_prefix", text: "&"),
281281
PunctuatorSpec(name: "Arrow", kind: "arrow", text: "->", requiresLeadingSpace: true, requiresTrailingSpace: true),
282282
PunctuatorSpec(name: "Backtick", kind: "backtick", text: "`"),
283283
PunctuatorSpec(name: "Backslash", kind: "backslash", text: "\\"),

Sources/SwiftBasicFormat/generated/BasicFormat.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ open class BasicFormat: SyntaxRewriter {
127127
return true
128128
case .equal:
129129
return true
130-
case .prefixAmpersand:
131-
return true
132130
case .arrow:
133131
return true
134132
case .spacedBinaryOperator:
@@ -250,8 +248,6 @@ open class BasicFormat: SyntaxRewriter {
250248
return true
251249
case .equal:
252250
return true
253-
case .prefixAmpersand:
254-
return true
255251
case .arrow:
256252
return true
257253
case .poundKeyPathKeyword:

Sources/SwiftSyntax/gyb_generated/SyntaxFactory.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9852,8 +9852,8 @@ public enum SyntaxFactory {
98529852
}
98539853
@available(*, deprecated, message: "Use TokenSyntax.prefixAmpersandToken instead")
98549854
public static func makePrefixAmpersandToken(
9855-
leadingTrivia: Trivia = .space,
9856-
trailingTrivia: Trivia = .space
9855+
leadingTrivia: Trivia = [],
9856+
trailingTrivia: Trivia = []
98579857
) -> TokenSyntax {
98589858
return makeToken(.prefixAmpersand, presence: .present,
98599859
leadingTrivia: leadingTrivia,
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import XCTest
14+
import SwiftSyntax
15+
import SwiftSyntaxBuilder
16+
17+
final class ReturnStmtTests: XCTestCase {
18+
19+
func testReturnStmt() {
20+
let buildable = ReturnStmt("return Self.parse(from: &parser)")
21+
22+
AssertBuildResult(buildable, """
23+
return Self.parse(from: &parser)
24+
""")
25+
}
26+
27+
}

gyb_syntax_support/Token.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,7 @@ def macro_name(self):
276276
Punctuator('AtSign', 'at_sign', text='@', classification='Attribute'),
277277
Punctuator('Pound', 'pound', text='#'),
278278

279-
Punctuator('PrefixAmpersand', 'amp_prefix', text='&',
280-
requires_leading_space=True, requires_trailing_space=True),
279+
Punctuator('PrefixAmpersand', 'amp_prefix', text='&'),
281280
Punctuator('Arrow', 'arrow', text='->', requires_leading_space=True,
282281
requires_trailing_space=True),
283282

0 commit comments

Comments
 (0)