Skip to content

Commit 447c3a8

Browse files
authored
Merge pull request #1728 from kimdv/kimdv/1723-inconsistent-name-of-importdeclsyntax-introducer-keyword
Rename `ImportDeclSyntax.importTok` to `ImportDeclSyntax.importKeyword`
2 parents 45e5366 + 04708c3 commit 447c3a8

File tree

6 files changed

+123
-52
lines changed

6 files changed

+123
-52
lines changed

CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ public let DECL_NODES: [Node] = [
12001200
isOptional: true
12011201
),
12021202
Child(
1203-
name: "ImportTok",
1203+
name: "ImportKeyword",
12041204
kind: .token(choices: [.keyword(text: "import")]),
12051205
documentation: "The `import` keyword for this declaration."
12061206
),

Sources/SwiftParser/Declarations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ extension Parser {
331331
attributes: attrs.attributes,
332332
modifiers: attrs.modifiers,
333333
unexpectedBeforeImportKeyword,
334-
importTok: importKeyword,
334+
importKeyword: importKeyword,
335335
importKind: kind,
336336
path: path,
337337
arena: self.arena

Sources/SwiftSyntax/SwiftSyntaxCompatibility.swift

Lines changed: 91 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,27 @@ public extension DeclGroupSyntax {
3434
}
3535
}
3636

37+
public extension EditorPlaceholderDeclSyntax {
38+
@available(*, deprecated, renamed: "placeholder")
39+
var identifier: TokenSyntax { placeholder }
40+
41+
@available(*, deprecated, renamed: "placeholder")
42+
@_disfavoredOverload
43+
init(
44+
leadingTrivia: Trivia? = nil,
45+
_ unexpectedBeforeIdentifier: UnexpectedNodesSyntax? = nil,
46+
identifier: TokenSyntax,
47+
_ unexpectedAfterIdentifier: UnexpectedNodesSyntax? = nil
48+
) {
49+
self.init(
50+
leadingTrivia: leadingTrivia,
51+
unexpectedBeforeIdentifier,
52+
placeholder: identifier,
53+
unexpectedAfterIdentifier
54+
)
55+
}
56+
}
57+
3758
public extension EnumDeclSyntax {
3859
@available(*, deprecated, renamed: "unexpectedBetweenIdentifierAndGenericParameterClause")
3960
var unexpectedBetweenIdentifierAndGenericParameters: UnexpectedNodesSyntax? {
@@ -66,6 +87,7 @@ public extension EnumDeclSyntax {
6687
}
6788

6889
@available(*, deprecated, message: "Use an initializer with a genericParameterClause argument.")
90+
@_disfavoredOverload
6991
init(
7092
leadingTrivia: Trivia? = nil,
7193
_ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil,
@@ -153,6 +175,7 @@ public extension FunctionTypeSyntax {
153175
}
154176

155177
@available(*, deprecated, message: "Use an initializer with a parameters")
178+
@_disfavoredOverload
156179
init(
157180
leadingTrivia: Trivia? = nil,
158181
_ unexpectedBeforeLeftParen: UnexpectedNodesSyntax? = nil,
@@ -186,6 +209,72 @@ public extension FunctionTypeSyntax {
186209
}
187210
}
188211

212+
public extension ImportDeclSyntax {
213+
@available(*, deprecated, renamed: "unexpectedBetweenModifiersAndImportKeyword")
214+
var unexpectedBetweenModifiersAndImportTok: UnexpectedNodesSyntax? {
215+
get {
216+
return unexpectedBetweenModifiersAndImportKeyword
217+
}
218+
set(value) {
219+
unexpectedBetweenModifiersAndImportKeyword = value
220+
}
221+
}
222+
223+
@available(*, deprecated, renamed: "importKeyword")
224+
var importTok: TokenSyntax {
225+
get {
226+
return importKeyword
227+
}
228+
set(value) {
229+
importKeyword = value
230+
}
231+
}
232+
233+
@available(*, deprecated, renamed: "unexpectedBetweenImportKeywordAndImportKind")
234+
var unexpectedBetweenImportTokAndImportKind: UnexpectedNodesSyntax? {
235+
get {
236+
return unexpectedBetweenImportKeywordAndImportKind
237+
}
238+
set(value) {
239+
unexpectedBetweenImportKeywordAndImportKind = value
240+
}
241+
}
242+
243+
@available(*, deprecated, message: "Use an initializer with importKeyword")
244+
@_disfavoredOverload
245+
init(
246+
leadingTrivia: Trivia? = nil,
247+
_ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil,
248+
attributes: AttributeListSyntax? = nil,
249+
_ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil,
250+
modifiers: ModifierListSyntax? = nil,
251+
_ unexpectedBetweenModifiersAndImportTok: UnexpectedNodesSyntax? = nil,
252+
importTok: TokenSyntax = .keyword(.import),
253+
_ unexpectedBetweenImportTokAndImportKind: UnexpectedNodesSyntax? = nil,
254+
importKind: TokenSyntax? = nil,
255+
_ unexpectedBetweenImportKindAndPath: UnexpectedNodesSyntax? = nil,
256+
path: ImportPathSyntax,
257+
_ unexpectedAfterPath: UnexpectedNodesSyntax? = nil,
258+
trailingTrivia: Trivia? = nil
259+
) {
260+
self.init(
261+
leadingTrivia: leadingTrivia,
262+
unexpectedBeforeAttributes,
263+
attributes: attributes,
264+
unexpectedBetweenAttributesAndModifiers,
265+
modifiers: modifiers,
266+
unexpectedBetweenModifiersAndImportTok,
267+
importKeyword: importTok,
268+
unexpectedBetweenImportTokAndImportKind,
269+
importKind: importKind,
270+
unexpectedBetweenImportKindAndPath,
271+
path: path,
272+
unexpectedAfterPath,
273+
trailingTrivia: trailingTrivia
274+
)
275+
}
276+
}
277+
189278
public extension NamedOpaqueReturnTypeSyntax {
190279
@available(*, deprecated, renamed: "unexpectedBeforeGenericParameterClause")
191280
var unexpectedBeforeGenericParameters: UnexpectedNodesSyntax? {
@@ -218,6 +307,7 @@ public extension NamedOpaqueReturnTypeSyntax {
218307
}
219308

220309
@available(*, deprecated, message: "Use an initializer with a genericParameterClause argument.")
310+
@_disfavoredOverload
221311
init(
222312
leadingTrivia: Trivia? = nil,
223313
_ unexpectedBeforeGenericParameters: UnexpectedNodesSyntax? = nil,
@@ -271,6 +361,7 @@ public extension TupleExprSyntax {
271361
}
272362

273363
@available(*, deprecated, message: "Use an initializer with a elements argument")
364+
@_disfavoredOverload
274365
init(
275366
leadingTrivia: Trivia? = nil,
276367
_ unexpectedBeforeLeftParen: UnexpectedNodesSyntax? = nil,
@@ -295,23 +386,3 @@ public extension TupleExprSyntax {
295386
)
296387
}
297388
}
298-
299-
public extension EditorPlaceholderDeclSyntax {
300-
@available(*, deprecated, renamed: "placeholder")
301-
var identifier: TokenSyntax { placeholder }
302-
303-
@available(*, deprecated, renamed: "placeholder")
304-
init(
305-
leadingTrivia: Trivia? = nil,
306-
_ unexpectedBeforeIdentifier: UnexpectedNodesSyntax? = nil,
307-
identifier: TokenSyntax,
308-
_ unexpectedAfterIdentifier: UnexpectedNodesSyntax? = nil
309-
) {
310-
self.init(
311-
leadingTrivia: leadingTrivia,
312-
unexpectedBeforeIdentifier,
313-
placeholder: identifier,
314-
unexpectedAfterIdentifier
315-
)
316-
}
317-
}

Sources/SwiftSyntax/generated/ChildNameForKeyPath.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,12 +1755,12 @@ public func childName(_ keyPath: AnyKeyPath) -> String? {
17551755
return "unexpectedBetweenAttributesAndModifiers"
17561756
case \ImportDeclSyntax.modifiers:
17571757
return "modifiers"
1758-
case \ImportDeclSyntax.unexpectedBetweenModifiersAndImportTok:
1759-
return "unexpectedBetweenModifiersAndImportTok"
1760-
case \ImportDeclSyntax.importTok:
1761-
return "importTok"
1762-
case \ImportDeclSyntax.unexpectedBetweenImportTokAndImportKind:
1763-
return "unexpectedBetweenImportTokAndImportKind"
1758+
case \ImportDeclSyntax.unexpectedBetweenModifiersAndImportKeyword:
1759+
return "unexpectedBetweenModifiersAndImportKeyword"
1760+
case \ImportDeclSyntax.importKeyword:
1761+
return "importKeyword"
1762+
case \ImportDeclSyntax.unexpectedBetweenImportKeywordAndImportKind:
1763+
return "unexpectedBetweenImportKeywordAndImportKind"
17641764
case \ImportDeclSyntax.importKind:
17651765
return "importKind"
17661766
case \ImportDeclSyntax.unexpectedBetweenImportKindAndPath:

Sources/SwiftSyntax/generated/raw/RawSyntaxNodes.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11741,9 +11741,9 @@ public struct RawImportDeclSyntax: RawDeclSyntaxNodeProtocol {
1174111741
attributes: RawAttributeListSyntax?,
1174211742
_ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil,
1174311743
modifiers: RawModifierListSyntax?,
11744-
_ unexpectedBetweenModifiersAndImportTok: RawUnexpectedNodesSyntax? = nil,
11745-
importTok: RawTokenSyntax,
11746-
_ unexpectedBetweenImportTokAndImportKind: RawUnexpectedNodesSyntax? = nil,
11744+
_ unexpectedBetweenModifiersAndImportKeyword: RawUnexpectedNodesSyntax? = nil,
11745+
importKeyword: RawTokenSyntax,
11746+
_ unexpectedBetweenImportKeywordAndImportKind: RawUnexpectedNodesSyntax? = nil,
1174711747
importKind: RawTokenSyntax?,
1174811748
_ unexpectedBetweenImportKindAndPath: RawUnexpectedNodesSyntax? = nil,
1174911749
path: RawImportPathSyntax,
@@ -11757,9 +11757,9 @@ public struct RawImportDeclSyntax: RawDeclSyntaxNodeProtocol {
1175711757
layout[1] = attributes?.raw
1175811758
layout[2] = unexpectedBetweenAttributesAndModifiers?.raw
1175911759
layout[3] = modifiers?.raw
11760-
layout[4] = unexpectedBetweenModifiersAndImportTok?.raw
11761-
layout[5] = importTok.raw
11762-
layout[6] = unexpectedBetweenImportTokAndImportKind?.raw
11760+
layout[4] = unexpectedBetweenModifiersAndImportKeyword?.raw
11761+
layout[5] = importKeyword.raw
11762+
layout[6] = unexpectedBetweenImportKeywordAndImportKind?.raw
1176311763
layout[7] = importKind?.raw
1176411764
layout[8] = unexpectedBetweenImportKindAndPath?.raw
1176511765
layout[9] = path.raw
@@ -11784,15 +11784,15 @@ public struct RawImportDeclSyntax: RawDeclSyntaxNodeProtocol {
1178411784
layoutView.children[3].map(RawModifierListSyntax.init(raw:))
1178511785
}
1178611786

11787-
public var unexpectedBetweenModifiersAndImportTok: RawUnexpectedNodesSyntax? {
11787+
public var unexpectedBetweenModifiersAndImportKeyword: RawUnexpectedNodesSyntax? {
1178811788
layoutView.children[4].map(RawUnexpectedNodesSyntax.init(raw:))
1178911789
}
1179011790

11791-
public var importTok: RawTokenSyntax {
11791+
public var importKeyword: RawTokenSyntax {
1179211792
layoutView.children[5].map(RawTokenSyntax.init(raw:))!
1179311793
}
1179411794

11795-
public var unexpectedBetweenImportTokAndImportKind: RawUnexpectedNodesSyntax? {
11795+
public var unexpectedBetweenImportKeywordAndImportKind: RawUnexpectedNodesSyntax? {
1179611796
layoutView.children[6].map(RawUnexpectedNodesSyntax.init(raw:))
1179711797
}
1179811798

Sources/SwiftSyntax/generated/syntaxNodes/SyntaxDeclNodes.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2943,9 +2943,9 @@ public struct ImportDeclSyntax: DeclSyntaxProtocol, SyntaxHashable {
29432943
attributes: AttributeListSyntax? = nil,
29442944
_ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil,
29452945
modifiers: ModifierListSyntax? = nil,
2946-
_ unexpectedBetweenModifiersAndImportTok: UnexpectedNodesSyntax? = nil,
2947-
importTok: TokenSyntax = .keyword(.import),
2948-
_ unexpectedBetweenImportTokAndImportKind: UnexpectedNodesSyntax? = nil,
2946+
_ unexpectedBetweenModifiersAndImportKeyword: UnexpectedNodesSyntax? = nil,
2947+
importKeyword: TokenSyntax = .keyword(.import),
2948+
_ unexpectedBetweenImportKeywordAndImportKind: UnexpectedNodesSyntax? = nil,
29492949
importKind: TokenSyntax? = nil,
29502950
_ unexpectedBetweenImportKindAndPath: UnexpectedNodesSyntax? = nil,
29512951
path: ImportPathSyntax,
@@ -2960,9 +2960,9 @@ public struct ImportDeclSyntax: DeclSyntaxProtocol, SyntaxHashable {
29602960
attributes,
29612961
unexpectedBetweenAttributesAndModifiers,
29622962
modifiers,
2963-
unexpectedBetweenModifiersAndImportTok,
2964-
importTok,
2965-
unexpectedBetweenImportTokAndImportKind,
2963+
unexpectedBetweenModifiersAndImportKeyword,
2964+
importKeyword,
2965+
unexpectedBetweenImportKeywordAndImportKind,
29662966
importKind,
29672967
unexpectedBetweenImportKindAndPath,
29682968
path,
@@ -2973,9 +2973,9 @@ public struct ImportDeclSyntax: DeclSyntaxProtocol, SyntaxHashable {
29732973
attributes?.raw,
29742974
unexpectedBetweenAttributesAndModifiers?.raw,
29752975
modifiers?.raw,
2976-
unexpectedBetweenModifiersAndImportTok?.raw,
2977-
importTok.raw,
2978-
unexpectedBetweenImportTokAndImportKind?.raw,
2976+
unexpectedBetweenModifiersAndImportKeyword?.raw,
2977+
importKeyword.raw,
2978+
unexpectedBetweenImportKeywordAndImportKind?.raw,
29792979
importKind?.raw,
29802980
unexpectedBetweenImportKindAndPath?.raw,
29812981
path.raw,
@@ -3070,7 +3070,7 @@ public struct ImportDeclSyntax: DeclSyntaxProtocol, SyntaxHashable {
30703070
return ImportDeclSyntax(newData)
30713071
}
30723072

3073-
public var unexpectedBetweenModifiersAndImportTok: UnexpectedNodesSyntax? {
3073+
public var unexpectedBetweenModifiersAndImportKeyword: UnexpectedNodesSyntax? {
30743074
get {
30753075
return data.child(at: 4, parent: Syntax(self)).map(UnexpectedNodesSyntax.init)
30763076
}
@@ -3080,7 +3080,7 @@ public struct ImportDeclSyntax: DeclSyntaxProtocol, SyntaxHashable {
30803080
}
30813081

30823082
/// The `import` keyword for this declaration.
3083-
public var importTok: TokenSyntax {
3083+
public var importKeyword: TokenSyntax {
30843084
get {
30853085
return TokenSyntax(data.child(at: 5, parent: Syntax(self))!)
30863086
}
@@ -3089,7 +3089,7 @@ public struct ImportDeclSyntax: DeclSyntaxProtocol, SyntaxHashable {
30893089
}
30903090
}
30913091

3092-
public var unexpectedBetweenImportTokAndImportKind: UnexpectedNodesSyntax? {
3092+
public var unexpectedBetweenImportKeywordAndImportKind: UnexpectedNodesSyntax? {
30933093
get {
30943094
return data.child(at: 6, parent: Syntax(self)).map(UnexpectedNodesSyntax.init)
30953095
}
@@ -3161,9 +3161,9 @@ public struct ImportDeclSyntax: DeclSyntaxProtocol, SyntaxHashable {
31613161
\Self.attributes,
31623162
\Self.unexpectedBetweenAttributesAndModifiers,
31633163
\Self.modifiers,
3164-
\Self.unexpectedBetweenModifiersAndImportTok,
3165-
\Self.importTok,
3166-
\Self.unexpectedBetweenImportTokAndImportKind,
3164+
\Self.unexpectedBetweenModifiersAndImportKeyword,
3165+
\Self.importKeyword,
3166+
\Self.unexpectedBetweenImportKeywordAndImportKind,
31673167
\Self.importKind,
31683168
\Self.unexpectedBetweenImportKindAndPath,
31693169
\Self.path,

0 commit comments

Comments
 (0)