Skip to content

Documentation - Typos & Consistency Fixes #1841

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
Jul 8, 2023
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 Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ For increased performance, the modelling of the syntax node hierarchy has been s
```swift
let identifierExprSyntax: IdentifierExprSyntax = /* ... */
let node = Syntax(identifierExprSyntax)
node.asProtocol(SyntaxProtocol.self) // returns a IdentifierExprSyntax with static type SyntaxProtocol
node.asProtocol(ExprSyntaxProtocol.self) // returns a IdentifierExprSyntax with static type ExprSyntaxProtocol?
node.asProtocol(SyntaxProtocol.self) // returns an IdentifierExprSyntax with static type SyntaxProtocol
node.asProtocol(ExprSyntaxProtocol.self) // returns an IdentifierExprSyntax with static type ExprSyntaxProtocol?
```


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public let AVAILABILITY_NODES: [Node] = [
kind: .availabilityLabeledArgument,
base: .syntax,
nameForDiagnostics: "availability argument",
documentation: "A argument to an `@available` attribute that consists of a label and a value, e.g. `message: \"This has been deprecated\"`.",
documentation: "An argument to an `@available` attribute that consists of a label and a value, e.g. `message: \"This has been deprecated\"`.",
children: [
Child(
name: "Label",
Expand Down
2 changes: 1 addition & 1 deletion CodeGeneration/Sources/SyntaxSupport/CommonNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public let COMMON_NODES: [Node] = [
kind: .missingExpr,
base: .expr,
nameForDiagnostics: "expression",
documentation: "In case the source code is missing a expression, this node stands in place of the missing expression.",
documentation: "In case the source code is missing an expression, this node stands in place of the missing expression.",
children: [
Child(
name: "Placeholder",
Expand Down
4 changes: 2 additions & 2 deletions CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@ public let DECL_NODES: [Node] = [
name: "Signature",
kind: .node(kind: .functionSignature),
nameForDiagnostics: "function signature",
documentation: "The arguments of the initializer. While the function signature allows specifying an return clause, doing so is not semantically valid."
documentation: "The arguments of the initializer. While the function signature allows specifying a return clause, doing so is not semantically valid."
),
Child(
name: "GenericWhereClause",
Expand All @@ -1353,7 +1353,7 @@ public let DECL_NODES: [Node] = [
Child(
name: "Body",
kind: .node(kind: .codeBlock),
documentation: "The initializer’s body. Missing if the initialier is a requirement of a protocol declaration.",
documentation: "The initializer’s body. Missing if the initializer is a requirement of a protocol declaration.",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed one more typo and regenerated the codes

isOptional: true
),
]
Expand Down
4 changes: 2 additions & 2 deletions CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ public let EXPR_NODES: [Node] = [
// else-clause ';'?
//
// This node represents both an 'if' expression, as well as an 'if' statement
// when wrapped in a ExpressionStmt node.
// when wrapped in an ExpressionStmt node.
Node(
kind: .ifExpr,
base: .expr,
Expand Down Expand Up @@ -1652,7 +1652,7 @@ public let EXPR_NODES: [Node] = [
// switch-case-list '}' ';'?
//
// This node represents both a 'switch' expression, as well as a 'switch'
// statement when wrapped in a ExpressionStmt node.
// statement when wrapped in an ExpressionStmt node.
Node(
kind: .switchExpr,
base: .expr,
Expand Down
6 changes: 3 additions & 3 deletions CodeGeneration/Sources/SyntaxSupport/Node.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import SwiftSyntax
/// The definition of a syntax node that, when generated, conforms to
/// `SyntaxProtocol`.
///
/// There are two fundemantally different kinds of nodes:
/// There are two fundamentally different kinds of nodes:
/// - Layout nodes contain a fixed number of children of possibly different,
/// but fixed types.
/// - Collection nodes contains an arbitrary number of children but all those
Expand Down Expand Up @@ -253,14 +253,14 @@ public struct CollectionNode {
self.node = node
}

/// Allow transparent accesss to the properties of the underlying `Node`.
/// Allow transparent access to the properties of the underlying `Node`.
public subscript<T>(dynamicMember keyPath: KeyPath<Node, T>) -> T {
return node[keyPath: keyPath]
}

/// The kinds the elements can have.
///
/// This can be more than one in which case each element an have either of
/// This can be more than one in which case each element can have either of
/// these kinds.
public var elementChoices: [SyntaxNodeKind] {
switch node.data {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public enum SyntaxNodeKind: String, CaseIterable {
case yieldList
case yieldStmt

// Nodes that have special handling throught the codebase
// Nodes that have special handling throughout the codebase

case syntax
case syntaxCollection
Expand Down
2 changes: 1 addition & 1 deletion CodeGeneration/Sources/Utils/CodeGenerationFormat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public class CodeGenerationFormat: BasicFormat {
// MARK: - Private

private func shouldBeSeparatedByTwoNewlines(node: CodeBlockItemSyntax) -> Bool {
// First item in the ``CodeBlockItemListSyntax`` don't need a newline or identation if the parent is a ``SourceFileSyntax``.
// First item in the ``CodeBlockItemListSyntax`` don't need a newline or indentation if the parent is a ``SourceFileSyntax``.
// We want to group imports so newline between them should be omitted
return node.parent?.as(CodeBlockItemListSyntax.self)?.first == node || node.item.is(ImportDeclSyntax.self)
}
Expand Down
2 changes: 1 addition & 1 deletion CodeGeneration/Sources/Utils/SyntaxBuildableChild.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public extension Child {

let choicesTexts: [String]
if tokenCanContainArbitraryText {
// Don't generate an precondition statement if token can contain arbitrary text.
// Don't generate a precondition statement if token can contain arbitrary text.
return nil
} else if !choices.isEmpty {
choicesTexts = choices.compactMap {
Expand Down
2 changes: 1 addition & 1 deletion CodeGeneration/Sources/Utils/SyntaxBuildableType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public struct SyntaxBuildableType: Hashable {
return optionalWrapped(type: SimpleTypeIdentifierSyntax(name: .identifier(syntaxBaseName)))
}

/// The type that is used for paramters in SwiftSyntaxBuilder that take this
/// The type that is used for parameters in SwiftSyntaxBuilder that take this
/// type of syntax node.
public var parameterBaseType: String {
if isBaseType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ extension LayoutNode {
}

/// Create a builder-based convenience initializer, if needed.
func createConvenienceBuilerInitializer(useDeprecatedChildName: Bool = false) throws -> InitializerDeclSyntax? {
func createConvenienceBuilderInitializer(useDeprecatedChildName: Bool = false) throws -> InitializerDeclSyntax? {
// Only create the convenience initializer if at least one parameter
// is different than in the default initializer generated above.
var shouldCreateInitializer = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ let parserEntryFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
"""
mutating func parseNonOptionalCodeBlockItem() -> RawCodeBlockItemSyntax {
guard let node = self.parseCodeBlockItem(isAtTopLevel: false, allowInitDecl: true) else {
// The missing item is not neccessary to be a declaration,
// The missing item is not necessary to be a declaration,
// which is just a placeholder here
return RawCodeBlockItemSyntax(
item: .decl(RawDeclSyntax(RawMissingDeclSyntax(attributes: nil, modifiers: nil, arena: self.arena))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ let syntaxAnyVisitorFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {

DeclSyntax(
"""
/// The function called after visiting the node and its descendents.
/// The function called after visiting the node and its descendants.
/// - node: the node we just finished visiting.
open func visitAnyPost(_ node: Syntax) {}
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extension Child {
}

/// This file generates the syntax nodes for SwiftSyntax. To keep the generated
/// files at a managable file size, it is to be invoked multiple times with the
/// files at a manageable file size, it is to be invoked multiple times with the
/// variable `emitKind` set to a base kind listed in
/// It then only emits those syntax nodes whose base kind are that specified kind.
func syntaxNode(emitKind: SyntaxNodeKind) -> SourceFileSyntax {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ let syntaxRewriterFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {

DeclSyntax(
"""
/// The function called before visiting the node and its descendents.
/// The function called before visiting the node and its descendants.
/// - node: the node we are about to visit.
open func visitPre(_ node: Syntax) {}
"""
Expand All @@ -92,7 +92,7 @@ let syntaxRewriterFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {

DeclSyntax(
"""
/// The function called after visiting the node and its descendents.
/// The function called after visiting the node and its descendants.
/// - node: the node we just finished visiting.
open func visitPost(_ node: Syntax) {}
"""
Expand Down Expand Up @@ -220,7 +220,7 @@ let syntaxRewriterFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
/// To circumvent this problem, make calling the specific visitation function
/// a two-step process: First determine the function to call in this function
/// and return a reference to it, then call it. This way, the stack frame
/// that determines the correct visitiation function will be popped of the
/// that determines the correct visitation function will be popped of the
/// stack before the function is being called, making the switch's stack
/// space transient instead of having it linger in the call stack.
private func visitationFunc(for data: SyntaxData) -> ((SyntaxData) -> Syntax)
Expand Down Expand Up @@ -281,7 +281,7 @@ let syntaxRewriterFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
// rewritten nodes until the first non-`nil` value is encountered. When this
// happens, retrieve all previous syntax nodes from the parent node to
// initialize the new layout. Once we know that we have to rewrite the
// layout, we need to collect all futher children, regardless of whether
// layout, we need to collect all further children, regardless of whether
// they are rewritten or not.

// newLayout is nil until the first child node is rewritten and rewritten
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import Utils
let syntaxVisitorFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
DeclSyntax(
"""
/// The enum describes how the SyntaxVistor should continue after visiting
/// The enum describes how the ``SyntaxVisitor`` should continue after visiting
/// the current node.
public enum SyntaxVisitorContinueKind {
/// The visitor should visit the descendents of the current node.
/// The visitor should visit the descendants of the current node.
case visitChildren
/// The visitor should avoid visiting the descendents of the current node.
/// The visitor should avoid visiting the descendants of the current node.
case skipChildren
}
"""
Expand Down Expand Up @@ -64,7 +64,7 @@ let syntaxVisitorFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {

DeclSyntax(
"""
/// The function called after visiting ``\(node.kind.syntaxType)`` and its descendents.
/// The function called after visiting ``\(node.kind.syntaxType)`` and its descendants.
/// - node: the node we just finished visiting.
open func visitPost(_ node: \(node.kind.syntaxType)) {}
"""
Expand All @@ -84,7 +84,7 @@ let syntaxVisitorFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {

DeclSyntax(
"""
/// The function called after visiting the node and its descendents.
/// The function called after visiting the node and its descendants.
/// - node: the node we just finished visiting.
open func visitPost(_ node: TokenSyntax) {}
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ let triviaPiecesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
/// Trivia piece for token RawSyntax.
///
/// In contrast to ``TriviaPiece``, a ``RawTriviaPiece`` does not own the source
/// text of a the trivia.
/// text of the trivia.
@_spi(RawSyntax)
public enum RawTriviaPiece: Equatable
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let buildableNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
for node in SYNTAX_NODES.compactMap(\.layoutNode) {
let type = node.type

if let convenienceInit = try! node.createConvenienceBuilerInitializer() {
if let convenienceInit = try! node.createConvenienceBuilderInitializer() {
DeclSyntax(
"""
extension \(raw: type.syntaxBaseName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let renamedChildrenBuilderCompatibilityFile = try! SourceFileSyntax(leadingTrivi
DeclSyntax("import SwiftSyntax")

for layoutNode in SYNTAX_NODES.compactMap(\.layoutNode).filter({ $0.children.hasDeprecatedChild }) {
if let convenienceInit = try layoutNode.createConvenienceBuilerInitializer(useDeprecatedChildName: true) {
if let convenienceInit = try layoutNode.createConvenienceBuilderInitializer(useDeprecatedChildName: true) {
let deprecatedNames = layoutNode.children
.filter { !$0.isUnexpectedNodes }
.compactMap { $0.deprecatedName?.withFirstCharacterLowercased }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class ValidateSyntaxNodes: XCTestCase {
/// Checks standardized naming of children with a single token choice
///
/// - If a child has a single keyword as its choice, it should be named `*Keyword` (e.g. `ImportKeyword`)
/// - If it’s another token kind, name it the same as the the token choice (e.g. `LeftParen`)
/// - If it’s another token kind, name it the same as the token choice (e.g. `LeftParen`)
func testSingleTokenChoiceChildNaming() {
var failures: [ValidationFailure] = []
for node in SYNTAX_NODES.compactMap(\.layoutNode) {
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftBasicFormat/BasicFormat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ open class BasicFormat: SyntaxRewriter {
/// How much indentation should be added at a new indentation level.
public let indentationWidth: Trivia

/// As we reach a new indendation level, its indentation will be added to the
/// stack. As we exit that indentation level, the indendation will be popped.
/// As we reach a new indentation level, its indentation will be added to the
/// stack. As we exit that indentation level, the indentation will be popped.
/// `isUserDefined` is `true` if the indentation was inferred from something
/// the user provided manually instead of being inferred from the nesting
/// level.
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftBasicFormat/Trivia+FormatExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ extension Trivia {

/// Returns `true` if this trivia contains indentation.
func containsIndentation(isOnNewline: Bool) -> Bool {
guard let indentaton = indentation(isOnNewline: isOnNewline) else {
guard let indentation = indentation(isOnNewline: isOnNewline) else {
return false
}
return !indentaton.isEmpty
return !indentation.isEmpty
}

/// Returns the indentation of the last trivia piece in this trivia that is
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftCompilerPlugin/CompilerPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import SwiftSyntaxMacros
// A plugin receives messages from the "plugin host" (typically
// 'swift-frontend'), and sends back messages in return based on its actions.
//
// Depending on the platform, plugins are invoked in a sanbox that blocks
// Depending on the platform, plugins are invoked in a sandbox that blocks
// network access and prevents any file system changes.
//
// The host process and the plugin communicate using messages in the form of
Expand All @@ -36,7 +36,7 @@ import SwiftSyntaxMacros
//
// Within the plugin process, `stdout` is redirected to `stderr` so that print
// statements from the plugin are treated as plain-text output, and `stdin` is
// closed so that any attemps by the plugin logic to read from console result
// closed so that any attempts by the plugin logic to read from console result
// in errors instead of blocking the process. The original `stdin` and `stdout`
// are duplicated for use as messaging pipes, and are not directly used by the
// plugin logic.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class SourceManager {
}

/// Get position (file name + UTF-8 offset) of `node` in the known root nodes.
/// The root node of `node` must be one of the retured value from `add(_:)`.
/// The root node of `node` must be one of the returned value from `add(_:)`.
func position(
of node: Syntax,
at kind: PositionInSyntaxNode
Expand All @@ -121,7 +121,7 @@ class SourceManager {
}

/// Get ``SourceRange`` (file name + UTF-8 offset range) of `node` in the known root nodes.
/// The root node of `node` must be one of the retured value from `add(_:)`.
/// The root node of `node` must be one of the returned value from `add(_:)`.
func range(
of node: Syntax,
from startKind: PositionInSyntaxNode = .afterLeadingTrivia,
Expand All @@ -144,7 +144,7 @@ class SourceManager {
}

/// Get location of `node` in the known root nodes.
/// The root node of `node` must be one of the retured value from `add(_:)`.
/// The root node of `node` must be one of the returned value from `add(_:)`.
func location(of node: Syntax, at kind: PositionInSyntaxNode, filePathMode: SourceLocationFilePathMode) -> SourceLocation? {
guard let base = self.knownSourceSyntax[node.root.id] else {
return nil
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftOperators/OperatorTable+Folding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ extension OperatorTable {
/// Syntax rewriter that folds all of the sequence expressions it
/// encounters.
private class SequenceFolder: SyntaxRewriter {
/// The first operator precedecence that caused the error handler to
/// The first operator precedence that caused the error handler to
/// also throw.
var firstFatalError: OperatorError? = nil

Expand Down
6 changes: 3 additions & 3 deletions Sources/SwiftParser/Availability.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extension Parser {
var elements = [RawAvailabilityArgumentSyntax]()
do {
var keepGoing: RawTokenSyntax? = nil
var availablityArgumentProgress = LoopProgressCondition()
var availabilityArgumentProgress = LoopProgressCondition()
repeat {
let entry: RawAvailabilityArgumentSyntax.Entry
if self.at(.identifier) {
Expand All @@ -48,7 +48,7 @@ extension Parser {
arena: self.arena
)
)
} while keepGoing != nil && availablityArgumentProgress.evaluate(currentToken)
} while keepGoing != nil && availabilityArgumentProgress.evaluate(currentToken)
}

return RawAvailabilitySpecListSyntax(elements: elements, arena: self.arena)
Expand Down Expand Up @@ -260,7 +260,7 @@ extension Parser {
///
/// version-tuple -> integer-literal version-list?
/// version-list -> version-tuple-element version-list?
/// version-tuple-element -> '.' interger-literal
/// version-tuple-element -> '.' integer-literal
mutating func parseVersionTuple(maxComponentCount: Int) -> RawVersionTupleSyntax {
if self.at(.floatingLiteral),
let periodIndex = self.currentToken.tokenText.firstIndex(of: UInt8(ascii: ".")),
Expand Down
Loading