diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 01cce58414d..5a1eedb8ec8 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -4,12 +4,14 @@ on: pull_request: types: [opened, reopened, synchronize] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: tests: name: Test uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main - with: - linux_exclude_swift_versions: "[{\"swift_version\": \"5.8\"}]" soundness: name: Soundness uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main diff --git a/BUILD.bazel b/BUILD.bazel index 1360cff9043..5a710ddeeb4 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -219,6 +219,8 @@ swift_syntax_library( ":SwiftSyntax509", ":SwiftSyntax510", ":SwiftSyntax600", + ":SwiftSyntax601", + ":SwiftSyntax602", ":_SwiftSyntaxCShims", ], ) @@ -251,6 +253,13 @@ swift_syntax_library( ], ) +swift_syntax_library( + name = "SwiftSyntax602", + srcs = glob(["Sources/VersionMarkerModules/SwiftSyntax602/**/*.swift"]), + deps = [ + ], +) + swift_syntax_library( name = "SwiftSyntaxBuilder", deps = [ @@ -376,6 +385,7 @@ cc_library( cc_library( name = "_SwiftSyntaxCShims", + srcs = glob(["Sources/_SwiftSyntaxCShims/*.c"]), hdrs = glob(["Sources/_SwiftSyntaxCShims/include/*.h"]), includes = ["Sources/_SwiftSyntaxCShims/include"], tags = ["swift_module=_SwiftSyntaxCShims"], diff --git a/Package.swift b/Package.swift index 43df607866b..5c20ee04b86 100644 --- a/Package.swift +++ b/Package.swift @@ -210,7 +210,9 @@ let package = Package( .target( name: "SwiftSyntax", - dependencies: ["_SwiftSyntaxCShims", "SwiftSyntax509", "SwiftSyntax510", "SwiftSyntax600"], + dependencies: [ + "_SwiftSyntaxCShims", "SwiftSyntax509", "SwiftSyntax510", "SwiftSyntax600", "SwiftSyntax601", "SwiftSyntax602", + ], exclude: ["CMakeLists.txt"], swiftSettings: swiftSyntaxSwiftSettings ), diff --git a/Sources/SwiftDiagnostics/DiagnosticsFormatter.swift b/Sources/SwiftDiagnostics/DiagnosticsFormatter.swift index 28f4d18bf4e..9717ecb4ac7 100644 --- a/Sources/SwiftDiagnostics/DiagnosticsFormatter.swift +++ b/Sources/SwiftDiagnostics/DiagnosticsFormatter.swift @@ -293,10 +293,13 @@ public struct DiagnosticsFormatter { ) ) - // If the line did not end with \n (e.g. the last line), append it manually - if annotatedSource.last != "\n" { - annotatedSource.append("\n") + // Remove any trailing newline and replace it; this may seem + // counterintuitive, but if we're running within CMake and we let a + // '\r\n' through, CMake will turn that into *two* newlines. + if let last = annotatedSource.last, last.isNewline { + annotatedSource.removeLast() } + annotatedSource.append("\n") let columnsWithDiagnostics = Set( annotatedLine.diagnostics.map { @@ -331,8 +334,13 @@ public struct DiagnosticsFormatter { } // Add suffix text. - annotatedSource.append(annotatedLine.suffixText) - if annotatedSource.last != "\n" { + if !annotatedLine.suffixText.isEmpty { + annotatedSource.append(annotatedLine.suffixText) + + // See above for an explanation of why we do this + if let last = annotatedSource.last, last.isNewline { + annotatedSource.removeLast() + } annotatedSource.append("\n") } } diff --git a/Sources/SwiftOperators/OperatorTable+Folding.swift b/Sources/SwiftOperators/OperatorTable+Folding.swift index c1c4f7f6025..3c2c63d3e97 100644 --- a/Sources/SwiftOperators/OperatorTable+Folding.swift +++ b/Sources/SwiftOperators/OperatorTable+Folding.swift @@ -141,7 +141,6 @@ extension OperatorTable { if let unsafeExpr = lhs.as(UnsafeExprSyntax.self) { return ExprSyntax( UnsafeExprSyntax( - leadingTrivia: unsafeExpr.leadingTrivia, unsafeExpr.unexpectedBeforeUnsafeKeyword, unsafeKeyword: unsafeExpr.unsafeKeyword, unsafeExpr.unexpectedBetweenUnsafeKeywordAndExpression, @@ -150,8 +149,7 @@ extension OperatorTable { op: op, rhs: rhs ), - unsafeExpr.unexpectedAfterExpression, - trailingTrivia: unsafeExpr.trailingTrivia + unsafeExpr.unexpectedAfterExpression ) ) } diff --git a/Sources/VersionMarkerModules/CMakeLists.txt b/Sources/VersionMarkerModules/CMakeLists.txt index 52457d79b36..467d4aa2202 100644 --- a/Sources/VersionMarkerModules/CMakeLists.txt +++ b/Sources/VersionMarkerModules/CMakeLists.txt @@ -14,3 +14,7 @@ add_library(${SWIFTSYNTAX_TARGET_NAMESPACE}SwiftSyntax510 STATIC SwiftSyntax509/Empty.swift) add_library(${SWIFTSYNTAX_TARGET_NAMESPACE}SwiftSyntax600 STATIC SwiftSyntax509/Empty.swift) +add_library(${SWIFTSYNTAX_TARGET_NAMESPACE}SwiftSyntax601 STATIC + SwiftSyntax509/Empty.swift) +add_library(${SWIFTSYNTAX_TARGET_NAMESPACE}SwiftSyntax602 STATIC + SwiftSyntax509/Empty.swift) \ No newline at end of file diff --git a/Tests/SwiftOperatorsTest/OperatorTableTests.swift b/Tests/SwiftOperatorsTest/OperatorTableTests.swift index e4c81c4605b..47e5bd2ad2f 100644 --- a/Tests/SwiftOperatorsTest/OperatorTableTests.swift +++ b/Tests/SwiftOperatorsTest/OperatorTableTests.swift @@ -435,4 +435,10 @@ class OperatorPrecedenceTests: XCTestCase { } } + + func testTriviaAroundUnsafeExpr() throws { + let original = ExprSyntax("/*leading*/ unsafe a /*trailing*/ + b") + let folded = try OperatorTable.standardOperators.foldAll(original) + XCTAssertEqual(original.description, folded.description) + } }