Skip to content

Terminology change: 'garbage' -> 'unexpected' #593

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
Aug 16, 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
4 changes: 2 additions & 2 deletions Sources/SwiftSyntax/RawSyntaxNodes.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ public struct Raw${node.name}: Raw${node.name if node.is_base() else node.base_t
% if node.is_buildable() or node.is_missing():
public init(
% for child in node.children:
% param_label = "_ " if child.is_garbage_nodes() else ""
% param_label = "_ " if child.is_unexpected_nodes() else ""
% optional_mark = "?" if child.is_optional else ""
% param_type = "Raw" + child.type_name + optional_mark
% param_default = " = nil" if child.is_garbage_nodes() else ""
% param_default = " = nil" if child.is_unexpected_nodes() else ""
${param_label}${child.swift_name}: ${param_type}${param_default},
% end
arena: SyntaxArena
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftSyntax/SourceLocation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ fileprivate extension TriviaPiece {
lineLength += SourceLength(utf8Length: text.utf8.count)
case let .blockComment(text),
let .docBlockComment(text),
let .garbageText(text):
let .unexpectedText(text):
lineLength = text.forEachLineLength(prefix: lineLength, body: body)
}
return lineLength
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftSyntax/SyntaxFactory.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public enum SyntaxFactory {
% if child.is_optional:
% param_type = param_type + "?"
% end
% if child.is_garbage_nodes():
% # It would be nice if we could label all of these arguments 'garbage'.
% if child.is_unexpected_nodes():
% # It would be nice if we could label all of these arguments 'unexpected'.
% # But if we do this, we hit https://github.com/apple/swift/issues/60274.
% child_params.append("_ %s: %s = nil" % (child.swift_name, param_type))
% else:
Expand Down
8 changes: 4 additions & 4 deletions Sources/SwiftSyntax/SyntaxNodes.swift.gyb.template
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public struct ${node.name}: ${base_type}Protocol, SyntaxHashable {
% param_type = child.type_name
% if child.is_optional:
% param_type = param_type + "?"
% if child.is_garbage_nodes():
% if child.is_unexpected_nodes():
_ ${child.swift_name}: ${param_type} = nil${comma}
% else:
${child.swift_name}: ${param_type}${comma}
Expand Down Expand Up @@ -143,9 +143,9 @@ public struct ${node.name}: ${base_type}Protocol, SyntaxHashable {
% # ===============
% # Adding children
% # ===============
% # We don't currently support adding elements to a specific garbage collection.
% # If needed, this could be added in the future, but for now withGarbage should be sufficient.
% if child_node and child_node.is_syntax_collection() and not child.is_garbage_nodes():
% # We don't currently support adding elements to a specific unexpected collection.
% # If needed, this could be added in the future, but for now withUnexpected should be sufficient.
% if child_node and child_node.is_syntax_collection() and not child.is_unexpected_nodes():
% child_elt = child.collection_element_name
% child_elt_type = child_node.collection_element_type
% if not child_elt:
Expand Down
10 changes: 5 additions & 5 deletions Sources/SwiftSyntax/SyntaxTreeViewMode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@
//
//===----------------------------------------------------------------------===//

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

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

/// Both missing and garbage nodes will be traversed.
/// Both missing and unexpected nodes will be traversed.
case all

/// Returns whether this traversal node should visit `node` or ignore it.
Expand All @@ -33,7 +33,7 @@ public enum SyntaxTreeViewMode {
case .sourceAccurate:
return node.presence == .present
case .fixedUp:
return node.kind != .garbageNodes
return node.kind != .unexpectedNodes
case .all:
return true
}
Expand Down
10 changes: 5 additions & 5 deletions Sources/SwiftSyntax/gyb_generated/Misc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ extension SyntaxNode {
return CodeBlockSyntax(asSyntaxData)
}

public var isGarbageNodes: Bool { return raw.kind == .garbageNodes }
public var asGarbageNodes: GarbageNodesSyntax? {
guard isGarbageNodes else { return nil }
return GarbageNodesSyntax(asSyntaxData)
public var isUnexpectedNodes: Bool { return raw.kind == .unexpectedNodes }
public var asUnexpectedNodes: UnexpectedNodesSyntax? {
guard isUnexpectedNodes else { return nil }
return UnexpectedNodesSyntax(asSyntaxData)
}

public var isInOutExpr: Bool { return raw.kind == .inOutExpr }
Expand Down Expand Up @@ -1625,7 +1625,7 @@ extension Syntax {
return node
case .codeBlock(let node):
return node
case .garbageNodes(let node):
case .unexpectedNodes(let node):
return node
case .inOutExpr(let node):
return node
Expand Down
Loading