Skip to content

Commit fa62e0b

Browse files
committed
Terminology change: 'garbage' -> 'unexpected'
There are no "garbage" characters in Swift code. They are just "unexpected."
1 parent 59c93fc commit fa62e0b

File tree

58 files changed

+17881
-17881
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+17881
-17881
lines changed

Sources/SwiftSyntax/RawSyntaxNodes.swift.gyb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ public struct Raw${node.name}: Raw${node.name if node.is_base() else node.base_t
7272
% if node.is_buildable() or node.is_missing():
7373
public init(
7474
% for child in node.children:
75-
% param_label = "_ " if child.is_garbage_nodes() else ""
75+
% param_label = "_ " if child.is_unexpected_nodes() else ""
7676
% optional_mark = "?" if child.is_optional else ""
7777
% param_type = "Raw" + child.type_name + optional_mark
78-
% param_default = " = nil" if child.is_garbage_nodes() else ""
78+
% param_default = " = nil" if child.is_unexpected_nodes() else ""
7979
${param_label}${child.swift_name}: ${param_type}${param_default},
8080
% end
8181
arena: SyntaxArena

Sources/SwiftSyntax/SourceLocation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ fileprivate extension TriviaPiece {
453453
lineLength += SourceLength(utf8Length: text.utf8.count)
454454
case let .blockComment(text),
455455
let .docBlockComment(text),
456-
let .garbageText(text):
456+
let .unexpectedText(text):
457457
lineLength = text.forEachLineLength(prefix: lineLength, body: body)
458458
}
459459
return lineLength

Sources/SwiftSyntax/SyntaxFactory.swift.gyb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ public enum SyntaxFactory {
5858
% if child.is_optional:
5959
% param_type = param_type + "?"
6060
% end
61-
% if child.is_garbage_nodes():
62-
% # It would be nice if we could label all of these arguments 'garbage'.
61+
% if child.is_unexpected_nodes():
62+
% # It would be nice if we could label all of these arguments 'unexpected'.
6363
% # But if we do this, we hit https://github.com/apple/swift/issues/60274.
6464
% child_params.append("_ %s: %s = nil" % (child.swift_name, param_type))
6565
% else:

Sources/SwiftSyntax/SyntaxNodes.swift.gyb.template

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public struct ${node.name}: ${base_type}Protocol, SyntaxHashable {
8686
% param_type = child.type_name
8787
% if child.is_optional:
8888
% param_type = param_type + "?"
89-
% if child.is_garbage_nodes():
89+
% if child.is_unexpected_nodes():
9090
_ ${child.swift_name}: ${param_type} = nil${comma}
9191
% else:
9292
${child.swift_name}: ${param_type}${comma}
@@ -143,9 +143,9 @@ public struct ${node.name}: ${base_type}Protocol, SyntaxHashable {
143143
% # ===============
144144
% # Adding children
145145
% # ===============
146-
% # We don't currently support adding elements to a specific garbage collection.
147-
% # If needed, this could be added in the future, but for now withGarbage should be sufficient.
148-
% if child_node and child_node.is_syntax_collection() and not child.is_garbage_nodes():
146+
% # We don't currently support adding elements to a specific unexpected collection.
147+
% # If needed, this could be added in the future, but for now withUnexpected should be sufficient.
148+
% if child_node and child_node.is_syntax_collection() and not child.is_unexpected_nodes():
149149
% child_elt = child.collection_element_name
150150
% child_elt_type = child_node.collection_element_type
151151
% if not child_elt:

Sources/SwiftSyntax/SyntaxTreeViewMode.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
/// Specifies how missing and garbage nodes should be handled when traversing
13+
/// Specifies how missing and unexpected nodes should be handled when traversing
1414
/// a syntax tree.
1515
public enum SyntaxTreeViewMode {
1616
/// Visit the tree in a way that reproduces the original source code.
17-
/// Missing nodes will not be visited, garbage nodes will be visited.
17+
/// Missing nodes will not be visited, unexpected nodes will be visited.
1818
/// This mode is useful for source code transformations like a formatter.
1919
case sourceAccurate
2020

2121
/// Views the syntax tree with fixes applied, that is missing nodes will be
22-
/// visited but garbage nodes will be skipped.
22+
/// visited but unexpected nodes will be skipped.
2323
/// This views the tree in a way that's closer to being syntactical correct
2424
/// and should be used for structural analysis of the syntax tree.
2525
case fixedUp
2626

27-
/// Both missing and garbage nodes will be traversed.
27+
/// Both missing and unexpected nodes will be traversed.
2828
case all
2929

3030
/// Returns whether this traversal node should visit `node` or ignore it.
@@ -33,7 +33,7 @@ public enum SyntaxTreeViewMode {
3333
case .sourceAccurate:
3434
return node.presence == .present
3535
case .fixedUp:
36-
return node.kind != .garbageNodes
36+
return node.kind != .unexpectedNodes
3737
case .all:
3838
return true
3939
}

Sources/SwiftSyntax/gyb_generated/Misc.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ extension SyntaxNode {
103103
return CodeBlockSyntax(asSyntaxData)
104104
}
105105

106-
public var isGarbageNodes: Bool { return raw.kind == .garbageNodes }
107-
public var asGarbageNodes: GarbageNodesSyntax? {
108-
guard isGarbageNodes else { return nil }
109-
return GarbageNodesSyntax(asSyntaxData)
106+
public var isUnexpectedNodes: Bool { return raw.kind == .unexpectedNodes }
107+
public var asUnexpectedNodes: UnexpectedNodesSyntax? {
108+
guard isUnexpectedNodes else { return nil }
109+
return UnexpectedNodesSyntax(asSyntaxData)
110110
}
111111

112112
public var isInOutExpr: Bool { return raw.kind == .inOutExpr }
@@ -1625,7 +1625,7 @@ extension Syntax {
16251625
return node
16261626
case .codeBlock(let node):
16271627
return node
1628-
case .garbageNodes(let node):
1628+
case .unexpectedNodes(let node):
16291629
return node
16301630
case .inOutExpr(let node):
16311631
return node

0 commit comments

Comments
 (0)