diff --git a/.github/actions/setup-tools/action.yml b/.github/actions/setup-tools/action.yml new file mode 100644 index 00000000..069f32e9 --- /dev/null +++ b/.github/actions/setup-tools/action.yml @@ -0,0 +1,29 @@ +name: Setup mise tools +description: >- + Restore (or build + save) the mise tool cache and put the binaries on PATH. + Implemented as a composite action so the cache scope is the caller job's + scope — reusable workflows scope caches separately, which silently breaks + hand-off between a setup job and a consumer lint job. + +runs: + using: composite + steps: + - name: Cache mise tools + id: mise-cache + uses: actions/cache@v4 + with: + path: ~/.local/share/mise/installs + key: mise-v2-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('mise.toml') }} + restore-keys: | + mise-v2-${{ runner.os }}-${{ runner.arch }}- + - name: Install mise tools (cache miss) + if: steps.mise-cache.outputs.cache-hit != 'true' + uses: jdx/mise-action@v4 + with: + cache: false + - name: Configure PATH for cached mise tools + if: steps.mise-cache.outputs.cache-hit == 'true' + uses: jdx/mise-action@v4 + with: + install: false + cache: false diff --git a/.github/workflows/SyntaxKit.yml b/.github/workflows/SyntaxKit.yml index ebfd1d44..1363b825 100644 --- a/.github/workflows/SyntaxKit.yml +++ b/.github/workflows/SyntaxKit.yml @@ -31,21 +31,43 @@ jobs: runs-on: ubuntu-latest if: ${{ github.event_name == 'pull_request' || !contains(github.event.head_commit.message, 'ci skip') }} outputs: - full-matrix: ${{ steps.set-matrix.outputs.full-matrix }} - ubuntu-os: ${{ steps.set-matrix.outputs.ubuntu-os }} - ubuntu-swift: ${{ steps.set-matrix.outputs.ubuntu-swift }} - ubuntu-type: ${{ steps.set-matrix.outputs.ubuntu-type }} + full-matrix: ${{ steps.check.outputs.full }} + ubuntu-os: ${{ steps.matrix.outputs.ubuntu-os }} + ubuntu-swift: ${{ steps.matrix.outputs.ubuntu-swift }} + ubuntu-type: ${{ steps.matrix.outputs.ubuntu-type }} steps: - - name: Determine build matrix - id: set-matrix + - id: check + name: Determine matrix scope run: | - if [[ "${{ github.ref }}" == "refs/heads/main" || "${{ github.event_name }}" == "pull_request" ]]; then - echo "full-matrix=true" >> "$GITHUB_OUTPUT" + FULL=false + REF="${{ github.ref }}" + EVENT="${{ github.event_name }}" + BASE_REF="${{ github.base_ref }}" + + # Full matrix on main + if [[ "$REF" == "refs/heads/main" ]]; then + FULL=true + # Full matrix on semver branches (v1.0.0, 1.2.3-alpha.1, etc.) + elif [[ "$REF" =~ ^refs/heads/v?[0-9]+\.[0-9]+\.[0-9]+ ]]; then + FULL=true + # Full matrix on PRs targeting main or semver branches + elif [[ "$EVENT" == "pull_request" ]]; then + if [[ "$BASE_REF" == "main" || "$BASE_REF" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+ ]]; then + FULL=true + fi + fi + + echo "full=$FULL" >> "$GITHUB_OUTPUT" + echo "Full matrix: $FULL (ref=$REF, event=$EVENT, base_ref=$BASE_REF)" + + - id: matrix + name: Build matrix values + run: | + if [[ "${{ steps.check.outputs.full }}" == "true" ]]; then echo 'ubuntu-os=["noble","jammy"]' >> "$GITHUB_OUTPUT" echo 'ubuntu-swift=[{"version":"6.0"},{"version":"6.1"},{"version":"6.2"},{"version":"6.3"}]' >> "$GITHUB_OUTPUT" echo 'ubuntu-type=["","wasm","wasm-embedded"]' >> "$GITHUB_OUTPUT" else - echo "full-matrix=false" >> "$GITHUB_OUTPUT" echo 'ubuntu-os=["noble"]' >> "$GITHUB_OUTPUT" echo 'ubuntu-swift=[{"version":"6.3"}]' >> "$GITHUB_OUTPUT" echo 'ubuntu-type=[""]' >> "$GITHUB_OUTPUT" @@ -86,6 +108,9 @@ jobs: run: | apt-get update -q apt-get install -y curl + - name: Install coverage.py (silences codecov-cli probe warning) + if: steps.build.outputs.contains-code-coverage == 'true' + run: pip3 install --quiet --user coverage 2>/dev/null || true - uses: sersoft-gmbh/swift-coverage-action@v5 id: coverage-files if: steps.build.outputs.contains-code-coverage == 'true' @@ -151,7 +176,7 @@ jobs: include: # SPM Build — no platform type; matrix.type evaluates to '' by design - runs-on: macos-26 - xcode: "/Applications/Xcode_26.4.app" + xcode: "/Applications/Xcode_26.5.app" steps: - uses: actions/checkout@v6 @@ -202,38 +227,38 @@ jobs: # macOS Build - type: macos runs-on: macos-26 - xcode: "/Applications/Xcode_26.4.app" + xcode: "/Applications/Xcode_26.5.app" # iOS Build Matrix - type: ios runs-on: macos-26 - xcode: "/Applications/Xcode_26.4.app" + xcode: "/Applications/Xcode_26.5.app" deviceName: "iPhone 17 Pro" - osVersion: "26.4" + osVersion: "26.5" download-platform: true # watchOS Build Matrix - type: watchos runs-on: macos-26 - xcode: "/Applications/Xcode_26.4.app" + xcode: "/Applications/Xcode_26.5.app" deviceName: "Apple Watch Ultra 3 (49mm)" - osVersion: "26.4" + osVersion: "26.5" download-platform: true # tvOS Build Matrix - type: tvos runs-on: macos-26 - xcode: "/Applications/Xcode_26.4.app" + xcode: "/Applications/Xcode_26.5.app" deviceName: "Apple TV" - osVersion: "26.4" + osVersion: "26.5" download-platform: true # visionOS Build Matrix - type: visionos runs-on: macos-26 - xcode: "/Applications/Xcode_26.4.app" + xcode: "/Applications/Xcode_26.5.app" deviceName: "Apple Vision Pro" - osVersion: "26.4" + osVersion: "26.5" download-platform: true steps: @@ -310,11 +335,14 @@ jobs: if: ${{ !cancelled() && !failure() && (github.event_name == 'pull_request' || !contains(github.event.head_commit.message, 'ci skip')) }} runs-on: ubuntu-latest needs: [build-ubuntu, build-macos, build-windows, build-macos-full, build-android] + # Serialize lint runs across workflows so a cold cache on a mise.toml + # bump only triggers one rebuild, not a race. + concurrency: + group: lint-tools-${{ github.head_ref || github.ref }} + cancel-in-progress: false steps: - uses: actions/checkout@v6 - - uses: jdx/mise-action@v4 - with: - cache: true + - uses: ./.github/actions/setup-tools - name: Lint run: ./Scripts/lint.sh diff --git a/.github/workflows/check-unsafe-flags.yml b/.github/workflows/check-unsafe-flags.yml new file mode 100644 index 00000000..348f4430 --- /dev/null +++ b/.github/workflows/check-unsafe-flags.yml @@ -0,0 +1,39 @@ +name: Check for unsafeFlags + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + dump-package-check: + name: Dump Swift package (authoritative) and scan JSON + runs-on: ubuntu-latest + container: + image: swift:latest + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Install jq + run: | + apt-get update && apt-get install -y jq + + - name: Dump package JSON and check for unsafeFlags + shell: bash + run: | + set -euo pipefail + # Compute unsafeFlags array directly from the dump (don't store the full dump variable) + unsafe_flags=$(swift package dump-package | jq -c '[.. | objects | .unsafeFlags? // empty]') + # Check array length to decide failure + if [ "$(echo "$unsafe_flags" | jq 'length')" -gt 0 ]; then + echo "ERROR: unsafeFlags found in resolved package JSON:" + echo "$unsafe_flags" | jq '.' || true + echo "--- resolved package dump (first 200 lines) ---" + # Print a sample of the authoritative dump (re-run dump-package for the sample) + swift package dump-package | sed -n '1,200p' || true + exit 1 + else + echo "No unsafeFlags in resolved package JSON." + fi diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 5e7f78bf..aa09eaf8 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -34,11 +34,9 @@ on: jobs: analyze: name: Analyze - # Runner size impacts CodeQL analysis time. To learn more, please see: - # - https://gh.io/recommended-hardware-resources-for-running-codeql - # - https://gh.io/supported-runners-and-hardware-resources - # - https://gh.io/using-larger-runners - # Consider using larger runners for possible analysis time improvements. + # CodeQL Swift analysis requires macOS runners — Linux is not supported + # ("Swift analysis is only supported on macOS runner images"). Other languages + # can run on Linux, hence the conditional. runs-on: ${{ (matrix.language == 'swift' && 'macos-26') || 'ubuntu-latest' }} timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} permissions: @@ -60,9 +58,11 @@ jobs: uses: actions/checkout@v6 - name: Setup Xcode - run: sudo xcode-select -s /Applications/Xcode_26.4.app/Contents/Developer + if: matrix.language == 'swift' + run: sudo xcode-select -s /Applications/Xcode_26.5.app/Contents/Developer - name: Verify Swift Version + if: matrix.language == 'swift' run: | swift --version swift package --version diff --git a/.github/workflows/swift-source-compat.yml b/.github/workflows/swift-source-compat.yml new file mode 100644 index 00000000..a8c05a03 --- /dev/null +++ b/.github/workflows/swift-source-compat.yml @@ -0,0 +1,31 @@ +name: Swift Source Compatibility + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +jobs: + swift-source-compat-suite: + name: Test Swift ${{ matrix.container }} For Source Compatibility Suite + runs-on: ubuntu-latest + if: ${{ !contains(github.event.head_commit.message, 'ci skip') }} + + strategy: + fail-fast: false + matrix: + container: + - swift:6.0 + - swift:6.1 + - swift:6.2 + - swift:6.3 + + container: ${{ matrix.container }} + + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Test Swift 6.x For Source Compatibility + run: swift build --disable-sandbox --verbose --configuration release diff --git a/.mise.toml b/.mise.toml deleted file mode 100644 index a5bd89f0..00000000 --- a/.mise.toml +++ /dev/null @@ -1,6 +0,0 @@ -[tools] -swiftlint = "0.63.2" -periphery = {version = "3.7.2", os = ["macos"]} -# Community asdf plugin — builds swift-format from source (no official binary releases) -# Plugin repo: https://github.com/eelcokoelewijn/asdf-swift-format -"asdf:eelcokoelewijn/asdf-swift-format" = "602.0.0" diff --git a/.swift-format b/.swift-format index a657e6cc..5393ff74 100644 --- a/.swift-format +++ b/.swift-format @@ -33,9 +33,9 @@ "FullyIndirectEnum" : true, "GroupNumericLiterals" : true, "IdentifiersMustBeASCII" : true, - "NeverForceUnwrap" : false, - "NeverUseForceTry" : false, - "NeverUseImplicitlyUnwrappedOptionals" : false, + "NeverForceUnwrap" : true, + "NeverUseForceTry" : true, + "NeverUseImplicitlyUnwrappedOptionals" : true, "NoAccessLevelOnExtensionDeclaration" : true, "NoAssignmentInExpressions" : true, "NoBlockComments" : true, @@ -56,13 +56,13 @@ "TypeNamesShouldBeCapitalized" : true, "UseEarlyExits" : false, "UseExplicitNilCheckInConditions" : true, - "UseLetInEveryBoundCaseVariable" : false, + "UseLetInEveryBoundCaseVariable" : true, "UseShorthandTypeNames" : true, "UseSingleLinePropertyGetter" : true, "UseSynthesizedInitializer" : true, "UseTripleSlashForDocumentationComments" : true, "UseWhereClausesInForLoops" : true, - "ValidateDocumentationComments" : false + "ValidateDocumentationComments" : true }, "spacesAroundRangeFormationOperators" : false, "tabWidth" : 2, diff --git a/.swiftlint.yml b/.swiftlint.yml index e468b7c6..43ef0b6a 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -11,6 +11,7 @@ opt_in_rules: - contains_over_range_nil_comparison - convenience_type - discouraged_object_literal + - discouraged_optional_boolean - empty_collection_literal - empty_count - empty_string @@ -52,11 +53,11 @@ opt_in_rules: - nslocalizedstring_require_bundle - number_separator - object_literal + - one_declaration_per_file - operator_usage_whitespace - optional_enum_case_matching - overridden_super_call - override_in_extension - - pattern_matching_keywords - prefer_self_type_over_type_of_self - prefer_zero_over_explicit_init - private_action @@ -114,6 +115,10 @@ type_name: excluded: - If - Do + min_length: 3 + max_length: + warning: 50 + error: 60 excluded: - DerivedData - .build @@ -138,3 +143,9 @@ disabled_rules: - opening_brace - optional_data_string_conversion - todo +custom_rules: + no_unchecked_sendable: + name: "No Unchecked Sendable" + regex: '@unchecked\s+Sendable' + message: "Use proper Sendable conformance instead of @unchecked Sendable to maintain strict concurrency safety" + severity: error diff --git a/Package.swift b/Package.swift index baf98d69..ea48d243 100644 --- a/Package.swift +++ b/Package.swift @@ -127,6 +127,7 @@ let package = Package( .product(name: "SwiftOperators", package: "swift-syntax"), .product(name: "SwiftParser", package: "swift-syntax") ], + exclude: ["README.md"], swiftSettings: swiftSettings ), .target( diff --git a/Scripts/lint.sh b/Scripts/lint.sh index 5b4560fd..5769c601 100755 --- a/Scripts/lint.sh +++ b/Scripts/lint.sh @@ -1,16 +1,12 @@ #!/bin/bash -# Remove set -e to prevent immediate exit on errors +# Remove set -e to allow script to continue running # set -e # Exit on any error ERRORS=0 run_command() { - if [ "$LINT_MODE" = "STRICT" ]; then - "$@" || ERRORS=$((ERRORS + 1)) - else - "$@" || ERRORS=$((ERRORS + 1)) - fi + "$@" || ERRORS=$((ERRORS + 1)) } if [ "$LINT_MODE" = "INSTALL" ]; then @@ -21,59 +17,59 @@ echo "LintMode: $LINT_MODE" # More portable way to get script directory if [ -z "$SRCROOT" ]; then - SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" - PACKAGE_DIR="${SCRIPT_DIR}/.." + SCRIPT_DIR=$(dirname "$(readlink -f "$0")") + PACKAGE_DIR="${SCRIPT_DIR}/.." else - PACKAGE_DIR="${SRCROOT}" + PACKAGE_DIR="${SRCROOT}" +fi + +# Ensure mise-managed tools are on PATH outside CI (CI uses jdx/mise-action) +if command -v mise >/dev/null 2>&1 && [ -z "$CI" ]; then + eval "$(mise -C "$PACKAGE_DIR" env -s bash)" fi if [ "$LINT_MODE" = "NONE" ]; then exit elif [ "$LINT_MODE" = "STRICT" ]; then - SWIFTFORMAT_OPTIONS="--strict --configuration .swift-format" + SWIFTFORMAT_OPTIONS="--configuration .swift-format" + SWIFTFORMAT_LINT_STRICT="--strict" SWIFTLINT_OPTIONS="--strict" STRINGSLINT_OPTIONS="--config .strict.stringslint.yml" else SWIFTFORMAT_OPTIONS="--configuration .swift-format" + SWIFTFORMAT_LINT_STRICT="" SWIFTLINT_OPTIONS="" STRINGSLINT_OPTIONS="--config .stringslint.yml" fi -pushd "$PACKAGE_DIR" -if [ -z "$CI" ]; then - mise install -fi -if command -v mise &> /dev/null; then - eval "$(mise env)" -fi +pushd $PACKAGE_DIR if [ -z "$CI" ]; then run_command swift-format format $SWIFTFORMAT_OPTIONS --recursive --parallel --in-place Sources Tests - run_command swiftlint --fix + run_command swiftlint --fix Sources Tests fi if [ -z "$FORMAT_ONLY" ]; then - run_command swift-format lint --configuration .swift-format --recursive --parallel $SWIFTFORMAT_OPTIONS Sources Tests - run_command swiftlint lint $SWIFTLINT_OPTIONS + run_command swift-format lint $SWIFTFORMAT_LINT_STRICT $SWIFTFORMAT_OPTIONS --recursive --parallel Sources Tests + run_command swiftlint lint $SWIFTLINT_OPTIONS Sources Tests + # Check for compilation errors + run_command swift build --build-tests fi -$PACKAGE_DIR/Scripts/header.sh -d $PACKAGE_DIR/Sources -c "Leo Dion" -o "BrightDigit" -p "SyntaxKit" - -run_command swiftlint lint $SWIFTLINT_OPTIONS -run_command swift-format lint --recursive --parallel $SWIFTFORMAT_OPTIONS Sources Tests +$PACKAGE_DIR/Scripts/header.sh -d "$PACKAGE_DIR/Sources" -c "Leo Dion" -o "BrightDigit" -p "SyntaxKit" +$PACKAGE_DIR/Scripts/header.sh -d "$PACKAGE_DIR/Tests" -c "Leo Dion" -o "BrightDigit" -p "SyntaxKit" if [ -z "$CI" ]; then - run_command periphery scan $PERIPHERY_OPTIONS --disable-update-check + run_command periphery scan $PERIPHERY_OPTIONS --disable-update-check fi - popd -# Return error count at the end instead of exiting immediately +# Exit with error code if any errors occurred if [ $ERRORS -gt 0 ]; then - echo "Lint script completed with $ERRORS error(s)" - exit $ERRORS + echo "Linting completed with $ERRORS error(s)" + exit 1 else - echo "Lint script completed successfully" - exit 0 + echo "Linting completed successfully" + exit 0 fi diff --git a/Sources/DocumentationHarness/CodeBlockType.swift b/Sources/DocumentationHarness/CodeBlockType.swift index 08435090..ab432807 100644 --- a/Sources/DocumentationHarness/CodeBlockType.swift +++ b/Sources/DocumentationHarness/CodeBlockType.swift @@ -31,6 +31,7 @@ import Foundation internal enum CodeBlockType: Sendable { case example + // periphery:ignore - intentionally unavailable; retained for source compatibility @available( *, unavailable, message: "Parsing Package.swift manifests as documentation code blocks is unsupported." diff --git a/Sources/DocumentationHarness/CodeBlockValidationParameters.swift b/Sources/DocumentationHarness/CodeBlockValidationParameters.swift index e13c0619..2950df3f 100644 --- a/Sources/DocumentationHarness/CodeBlockValidationParameters.swift +++ b/Sources/DocumentationHarness/CodeBlockValidationParameters.swift @@ -33,6 +33,7 @@ import Foundation internal struct CodeBlockValidationParameters: ValidationParameters, Sendable { internal let codeBlock: CodeBlock internal let fileURL: URL + // periphery:ignore - carried for downstream diagnostic context; intentionally unread here internal let blockIndex: Int // MARK: - ValidationParameters conformance diff --git a/Sources/DocumentationHarness/DocumentationValidator.swift b/Sources/DocumentationHarness/DocumentationValidator.swift index cdc1a627..6ece6b67 100644 --- a/Sources/DocumentationHarness/DocumentationValidator.swift +++ b/Sources/DocumentationHarness/DocumentationValidator.swift @@ -41,7 +41,6 @@ package struct DocumentationValidator: Validator { /// Creates a new documentation test harness /// - Parameters: /// - codeValidator: Validator for Swift code syntax (defaults to CodeSyntaxValidator) - /// - fileSearcher: File system searcher (defaults to FileManager.default) /// - codeBlocksFrom: Function to extract code blocks from content package init( codeValidator: any SyntaxValidator = CodeSyntaxValidator(), diff --git a/Sources/DocumentationHarness/PackageValidator.swift b/Sources/DocumentationHarness/PackageValidator.swift index b10107cd..1704b312 100644 --- a/Sources/DocumentationHarness/PackageValidator.swift +++ b/Sources/DocumentationHarness/PackageValidator.swift @@ -30,6 +30,7 @@ import Foundation #if canImport(Foundation) && (os(macOS) || os(Linux)) + // periphery:ignore - intentionally unavailable; preserved for future enablement @available(*, unavailable) private enum PackageValidator { /// Validates a Package.swift manifest diff --git a/Sources/DocumentationHarness/ProcessError.swift b/Sources/DocumentationHarness/ProcessError.swift new file mode 100644 index 00000000..2fc65869 --- /dev/null +++ b/Sources/DocumentationHarness/ProcessError.swift @@ -0,0 +1,38 @@ +// +// ProcessError.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation + +/// Errors that can occur during process execution +package enum ProcessError: Error, Sendable { + /// Package.swift validation failed + case packageValidationFailed + /// Package validation setup failed + case setupError(any Error) +} diff --git a/Sources/DocumentationHarness/TestType.swift b/Sources/DocumentationHarness/TestType.swift index 40dcfe0b..1671f5f5 100644 --- a/Sources/DocumentationHarness/TestType.swift +++ b/Sources/DocumentationHarness/TestType.swift @@ -33,6 +33,7 @@ import Foundation package enum TestType { /// Code was parsed for syntax validation only case parsing + // periphery:ignore - part of the package's public API surface; consumers may switch on it /// Code was executed (compiled and run) case execution /// Code validation was skipped diff --git a/Sources/DocumentationHarness/ValidationError.swift b/Sources/DocumentationHarness/ValidationError.swift index d16a113f..c3066311 100644 --- a/Sources/DocumentationHarness/ValidationError.swift +++ b/Sources/DocumentationHarness/ValidationError.swift @@ -29,14 +29,6 @@ import Foundation -/// Errors that can occur during process execution -package enum ProcessError: Error, Sendable { - /// Package.swift validation failed - case packageValidationFailed - /// Package validation setup failed - case setupError(any Error) -} - /// Errors that can occur during Swift code validation package enum ValidationError: Error, Sendable { /// Syntax parsing detected errors in the code diff --git a/Sources/DocumentationHarness/Validator.swift b/Sources/DocumentationHarness/Validator.swift index b01a2e41..85853040 100644 --- a/Sources/DocumentationHarness/Validator.swift +++ b/Sources/DocumentationHarness/Validator.swift @@ -45,6 +45,7 @@ extension Validator { /// - relativePaths: Array of relative paths to search for documentation /// - projectRoot: Root URL of the project /// - pathExtensions: File extensions to search for (defaults to ["md"]) + /// - fileSearcher: File system searcher (defaults to ``FileManager``.``default``) /// - Returns: Array of validation results for all code blocks found /// - Throws: FileSearchError if file operations fail package func validate( diff --git a/Sources/SyntaxKit/CodeBlocks/CodeBlock+ExprSyntax.swift b/Sources/SyntaxKit/CodeBlocks/CodeBlock+ExprSyntax.swift index e07fc1ca..2cd32f0b 100644 --- a/Sources/SyntaxKit/CodeBlocks/CodeBlock+ExprSyntax.swift +++ b/Sources/SyntaxKit/CodeBlocks/CodeBlock+ExprSyntax.swift @@ -46,11 +46,9 @@ extension CodeBlock { return ExprSyntax(DeclReferenceExprSyntax(baseName: .identifier(token.text))) } - // Fallback for unsupported syntax types - create a default expression - // This prevents crashes while still allowing code generation to continue - #warning( - "TODO: Review fallback for unsupported syntax types - consider if this should be an error instead" - ) + // TODO: Review fallback for unsupported syntax types - consider if this should be an error instead. + // Fallback for unsupported syntax types - create a default expression so code + // generation can continue rather than crashing. return ExprSyntax(DeclReferenceExprSyntax(baseName: .identifier(""))) } } diff --git a/Sources/SyntaxKit/CodeBlocks/CodeBlock+Generate.swift b/Sources/SyntaxKit/CodeBlocks/CodeBlock+Generate.swift index 914fdf6b..80fb6618 100644 --- a/Sources/SyntaxKit/CodeBlocks/CodeBlock+Generate.swift +++ b/Sources/SyntaxKit/CodeBlocks/CodeBlock+Generate.swift @@ -28,7 +28,7 @@ // import Foundation -public import SwiftSyntax +import SwiftSyntax extension CodeBlock { /// Generates the Swift code for the ``CodeBlock``. @@ -45,11 +45,9 @@ extension CodeBlock { if let convertedItem = CodeBlockItemSyntax.Item.create(from: self.syntax) { item = convertedItem } else { - // Fallback for unsupported syntax types - create an empty code block - // This prevents crashes while still allowing code generation to continue - #warning( - "TODO: Review fallback for unsupported syntax types - consider if this should be an error instead" - ) + // TODO: Review fallback for unsupported syntax types - consider if this should be an error instead. + // Fallback for unsupported syntax types - create an empty code block so code + // generation can continue rather than crashing. let emptyExpr = ExprSyntax(DeclReferenceExprSyntax(baseName: .identifier(""))) item = .expr(emptyExpr) } diff --git a/Sources/SyntaxKit/CodeBlocks/CodeBlockItemSyntax.Item.swift b/Sources/SyntaxKit/CodeBlocks/CodeBlockItemSyntax.Item.swift index f19bb6f8..996def5a 100644 --- a/Sources/SyntaxKit/CodeBlocks/CodeBlockItemSyntax.Item.swift +++ b/Sources/SyntaxKit/CodeBlocks/CodeBlockItemSyntax.Item.swift @@ -45,11 +45,9 @@ extension CodeBlockItemSyntax.Item { let expr = ExprSyntax(DeclReferenceExprSyntax(baseName: .identifier(token.text))) return .expr(expr) } else if let switchCase = syntax.as(SwitchCaseSyntax.self) { - // Wrap SwitchCaseSyntax in a SwitchExprSyntax and treat it as an expression - // This is a fallback for when SwitchCase is used standalone - #warning( - "TODO: Review fallback for SwitchCase used standalone - consider if this should be an error instead" - ) + // TODO: Review fallback for SwitchCase used standalone - consider if this should be an error instead. + // Wrap SwitchCaseSyntax in a SwitchExprSyntax and treat it as an expression so + // standalone SwitchCase usage continues to work. let switchExpr = SwitchExprSyntax( switchKeyword: .keyword(.switch, trailingTrivia: .space), subject: ExprSyntax(DeclReferenceExprSyntax(baseName: .identifier("_"))), diff --git a/Sources/SyntaxKit/CodeBlocks/CommentedCodeBlock.swift b/Sources/SyntaxKit/CodeBlocks/CommentedCodeBlock.swift index 1744372f..f616e3de 100644 --- a/Sources/SyntaxKit/CodeBlocks/CommentedCodeBlock.swift +++ b/Sources/SyntaxKit/CodeBlocks/CommentedCodeBlock.swift @@ -59,8 +59,8 @@ internal struct CommentedCodeBlock: CodeBlock { let commentTrivia = Trivia(pieces: lines.flatMap { [$0.triviaPiece, TriviaPiece.newlines(1)] }) guard let firstToken = base.syntax.firstToken(viewMode: .sourceAccurate) else { - // Fallback – no tokens? return original syntax - #warning("TODO: Review fallback for no tokens - consider if this should be an error instead") + // TODO: Review fallback for no tokens - consider if this should be an error instead. + // Fallback – no tokens? return original syntax. return base.syntax } diff --git a/Sources/SyntaxKit/CodeBlocks/EmptyCodeBlock.swift b/Sources/SyntaxKit/CodeBlocks/EmptyCodeBlock.swift index 4ebdf4d0..bbaba89c 100644 --- a/Sources/SyntaxKit/CodeBlocks/EmptyCodeBlock.swift +++ b/Sources/SyntaxKit/CodeBlocks/EmptyCodeBlock.swift @@ -28,7 +28,7 @@ // import Foundation -public import SwiftSyntax +import SwiftSyntax /// An empty code block that generates no syntax. internal struct EmptyCodeBlock: CodeBlock, Sendable, Equatable { diff --git a/Sources/SyntaxKit/Collections/CodeBlock+DictionaryValue.swift b/Sources/SyntaxKit/Collections/CodeBlock+DictionaryValue.swift index 8a38ca05..8f1575f1 100644 --- a/Sources/SyntaxKit/Collections/CodeBlock+DictionaryValue.swift +++ b/Sources/SyntaxKit/Collections/CodeBlock+DictionaryValue.swift @@ -45,11 +45,9 @@ extension CodeBlock where Self: DictionaryValue { return ExprSyntax(DeclReferenceExprSyntax(baseName: .identifier(token.text))) } - // Fallback for unsupported syntax types - create a default expression - // This prevents crashes while still allowing dictionary operations to continue - #warning( - "TODO: Review fallback for unsupported syntax types - consider if this should be an error instead" - ) + // TODO: Review fallback for unsupported syntax types - consider if this should be an error instead. + // Fallback for unsupported syntax types - create a default expression so dictionary + // operations can continue rather than crashing. return ExprSyntax(DeclReferenceExprSyntax(baseName: .identifier(""))) } } diff --git a/Sources/SyntaxKit/Collections/Tuple.swift b/Sources/SyntaxKit/Collections/Tuple.swift index df42ff32..60013ea0 100644 --- a/Sources/SyntaxKit/Collections/Tuple.swift +++ b/Sources/SyntaxKit/Collections/Tuple.swift @@ -37,7 +37,7 @@ public struct Tuple: CodeBlock { /// The SwiftSyntax representation of this tuple expression. public var syntax: any SyntaxProtocol { - let list = TupleExprElementListSyntax( + let list = LabeledExprListSyntax( elements.enumerated().map { index, block in let elementExpr: ExprSyntax if isAsync { @@ -53,7 +53,7 @@ public struct Tuple: CodeBlock { elementExpr = block.expr } - return TupleExprElementSyntax( + return LabeledExprSyntax( label: nil, colon: nil, expression: elementExpr, @@ -90,12 +90,14 @@ public struct Tuple: CodeBlock { /// Creates a tuple pattern for switch cases. /// - Parameter elements: Array of pattern elements, where `nil` represents a wildcard pattern. + /// - Returns: A pattern that can match the supplied elements in a `switch` case. public static func pattern(_ elements: [(any PatternConvertible)?]) -> any PatternConvertible { TuplePattern(elements: elements) } /// Creates a tuple pattern that can be used as a CodeBlock. /// - Parameter elements: Array of pattern elements, where `nil` represents a wildcard pattern. + /// - Returns: A pattern wrapped as a ``PatternCodeBlock`` for use inside builders. public static func patternCodeBlock(_ elements: [(any PatternConvertible)?]) -> any PatternCodeBlock { diff --git a/Sources/SyntaxKit/Collections/TupleAssignment.swift b/Sources/SyntaxKit/Collections/TupleAssignment.swift index 42b93649..fbea0ba4 100644 --- a/Sources/SyntaxKit/Collections/TupleAssignment.swift +++ b/Sources/SyntaxKit/Collections/TupleAssignment.swift @@ -83,11 +83,9 @@ internal struct TupleAssignment: CodeBlock { private func generateAsyncSetSyntax() -> any SyntaxProtocol { // Generate a single async let tuple destructuring assignment guard let tuple = value as? Tuple, elements.count == tuple.elements.count else { - // Fallback to regular syntax if conditions aren't met for asyncSet - // This provides a more robust API instead of crashing - #warning( - "TODO: Review fallback for asyncSet conditions - consider if this should be an error instead" - ) + // TODO: Review fallback for asyncSet conditions - consider if this should be an error instead. + // Fallback to regular syntax if conditions aren't met for asyncSet so callers get + // a usable result instead of crashing. return generateRegularSyntax() } diff --git a/Sources/SyntaxKit/ControlFlow/For.swift b/Sources/SyntaxKit/ControlFlow/For.swift index 2b790170..f4111a9e 100644 --- a/Sources/SyntaxKit/ControlFlow/For.swift +++ b/Sources/SyntaxKit/ControlFlow/For.swift @@ -56,7 +56,7 @@ public struct For: CodeBlock, Sendable { ) whereClauseSyntax = WhereClauseSyntax( whereKeyword: .keyword(.where, leadingTrivia: .space, trailingTrivia: .space), - guardResult: whereExpr + condition: whereExpr ) } @@ -80,7 +80,7 @@ public struct For: CodeBlock, Sendable { ) return StmtSyntax( - ForInStmtSyntax( + ForStmtSyntax( forKeyword: .keyword(.for, trailingTrivia: .space), tryKeyword: nil, awaitKeyword: nil, diff --git a/Sources/SyntaxKit/ControlFlow/Guard.swift b/Sources/SyntaxKit/ControlFlow/Guard.swift index 47e12576..84ff5b9c 100644 --- a/Sources/SyntaxKit/ControlFlow/Guard.swift +++ b/Sources/SyntaxKit/ControlFlow/Guard.swift @@ -34,6 +34,7 @@ public struct Guard: CodeBlock, Sendable { private let conditions: [any CodeBlock] private let elseBody: [any CodeBlock] + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { // MARK: Build conditions list (mirror implementation from `If`) let condList = ConditionElementListSyntax( @@ -135,8 +136,7 @@ public struct Guard: CodeBlock, Sendable { } /// Creates a `guard` statement without a condition (uses true as default). - /// - Parameters: - /// - elseBody: A ``CodeBlockBuilder`` that provides the body when the condition is false. + /// - Parameter elseBody: A ``CodeBlockBuilder`` that provides the body when the condition is false. public init( @CodeBlockBuilderResult else elseBody: () throws -> [any CodeBlock] ) rethrows { diff --git a/Sources/SyntaxKit/ControlFlow/If+ElseBody.swift b/Sources/SyntaxKit/ControlFlow/If+ElseBody.swift index a4b373bc..aec1affc 100644 --- a/Sources/SyntaxKit/ControlFlow/If+ElseBody.swift +++ b/Sources/SyntaxKit/ControlFlow/If+ElseBody.swift @@ -83,9 +83,8 @@ extension If { } else if let nestedIf = nested.as(IfExprSyntax.self) { return IfExprSyntax.ElseBody(nestedIf) } else { + // TODO: Review fallback to empty code block - consider if this should be an error instead. // Fallback to empty code block - #warning( - "TODO: Review fallback to empty code block - consider if this should be an error instead") return IfExprSyntax.ElseBody( CodeBlockSyntax( leftBrace: .leftBraceToken(leadingTrivia: .space, trailingTrivia: .newline), diff --git a/Sources/SyntaxKit/ControlFlow/Switch.swift b/Sources/SyntaxKit/ControlFlow/Switch.swift index b1327a6b..9b407a50 100644 --- a/Sources/SyntaxKit/ControlFlow/Switch.swift +++ b/Sources/SyntaxKit/ControlFlow/Switch.swift @@ -34,6 +34,7 @@ public struct Switch: CodeBlock, Sendable { private let expression: any CodeBlock private let cases: [any CodeBlock] + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { let expr = ExprSyntax( fromProtocol: expression.syntax.as(ExprSyntax.self) diff --git a/Sources/SyntaxKit/ControlFlow/While.swift b/Sources/SyntaxKit/ControlFlow/While.swift index 611d8253..5f323a9e 100644 --- a/Sources/SyntaxKit/ControlFlow/While.swift +++ b/Sources/SyntaxKit/ControlFlow/While.swift @@ -66,7 +66,7 @@ public struct While: CodeBlock, Sendable { switch kind { case .repeatWhile: return StmtSyntax( - RepeatWhileStmtSyntax( + RepeatStmtSyntax( repeatKeyword: .keyword(.repeat, trailingTrivia: .space), body: bodyBlock, whileKeyword: .keyword(.while, trailingTrivia: .space), @@ -107,8 +107,8 @@ public struct While: CodeBlock, Sendable { /// Creates a `while` loop statement with a builder closure for the condition. /// - Parameters: - /// - condition: A `CodeBlockBuilder` that produces exactly one condition expression. /// - kind: The kind of loop (default is `.while`). + /// - condition: A `CodeBlockBuilder` that produces exactly one condition expression. /// - then: A ``CodeBlockBuilder`` that provides the body of the loop. public init( kind: Kind = .while, @@ -122,8 +122,8 @@ public struct While: CodeBlock, Sendable { /// Creates a `while` loop. /// - Parameters: - /// - condition: A ``CodeBlockBuilder`` that provides the condition expression. /// - kind: The kind of loop (default is `.while`). + /// - condition: A ``CodeBlockBuilder`` that provides the condition expression. /// - then: A ``CodeBlockBuilder`` that provides the body of the loop. @available( *, deprecated, diff --git a/Sources/SyntaxKit/Declarations/Extension.swift b/Sources/SyntaxKit/Declarations/Extension.swift index 8c883289..fe87fb17 100644 --- a/Sources/SyntaxKit/Declarations/Extension.swift +++ b/Sources/SyntaxKit/Declarations/Extension.swift @@ -36,6 +36,7 @@ public struct Extension: CodeBlock, Sendable { private var inheritance: [String] = [] private var attributes: [AttributeInfo] = [] + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { let extensionKeyword = TokenSyntax.keyword(.extension, trailingTrivia: .space) let identifier = TokenSyntax.identifier(extendedType, trailingTrivia: .space) diff --git a/Sources/SyntaxKit/Declarations/Import.swift b/Sources/SyntaxKit/Declarations/Import.swift index 2a94b716..6443de59 100644 --- a/Sources/SyntaxKit/Declarations/Import.swift +++ b/Sources/SyntaxKit/Declarations/Import.swift @@ -35,6 +35,7 @@ public struct Import: CodeBlock, Sendable { private var accessModifier: AccessModifier? private var attributes: [AttributeInfo] = [] + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { // Build access modifier var modifiers: DeclModifierListSyntax = [] diff --git a/Sources/SyntaxKit/Declarations/Init.swift b/Sources/SyntaxKit/Declarations/Init.swift index 4adb18dc..74e04eee 100644 --- a/Sources/SyntaxKit/Declarations/Init.swift +++ b/Sources/SyntaxKit/Declarations/Init.swift @@ -39,6 +39,7 @@ public struct Init: CodeBlock, ExprCodeBlock, LiteralValue, CodeBlockable, Senda self } + /// The SwiftSyntax expression representation of this code block. public var exprSyntax: ExprSyntax { var args = parameters var trailingClosure: ClosureExprSyntax? @@ -99,16 +100,19 @@ public struct Init: CodeBlock, ExprCodeBlock, LiteralValue, CodeBlockable, Senda ) } + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { exprSyntax } // MARK: - LiteralValue Conformance + /// The type name for this initializer. public var typeName: String { type } + /// The literal string representation. public var literalString: String { "\(type)()" } diff --git a/Sources/SyntaxKit/Declarations/Protocol.swift b/Sources/SyntaxKit/Declarations/Protocol.swift index d93abf4c..db19c7ae 100644 --- a/Sources/SyntaxKit/Declarations/Protocol.swift +++ b/Sources/SyntaxKit/Declarations/Protocol.swift @@ -36,6 +36,7 @@ public struct Protocol: CodeBlock, Sendable { private var inheritance: [String] = [] private var attributes: [AttributeInfo] = [] + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { let protocolKeyword = TokenSyntax.keyword(.protocol, trailingTrivia: .space) let identifier = TokenSyntax.identifier(name) diff --git a/Sources/SyntaxKit/Declarations/TypeAlias.swift b/Sources/SyntaxKit/Declarations/TypeAlias.swift index 4b6fe9b9..06cb2175 100644 --- a/Sources/SyntaxKit/Declarations/TypeAlias.swift +++ b/Sources/SyntaxKit/Declarations/TypeAlias.swift @@ -35,6 +35,7 @@ public struct TypeAlias: CodeBlock, Sendable { private let existingType: String private var attributes: [AttributeInfo] = [] + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { // `typealias` keyword token let keyword = TokenSyntax.keyword(.typealias, trailingTrivia: .space) diff --git a/Sources/SyntaxKit/ErrorHandling/Catch.swift b/Sources/SyntaxKit/ErrorHandling/Catch.swift index 1797179f..06c9e5d8 100644 --- a/Sources/SyntaxKit/ErrorHandling/Catch.swift +++ b/Sources/SyntaxKit/ErrorHandling/Catch.swift @@ -35,6 +35,7 @@ public struct Catch: CodeBlock { private let pattern: (any CodeBlock)? private let body: [any CodeBlock] + /// The SwiftSyntax representation of this catch clause. public var catchClauseSyntax: CatchClauseSyntax { // Build catch items (patterns) var catchItems: CatchItemListSyntax? @@ -51,40 +52,8 @@ public struct Catch: CodeBlock { let memberAccess = MemberAccessExprSyntax( base: typeName.isEmpty ? nil : ExprSyntax(DeclReferenceExprSyntax(baseName: .identifier(typeName))), - dot: .periodToken(), - name: .identifier(caseName) - ) - let patternWithTuple = PatternSyntax( - ValueBindingPatternSyntax( - bindingSpecifier: .keyword(.case, trailingTrivia: .space), - pattern: PatternSyntax( - ExpressionPatternSyntax( - expression: ExprSyntax(memberAccess) - ) - ) - ) - ) - // Actually, Swift's catch pattern for associated values is: .caseName(let a, let b) - // So we want: ExpressionPatternSyntax(MemberAccessExprSyntax + tuplePattern) - let tuplePattern = TuplePatternSyntax( - leftParen: .leftParenToken(), - elements: TuplePatternElementListSyntax( - enumCase.caseAssociatedValues.enumerated().map { index, associated in - TuplePatternElementSyntax( - pattern: PatternSyntax( - ValueBindingPatternSyntax( - bindingSpecifier: .keyword(.let, trailingTrivia: .space), - pattern: PatternSyntax( - IdentifierPatternSyntax(identifier: .identifier(associated.name)) - ) - ) - ), - trailingComma: index < enumCase.caseAssociatedValues.count - 1 - ? .commaToken(trailingTrivia: .space) : nil - ) - } - ), - rightParen: .rightParenToken() + period: .periodToken(), + declName: DeclReferenceExprSyntax(baseName: .identifier(caseName)) ) let patternSyntaxExpr = ExprSyntax( FunctionCallExprSyntax( @@ -163,6 +132,7 @@ public struct Catch: CodeBlock { ) } + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { catchClauseSyntax } @@ -197,6 +167,7 @@ public struct Catch: CodeBlock { /// - Parameters: /// - enumCase: The enum case to catch. /// - content: A ``CodeBlockBuilder`` that provides the body of the catch clause. + /// - Returns: A configured ``Catch`` clause that matches the given enum case. public static func `catch`( _ enumCase: EnumCase, @CodeBlockBuilderResult _ content: () -> [any CodeBlock] diff --git a/Sources/SyntaxKit/ErrorHandling/Throw.swift b/Sources/SyntaxKit/ErrorHandling/Throw.swift index 51f92416..cdcb9bef 100644 --- a/Sources/SyntaxKit/ErrorHandling/Throw.swift +++ b/Sources/SyntaxKit/ErrorHandling/Throw.swift @@ -34,6 +34,7 @@ public import SwiftSyntax public struct Throw: CodeBlock { private let expr: any CodeBlock + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { let expression: ExprSyntax if let enumCase = expr as? EnumCase { @@ -51,6 +52,7 @@ public struct Throw: CodeBlock { ) } + /// Creates a new instance. public init(_ expr: any CodeBlock) { self.expr = expr } diff --git a/Sources/SyntaxKit/Expressions/Assignment.swift b/Sources/SyntaxKit/Expressions/Assignment.swift index 4cfb55cd..d1852cfc 100644 --- a/Sources/SyntaxKit/Expressions/Assignment.swift +++ b/Sources/SyntaxKit/Expressions/Assignment.swift @@ -34,6 +34,7 @@ public struct Assignment: CodeBlock { private let target: String private let valueExpr: ExprSyntax + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { let left = ExprSyntax(DeclReferenceExprSyntax(baseName: .identifier(target))) let right = valueExpr diff --git a/Sources/SyntaxKit/Expressions/CaptureInfo.swift b/Sources/SyntaxKit/Expressions/CaptureInfo.swift index 69f4847f..a8601a59 100644 --- a/Sources/SyntaxKit/Expressions/CaptureInfo.swift +++ b/Sources/SyntaxKit/Expressions/CaptureInfo.swift @@ -52,10 +52,8 @@ internal struct CaptureInfo { if let varExp = refExp.captureExpression as? VariableExp { self.name = .identifier(varExp.name) } else { + // TODO: Review fallback for non-VariableExp capture expression. self.name = .identifier("self") // fallback - #warning( - "TODO: Review fallback for non-VariableExp capture expression" - ) } } @@ -65,10 +63,8 @@ internal struct CaptureInfo { if let varExp = param.value as? VariableExp { self.name = .identifier(varExp.name) } else { + // TODO: Review fallback for non-VariableExp parameter value. self.name = .identifier("self") // fallback - #warning( - "TODO: Review fallback for non-VariableExp parameter value" - ) } } } diff --git a/Sources/SyntaxKit/Expressions/Closure.swift b/Sources/SyntaxKit/Expressions/Closure.swift index 8941f030..2ec36d80 100644 --- a/Sources/SyntaxKit/Expressions/Closure.swift +++ b/Sources/SyntaxKit/Expressions/Closure.swift @@ -161,8 +161,7 @@ public struct Closure: CodeBlock { } /// Creates a simple closure with only a body. - /// - Parameters: - /// - body: A ``CodeBlockBuilder`` that provides the body of the closure. + /// - Parameter body: A ``CodeBlockBuilder`` that provides the body of the closure. public init( @CodeBlockBuilderResult body: () throws -> [any CodeBlock] ) rethrows { @@ -175,8 +174,7 @@ public struct Closure: CodeBlock { } /// Creates a closure with just a CodeBlock array. - /// - Parameters: - /// - body: An array of CodeBlock elements that form the body of the closure. + /// - Parameter body: An array of CodeBlock elements that form the body of the closure. public init(body: [any CodeBlock]) { self.capture = [] self.parameters = [] @@ -200,6 +198,7 @@ public struct Closure: CodeBlock { ) } + /// Adds an attribute to the closure with optional arguments. public func attribute(_ attribute: String, arguments: [String] = []) -> Self { var copy = self copy.attributes.append(AttributeInfo(name: attribute, arguments: arguments)) diff --git a/Sources/SyntaxKit/Expressions/ClosureType.swift b/Sources/SyntaxKit/Expressions/ClosureType.swift index e2fb1779..fa9c7109 100644 --- a/Sources/SyntaxKit/Expressions/ClosureType.swift +++ b/Sources/SyntaxKit/Expressions/ClosureType.swift @@ -35,6 +35,7 @@ public struct ClosureType: CodeBlock, TypeRepresentable { private let returnType: String? private var attributes: [AttributeInfo] = [] + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { // Build parameters let paramList = parameters.map { param in diff --git a/Sources/SyntaxKit/Expressions/ConditionalOp.swift b/Sources/SyntaxKit/Expressions/ConditionalOp.swift index d2c55899..c5051f4c 100644 --- a/Sources/SyntaxKit/Expressions/ConditionalOp.swift +++ b/Sources/SyntaxKit/Expressions/ConditionalOp.swift @@ -35,6 +35,7 @@ public struct ConditionalOp: CodeBlock { private let thenExpression: any CodeBlock private let elseExpression: any CodeBlock + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { let conditionExpr = ExprSyntax( fromProtocol: condition.syntax.as(ExprSyntax.self) diff --git a/Sources/SyntaxKit/Expressions/FunctionCallExp.swift b/Sources/SyntaxKit/Expressions/FunctionCallExp.swift index 5f3a8782..4697f80b 100644 --- a/Sources/SyntaxKit/Expressions/FunctionCallExp.swift +++ b/Sources/SyntaxKit/Expressions/FunctionCallExp.swift @@ -102,8 +102,8 @@ internal struct FunctionCallExp: CodeBlock { calledExpression: ExprSyntax( MemberAccessExprSyntax( base: baseExpr, - dot: .periodToken(), - name: .identifier(methodName) + period: .periodToken(), + declName: DeclReferenceExprSyntax(baseName: .identifier(methodName)) ) ), leftParen: .leftParenToken(), diff --git a/Sources/SyntaxKit/Expressions/Infix+Comparison.swift b/Sources/SyntaxKit/Expressions/Infix+Comparison.swift index fa88f6a9..9edaaebc 100644 --- a/Sources/SyntaxKit/Expressions/Infix+Comparison.swift +++ b/Sources/SyntaxKit/Expressions/Infix+Comparison.swift @@ -27,7 +27,7 @@ // OTHER DEALINGS IN THE SOFTWARE. // -public import SwiftSyntax +import SwiftSyntax // MARK: - Comparison Operators diff --git a/Sources/SyntaxKit/Expressions/Infix.swift b/Sources/SyntaxKit/Expressions/Infix.swift index 534c29c2..c1a0cc2c 100644 --- a/Sources/SyntaxKit/Expressions/Infix.swift +++ b/Sources/SyntaxKit/Expressions/Infix.swift @@ -51,9 +51,10 @@ public struct Infix: CodeBlock, ExprCodeBlock { case wrongOperandCount(expected: Int, got: Int) case nonExprCodeBlockOperand + /// A human-readable description of this error. public var description: String { switch self { - case let .wrongOperandCount(expected, got): + case .wrongOperandCount(let expected, let got): return "Infix expects exactly \(expected) operands, got \(got)." case .nonExprCodeBlockOperand: return "Infix operands must conform to ExprCodeBlock protocol" @@ -65,6 +66,7 @@ public struct Infix: CodeBlock, ExprCodeBlock { private let leftOperand: any ExprCodeBlock private let rightOperand: any ExprCodeBlock + /// The SwiftSyntax expression representation of this code block. public var exprSyntax: ExprSyntax { let left = leftOperand.exprSyntax let right = rightOperand.exprSyntax @@ -86,6 +88,7 @@ public struct Infix: CodeBlock, ExprCodeBlock { ) } + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { exprSyntax } @@ -116,6 +119,9 @@ public struct Infix: CodeBlock, ExprCodeBlock { /// - Parameters: /// - operation: The operator symbol as it should appear in source (e.g. "+", "-", "&&"). /// - content: A ``CodeBlockBuilder`` that supplies exactly two operand expressions. + /// - Throws: ``InfixError/wrongOperandCount`` if `content` returns a number of operands + /// other than two, or ``InfixError/nonExprCodeBlockOperand`` if any operand does not + /// conform to ``ExprCodeBlock``. /// /// Exactly two operands must be supplied – a left-hand side and a right-hand side. /// Each operand must conform to ExprCodeBlock. diff --git a/Sources/SyntaxKit/Expressions/Literal+ExprCodeBlock.swift b/Sources/SyntaxKit/Expressions/Literal+ExprCodeBlock.swift index be54e85a..955414f5 100644 --- a/Sources/SyntaxKit/Expressions/Literal+ExprCodeBlock.swift +++ b/Sources/SyntaxKit/Expressions/Literal+ExprCodeBlock.swift @@ -50,7 +50,7 @@ extension Literal: ExprCodeBlock { case .float(let value): return ExprSyntax(FloatLiteralExprSyntax(literal: .floatLiteral(String(value)))) case .integer(let value): - return ExprSyntax(IntegerLiteralExprSyntax(digits: .integerLiteral(String(value)))) + return ExprSyntax(IntegerLiteralExprSyntax(literal: .integerLiteral(String(value)))) case .nil: return ExprSyntax(NilLiteralExprSyntax(nilKeyword: .keyword(.nil))) case .boolean(let value): @@ -62,7 +62,7 @@ extension Literal: ExprCodeBlock { case .ref(let value): return ExprSyntax(DeclReferenceExprSyntax(baseName: .identifier(value))) case .tuple(let elements): - let tupleElements = TupleExprElementListSyntax( + let tupleElements = LabeledExprListSyntax( elements.enumerated().map { index, element in let elementExpr: ExprSyntax if let element = element { @@ -71,7 +71,7 @@ extension Literal: ExprCodeBlock { // Wildcard pattern - use underscore elementExpr = ExprSyntax(DeclReferenceExprSyntax(baseName: .identifier("_"))) } - return TupleExprElementSyntax( + return LabeledExprSyntax( label: nil, colon: nil, expression: elementExpr, @@ -123,9 +123,9 @@ extension Literal: ExprCodeBlock { elements.enumerated().map { index, keyValue in let (key, value) = keyValue return DictionaryElementSyntax( - keyExpression: key.exprSyntax, + key: key.exprSyntax, colon: .colonToken(), - valueExpression: value.exprSyntax, + value: value.exprSyntax, trailingComma: index < elements.count - 1 ? .commaToken(trailingTrivia: .space) : nil diff --git a/Sources/SyntaxKit/Expressions/Literal.swift b/Sources/SyntaxKit/Expressions/Literal.swift index 1b5ddb1d..7d16d19b 100644 --- a/Sources/SyntaxKit/Expressions/Literal.swift +++ b/Sources/SyntaxKit/Expressions/Literal.swift @@ -119,7 +119,7 @@ public enum Literal: CodeBlock, CodeBlockable, Sendable { return FloatLiteralExprSyntax(literal: .floatLiteral(String(value))) case .integer(let value): - return IntegerLiteralExprSyntax(digits: .integerLiteral(String(value))) + return IntegerLiteralExprSyntax(literal: .integerLiteral(String(value))) case .nil: return NilLiteralExprSyntax(nilKeyword: .keyword(.nil)) case .boolean(let value): @@ -127,7 +127,7 @@ public enum Literal: CodeBlock, CodeBlockable, Sendable { case .ref(let value): return DeclReferenceExprSyntax(baseName: .identifier(value)) case .tuple(let elements): - let tupleElements = TupleExprElementListSyntax( + let tupleElements = LabeledExprListSyntax( elements.enumerated().map { index, element in let elementExpr: ExprSyntax if let element = element { @@ -138,7 +138,7 @@ public enum Literal: CodeBlock, CodeBlockable, Sendable { // Wildcard pattern - use underscore elementExpr = ExprSyntax(DeclReferenceExprSyntax(baseName: .identifier("_"))) } - return TupleExprElementSyntax( + return LabeledExprSyntax( label: nil, colon: nil, expression: elementExpr, @@ -175,10 +175,10 @@ public enum Literal: CodeBlock, CodeBlockable, Sendable { elements.enumerated().map { index, keyValue in let (key, value) = keyValue return DictionaryElementSyntax( - keyExpression: key.syntax.as(ExprSyntax.self) + key: key.syntax.as(ExprSyntax.self) ?? ExprSyntax(DeclReferenceExprSyntax(baseName: .identifier(""))), colon: .colonToken(), - valueExpression: value.syntax.as(ExprSyntax.self) + value: value.syntax.as(ExprSyntax.self) ?? ExprSyntax(DeclReferenceExprSyntax(baseName: .identifier(""))), trailingComma: index < elements.count - 1 ? .commaToken(trailingTrivia: .space) : nil ) diff --git a/Sources/SyntaxKit/Expressions/OptionalChainingExp.swift b/Sources/SyntaxKit/Expressions/OptionalChainingExp.swift index c287679b..6208487b 100644 --- a/Sources/SyntaxKit/Expressions/OptionalChainingExp.swift +++ b/Sources/SyntaxKit/Expressions/OptionalChainingExp.swift @@ -39,10 +39,8 @@ internal struct OptionalChainingExp: CodeBlock { if let expr = base.syntax.as(ExprSyntax.self) { baseExpr = expr } else { - // Fallback to a default expression if conversion fails - #warning( - "TODO: Review fallback for failed expression conversion" - ) + // TODO: Review fallback for failed expression conversion. + // Fallback to a default expression if conversion fails. baseExpr = ExprSyntax(DeclReferenceExprSyntax(baseName: .identifier(""))) } return OptionalChainingExprSyntax(expression: baseExpr) diff --git a/Sources/SyntaxKit/Expressions/PropertyAccessExp.swift b/Sources/SyntaxKit/Expressions/PropertyAccessExp.swift index 86dced06..a9d51d09 100644 --- a/Sources/SyntaxKit/Expressions/PropertyAccessExp.swift +++ b/Sources/SyntaxKit/Expressions/PropertyAccessExp.swift @@ -40,12 +40,11 @@ internal struct PropertyAccessExp: CodeBlock, ExprCodeBlock, PropertyAccessible ?? ExprSyntax( DeclReferenceExprSyntax(baseName: .identifier("")) ) - let property = TokenSyntax.identifier(propertyName) return ExprSyntax( MemberAccessExprSyntax( base: baseSyntax, - dot: .periodToken(), - name: property + period: .periodToken(), + declName: DeclReferenceExprSyntax(baseName: .identifier(propertyName)) ) ) } diff --git a/Sources/SyntaxKit/Expressions/Return.swift b/Sources/SyntaxKit/Expressions/Return.swift index 8ccbbf07..ce7786be 100644 --- a/Sources/SyntaxKit/Expressions/Return.swift +++ b/Sources/SyntaxKit/Expressions/Return.swift @@ -33,6 +33,7 @@ public import SwiftSyntax public struct Return: CodeBlock { private let exprs: [any CodeBlock] + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { if let expr = exprs.first { if let varExp = expr as? VariableExp { @@ -49,10 +50,8 @@ public struct Return: CodeBlock { } else if let syntax = expr.syntax.as(ExprSyntax.self) { exprSyntax = syntax } else { + // TODO: Review fallback for no valid expression - consider if this should be an error instead. // fallback: no valid expression - #warning( - "TODO: Review fallback for no valid expression - consider if this should be an error instead" - ) return ReturnStmtSyntax( returnKeyword: .keyword(.return, trailingTrivia: .space) ) diff --git a/Sources/SyntaxKit/Functions/Function+EffectSpecifiers.swift b/Sources/SyntaxKit/Functions/Function+EffectSpecifiers.swift index da188940..8be6c185 100644 --- a/Sources/SyntaxKit/Functions/Function+EffectSpecifiers.swift +++ b/Sources/SyntaxKit/Functions/Function+EffectSpecifiers.swift @@ -35,37 +35,23 @@ extension Function { switch effect { case .none: return nil - case let .throws(isRethrows, errorType): + case .throws(let isRethrows, let errorType): let throwsSpecifier = buildThrowsSpecifier(isRethrows: isRethrows) - if let errorType = errorType { - return FunctionEffectSpecifiersSyntax( - asyncSpecifier: nil, - throwsClause: buildThrowsClause(throwsSpecifier: throwsSpecifier, errorType: errorType) - ) - } else { - return FunctionEffectSpecifiersSyntax( - asyncSpecifier: nil, - throwsSpecifier: throwsSpecifier - ) - } + return FunctionEffectSpecifiersSyntax( + asyncSpecifier: nil, + throwsClause: buildThrowsClause(throwsSpecifier: throwsSpecifier, errorType: errorType) + ) case .async: return FunctionEffectSpecifiersSyntax( asyncSpecifier: .keyword(.async, leadingTrivia: .space, trailingTrivia: .space), - throwsSpecifier: nil + throwsClause: nil ) - case let .asyncThrows(isRethrows, errorType): + case .asyncThrows(let isRethrows, let errorType): let throwsSpecifier = buildThrowsSpecifier(isRethrows: isRethrows) - if let errorType = errorType { - return FunctionEffectSpecifiersSyntax( - asyncSpecifier: .keyword(.async, leadingTrivia: .space, trailingTrivia: .space), - throwsClause: buildThrowsClause(throwsSpecifier: throwsSpecifier, errorType: errorType) - ) - } else { - return FunctionEffectSpecifiersSyntax( - asyncSpecifier: .keyword(.async, leadingTrivia: .space, trailingTrivia: .space), - throwsSpecifier: throwsSpecifier - ) - } + return FunctionEffectSpecifiersSyntax( + asyncSpecifier: .keyword(.async, leadingTrivia: .space, trailingTrivia: .space), + throwsClause: buildThrowsClause(throwsSpecifier: throwsSpecifier, errorType: errorType) + ) } } @@ -74,15 +60,19 @@ extension Function { .keyword(isRethrows ? .rethrows : .throws, leadingTrivia: .space) } - /// Builds the throws clause with error type. - private func buildThrowsClause(throwsSpecifier: TokenSyntax, errorType: String) + /// Builds the throws clause, optionally with a typed error. + private func buildThrowsClause(throwsSpecifier: TokenSyntax, errorType: String?) -> ThrowsClauseSyntax { - ThrowsClauseSyntax( - throwsSpecifier: throwsSpecifier, - leftParen: .leftParenToken(), - type: IdentifierTypeSyntax(name: .identifier(errorType)), - rightParen: .rightParenToken() - ) + if let errorType { + ThrowsClauseSyntax( + throwsSpecifier: throwsSpecifier, + leftParen: .leftParenToken(), + type: IdentifierTypeSyntax(name: .identifier(errorType)), + rightParen: .rightParenToken() + ) + } else { + ThrowsClauseSyntax(throwsSpecifier: throwsSpecifier) + } } } diff --git a/Sources/SyntaxKit/Functions/Function+Effects.swift b/Sources/SyntaxKit/Functions/Function+Effects.swift index 7765f4c6..b0505647 100644 --- a/Sources/SyntaxKit/Functions/Function+Effects.swift +++ b/Sources/SyntaxKit/Functions/Function+Effects.swift @@ -42,6 +42,7 @@ extension Function { /// Marks the function as `throws` or `rethrows`. /// - Parameter isRethrows: Pass `true` to emit `rethrows` instead of `throws`. + /// - Returns: A copy of the function with the throws effect applied. public func `throws`(isRethrows: Bool = false) -> Self { var copy = self switch effect { @@ -55,6 +56,7 @@ extension Function { /// Marks the function as `throws` with a specific error type. /// - Parameter errorType: The error type to specify in the throws clause. + /// - Returns: A copy of the function with the typed throws effect applied. public func `throws`(_ errorType: String) -> Self { var copy = self switch effect { @@ -75,6 +77,7 @@ extension Function { /// Marks the function as `async throws` or `async rethrows`. /// - Parameter isRethrows: Pass `true` to emit `async rethrows`. + /// - Returns: A copy of the function with the async-throws effect applied. public func asyncThrows(isRethrows: Bool = false) -> Self { var copy = self copy.effect = .asyncThrows(isRethrows: isRethrows, errorType: nil) @@ -83,6 +86,7 @@ extension Function { /// Marks the function as `async throws` with a specific error type. /// - Parameter errorType: The error type to specify in the throws clause. + /// - Returns: A copy of the function with the typed async-throws effect applied. public func asyncThrows(_ errorType: String) -> Self { var copy = self copy.effect = .asyncThrows(isRethrows: false, errorType: errorType) diff --git a/Sources/SyntaxKit/Functions/Function+Syntax.swift b/Sources/SyntaxKit/Functions/Function+Syntax.swift index 9a7d652a..e766bea1 100644 --- a/Sources/SyntaxKit/Functions/Function+Syntax.swift +++ b/Sources/SyntaxKit/Functions/Function+Syntax.swift @@ -91,11 +91,9 @@ extension Function { ) } if isMutating { - modifiers = DeclModifierListSyntax( - modifiers + [ - DeclModifierSyntax(name: .keyword(.mutating, trailingTrivia: .space)) - ] - ) + modifiers += [ + DeclModifierSyntax(name: .keyword(.mutating, trailingTrivia: .space)) + ] } return FunctionDeclSyntax( diff --git a/Sources/SyntaxKit/Functions/FunctionRequirement.swift b/Sources/SyntaxKit/Functions/FunctionRequirement.swift index 341dd80c..1f7dd7dd 100644 --- a/Sources/SyntaxKit/Functions/FunctionRequirement.swift +++ b/Sources/SyntaxKit/Functions/FunctionRequirement.swift @@ -37,6 +37,7 @@ public struct FunctionRequirement: CodeBlock { private var isStatic: Bool = false private var isMutating: Bool = false + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { let funcKeyword = TokenSyntax.keyword(.func, trailingTrivia: .space) let identifier = TokenSyntax.identifier(name) @@ -89,9 +90,9 @@ public struct FunctionRequirement: CodeBlock { ]) } if isMutating { - modifiers = DeclModifierListSyntax( - modifiers + [DeclModifierSyntax(name: .keyword(.mutating, trailingTrivia: .space))] - ) + modifiers += [ + DeclModifierSyntax(name: .keyword(.mutating, trailingTrivia: .space)) + ] } return FunctionDeclSyntax( diff --git a/Sources/SyntaxKit/Parameters/Parameter.swift b/Sources/SyntaxKit/Parameters/Parameter.swift index 1b154751..3a5f81a7 100644 --- a/Sources/SyntaxKit/Parameters/Parameter.swift +++ b/Sources/SyntaxKit/Parameters/Parameter.swift @@ -49,6 +49,7 @@ public struct Parameter: CodeBlock { /// Convenience flag – true when the parameter uses the underscore label. internal var isUnnamed: Bool { label == "_" } + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { let callLabel = label ?? name diff --git a/Sources/SyntaxKit/Parameters/ParameterExp.swift b/Sources/SyntaxKit/Parameters/ParameterExp.swift index 8cdf23c8..8903bf18 100644 --- a/Sources/SyntaxKit/Parameters/ParameterExp.swift +++ b/Sources/SyntaxKit/Parameters/ParameterExp.swift @@ -34,6 +34,7 @@ public struct ParameterExp: CodeBlock { internal let name: String internal let value: any CodeBlock + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { if name.isEmpty { if let exprBlock = value as? any ExprCodeBlock { diff --git a/Sources/SyntaxKit/Patterns/LetBindingPattern.swift b/Sources/SyntaxKit/Patterns/LetBindingPattern.swift index f7da63c5..fcad1d6c 100644 --- a/Sources/SyntaxKit/Patterns/LetBindingPattern.swift +++ b/Sources/SyntaxKit/Patterns/LetBindingPattern.swift @@ -29,18 +29,6 @@ import SwiftSyntax -// MARK: - Let binding pattern - -/// Namespace for pattern creation utilities. -public enum Pattern { - /// Creates a `let` binding pattern for switch cases. - /// - Parameter identifier: The name of the variable to bind. - /// - Returns: A pattern that binds the value to the given identifier. - public static func `let`(_ identifier: String) -> any PatternConvertible { - LetBindingPattern(identifier: identifier) - } -} - /// A `let` binding pattern for switch cases. internal struct LetBindingPattern: PatternConvertible { private let identifier: String diff --git a/Sources/SyntaxKit/Patterns/Pattern.swift b/Sources/SyntaxKit/Patterns/Pattern.swift new file mode 100644 index 00000000..d6392b95 --- /dev/null +++ b/Sources/SyntaxKit/Patterns/Pattern.swift @@ -0,0 +1,38 @@ +// +// Pattern.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +/// Namespace for pattern creation utilities. +public enum Pattern { + /// Creates a `let` binding pattern for switch cases. + /// - Parameter identifier: The name of the variable to bind. + /// - Returns: A pattern that binds the value to the given identifier. + public static func `let`(_ identifier: String) -> any PatternConvertible { + LetBindingPattern(identifier: identifier) + } +} diff --git a/Sources/SyntaxKit/Utilities/Break.swift b/Sources/SyntaxKit/Utilities/Break.swift index cf1e33ed..3420b70e 100644 --- a/Sources/SyntaxKit/Utilities/Break.swift +++ b/Sources/SyntaxKit/Utilities/Break.swift @@ -33,6 +33,7 @@ public import SwiftSyntax public struct Break: CodeBlock { private let label: String? + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { let breakStmt = BreakStmtSyntax( breakKeyword: .keyword(.break, trailingTrivia: .newline) diff --git a/Sources/SyntaxKit/Utilities/Case.swift b/Sources/SyntaxKit/Utilities/Case.swift index b403ded9..283ca989 100644 --- a/Sources/SyntaxKit/Utilities/Case.swift +++ b/Sources/SyntaxKit/Utilities/Case.swift @@ -37,6 +37,7 @@ public struct Case: CodeBlock { private let enumCaseName: String? private var associatedValue: (name: String, type: String)? + /// The SwiftSyntax representation of this switch case. public var switchCaseSyntax: SwitchCaseSyntax { let caseItems = SwitchCaseItemListSyntax( patterns.enumerated().map { index, pat in @@ -72,6 +73,7 @@ public struct Case: CodeBlock { ) } + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { if isEnumCase { // Handle enum case declaration diff --git a/Sources/SyntaxKit/Utilities/Continue.swift b/Sources/SyntaxKit/Utilities/Continue.swift index 4f1fe599..fcb520ab 100644 --- a/Sources/SyntaxKit/Utilities/Continue.swift +++ b/Sources/SyntaxKit/Utilities/Continue.swift @@ -33,6 +33,7 @@ public import SwiftSyntax public struct Continue: CodeBlock { private let label: String? + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { let continueStmt = ContinueStmtSyntax( continueKeyword: .keyword(.continue, trailingTrivia: .newline) diff --git a/Sources/SyntaxKit/Utilities/Default.swift b/Sources/SyntaxKit/Utilities/Default.swift index fc7b04cb..b49a1c10 100644 --- a/Sources/SyntaxKit/Utilities/Default.swift +++ b/Sources/SyntaxKit/Utilities/Default.swift @@ -33,6 +33,7 @@ public import SwiftSyntax public struct Default: CodeBlock { private let body: [any CodeBlock] + /// The SwiftSyntax representation of this switch case. public var switchCaseSyntax: SwitchCaseSyntax { let statements = CodeBlockItemListSyntax( body.compactMap { @@ -56,6 +57,7 @@ public struct Default: CodeBlock { statements: statements ) } + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { switchCaseSyntax } /// Creates a default case declaration. diff --git a/Sources/SyntaxKit/Utilities/Fallthrough.swift b/Sources/SyntaxKit/Utilities/Fallthrough.swift index ce2d891c..85de9132 100644 --- a/Sources/SyntaxKit/Utilities/Fallthrough.swift +++ b/Sources/SyntaxKit/Utilities/Fallthrough.swift @@ -31,6 +31,7 @@ public import SwiftSyntax /// A `fallthrough` statement. public struct Fallthrough: CodeBlock { + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { StmtSyntax( FallThroughStmtSyntax( diff --git a/Sources/SyntaxKit/Utilities/Group.swift b/Sources/SyntaxKit/Utilities/Group.swift index 58a7187f..5623917d 100644 --- a/Sources/SyntaxKit/Utilities/Group.swift +++ b/Sources/SyntaxKit/Utilities/Group.swift @@ -33,6 +33,7 @@ public import SwiftSyntax public struct Group: CodeBlock { internal let members: [any CodeBlock] + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { let statements = members.flatMap { block -> [CodeBlockItemSyntax] in if let list = block.syntax.as(CodeBlockItemListSyntax.self) { @@ -47,11 +48,9 @@ public struct Group: CodeBlock { } else if let expr = block.syntax.as(ExprSyntax.self) { item = .expr(expr) } else { - // Skip unsupported syntax types instead of crashing - // This allows the group to continue processing other valid blocks - #warning( - "TODO: Review fallback for unsupported syntax types - consider if this should be an error instead" - ) + // TODO: Review fallback for unsupported syntax types - consider if this should be an error instead. + // Skip unsupported syntax types instead of crashing so the group can continue + // processing other valid blocks. return [] } return [CodeBlockItemSyntax(item: item, trailingTrivia: .newline)] diff --git a/Sources/SyntaxKit/Utilities/Let.swift b/Sources/SyntaxKit/Utilities/Let.swift index 76000263..5bf653b7 100644 --- a/Sources/SyntaxKit/Utilities/Let.swift +++ b/Sources/SyntaxKit/Utilities/Let.swift @@ -34,6 +34,7 @@ public struct Let: CodeBlock { internal let name: String internal let value: any CodeBlock + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { CodeBlockItemSyntax( item: .decl( diff --git a/Sources/SyntaxKit/Utilities/Parenthesized.swift b/Sources/SyntaxKit/Utilities/Parenthesized.swift index 068c9d32..a65882b1 100644 --- a/Sources/SyntaxKit/Utilities/Parenthesized.swift +++ b/Sources/SyntaxKit/Utilities/Parenthesized.swift @@ -33,6 +33,7 @@ public import SwiftSyntax public struct Parenthesized: CodeBlock, ExprCodeBlock { private let content: any CodeBlock + /// The SwiftSyntax expression representation of this code block. public var exprSyntax: ExprSyntax { ExprSyntax( TupleExprSyntax( @@ -45,6 +46,7 @@ public struct Parenthesized: CodeBlock, ExprCodeBlock { ) } + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { exprSyntax } diff --git a/Sources/SyntaxKit/Utilities/PropertyRequirement.swift b/Sources/SyntaxKit/Utilities/PropertyRequirement.swift index 5620b9eb..3fd9a6ad 100644 --- a/Sources/SyntaxKit/Utilities/PropertyRequirement.swift +++ b/Sources/SyntaxKit/Utilities/PropertyRequirement.swift @@ -41,6 +41,7 @@ public struct PropertyRequirement: CodeBlock { private let type: String private let access: Access + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { let varKeyword = TokenSyntax.keyword(.var, trailingTrivia: .space) let identifier = TokenSyntax.identifier(name, trailingTrivia: .space) diff --git a/Sources/SyntaxKit/Utilities/Then.swift b/Sources/SyntaxKit/Utilities/Then.swift index ea85cee7..5909f399 100644 --- a/Sources/SyntaxKit/Utilities/Then.swift +++ b/Sources/SyntaxKit/Utilities/Then.swift @@ -46,6 +46,7 @@ public struct Then: CodeBlock { /// The statements that make up the `else` body. public let body: [any CodeBlock] + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { let statements = CodeBlockItemListSyntax( body.compactMap { element in diff --git a/Sources/SyntaxKit/Variables/ComputedProperty.swift b/Sources/SyntaxKit/Variables/ComputedProperty.swift index a9de0069..7795f12f 100644 --- a/Sources/SyntaxKit/Variables/ComputedProperty.swift +++ b/Sources/SyntaxKit/Variables/ComputedProperty.swift @@ -37,6 +37,7 @@ public struct ComputedProperty: CodeBlock { private var accessModifier: AccessModifier? private let explicitType: Bool + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { let accessor = AccessorBlockSyntax( leftBrace: TokenSyntax.leftBraceToken(leadingTrivia: .space, trailingTrivia: .newline), diff --git a/Sources/SyntaxKit/Variables/Variable+LiteralInitializers.swift b/Sources/SyntaxKit/Variables/Variable+LiteralInitializers.swift index 5769bacf..1325ea28 100644 --- a/Sources/SyntaxKit/Variables/Variable+LiteralInitializers.swift +++ b/Sources/SyntaxKit/Variables/Variable+LiteralInitializers.swift @@ -144,6 +144,7 @@ extension Variable { _ kind: VariableKind, name: String, @CodeBlockBuilderResult value: () throws -> [any CodeBlock], + // swiftlint:disable:next discouraged_optional_boolean explicitType: Bool? = nil ) rethrows { self.init( diff --git a/Sources/SyntaxKit/Variables/VariableExp.swift b/Sources/SyntaxKit/Variables/VariableExp.swift index 70e55e9e..f4b61e61 100644 --- a/Sources/SyntaxKit/Variables/VariableExp.swift +++ b/Sources/SyntaxKit/Variables/VariableExp.swift @@ -33,14 +33,17 @@ public import SwiftSyntax public struct VariableExp: CodeBlock, PatternConvertible, ExprCodeBlock { internal let name: String + /// The SwiftSyntax representation of this code block. public var syntax: any SyntaxProtocol { ExprSyntax(DeclReferenceExprSyntax(baseName: .identifier(name))) } + /// The SwiftSyntax expression representation of this code block. public var exprSyntax: ExprSyntax { ExprSyntax(DeclReferenceExprSyntax(baseName: .identifier(name))) } + /// The SwiftSyntax pattern representation of this code block. public var patternSyntax: PatternSyntax { PatternSyntax(IdentifierPatternSyntax(identifier: .identifier(name))) } diff --git a/Sources/SyntaxParser/SyntaxParser.swift b/Sources/SyntaxParser/SyntaxParser.swift index be15e1e6..67417f15 100644 --- a/Sources/SyntaxParser/SyntaxParser.swift +++ b/Sources/SyntaxParser/SyntaxParser.swift @@ -49,6 +49,7 @@ import TokenVisitor package enum SyntaxParser { // MARK: - Configuration Constants + // periphery:ignore - retained until deprecated parse(code:options:) is removed (see #149) /// Option key to enable operator precedence folding during parsing. /// When enabled, expressions are reorganized according to Swift's operator precedence rules. @available( @@ -57,6 +58,7 @@ package enum SyntaxParser { ) private static let fold = "fold" + // periphery:ignore - retained until deprecated parse(code:options:) is removed (see #149) /// Option key to include missing/implicit tokens in the output. /// Useful for debugging or when you need to see all syntax elements including placeholders. @available( @@ -82,6 +84,7 @@ package enum SyntaxParser { return TreeNode.parseTree(from: sourceFile) } + // periphery:ignore - scheduled for removal (see #149); kept for source compatibility /// Parses Swift source code and returns a JSON representation of its syntax tree. /// /// This method performs the complete parsing pipeline: diff --git a/Sources/SyntaxParser/SyntaxResponse.swift b/Sources/SyntaxParser/SyntaxResponse.swift index 03bd0c35..0c63b831 100644 --- a/Sources/SyntaxParser/SyntaxResponse.swift +++ b/Sources/SyntaxParser/SyntaxResponse.swift @@ -29,6 +29,7 @@ import Foundation +// periphery:ignore - scheduled for removal (see #149); preserved for source compatibility /// Container for the final JSON representation of parsed Swift syntax. /// /// SyntaxResponse is the top-level result type returned by the SyntaxParser. diff --git a/Sources/TokenVisitor/String.swift b/Sources/TokenVisitor/String.swift index 0596f1d1..fd125313 100644 --- a/Sources/TokenVisitor/String.swift +++ b/Sources/TokenVisitor/String.swift @@ -28,5 +28,6 @@ // extension String { + // periphery:ignore - utility constant for downstream consumers internal static let empty = "" } diff --git a/Sources/TokenVisitor/StructureProperty.swift b/Sources/TokenVisitor/StructureProperty.swift index 9c0e7223..cf5246e0 100644 --- a/Sources/TokenVisitor/StructureProperty.swift +++ b/Sources/TokenVisitor/StructureProperty.swift @@ -83,9 +83,7 @@ package struct StructureProperty: Codable, Equatable, Sendable { /// Creates a StructureProperty for a missing property with a nil value indicator. /// - /// - Parameters: - /// - name: The property name - /// - nilValue: The value to display for the nil value (will be converted to string) + /// - Parameter name: The property name. The value will be displayed as the nil-value placeholder. internal init(nilValueWithName name: String) { self.init(name: name, value: StructureValue(text: Self.nilValue), ref: nil) } diff --git a/Sources/TokenVisitor/TreeNodeProtocol+Extensions.swift b/Sources/TokenVisitor/TreeNodeProtocol+Extensions.swift index 1a4c9262..a8e15ba0 100644 --- a/Sources/TokenVisitor/TreeNodeProtocol+Extensions.swift +++ b/Sources/TokenVisitor/TreeNodeProtocol+Extensions.swift @@ -30,6 +30,7 @@ package import SwiftSyntax extension TreeNodeProtocol { + // periphery:ignore:parameters showingMissingTokens - parameter currently ignored (see #152) package static func parseTree( from sourceFile: SourceFileSyntax, withFileName fileName: String = .defaultFileName, diff --git a/Tests/SyntaxDocTests/DocumentationExampleTests.swift b/Tests/SyntaxDocTests/DocumentationExampleTests.swift index d2222f75..c9c4f709 100644 --- a/Tests/SyntaxDocTests/DocumentationExampleTests.swift +++ b/Tests/SyntaxDocTests/DocumentationExampleTests.swift @@ -1,3 +1,32 @@ +// +// DocumentationExampleTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import DocumentationHarness import Foundation import Testing diff --git a/Tests/SyntaxDocTests/DocumentationTestError.swift b/Tests/SyntaxDocTests/DocumentationTestError.swift index 56dda8f0..59aecda6 100644 --- a/Tests/SyntaxDocTests/DocumentationTestError.swift +++ b/Tests/SyntaxDocTests/DocumentationTestError.swift @@ -1,3 +1,32 @@ +// +// DocumentationTestError.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation internal enum DocumentationTestError: Error, CustomStringConvertible { diff --git a/Tests/SyntaxDocTests/Settings.swift b/Tests/SyntaxDocTests/Settings.swift index 92161966..1dba7b28 100644 --- a/Tests/SyntaxDocTests/Settings.swift +++ b/Tests/SyntaxDocTests/Settings.swift @@ -2,7 +2,29 @@ // Settings.swift // SyntaxKit // -// Created by Leo Dion on 9/5/25. +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. // import Foundation diff --git a/Tests/SyntaxKitTests/Integration/BlackjackCardTests.swift b/Tests/SyntaxKitTests/Integration/BlackjackCardTests.swift index 7cf55ec5..08dcae06 100644 --- a/Tests/SyntaxKitTests/Integration/BlackjackCardTests.swift +++ b/Tests/SyntaxKitTests/Integration/BlackjackCardTests.swift @@ -1,3 +1,32 @@ +// +// BlackjackCardTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import SyntaxKit import Testing diff --git a/Tests/SyntaxKitTests/Integration/BlackjackTests.swift b/Tests/SyntaxKitTests/Integration/BlackjackTests.swift index 46ca6f73..8b4be73a 100644 --- a/Tests/SyntaxKitTests/Integration/BlackjackTests.swift +++ b/Tests/SyntaxKitTests/Integration/BlackjackTests.swift @@ -1,3 +1,32 @@ +// +// BlackjackTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import SyntaxKit import Testing @@ -131,11 +160,15 @@ internal struct BlackjackTests { Variable(.let, name: "suit", type: "Suit") ComputedProperty("description", type: "String") { Variable(.var, name: "output", equals: Literal.string("suit is \\(suit.rawValue),")) - PlusAssign("output", " value is \\(rank.values.first)") + Infix( + "+=", + lhs: VariableExp("output"), + rhs: Literal.string(" value is \\(rank.values.first)") + ) If( Let("second", "rank.values.second"), then: { - PlusAssign("output", " or \\(second)") + Infix("+=", lhs: VariableExp("output"), rhs: Literal.string(" or \\(second)")) } ) Return { diff --git a/Tests/SyntaxKitTests/Integration/CommentTests.swift b/Tests/SyntaxKitTests/Integration/CommentTests.swift index 92a270de..bd90a473 100644 --- a/Tests/SyntaxKitTests/Integration/CommentTests.swift +++ b/Tests/SyntaxKitTests/Integration/CommentTests.swift @@ -1,3 +1,32 @@ +// +// CommentTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import SyntaxKit import Testing diff --git a/Tests/SyntaxKitTests/Integration/CompleteProtocolsExampleTests.swift b/Tests/SyntaxKitTests/Integration/CompleteProtocolsExampleTests.swift index 986e834b..4884d274 100644 --- a/Tests/SyntaxKitTests/Integration/CompleteProtocolsExampleTests.swift +++ b/Tests/SyntaxKitTests/Integration/CompleteProtocolsExampleTests.swift @@ -1,13 +1,13 @@ // // CompleteProtocolsExampleTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT @@ -51,13 +51,13 @@ import Testing Extension("Vehicle") { Function("start") { Call("print") { - ParameterExp(name: "", value: "\"Starting \\(brand) vehicle...\"") + ParameterExp(name: "", value: VariableExp("\"Starting \\(brand) vehicle...\"")) } } Function("stop") { Call("print") { - ParameterExp(name: "", value: "\"Stopping \\(brand) vehicle...\"") + ParameterExp(name: "", value: VariableExp("\"Stopping \\(brand) vehicle...\"")) } } } @@ -81,7 +81,7 @@ import Testing Function("start") { Call("print") { - ParameterExp(name: "", value: "\"Starting \\(brand) car engine...\"") + ParameterExp(name: "", value: VariableExp("\"Starting \\(brand) car engine...\"")) } } } @@ -97,7 +97,7 @@ import Testing Function("charge") { Call("print") { - ParameterExp(name: "", value: "\"Charging \\(brand) electric car...\"") + ParameterExp(name: "", value: VariableExp("\"Charging \\(brand) electric car...\"")) } Assignment("batteryLevel", Literal.float(100.0)) } @@ -126,13 +126,16 @@ import Testing // Demonstrate protocol usage Function("demonstrateVehicle") { - Parameter(name: "vehicle", type: "Vehicle", isUnnamed: true) + Parameter(unlabeled: "vehicle", type: "Vehicle") } _: { Call("print") { - ParameterExp(name: "", value: "\"Vehicle brand: \\(vehicle.brand)\"") + ParameterExp(name: "", value: VariableExp("\"Vehicle brand: \\(vehicle.brand)\"")) } Call("print") { - ParameterExp(name: "", value: "\"Number of wheels: \\(vehicle.numberOfWheels)\"") + ParameterExp( + name: "", + value: VariableExp("\"Number of wheels: \\(vehicle.numberOfWheels)\"") + ) } VariableExp("vehicle").call("start") VariableExp("vehicle").call("stop") @@ -143,13 +146,13 @@ import Testing // Demonstrate protocol composition Function("demonstrateElectricVehicle") { - Parameter(name: "vehicle", type: "Vehicle & Electric", isUnnamed: true) + Parameter(unlabeled: "vehicle", type: "Vehicle & Electric") } _: { Call("demonstrateVehicle") { - ParameterExp(name: "", value: "vehicle") + ParameterExp(name: "", value: VariableExp("vehicle")) } Call("print") { - ParameterExp(name: "", value: "\"Battery level: \\(vehicle.batteryLevel)%\"") + ParameterExp(name: "", value: VariableExp("\"Battery level: \\(vehicle.batteryLevel)%\"")) } VariableExp("vehicle").call("charge") } @@ -159,20 +162,20 @@ import Testing // Test the implementations Call("print") { - ParameterExp(name: "", value: "\"Testing regular car:\"") + ParameterExp(name: "", value: VariableExp("\"Testing regular car:\"")) } .comment { Line("Test the implementations") } Call("demonstrateVehicle") { - ParameterExp(name: "", value: "toyota") + ParameterExp(name: "", value: VariableExp("toyota")) } Call("print") { - ParameterExp(name: "", value: "\"Testing electric car:\"") + ParameterExp(name: "", value: VariableExp("\"Testing electric car:\"")) } Call("demonstrateElectricVehicle") { - ParameterExp(name: "", value: "tesla") + ParameterExp(name: "", value: VariableExp("tesla")) } } } diff --git a/Tests/SyntaxKitTests/Integration/ConcurrencyExampleTests.swift b/Tests/SyntaxKitTests/Integration/ConcurrencyExampleTests.swift index b9c83e86..c815dc2c 100644 --- a/Tests/SyntaxKitTests/Integration/ConcurrencyExampleTests.swift +++ b/Tests/SyntaxKitTests/Integration/ConcurrencyExampleTests.swift @@ -1,9 +1,39 @@ +// +// ConcurrencyExampleTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import SyntaxKit import Testing @Suite internal struct ConcurrencyExampleTests { @Test("Concurrency vending machine DSL generates expected Swift code") + @available(*, deprecated, message: "Exercises deprecated Infix builder closure init") internal func testConcurrencyVendingMachineExample() throws { // Build DSL equivalent of Examples/Remaining/concurrency/dsl.swift // Note: This test includes the Item struct that's referenced but not defined in the original DSL diff --git a/Tests/SyntaxKitTests/Integration/ConditionalsExampleTests.swift b/Tests/SyntaxKitTests/Integration/ConditionalsExampleTests.swift index c418e699..290f4c00 100644 --- a/Tests/SyntaxKitTests/Integration/ConditionalsExampleTests.swift +++ b/Tests/SyntaxKitTests/Integration/ConditionalsExampleTests.swift @@ -1,3 +1,32 @@ +// +// ConditionalsExampleTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import SyntaxKit import Testing @@ -7,21 +36,18 @@ import Testing internal func testCompletedConditionalsExample() throws { // Build DSL equivalent of Examples/Completed/conditionals/dsl.swift - let program = try Group { + let program = Group { // MARK: Basic If Statements Variable(.let, name: "temperature", equals: 25) .comment { Line("Simple if statement") } - try If { - try Infix(">") { - VariableExp("temperature") - Literal.integer(30) - } + If { + Infix(">", lhs: VariableExp("temperature"), rhs: Literal.integer(30)) } then: { Call("print") { - ParameterExp(unlabeled: "\"It's hot outside!\"") + ParameterExp(unlabeled: VariableExp("\"It's hot outside!\"")) } } @@ -31,38 +57,29 @@ import Testing Line("If-else statement") } - try If { - try Infix(">=") { - VariableExp("score") - Literal.integer(90) - } + If { + Infix(">=", lhs: VariableExp("score"), rhs: Literal.integer(90)) } then: { Call("print") { - ParameterExp(unlabeled: "\"Excellent!\"") + ParameterExp(unlabeled: VariableExp("\"Excellent!\"")) } } else: { - try If { - try Infix(">=") { - VariableExp("score") - Literal.integer(80) - } + If { + Infix(">=", lhs: VariableExp("score"), rhs: Literal.integer(80)) } then: { Call("print") { - ParameterExp(unlabeled: "\"Good job!\"") + ParameterExp(unlabeled: VariableExp("\"Good job!\"")) } } else: { - try If { - try Infix(">=") { - VariableExp("score") - Literal.integer(70) - } + If { + Infix(">=", lhs: VariableExp("score"), rhs: Literal.integer(70)) } then: { Call("print") { - ParameterExp(unlabeled: "\"Passing\"") + ParameterExp(unlabeled: VariableExp("\"Passing\"")) } } else: { Call("print") { - ParameterExp(unlabeled: "\"Needs improvement\"") + ParameterExp(unlabeled: VariableExp("\"Needs improvement\"")) } } } @@ -81,8 +98,9 @@ import Testing Call("print") { ParameterExp( name: "", - value: + value: VariableExp( "\"The string \"\\(possibleNumber)\" has an integer value of \\(actualNumber)\"" + ) ) } }, @@ -90,7 +108,9 @@ import Testing Call("print") { ParameterExp( name: "", - value: "\"The string \"\\(possibleNumber)\" could not be converted to an integer\"" + value: VariableExp( + "\"The string \"\\(possibleNumber)\" could not be converted to an integer\"" + ) ) } } @@ -110,12 +130,12 @@ import Testing Let("age", "possibleAge") } then: { Call("print") { - ParameterExp(name: "", value: "\"\\(name) is \\(age) years old\"") + ParameterExp(name: "", value: VariableExp("\"\\(name) is \\(age) years old\"")) } } // MARK: - Guard Statements - try Function( + Function( "greet", { Parameter(name: "person", type: "[String: String]") @@ -125,7 +145,7 @@ import Testing Let("name", "person[\"name\"]") } else: { Call("print") { - ParameterExp(name: "", value: "\"No name provided\"") + ParameterExp(name: "", value: VariableExp("\"No name provided\"")) } } @@ -134,12 +154,15 @@ import Testing Let("ageInt", "Int(age)") } else: { Call("print") { - ParameterExp(name: "", value: "\"Invalid age provided\"") + ParameterExp(name: "", value: VariableExp("\"Invalid age provided\"")) } } Call("print") { - ParameterExp(name: "", value: "\"Hello \\(name), you are \\(ageInt) years old\"") + ParameterExp( + name: "", + value: VariableExp("\"Hello \\(name), you are \\(ageInt) years old\"") + ) } } ) @@ -176,7 +199,10 @@ import Testing } } Call("print") { - ParameterExp(name: "", value: "\"There are \\(naturalCount) \\(countedThings).\"") + ParameterExp( + name: "", + value: VariableExp("\"There are \\(naturalCount) \\(countedThings).\"") + ) } // MARK: - Tuple literal and tuple pattern switch @@ -187,30 +213,32 @@ import Testing Switch("somePoint") { SwitchCase(Tuple.pattern([0, 0])) { Call("print") { - ParameterExp(name: "", value: "\"(0, 0) is at the origin\"") + ParameterExp(name: "", value: VariableExp("\"(0, 0) is at the origin\"")) } } SwitchCase(Tuple.pattern([nil, 0])) { Call("print") { - ParameterExp(name: "", value: "\"(\\(somePoint.0), 0) is on the x-axis\"") + ParameterExp(name: "", value: VariableExp("\"(\\(somePoint.0), 0) is on the x-axis\"")) } } SwitchCase(Tuple.pattern([0, nil])) { Call("print") { - ParameterExp(name: "", value: "\"(0, \\(somePoint.1)) is on the y-axis\"") + ParameterExp(name: "", value: VariableExp("\"(0, \\(somePoint.1)) is on the y-axis\"")) } } SwitchCase(Tuple.pattern([(-2...2), (-2...2)])) { Call("print") { ParameterExp( - name: "", value: "\"(\\(somePoint.0), \\(somePoint.1)) is inside the box\"" + name: "", + value: VariableExp("\"(\\(somePoint.0), \\(somePoint.1)) is inside the box\"") ) } } Default { Call("print") { ParameterExp( - name: "", value: "\"(\\(somePoint.0), \\(somePoint.1)) is outside of the box\"" + name: "", + value: VariableExp("\"(\\(somePoint.0), \\(somePoint.1)) is outside of the box\"") ) } } @@ -225,23 +253,17 @@ import Testing Switch("anotherPoint") { SwitchCase(Tuple.pattern([Pattern.let("x"), 0])) { Call("print") { - ParameterExp( - name: "", value: "\"on the x-axis with an x value of \\(x)\"" - ) + ParameterExp(name: "", value: VariableExp("\"on the x-axis with an x value of \\(x)\"")) } } SwitchCase(Tuple.pattern([0, Pattern.let("y")])) { Call("print") { - ParameterExp( - name: "", value: "\"on the y-axis with a y value of \\(y)\"" - ) + ParameterExp(name: "", value: VariableExp("\"on the y-axis with a y value of \\(y)\"")) } } SwitchCase(Tuple.pattern([Pattern.let("x"), Pattern.let("y")])) { Call("print") { - ParameterExp( - name: "", value: "\"somewhere else at (\\(x), \\(y))\"" - ) + ParameterExp(name: "", value: VariableExp("\"somewhere else at (\\(x), \\(y))\"")) } } } @@ -255,15 +277,19 @@ import Testing Variable(.var, name: "description", equals: "The number \\(integerToDescribe) is") Switch("integerToDescribe") { SwitchCase(2, 3, 5, 7, 11, 13, 17, 19) { - PlusAssign("description", " a prime number, and also") + Infix( + "+=", + lhs: VariableExp("description"), + rhs: Literal.string(" a prime number, and also") + ) Fallthrough() } Default { - PlusAssign("description", " an integer.") + Infix("+=", lhs: VariableExp("description"), rhs: Literal.string(" an integer.")) } } Call("print") { - ParameterExp(name: "", value: "description") + ParameterExp(name: "", value: VariableExp("description")) } // MARK: - Labeled Statements @@ -272,15 +298,12 @@ import Testing Line("MARK: - Labeled Statements") Line("Using labeled statements with break") } - try Variable(.var, name: "board") { - try Init("[Int]") { + Variable(.var, name: "board") { + Init("[Int]") { ParameterExp(name: "repeating", value: Literal.integer(0)) ParameterExp( name: "count", - value: try Infix("+") { - VariableExp("finalSquare") - Literal.integer(1) - } + value: Infix("+", lhs: VariableExp("finalSquare"), rhs: Literal.integer(1)) ) } } @@ -297,48 +320,30 @@ import Testing Variable(.var, name: "square", equals: Literal.integer(0)) Variable(.var, name: "diceRoll", equals: Literal.integer(0)) - try While( - try Infix("!=") { - VariableExp("square") - VariableExp("finalSquare") - } + While( + Infix("!=", lhs: VariableExp("square"), rhs: VariableExp("finalSquare")) ) { - PlusAssign("diceRoll", 1) - try If { - try Infix("==") { - VariableExp("diceRoll") - Literal.integer(7) - } + Infix("+=", lhs: VariableExp("diceRoll"), rhs: Literal.integer(1)) + If { + Infix("==", lhs: VariableExp("diceRoll"), rhs: Literal.integer(7)) } then: { Assignment("diceRoll", 1) } - try Switch( - try Infix("+") { - VariableExp("square") - VariableExp("diceRoll") - } + Switch( + Infix("+", lhs: VariableExp("square"), rhs: VariableExp("diceRoll")) ) { SwitchCase("finalSquare") { Break() } - try SwitchCase { + SwitchCase { SwitchLet("newSquare") - try Infix(">") { - VariableExp("newSquare") - VariableExp("finalSquare") - } + Infix(">", lhs: VariableExp("newSquare"), rhs: VariableExp("finalSquare")) } content: { Continue() } - try Default { - try Infix("+=") { - VariableExp("square") - VariableExp("diceRoll") - } - try Infix("+=") { - VariableExp("square") - VariableExp("board[square]") - } + Default { + Infix("+=", lhs: VariableExp("square"), rhs: VariableExp("diceRoll")) + Infix("+=", lhs: VariableExp("square"), rhs: VariableExp("board[square]")) } } } @@ -498,48 +503,36 @@ import Testing @Test("Conditionals example generates correct syntax") internal func testConditionalsExample() throws { - _ = try If { - try Infix(">") { - VariableExp("temperature") - Literal.integer(30) - } + _ = If { + Infix(">", lhs: VariableExp("temperature"), rhs: Literal.integer(30)) } then: { Call("print") { - ParameterExp(unlabeled: "It's hot!") + ParameterExp(unlabeled: VariableExp("It's hot!")) } } else: { - try If { - try Infix(">=") { - VariableExp("score") - Literal.integer(90) - } + If { + Infix(">=", lhs: VariableExp("score"), rhs: Literal.integer(90)) } then: { Call("print") { - ParameterExp(unlabeled: "Excellent!") + ParameterExp(unlabeled: VariableExp("Excellent!")) } } else: { - try If { - try Infix(">=") { - VariableExp("score") - Literal.integer(80) - } + If { + Infix(">=", lhs: VariableExp("score"), rhs: Literal.integer(80)) } then: { Call("print") { - ParameterExp(unlabeled: "Good!") + ParameterExp(unlabeled: VariableExp("Good!")) } } else: { - try If { - try Infix(">=") { - VariableExp("score") - Literal.integer(70) - } + If { + Infix(">=", lhs: VariableExp("score"), rhs: Literal.integer(70)) } then: { Call("print") { - ParameterExp(unlabeled: "Pass") + ParameterExp(unlabeled: VariableExp("Pass")) } } else: { Call("print") { - ParameterExp(unlabeled: "Fail") + ParameterExp(unlabeled: VariableExp("Fail")) } } } diff --git a/Tests/SyntaxKitTests/Integration/ForLoopsExampleTests.swift b/Tests/SyntaxKitTests/Integration/ForLoopsExampleTests.swift index 740f0134..10aa0dd0 100644 --- a/Tests/SyntaxKitTests/Integration/ForLoopsExampleTests.swift +++ b/Tests/SyntaxKitTests/Integration/ForLoopsExampleTests.swift @@ -1,3 +1,32 @@ +// +// ForLoopsExampleTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import SyntaxKit import Testing @@ -7,7 +36,7 @@ import Testing internal func testCompletedForLoopsExample() throws { // Build DSL equivalent of Examples/Completed/for_loops/dsl.swift - let program = try Group { + let program = Group { // MARK: - Basic For-in Loop Variable( .let, @@ -28,14 +57,14 @@ import Testing in: VariableExp("names"), then: { Call("print") { - ParameterExp(unlabeled: "\"Hello, \\(name)!\"") + ParameterExp(unlabeled: VariableExp("\"Hello, \\(name)!\"")) } } ) // MARK: - For-in with Enumerated Call("print") { - ParameterExp(unlabeled: "\"\\n=== For-in with Enumerated ===\"") + ParameterExp(unlabeled: VariableExp("\"\\n=== For-in with Enumerated ===\"")) } .comment { Line("MARK: - For-in with Enumerated") @@ -49,14 +78,14 @@ import Testing in: VariableExp("names").call("enumerated"), then: { Call("print") { - ParameterExp(unlabeled: "\"Index: \\(index), Name: \\(name)\"") + ParameterExp(unlabeled: VariableExp("\"Index: \\(index), Name: \\(name)\"")) } } ) // MARK: - For-in with Where Clause Call("print") { - ParameterExp(unlabeled: "\"\\n=== For-in with Where Clause ===\"") + ParameterExp(unlabeled: VariableExp("\"\\n=== For-in with Where Clause ===\"")) } .comment { Line("MARK: - For-in with Where Clause") @@ -79,28 +108,26 @@ import Testing ]) ) - try For( + For( VariableExp("number"), in: VariableExp("numbers"), where: { - try Infix("==") { - try Infix("%") { - VariableExp("number") - Literal.integer(2) - } - Literal.integer(0) - } + Infix( + "==", + lhs: Infix("%", lhs: VariableExp("number"), rhs: Literal.integer(2)), + rhs: Literal.integer(0) + ) }, then: { Call("print") { - ParameterExp(unlabeled: "\"Even number: \\(number)\"") + ParameterExp(unlabeled: VariableExp("\"Even number: \\(number)\"")) } } ) // MARK: - For-in with Dictionary Call("print") { - ParameterExp(unlabeled: "\"\\n=== For-in with Dictionary ===\"") + ParameterExp(unlabeled: VariableExp("\"\\n=== For-in with Dictionary ===\"")) } .comment { Line("MARK: - For-in with Dictionary") @@ -124,7 +151,7 @@ import Testing in: VariableExp("scores"), then: { Call("print") { - ParameterExp(unlabeled: "\"\\(name): \\(score)\"") + ParameterExp(unlabeled: VariableExp("\"\\(name): \\(score)\"")) } } ) diff --git a/Tests/SyntaxKitTests/Integration/SimpleDocTests.swift b/Tests/SyntaxKitTests/Integration/SimpleDocTests.swift index af89e6e5..215a1323 100644 --- a/Tests/SyntaxKitTests/Integration/SimpleDocTests.swift +++ b/Tests/SyntaxKitTests/Integration/SimpleDocTests.swift @@ -1,3 +1,32 @@ +// +// SimpleDocTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing diff --git a/Tests/SyntaxKitTests/Integration/SwiftUIExampleTests.swift b/Tests/SyntaxKitTests/Integration/SwiftUIExampleTests.swift index d0529eff..d1843aa0 100644 --- a/Tests/SyntaxKitTests/Integration/SwiftUIExampleTests.swift +++ b/Tests/SyntaxKitTests/Integration/SwiftUIExampleTests.swift @@ -1,13 +1,13 @@ // // SwiftUIExampleTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT diff --git a/Tests/SyntaxKitTests/Unit/Attributes/AttributeTests.swift b/Tests/SyntaxKitTests/Unit/Attributes/AttributeTests.swift index 432fdbd6..1d9ce813 100644 --- a/Tests/SyntaxKitTests/Unit/Attributes/AttributeTests.swift +++ b/Tests/SyntaxKitTests/Unit/Attributes/AttributeTests.swift @@ -1,13 +1,13 @@ // // AttributeTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT diff --git a/Tests/SyntaxKitTests/Unit/Collections/TupleAssignmentAsyncTests.swift b/Tests/SyntaxKitTests/Unit/Collections/TupleAssignmentAsyncTests.swift index f92d1bbb..bb1506d7 100644 --- a/Tests/SyntaxKitTests/Unit/Collections/TupleAssignmentAsyncTests.swift +++ b/Tests/SyntaxKitTests/Unit/Collections/TupleAssignmentAsyncTests.swift @@ -1,3 +1,32 @@ +// +// TupleAssignmentAsyncTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing diff --git a/Tests/SyntaxKitTests/Unit/Collections/TupleAssignmentBasicTests.swift b/Tests/SyntaxKitTests/Unit/Collections/TupleAssignmentBasicTests.swift index ba739056..18bfd557 100644 --- a/Tests/SyntaxKitTests/Unit/Collections/TupleAssignmentBasicTests.swift +++ b/Tests/SyntaxKitTests/Unit/Collections/TupleAssignmentBasicTests.swift @@ -1,3 +1,32 @@ +// +// TupleAssignmentBasicTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing diff --git a/Tests/SyntaxKitTests/Unit/Collections/TupleAssignmentEdgeCaseTests.swift b/Tests/SyntaxKitTests/Unit/Collections/TupleAssignmentEdgeCaseTests.swift index cbb5b2c1..5b9fd529 100644 --- a/Tests/SyntaxKitTests/Unit/Collections/TupleAssignmentEdgeCaseTests.swift +++ b/Tests/SyntaxKitTests/Unit/Collections/TupleAssignmentEdgeCaseTests.swift @@ -1,3 +1,32 @@ +// +// TupleAssignmentEdgeCaseTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing diff --git a/Tests/SyntaxKitTests/Unit/Collections/TupleAssignmentIntegrationTests.swift b/Tests/SyntaxKitTests/Unit/Collections/TupleAssignmentIntegrationTests.swift index 87f2046c..2405e0a0 100644 --- a/Tests/SyntaxKitTests/Unit/Collections/TupleAssignmentIntegrationTests.swift +++ b/Tests/SyntaxKitTests/Unit/Collections/TupleAssignmentIntegrationTests.swift @@ -1,3 +1,32 @@ +// +// TupleAssignmentIntegrationTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing diff --git a/Tests/SyntaxKitTests/Unit/ControlFlow/ConditionalsTests.swift b/Tests/SyntaxKitTests/Unit/ControlFlow/ConditionalsTests.swift index b0d23783..e8f3a95b 100644 --- a/Tests/SyntaxKitTests/Unit/ControlFlow/ConditionalsTests.swift +++ b/Tests/SyntaxKitTests/Unit/ControlFlow/ConditionalsTests.swift @@ -1,3 +1,32 @@ +// +// ConditionalsTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing @@ -7,33 +36,27 @@ import Testing @Test("If / else-if / else chain generates correct syntax") internal func testIfElseChain() throws { // Arrange: build the DSL example using the updated APIs - let conditional = try Group { + let conditional = Group { Variable(.let, name: "score", type: "Int", equals: "85") - try If { - try Infix(">=") { - VariableExp("score") - Literal.integer(90) - } + If { + Infix(">=", lhs: VariableExp("score"), rhs: Literal.integer(90)) } then: { Call("print") { - ParameterExp(name: "", value: "\"Excellent!\"") + ParameterExp(name: "", value: VariableExp("\"Excellent!\"")) } } else: { - try If { - try Infix(">=") { - VariableExp("score") - Literal.integer(80) - } + If { + Infix(">=", lhs: VariableExp("score"), rhs: Literal.integer(80)) } then: { Call("print") { - ParameterExp(name: "", value: "\"Good job!\"") + ParameterExp(name: "", value: VariableExp("\"Good job!\"")) } } Then { Call("print") { - ParameterExp(name: "", value: "\"Needs improvement\"") + ParameterExp(name: "", value: VariableExp("\"Needs improvement\"")) } } } @@ -51,24 +74,18 @@ import Testing @Test("If with multiple conditions generates correct syntax") internal func testIfWithMultipleConditions() throws { - let ifStatement = try If { - try Infix(">=") { - VariableExp("score") - Literal.integer(90) - } + let ifStatement = If { + Infix(">=", lhs: VariableExp("score"), rhs: Literal.integer(90)) } then: { Call("print") { - ParameterExp(unlabeled: "Excellent!") + ParameterExp(unlabeled: VariableExp("Excellent!")) } } else: { - try If { - try Infix(">=") { - VariableExp("score") - Literal.integer(80) - } + If { + Infix(">=", lhs: VariableExp("score"), rhs: Literal.integer(80)) } then: { Call("print") { - ParameterExp(unlabeled: "Good!") + ParameterExp(unlabeled: VariableExp("Good!")) } } } diff --git a/Tests/SyntaxKitTests/Unit/ControlFlow/ForLoopTests.swift b/Tests/SyntaxKitTests/Unit/ControlFlow/ForLoopTests.swift index 8d0b3039..a7783265 100644 --- a/Tests/SyntaxKitTests/Unit/ControlFlow/ForLoopTests.swift +++ b/Tests/SyntaxKitTests/Unit/ControlFlow/ForLoopTests.swift @@ -1,3 +1,32 @@ +// +// ForLoopTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing @@ -12,30 +41,26 @@ internal final class ForLoopTests { in: VariableExp("items"), then: { Call("print") { - ParameterExp(name: "", value: "item") + ParameterExp(name: "", value: VariableExp("item")) } } ) let generated = forLoop.syntax.description - let expected = "for item in items {\n print(item)\n}" #expect(generated.contains("for item in items")) #expect(generated.contains("print(item)")) } @Test internal func testForInWithWhereClause() throws { - let forLoop = try For( + let forLoop = For( VariableExp("number"), in: VariableExp("numbers"), where: { - try Infix("%") { - VariableExp("number") - Literal.integer(2) - } + Infix("%", lhs: VariableExp("number"), rhs: Literal.integer(2)) }, then: { Call("print") { - ParameterExp(name: "", value: "number") + ParameterExp(name: "", value: VariableExp("number")) } } ) diff --git a/Tests/SyntaxKitTests/Unit/Core/PatternConvertibleTests.swift b/Tests/SyntaxKitTests/Unit/Core/PatternConvertibleTests.swift index ca914cf3..1d698db0 100644 --- a/Tests/SyntaxKitTests/Unit/Core/PatternConvertibleTests.swift +++ b/Tests/SyntaxKitTests/Unit/Core/PatternConvertibleTests.swift @@ -1,13 +1,13 @@ // // PatternConvertibleTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT @@ -55,7 +55,7 @@ internal struct PatternConvertibleTests { @Test internal func testLetBindingPatternInSwitchCase() { let switchCase = SwitchCase(Tuple.pattern([Pattern.let("x"), Pattern.let("y")])) { Call("print") { - ParameterExp(name: "", value: "\"somewhere else at (\\(x), \\(y))\"") + ParameterExp(name: "", value: VariableExp("\"somewhere else at (\\(x), \\(y))\"")) } } diff --git a/Tests/SyntaxKitTests/Unit/Declarations/ClassTests.swift b/Tests/SyntaxKitTests/Unit/Declarations/ClassTests.swift index 1cc8ff8d..ccd6573d 100644 --- a/Tests/SyntaxKitTests/Unit/Declarations/ClassTests.swift +++ b/Tests/SyntaxKitTests/Unit/Declarations/ClassTests.swift @@ -1,3 +1,32 @@ +// +// ClassTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing diff --git a/Tests/SyntaxKitTests/Unit/Declarations/ExtensionTests.swift b/Tests/SyntaxKitTests/Unit/Declarations/ExtensionTests.swift index be84e01f..091c6cdb 100644 --- a/Tests/SyntaxKitTests/Unit/Declarations/ExtensionTests.swift +++ b/Tests/SyntaxKitTests/Unit/Declarations/ExtensionTests.swift @@ -1,13 +1,13 @@ // // ExtensionTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT diff --git a/Tests/SyntaxKitTests/Unit/Declarations/ProtocolTests.swift b/Tests/SyntaxKitTests/Unit/Declarations/ProtocolTests.swift index 5e847ac1..7fdcc7a0 100644 --- a/Tests/SyntaxKitTests/Unit/Declarations/ProtocolTests.swift +++ b/Tests/SyntaxKitTests/Unit/Declarations/ProtocolTests.swift @@ -1,3 +1,32 @@ +// +// ProtocolTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing diff --git a/Tests/SyntaxKitTests/Unit/Declarations/StructTests.swift b/Tests/SyntaxKitTests/Unit/Declarations/StructTests.swift index b46a2829..51a0cb19 100644 --- a/Tests/SyntaxKitTests/Unit/Declarations/StructTests.swift +++ b/Tests/SyntaxKitTests/Unit/Declarations/StructTests.swift @@ -1,3 +1,32 @@ +// +// StructTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing @@ -9,10 +38,10 @@ internal struct StructTests { Variable(.var, name: "items", type: "[Element]", equals: Literal.array([])).withExplicitType() Function("push") { - Parameter(name: "item", type: "Element", isUnnamed: true) + Parameter(unlabeled: "item", type: "Element") } _: { VariableExp("items").call("append") { - ParameterExp(name: "", value: "item") + ParameterExp(name: "", value: VariableExp("item")) } }.mutating() diff --git a/Tests/SyntaxKitTests/Unit/Declarations/TypeAliasTests.swift b/Tests/SyntaxKitTests/Unit/Declarations/TypeAliasTests.swift index ce05d1c3..8ee9c10e 100644 --- a/Tests/SyntaxKitTests/Unit/Declarations/TypeAliasTests.swift +++ b/Tests/SyntaxKitTests/Unit/Declarations/TypeAliasTests.swift @@ -1,13 +1,13 @@ // // TypeAliasTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT diff --git a/Tests/SyntaxKitTests/Unit/EdgeCases/EdgeCaseTests.swift b/Tests/SyntaxKitTests/Unit/EdgeCases/EdgeCaseTests.swift index 17855a6c..0a5f1c7d 100644 --- a/Tests/SyntaxKitTests/Unit/EdgeCases/EdgeCaseTests.swift +++ b/Tests/SyntaxKitTests/Unit/EdgeCases/EdgeCaseTests.swift @@ -1,3 +1,32 @@ +// +// EdgeCaseTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing @@ -7,6 +36,7 @@ internal struct EdgeCaseTests { // MARK: - Error Handling Tests @Test("Infix with wrong number of operands throws error") + @available(*, deprecated, message: "Exercises the deprecated Infix(_:_:) builder init") internal func testInfixWrongOperandCount() throws { // Test that Infix throws an error when given wrong number of operands do { @@ -15,18 +45,18 @@ internal struct EdgeCaseTests { VariableExp("x") } // If we reach here, no error was thrown, which is unexpected - #expect(false, "Expected error to be thrown for wrong operand count") + Issue.record("Expected error to be thrown for wrong operand count") } catch let error as Infix.InfixError { // Verify it's the correct error type switch error { - case let .wrongOperandCount(expected, got): + case .wrongOperandCount(let expected, let got): #expect(expected == 2) #expect(got == 1) case .nonExprCodeBlockOperand: - #expect(false, "Expected wrongOperandCount error, got nonExprCodeBlockOperand") + Issue.record("Expected wrongOperandCount error, got nonExprCodeBlockOperand") } } catch { - #expect(false, "Expected InfixError, got \(type(of: error))") + Issue.record("Expected InfixError, got \(type(of: error))") } } diff --git a/Tests/SyntaxKitTests/Unit/EdgeCases/EdgeCaseTestsExpressions.swift b/Tests/SyntaxKitTests/Unit/EdgeCases/EdgeCaseTestsExpressions.swift index bdd74438..8df03f90 100644 --- a/Tests/SyntaxKitTests/Unit/EdgeCases/EdgeCaseTestsExpressions.swift +++ b/Tests/SyntaxKitTests/Unit/EdgeCases/EdgeCaseTestsExpressions.swift @@ -1,3 +1,32 @@ +// +// EdgeCaseTestsExpressions.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import SwiftSyntax import Testing @@ -38,20 +67,15 @@ internal struct EdgeCaseTestsExpressions { @Test("Infix with complex expressions generates correct syntax") internal func testInfixWithComplexExpressions() throws { - let infix = try Infix("*") { - try Parenthesized { - try Infix("+") { - VariableExp("a") - VariableExp("b") - } - } - try Parenthesized { - try Infix("-") { - VariableExp("c") - VariableExp("d") - } + let infix = Infix( + "*", + lhs: Parenthesized { + Infix("+", lhs: VariableExp("a"), rhs: VariableExp("b")) + }, + rhs: Parenthesized { + Infix("-", lhs: VariableExp("c"), rhs: VariableExp("d")) } - } + ) let generated = infix.generateCode() #expect(generated.contains("(a + b) * (c - d)")) @@ -69,11 +93,8 @@ internal struct EdgeCaseTestsExpressions { @Test("Return with complex expression generates correct syntax") internal func testReturnWithComplexExpression() throws { - let returnStmt = try Return { - try Infix("+") { - VariableExp("a") - VariableExp("b") - } + let returnStmt = Return { + Infix("+", lhs: VariableExp("a"), rhs: VariableExp("b")) } let generated = returnStmt.generateCode() diff --git a/Tests/SyntaxKitTests/Unit/EdgeCases/EdgeCaseTestsTypes.swift b/Tests/SyntaxKitTests/Unit/EdgeCases/EdgeCaseTestsTypes.swift index 1737ba65..97b5ee43 100644 --- a/Tests/SyntaxKitTests/Unit/EdgeCases/EdgeCaseTestsTypes.swift +++ b/Tests/SyntaxKitTests/Unit/EdgeCases/EdgeCaseTestsTypes.swift @@ -1,3 +1,32 @@ +// +// EdgeCaseTestsTypes.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing @@ -31,7 +60,7 @@ internal struct EdgeCaseTestsTypes { @Test("Function with unnamed parameter generates correct syntax") internal func testFunctionWithUnnamedParameter() throws { let function = Function("process") { - Parameter(name: "data", type: "Data", isUnnamed: true) + Parameter(unlabeled: "data", type: "Data") } _: { Variable(.let, name: "result", type: "String", equals: "processed") } @@ -85,7 +114,7 @@ internal struct EdgeCaseTestsTypes { let computedProperty = ComputedProperty("description", type: "String") { Return { VariableExp("name").call("appending") { - ParameterExp(name: "", value: "\" - \" + String(count)") + ParameterExp(name: "", value: VariableExp("\" - \" + String(count)")) } } } diff --git a/Tests/SyntaxKitTests/Unit/ErrorHandling/CatchBasicTests.swift b/Tests/SyntaxKitTests/Unit/ErrorHandling/CatchBasicTests.swift index f182781b..a2195ccf 100644 --- a/Tests/SyntaxKitTests/Unit/ErrorHandling/CatchBasicTests.swift +++ b/Tests/SyntaxKitTests/Unit/ErrorHandling/CatchBasicTests.swift @@ -1,3 +1,32 @@ +// +// CatchBasicTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing diff --git a/Tests/SyntaxKitTests/Unit/ErrorHandling/CatchComplexTests.swift b/Tests/SyntaxKitTests/Unit/ErrorHandling/CatchComplexTests.swift index c4849279..b1ff8f47 100644 --- a/Tests/SyntaxKitTests/Unit/ErrorHandling/CatchComplexTests.swift +++ b/Tests/SyntaxKitTests/Unit/ErrorHandling/CatchComplexTests.swift @@ -1,3 +1,32 @@ +// +// CatchComplexTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing diff --git a/Tests/SyntaxKitTests/Unit/ErrorHandling/CatchEdgeCaseTests.swift b/Tests/SyntaxKitTests/Unit/ErrorHandling/CatchEdgeCaseTests.swift index b7853308..40f503b2 100644 --- a/Tests/SyntaxKitTests/Unit/ErrorHandling/CatchEdgeCaseTests.swift +++ b/Tests/SyntaxKitTests/Unit/ErrorHandling/CatchEdgeCaseTests.swift @@ -1,3 +1,32 @@ +// +// CatchEdgeCaseTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing diff --git a/Tests/SyntaxKitTests/Unit/ErrorHandling/CatchIntegrationTests.swift b/Tests/SyntaxKitTests/Unit/ErrorHandling/CatchIntegrationTests.swift index 31d2ead6..2a5e4d5c 100644 --- a/Tests/SyntaxKitTests/Unit/ErrorHandling/CatchIntegrationTests.swift +++ b/Tests/SyntaxKitTests/Unit/ErrorHandling/CatchIntegrationTests.swift @@ -1,3 +1,32 @@ +// +// CatchIntegrationTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing diff --git a/Tests/SyntaxKitTests/Unit/ErrorHandling/DoBasicTests.swift b/Tests/SyntaxKitTests/Unit/ErrorHandling/DoBasicTests.swift index e38dd7fa..11f85163 100644 --- a/Tests/SyntaxKitTests/Unit/ErrorHandling/DoBasicTests.swift +++ b/Tests/SyntaxKitTests/Unit/ErrorHandling/DoBasicTests.swift @@ -1,3 +1,32 @@ +// +// DoBasicTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing diff --git a/Tests/SyntaxKitTests/Unit/ErrorHandling/DoComplexTests.swift b/Tests/SyntaxKitTests/Unit/ErrorHandling/DoComplexTests.swift index c3faa800..78b0c216 100644 --- a/Tests/SyntaxKitTests/Unit/ErrorHandling/DoComplexTests.swift +++ b/Tests/SyntaxKitTests/Unit/ErrorHandling/DoComplexTests.swift @@ -1,3 +1,32 @@ +// +// DoComplexTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing diff --git a/Tests/SyntaxKitTests/Unit/ErrorHandling/DoEdgeCaseTests.swift b/Tests/SyntaxKitTests/Unit/ErrorHandling/DoEdgeCaseTests.swift index 2d3e6b1a..e2a4711d 100644 --- a/Tests/SyntaxKitTests/Unit/ErrorHandling/DoEdgeCaseTests.swift +++ b/Tests/SyntaxKitTests/Unit/ErrorHandling/DoEdgeCaseTests.swift @@ -1,3 +1,32 @@ +// +// DoEdgeCaseTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing diff --git a/Tests/SyntaxKitTests/Unit/ErrorHandling/DoIntegrationTests.swift b/Tests/SyntaxKitTests/Unit/ErrorHandling/DoIntegrationTests.swift index b4e80d0c..6e15be0e 100644 --- a/Tests/SyntaxKitTests/Unit/ErrorHandling/DoIntegrationTests.swift +++ b/Tests/SyntaxKitTests/Unit/ErrorHandling/DoIntegrationTests.swift @@ -1,3 +1,32 @@ +// +// DoIntegrationTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing diff --git a/Tests/SyntaxKitTests/Unit/ErrorHandling/ErrorHandlingTests.swift b/Tests/SyntaxKitTests/Unit/ErrorHandling/ErrorHandlingTests.swift index f50b972a..e231288f 100644 --- a/Tests/SyntaxKitTests/Unit/ErrorHandling/ErrorHandlingTests.swift +++ b/Tests/SyntaxKitTests/Unit/ErrorHandling/ErrorHandlingTests.swift @@ -1,3 +1,32 @@ +// +// ErrorHandlingTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing diff --git a/Tests/SyntaxKitTests/Unit/ErrorHandling/ThrowBasicTests.swift b/Tests/SyntaxKitTests/Unit/ErrorHandling/ThrowBasicTests.swift index fbfb0c45..ad422157 100644 --- a/Tests/SyntaxKitTests/Unit/ErrorHandling/ThrowBasicTests.swift +++ b/Tests/SyntaxKitTests/Unit/ErrorHandling/ThrowBasicTests.swift @@ -1,3 +1,32 @@ +// +// ThrowBasicTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing diff --git a/Tests/SyntaxKitTests/Unit/ErrorHandling/ThrowComplexTests.swift b/Tests/SyntaxKitTests/Unit/ErrorHandling/ThrowComplexTests.swift index 019df7d0..85422e2c 100644 --- a/Tests/SyntaxKitTests/Unit/ErrorHandling/ThrowComplexTests.swift +++ b/Tests/SyntaxKitTests/Unit/ErrorHandling/ThrowComplexTests.swift @@ -1,3 +1,32 @@ +// +// ThrowComplexTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing diff --git a/Tests/SyntaxKitTests/Unit/ErrorHandling/ThrowEdgeCaseTests.swift b/Tests/SyntaxKitTests/Unit/ErrorHandling/ThrowEdgeCaseTests.swift index a706277a..9addee14 100644 --- a/Tests/SyntaxKitTests/Unit/ErrorHandling/ThrowEdgeCaseTests.swift +++ b/Tests/SyntaxKitTests/Unit/ErrorHandling/ThrowEdgeCaseTests.swift @@ -1,3 +1,32 @@ +// +// ThrowEdgeCaseTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing diff --git a/Tests/SyntaxKitTests/Unit/ErrorHandling/ThrowFunctionTests.swift b/Tests/SyntaxKitTests/Unit/ErrorHandling/ThrowFunctionTests.swift index 9efde18e..c2233fb5 100644 --- a/Tests/SyntaxKitTests/Unit/ErrorHandling/ThrowFunctionTests.swift +++ b/Tests/SyntaxKitTests/Unit/ErrorHandling/ThrowFunctionTests.swift @@ -1,3 +1,32 @@ +// +// ThrowFunctionTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing diff --git a/Tests/SyntaxKitTests/Unit/Expressions/CallTests.swift b/Tests/SyntaxKitTests/Unit/Expressions/CallTests.swift index 415df158..f04e5a9f 100644 --- a/Tests/SyntaxKitTests/Unit/Expressions/CallTests.swift +++ b/Tests/SyntaxKitTests/Unit/Expressions/CallTests.swift @@ -1,13 +1,13 @@ // // CallTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT @@ -42,7 +42,7 @@ import Testing @Test("Call with string parameter generates correct syntax") internal func testCallWithStringParameter() throws { let call = Call("print") { - ParameterExp(name: "", value: "\"Hello, World!\"") + ParameterExp(name: "", value: VariableExp("\"Hello, World!\"")) } let generated = call.generateCode() #expect(generated.contains("print(\"Hello, World!\")")) @@ -51,7 +51,7 @@ import Testing @Test("Call with named parameter generates correct syntax") internal func testCallWithNamedParameter() throws { let call = Call("function") { - ParameterExp(name: "value", value: "42") + ParameterExp(name: "value", value: VariableExp("42")) } let generated = call.generateCode() #expect(generated.contains("function(value:42)")) @@ -60,8 +60,8 @@ import Testing @Test("Call with multiple parameters generates correct syntax") internal func testCallWithMultipleParameters() throws { let call = Call("print") { - ParameterExp(name: "", value: "\"Count:\"") - ParameterExp(name: "count", value: "5") + ParameterExp(name: "", value: VariableExp("\"Count:\"")) + ParameterExp(name: "count", value: VariableExp("5")) } let generated = call.generateCode() #expect(generated.contains("print(\"Count:\", count:5)")) @@ -70,7 +70,7 @@ import Testing @Test("Call with string interpolation generates correct syntax") internal func testCallWithStringInterpolation() throws { let call = Call("print") { - ParameterExp(name: "", value: "\"Starting \\(brand) vehicle...\"") + ParameterExp(name: "", value: VariableExp("\"Starting \\(brand) vehicle...\"")) } let generated = call.generateCode() #expect(generated.contains("print(\"Starting \\(brand) vehicle...\")")) @@ -80,7 +80,7 @@ import Testing internal func testCallInFunctionBody() throws { let function = Function("test") { Call("print") { - ParameterExp(name: "", value: "\"Hello\"") + ParameterExp(name: "", value: VariableExp("\"Hello\"")) } } let generated = function.generateCode() @@ -93,7 +93,7 @@ import Testing let extSyntax = Extension("Vehicle") { Function("start") { Call("print") { - ParameterExp(name: "", value: "\"Starting \\(brand) vehicle...\"") + ParameterExp(name: "", value: VariableExp("\"Starting \\(brand) vehicle...\"")) } } } @@ -108,7 +108,7 @@ import Testing let structExp = Struct("Car") { Function("start") { Call("print") { - ParameterExp(name: "", value: "\"Starting \\(brand) car engine...\"") + ParameterExp(name: "", value: VariableExp("\"Starting \\(brand) car engine...\"")) } } } diff --git a/Tests/SyntaxKitTests/Unit/Expressions/ClosureCaptureCoverageTests.swift b/Tests/SyntaxKitTests/Unit/Expressions/ClosureCaptureCoverageTests.swift index a6e1a1e3..852c2194 100644 --- a/Tests/SyntaxKitTests/Unit/Expressions/ClosureCaptureCoverageTests.swift +++ b/Tests/SyntaxKitTests/Unit/Expressions/ClosureCaptureCoverageTests.swift @@ -1,13 +1,13 @@ // // ClosureCaptureCoverageTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT diff --git a/Tests/SyntaxKitTests/Unit/Expressions/ClosureCoverageTests.swift b/Tests/SyntaxKitTests/Unit/Expressions/ClosureCoverageTests.swift index 2d2f443a..ee861861 100644 --- a/Tests/SyntaxKitTests/Unit/Expressions/ClosureCoverageTests.swift +++ b/Tests/SyntaxKitTests/Unit/Expressions/ClosureCoverageTests.swift @@ -1,13 +1,13 @@ // // ClosureCoverageTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT @@ -76,7 +76,7 @@ internal final class ClosureCoverageTests { @Test("Build parameter expression item") internal func testBuildParameterExpressionItem() { // Test the buildParameterExpressionItem method - let paramExp = ParameterExp(name: "test", value: "value") + let paramExp = ParameterExp(name: "test", value: VariableExp("value")) let closure = Closure(body: { paramExp }) @@ -126,7 +126,7 @@ internal final class ClosureCoverageTests { @Test("Build parameter expression item with param expr syntax") internal func testBuildParameterExpressionItemWithParamExprSyntax() { // Test ParameterExp with parameter expression syntax - let paramExp = ParameterExp(name: "test", value: "value") + let paramExp = ParameterExp(name: "test", value: VariableExp("value")) let closure = Closure(body: { paramExp }) diff --git a/Tests/SyntaxKitTests/Unit/Expressions/ConditionalOp/ConditionalOpBasicTests.swift b/Tests/SyntaxKitTests/Unit/Expressions/ConditionalOp/ConditionalOpBasicTests.swift index 7f5e47b8..45b04875 100644 --- a/Tests/SyntaxKitTests/Unit/Expressions/ConditionalOp/ConditionalOpBasicTests.swift +++ b/Tests/SyntaxKitTests/Unit/Expressions/ConditionalOp/ConditionalOpBasicTests.swift @@ -1,13 +1,13 @@ // // ConditionalOpBasicTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT diff --git a/Tests/SyntaxKitTests/Unit/Expressions/ConditionalOp/ConditionalOpComplexTests.swift b/Tests/SyntaxKitTests/Unit/Expressions/ConditionalOp/ConditionalOpComplexTests.swift index 7eec2ffd..2e213dc9 100644 --- a/Tests/SyntaxKitTests/Unit/Expressions/ConditionalOp/ConditionalOpComplexTests.swift +++ b/Tests/SyntaxKitTests/Unit/Expressions/ConditionalOp/ConditionalOpComplexTests.swift @@ -1,13 +1,13 @@ // // ConditionalOpComplexTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT diff --git a/Tests/SyntaxKitTests/Unit/Expressions/ConditionalOp/ConditionalOpLiteralTests.swift b/Tests/SyntaxKitTests/Unit/Expressions/ConditionalOp/ConditionalOpLiteralTests.swift index 596d328e..7267d272 100644 --- a/Tests/SyntaxKitTests/Unit/Expressions/ConditionalOp/ConditionalOpLiteralTests.swift +++ b/Tests/SyntaxKitTests/Unit/Expressions/ConditionalOp/ConditionalOpLiteralTests.swift @@ -1,13 +1,13 @@ // // ConditionalOpLiteralTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT diff --git a/Tests/SyntaxKitTests/Unit/Expressions/LiteralTests.swift b/Tests/SyntaxKitTests/Unit/Expressions/LiteralTests.swift index 9484f253..27f31816 100644 --- a/Tests/SyntaxKitTests/Unit/Expressions/LiteralTests.swift +++ b/Tests/SyntaxKitTests/Unit/Expressions/LiteralTests.swift @@ -1,3 +1,32 @@ +// +// LiteralTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing diff --git a/Tests/SyntaxKitTests/Unit/Expressions/LiteralValueTests.swift b/Tests/SyntaxKitTests/Unit/Expressions/LiteralValueTests.swift index 2a9914b9..396129cd 100644 --- a/Tests/SyntaxKitTests/Unit/Expressions/LiteralValueTests.swift +++ b/Tests/SyntaxKitTests/Unit/Expressions/LiteralValueTests.swift @@ -1,13 +1,13 @@ // // LiteralValueTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT diff --git a/Tests/SyntaxKitTests/Unit/Expressions/NegatedPropertyAccessExp/NegatedPropertyAccessExpBasicTests.swift b/Tests/SyntaxKitTests/Unit/Expressions/NegatedPropertyAccessExp/NegatedPropertyAccessExpBasicTests.swift index 5db808bd..f2f1d9b5 100644 --- a/Tests/SyntaxKitTests/Unit/Expressions/NegatedPropertyAccessExp/NegatedPropertyAccessExpBasicTests.swift +++ b/Tests/SyntaxKitTests/Unit/Expressions/NegatedPropertyAccessExp/NegatedPropertyAccessExpBasicTests.swift @@ -1,13 +1,13 @@ // // NegatedPropertyAccessExpBasicTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT diff --git a/Tests/SyntaxKitTests/Unit/Expressions/NegatedPropertyAccessExp/NegatedPropertyAccessExpFunctionTests.swift b/Tests/SyntaxKitTests/Unit/Expressions/NegatedPropertyAccessExp/NegatedPropertyAccessExpFunctionTests.swift index 84f26016..f1a7373b 100644 --- a/Tests/SyntaxKitTests/Unit/Expressions/NegatedPropertyAccessExp/NegatedPropertyAccessExpFunctionTests.swift +++ b/Tests/SyntaxKitTests/Unit/Expressions/NegatedPropertyAccessExp/NegatedPropertyAccessExpFunctionTests.swift @@ -1,13 +1,13 @@ // // NegatedPropertyAccessExpFunctionTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT diff --git a/Tests/SyntaxKitTests/Unit/Expressions/NegatedPropertyAccessExp/NegatedPropertyAccessExpLiteralTests.swift b/Tests/SyntaxKitTests/Unit/Expressions/NegatedPropertyAccessExp/NegatedPropertyAccessExpLiteralTests.swift index b9be7ec3..387e2e80 100644 --- a/Tests/SyntaxKitTests/Unit/Expressions/NegatedPropertyAccessExp/NegatedPropertyAccessExpLiteralTests.swift +++ b/Tests/SyntaxKitTests/Unit/Expressions/NegatedPropertyAccessExp/NegatedPropertyAccessExpLiteralTests.swift @@ -1,13 +1,13 @@ // // NegatedPropertyAccessExpLiteralTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT diff --git a/Tests/SyntaxKitTests/Unit/Expressions/NegatedPropertyAccessExp/NegatedPropertyAccessExpPropertyTests.swift b/Tests/SyntaxKitTests/Unit/Expressions/NegatedPropertyAccessExp/NegatedPropertyAccessExpPropertyTests.swift index 41fa5541..cdf655dc 100644 --- a/Tests/SyntaxKitTests/Unit/Expressions/NegatedPropertyAccessExp/NegatedPropertyAccessExpPropertyTests.swift +++ b/Tests/SyntaxKitTests/Unit/Expressions/NegatedPropertyAccessExp/NegatedPropertyAccessExpPropertyTests.swift @@ -1,13 +1,13 @@ // // NegatedPropertyAccessExpPropertyTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT diff --git a/Tests/SyntaxKitTests/Unit/Expressions/OptionalChaining/OptionalChainingBasicTests.swift b/Tests/SyntaxKitTests/Unit/Expressions/OptionalChaining/OptionalChainingBasicTests.swift index 74f966a2..0fc1413c 100644 --- a/Tests/SyntaxKitTests/Unit/Expressions/OptionalChaining/OptionalChainingBasicTests.swift +++ b/Tests/SyntaxKitTests/Unit/Expressions/OptionalChaining/OptionalChainingBasicTests.swift @@ -1,13 +1,13 @@ // // OptionalChainingBasicTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT diff --git a/Tests/SyntaxKitTests/Unit/Expressions/OptionalChaining/OptionalChainingLiteralTests.swift b/Tests/SyntaxKitTests/Unit/Expressions/OptionalChaining/OptionalChainingLiteralTests.swift index 5844b504..65757aa8 100644 --- a/Tests/SyntaxKitTests/Unit/Expressions/OptionalChaining/OptionalChainingLiteralTests.swift +++ b/Tests/SyntaxKitTests/Unit/Expressions/OptionalChaining/OptionalChainingLiteralTests.swift @@ -1,13 +1,13 @@ // // OptionalChainingLiteralTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT diff --git a/Tests/SyntaxKitTests/Unit/Expressions/OptionalChaining/OptionalChainingOperatorTests.swift b/Tests/SyntaxKitTests/Unit/Expressions/OptionalChaining/OptionalChainingOperatorTests.swift index f73dc7d2..7dff7f36 100644 --- a/Tests/SyntaxKitTests/Unit/Expressions/OptionalChaining/OptionalChainingOperatorTests.swift +++ b/Tests/SyntaxKitTests/Unit/Expressions/OptionalChaining/OptionalChainingOperatorTests.swift @@ -1,13 +1,13 @@ // // OptionalChainingOperatorTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT diff --git a/Tests/SyntaxKitTests/Unit/Expressions/OptionalChaining/OptionalChainingPropertyTests.swift b/Tests/SyntaxKitTests/Unit/Expressions/OptionalChaining/OptionalChainingPropertyTests.swift index db179e2f..f642edf8 100644 --- a/Tests/SyntaxKitTests/Unit/Expressions/OptionalChaining/OptionalChainingPropertyTests.swift +++ b/Tests/SyntaxKitTests/Unit/Expressions/OptionalChaining/OptionalChainingPropertyTests.swift @@ -1,13 +1,13 @@ // // OptionalChainingPropertyTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT diff --git a/Tests/SyntaxKitTests/Unit/Expressions/PlusAssign/PlusAssignBasicTests.swift b/Tests/SyntaxKitTests/Unit/Expressions/PlusAssign/PlusAssignBasicTests.swift index 7fb61f99..2f08c0b7 100644 --- a/Tests/SyntaxKitTests/Unit/Expressions/PlusAssign/PlusAssignBasicTests.swift +++ b/Tests/SyntaxKitTests/Unit/Expressions/PlusAssign/PlusAssignBasicTests.swift @@ -1,13 +1,13 @@ // // PlusAssignBasicTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT @@ -40,6 +40,7 @@ import Testing internal final class PlusAssignBasicTests { /// Tests basic plus assignment expression. @Test("Basic plus assignment expression generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testBasicPlusAssign() { let plusAssign = PlusAssign("count", 1) @@ -51,6 +52,7 @@ internal final class PlusAssignBasicTests { /// Tests plus assignment with variable and literal value. @Test("Plus assignment with variable and literal value generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithVariableAndLiteralValue() { let plusAssign = PlusAssign("total", 42) @@ -62,6 +64,7 @@ internal final class PlusAssignBasicTests { /// Tests plus assignment with function call value. @Test("Plus assignment with function call value generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithFunctionCallValue() { let plusAssign = PlusAssign("total", 50) @@ -73,6 +76,7 @@ internal final class PlusAssignBasicTests { /// Tests plus assignment with complex expression value. @Test("Plus assignment with complex expression value generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithComplexExpressionValue() { let plusAssign = PlusAssign("score", 55) @@ -84,6 +88,7 @@ internal final class PlusAssignBasicTests { /// Tests plus assignment with conditional expression value. @Test("Plus assignment with conditional expression value generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithConditionalExpressionValue() { let plusAssign = PlusAssign("total", 60) @@ -95,6 +100,7 @@ internal final class PlusAssignBasicTests { /// Tests plus assignment with closure expression value. @Test("Plus assignment with closure expression value generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithClosureExpressionValue() { let plusAssign = PlusAssign("sum", 65) @@ -106,6 +112,7 @@ internal final class PlusAssignBasicTests { /// Tests plus assignment with array literal value. @Test("Plus assignment with array literal value generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithArrayLiteralValue() { let plusAssign = PlusAssign("list", 70) @@ -117,6 +124,7 @@ internal final class PlusAssignBasicTests { /// Tests plus assignment with dictionary literal value. @Test("Plus assignment with dictionary literal value generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithDictionaryLiteralValue() { let plusAssign = PlusAssign("dict", 75) @@ -128,6 +136,7 @@ internal final class PlusAssignBasicTests { /// Tests plus assignment with tuple literal value. @Test("Plus assignment with tuple literal value generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithTupleLiteralValue() { let plusAssign = PlusAssign("tuple", 80) diff --git a/Tests/SyntaxKitTests/Unit/Expressions/PlusAssign/PlusAssignLiteralTests.swift b/Tests/SyntaxKitTests/Unit/Expressions/PlusAssign/PlusAssignLiteralTests.swift index 0b1296d3..835ee7c2 100644 --- a/Tests/SyntaxKitTests/Unit/Expressions/PlusAssign/PlusAssignLiteralTests.swift +++ b/Tests/SyntaxKitTests/Unit/Expressions/PlusAssign/PlusAssignLiteralTests.swift @@ -1,13 +1,13 @@ // // PlusAssignLiteralTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT @@ -40,6 +40,7 @@ import Testing internal final class PlusAssignLiteralTests { /// Tests plus assignment with string literal value. @Test("Plus assignment with string literal value generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithStringLiteralValue() { let plusAssign = PlusAssign("message", "Hello") @@ -51,6 +52,7 @@ internal final class PlusAssignLiteralTests { /// Tests plus assignment with numeric literal value. @Test("Plus assignment with numeric literal value generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithNumericLiteralValue() { let plusAssign = PlusAssign("count", 42) @@ -62,6 +64,7 @@ internal final class PlusAssignLiteralTests { /// Tests plus assignment with boolean literal value. @Test("Plus assignment with boolean literal value generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithBooleanLiteralValue() { let plusAssign = PlusAssign("flags", true) @@ -73,6 +76,7 @@ internal final class PlusAssignLiteralTests { /// Tests plus assignment with float literal value. @Test("Plus assignment with float literal value generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithFloatLiteralValue() { let plusAssign = PlusAssign("value", 3.14) diff --git a/Tests/SyntaxKitTests/Unit/Expressions/PlusAssign/PlusAssignPropertyTests.swift b/Tests/SyntaxKitTests/Unit/Expressions/PlusAssign/PlusAssignPropertyTests.swift index 83623ce9..b1cb97a8 100644 --- a/Tests/SyntaxKitTests/Unit/Expressions/PlusAssign/PlusAssignPropertyTests.swift +++ b/Tests/SyntaxKitTests/Unit/Expressions/PlusAssign/PlusAssignPropertyTests.swift @@ -1,13 +1,13 @@ // // PlusAssignPropertyTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT @@ -40,6 +40,7 @@ import Testing internal final class PlusAssignPropertyTests { /// Tests plus assignment with property access variable. @Test("Plus assignment with property access variable generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithPropertyAccessVariable() { let plusAssign = PlusAssign("user.score", 10) @@ -51,6 +52,7 @@ internal final class PlusAssignPropertyTests { /// Tests plus assignment with complex variable expression. @Test("Plus assignment with complex variable expression generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithComplexVariableExpression() { let plusAssign = PlusAssign("getCurrentUser().score", 5) @@ -62,6 +64,7 @@ internal final class PlusAssignPropertyTests { /// Tests plus assignment with nested property access variable. @Test("Plus assignment with nested property access variable generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithNestedPropertyAccessVariable() { let plusAssign = PlusAssign("user.profile.score", 15) @@ -73,6 +76,7 @@ internal final class PlusAssignPropertyTests { /// Tests plus assignment with array element variable. @Test("Plus assignment with array element variable generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithArrayElementVariable() { let plusAssign = PlusAssign("scores[0]", 20) @@ -84,6 +88,7 @@ internal final class PlusAssignPropertyTests { /// Tests plus assignment with dictionary element variable. @Test("Plus assignment with dictionary element variable generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithDictionaryElementVariable() { let plusAssign = PlusAssign("scores[\"player1\"]", 25) @@ -95,6 +100,7 @@ internal final class PlusAssignPropertyTests { /// Tests plus assignment with tuple element variable. @Test("Plus assignment with tuple element variable generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithTupleElementVariable() { let plusAssign = PlusAssign("stats.0", 30) @@ -106,6 +112,7 @@ internal final class PlusAssignPropertyTests { /// Tests plus assignment with computed property variable. @Test("Plus assignment with computed property variable generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithComputedPropertyVariable() { let plusAssign = PlusAssign("self.totalScore", 35) @@ -117,6 +124,7 @@ internal final class PlusAssignPropertyTests { /// Tests plus assignment with static property variable. @Test("Plus assignment with static property variable generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithStaticPropertyVariable() { let plusAssign = PlusAssign("GameManager.totalScore", 40) @@ -128,6 +136,7 @@ internal final class PlusAssignPropertyTests { /// Tests plus assignment with enum case variable. @Test("Plus assignment with enum case variable generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithEnumCaseVariable() { let plusAssign = PlusAssign("ScoreType.bonus", 45) diff --git a/Tests/SyntaxKitTests/Unit/Expressions/PlusAssign/PlusAssignSpecialValueTests.swift b/Tests/SyntaxKitTests/Unit/Expressions/PlusAssign/PlusAssignSpecialValueTests.swift index cea8a543..15f96df9 100644 --- a/Tests/SyntaxKitTests/Unit/Expressions/PlusAssign/PlusAssignSpecialValueTests.swift +++ b/Tests/SyntaxKitTests/Unit/Expressions/PlusAssign/PlusAssignSpecialValueTests.swift @@ -1,13 +1,13 @@ // // PlusAssignSpecialValueTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT @@ -40,6 +40,7 @@ import Testing internal final class PlusAssignSpecialValueTests { /// Tests plus assignment with nil literal value. @Test("Plus assignment with nil literal value generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithNilLiteralValue() { let plusAssign = PlusAssign("optional", Literal.nil) @@ -51,6 +52,7 @@ internal final class PlusAssignSpecialValueTests { /// Tests plus assignment with negative integer value. @Test("Plus assignment with negative integer value generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithNegativeIntegerValue() { let plusAssign = PlusAssign("count", -5) @@ -62,6 +64,7 @@ internal final class PlusAssignSpecialValueTests { /// Tests plus assignment with zero value. @Test("Plus assignment with zero value generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithZeroValue() { let plusAssign = PlusAssign("total", 0) @@ -73,6 +76,7 @@ internal final class PlusAssignSpecialValueTests { /// Tests plus assignment with large integer value. @Test("Plus assignment with large integer value generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithLargeIntegerValue() { let plusAssign = PlusAssign("score", 1_000_000) @@ -84,6 +88,7 @@ internal final class PlusAssignSpecialValueTests { /// Tests plus assignment with empty string value. @Test("Plus assignment with empty string value generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithEmptyStringValue() { let plusAssign = PlusAssign("text", "") @@ -95,6 +100,7 @@ internal final class PlusAssignSpecialValueTests { /// Tests plus assignment with special characters in string value. @Test("Plus assignment with special characters in string value generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithSpecialCharactersInStringValue() { let plusAssign = PlusAssign("message", "Hello\nWorld\t!") @@ -106,6 +112,7 @@ internal final class PlusAssignSpecialValueTests { /// Tests plus assignment with unicode characters in string value. @Test("Plus assignment with unicode characters in string value generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithUnicodeCharactersInStringValue() { let plusAssign = PlusAssign("text", "café") @@ -117,6 +124,7 @@ internal final class PlusAssignSpecialValueTests { /// Tests plus assignment with emoji in string value. @Test("Plus assignment with emoji in string value generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithEmojiInStringValue() { let plusAssign = PlusAssign("message", "Hello 👋") @@ -128,6 +136,7 @@ internal final class PlusAssignSpecialValueTests { /// Tests plus assignment with scientific notation float value. @Test("Plus assignment with scientific notation float value generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithScientificNotationFloatValue() { let plusAssign = PlusAssign("value", 1.23e-4) @@ -139,6 +148,7 @@ internal final class PlusAssignSpecialValueTests { /// Tests plus assignment with infinity float value. @Test("Plus assignment with infinity float value generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithInfinityFloatValue() { let plusAssign = PlusAssign("value", Double.infinity) @@ -150,6 +160,7 @@ internal final class PlusAssignSpecialValueTests { /// Tests plus assignment with NaN float value. @Test("Plus assignment with NaN float value generates correct syntax") + @available(*, deprecated, message: "Exercises deprecated PlusAssign API") internal func testPlusAssignWithNaNFloatValue() { let plusAssign = PlusAssign("value", Double.nan) diff --git a/Tests/SyntaxKitTests/Unit/Expressions/ReferenceExp/ReferenceExpBasicTests.swift b/Tests/SyntaxKitTests/Unit/Expressions/ReferenceExp/ReferenceExpBasicTests.swift index b3a6250c..bb01613f 100644 --- a/Tests/SyntaxKitTests/Unit/Expressions/ReferenceExp/ReferenceExpBasicTests.swift +++ b/Tests/SyntaxKitTests/Unit/Expressions/ReferenceExp/ReferenceExpBasicTests.swift @@ -1,13 +1,13 @@ // // ReferenceExpBasicTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT diff --git a/Tests/SyntaxKitTests/Unit/Expressions/ReferenceExp/ReferenceExpComplexTests.swift b/Tests/SyntaxKitTests/Unit/Expressions/ReferenceExp/ReferenceExpComplexTests.swift index 91a4e6fd..78b76868 100644 --- a/Tests/SyntaxKitTests/Unit/Expressions/ReferenceExp/ReferenceExpComplexTests.swift +++ b/Tests/SyntaxKitTests/Unit/Expressions/ReferenceExp/ReferenceExpComplexTests.swift @@ -1,13 +1,13 @@ // // ReferenceExpComplexTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT diff --git a/Tests/SyntaxKitTests/Unit/Expressions/ReferenceExp/ReferenceExpFunctionTests.swift b/Tests/SyntaxKitTests/Unit/Expressions/ReferenceExp/ReferenceExpFunctionTests.swift index a390e521..647474d5 100644 --- a/Tests/SyntaxKitTests/Unit/Expressions/ReferenceExp/ReferenceExpFunctionTests.swift +++ b/Tests/SyntaxKitTests/Unit/Expressions/ReferenceExp/ReferenceExpFunctionTests.swift @@ -1,13 +1,13 @@ // // ReferenceExpFunctionTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT diff --git a/Tests/SyntaxKitTests/Unit/Expressions/ReferenceExp/ReferenceExpLiteralTests.swift b/Tests/SyntaxKitTests/Unit/Expressions/ReferenceExp/ReferenceExpLiteralTests.swift index f6457a29..a184a35f 100644 --- a/Tests/SyntaxKitTests/Unit/Expressions/ReferenceExp/ReferenceExpLiteralTests.swift +++ b/Tests/SyntaxKitTests/Unit/Expressions/ReferenceExp/ReferenceExpLiteralTests.swift @@ -1,13 +1,13 @@ // // ReferenceExpLiteralTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT diff --git a/Tests/SyntaxKitTests/Unit/Expressions/ReferenceExp/ReferenceExpPropertyTests.swift b/Tests/SyntaxKitTests/Unit/Expressions/ReferenceExp/ReferenceExpPropertyTests.swift index c880cbc4..0786e168 100644 --- a/Tests/SyntaxKitTests/Unit/Expressions/ReferenceExp/ReferenceExpPropertyTests.swift +++ b/Tests/SyntaxKitTests/Unit/Expressions/ReferenceExp/ReferenceExpPropertyTests.swift @@ -1,13 +1,13 @@ // // ReferenceExpPropertyTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT diff --git a/Tests/SyntaxKitTests/Unit/Functions/FunctionTests.swift b/Tests/SyntaxKitTests/Unit/Functions/FunctionTests.swift index 572dd728..4e5605a9 100644 --- a/Tests/SyntaxKitTests/Unit/Functions/FunctionTests.swift +++ b/Tests/SyntaxKitTests/Unit/Functions/FunctionTests.swift @@ -1,3 +1,32 @@ +// +// FunctionTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing diff --git a/Tests/SyntaxKitTests/Unit/Integration/FrameworkCompatibilityTests.swift b/Tests/SyntaxKitTests/Unit/Integration/FrameworkCompatibilityTests.swift index b82a0faf..6b4a9715 100644 --- a/Tests/SyntaxKitTests/Unit/Integration/FrameworkCompatibilityTests.swift +++ b/Tests/SyntaxKitTests/Unit/Integration/FrameworkCompatibilityTests.swift @@ -1,3 +1,32 @@ +// +// FrameworkCompatibilityTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing diff --git a/Tests/SyntaxKitTests/Unit/Integration/OptionsMacroIntegrationTests.swift b/Tests/SyntaxKitTests/Unit/Integration/OptionsMacroIntegrationTests.swift index d687e905..2d36967c 100644 --- a/Tests/SyntaxKitTests/Unit/Integration/OptionsMacroIntegrationTests.swift +++ b/Tests/SyntaxKitTests/Unit/Integration/OptionsMacroIntegrationTests.swift @@ -1,13 +1,13 @@ // // OptionsMacroIntegrationTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT diff --git a/Tests/SyntaxKitTests/Unit/Integration/OptionsMacroIntegrationTestsAPI.swift b/Tests/SyntaxKitTests/Unit/Integration/OptionsMacroIntegrationTestsAPI.swift index 88c26d15..0d10a3c2 100644 --- a/Tests/SyntaxKitTests/Unit/Integration/OptionsMacroIntegrationTestsAPI.swift +++ b/Tests/SyntaxKitTests/Unit/Integration/OptionsMacroIntegrationTestsAPI.swift @@ -1,3 +1,32 @@ +// +// OptionsMacroIntegrationTestsAPI.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing diff --git a/Tests/SyntaxKitTests/Unit/Migration/AssertionMigrationTests.swift b/Tests/SyntaxKitTests/Unit/Migration/AssertionMigrationTests.swift index 7e1d9fc0..7bfbee15 100644 --- a/Tests/SyntaxKitTests/Unit/Migration/AssertionMigrationTests.swift +++ b/Tests/SyntaxKitTests/Unit/Migration/AssertionMigrationTests.swift @@ -1,3 +1,32 @@ +// +// AssertionMigrationTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing diff --git a/Tests/SyntaxKitTests/Unit/Migration/CodeStyleMigrationTests.swift b/Tests/SyntaxKitTests/Unit/Migration/CodeStyleMigrationTests.swift index f10db711..a64f8672 100644 --- a/Tests/SyntaxKitTests/Unit/Migration/CodeStyleMigrationTests.swift +++ b/Tests/SyntaxKitTests/Unit/Migration/CodeStyleMigrationTests.swift @@ -1,3 +1,32 @@ +// +// CodeStyleMigrationTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing diff --git a/Tests/SyntaxKitTests/Unit/Migration/MigrationTests.swift b/Tests/SyntaxKitTests/Unit/Migration/MigrationTests.swift index 490c12c8..26b08dd7 100644 --- a/Tests/SyntaxKitTests/Unit/Migration/MigrationTests.swift +++ b/Tests/SyntaxKitTests/Unit/Migration/MigrationTests.swift @@ -1,3 +1,32 @@ +// +// MigrationTests.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation import Testing diff --git a/Tests/SyntaxKitTests/Unit/SwiftUIFeatureTests.swift b/Tests/SyntaxKitTests/Unit/SwiftUIFeatureTests.swift index 42de7ede..030a8def 100644 --- a/Tests/SyntaxKitTests/Unit/SwiftUIFeatureTests.swift +++ b/Tests/SyntaxKitTests/Unit/SwiftUIFeatureTests.swift @@ -1,13 +1,13 @@ // -// SwiftUIExampleTests.swift -// SyntaxKitTests +// SwiftUIFeatureTests.swift +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT @@ -101,13 +101,13 @@ import Testing if let weakRefExp = weakRef as? ReferenceExp { #expect(weakRefExp.captureReferenceType == .weak) } else { - #expect(false, "Expected ReferenceExp type") + Issue.record("Expected ReferenceExp type") } if let unownedRefExp = unownedRef as? ReferenceExp { #expect(unownedRefExp.captureReferenceType == .unowned) } else { - #expect(false, "Expected ReferenceExp type") + Issue.record("Expected ReferenceExp type") } } diff --git a/Tests/SyntaxKitTests/Unit/Utilities/NormalizeOptions.swift b/Tests/SyntaxKitTests/Unit/Utilities/NormalizeOptions.swift index e4e99688..bf679ec3 100644 --- a/Tests/SyntaxKitTests/Unit/Utilities/NormalizeOptions.swift +++ b/Tests/SyntaxKitTests/Unit/Utilities/NormalizeOptions.swift @@ -1,3 +1,32 @@ +// +// NormalizeOptions.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation /// Options for string normalization @@ -20,8 +49,10 @@ public struct NormalizeOptions: OptionSet, Sendable { /// Options for structural comparison (ignores all formatting) public static let structural: NormalizeOptions = [] + /// The raw value backing this option set. public let rawValue: Int + /// Creates a new instance. public init(rawValue: Int) { self.rawValue = rawValue } diff --git a/Tests/SyntaxKitTests/Unit/Utilities/String+NormalizeExtensions.swift b/Tests/SyntaxKitTests/Unit/Utilities/String+NormalizeExtensions.swift index 075b538b..c9c88bc2 100644 --- a/Tests/SyntaxKitTests/Unit/Utilities/String+NormalizeExtensions.swift +++ b/Tests/SyntaxKitTests/Unit/Utilities/String+NormalizeExtensions.swift @@ -1,3 +1,32 @@ +// +// String+NormalizeExtensions.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + import Foundation extension String { diff --git a/Tests/SyntaxKitTests/Unit/Variables/VariableCoverageTests.swift b/Tests/SyntaxKitTests/Unit/Variables/VariableCoverageTests.swift index 0bda6b3a..da72bde2 100644 --- a/Tests/SyntaxKitTests/Unit/Variables/VariableCoverageTests.swift +++ b/Tests/SyntaxKitTests/Unit/Variables/VariableCoverageTests.swift @@ -1,13 +1,13 @@ // // VariableCoverageTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT diff --git a/Tests/SyntaxKitTests/Unit/Variables/VariableStaticTests.swift b/Tests/SyntaxKitTests/Unit/Variables/VariableStaticTests.swift index 5199d16a..93f169d7 100644 --- a/Tests/SyntaxKitTests/Unit/Variables/VariableStaticTests.swift +++ b/Tests/SyntaxKitTests/Unit/Variables/VariableStaticTests.swift @@ -1,13 +1,13 @@ // // VariableStaticTests.swift -// SyntaxKitTests +// SyntaxKit // // Created by Leo Dion. -// Copyright © 2025 BrightDigit. +// Copyright © 2026 BrightDigit. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without +// files (the “Software”), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the @@ -17,7 +17,7 @@ // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT diff --git a/mise.toml b/mise.toml new file mode 100644 index 00000000..6df20abb --- /dev/null +++ b/mise.toml @@ -0,0 +1,7 @@ +[settings] +experimental = true + +[tools] +"spm:swiftlang/swift-format" = "602.0.0" +"aqua:realm/SwiftLint" = "0.62.2" +"spm:peripheryapp/periphery" = "3.7.4"