Skip to content

Add @retroactive annotations #971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Sources/LSPTestSupport/TestJSONRPCConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,11 @@ private let testMessageRegistry = MessageRegistry(
notifications: [EchoNotification.self]
)

#if swift(<5.10)
extension String: ResponseType {}
#else
extension String: @retroactive ResponseType {}
#endif

public struct EchoRequest: RequestType {
public static var method: String = "test_server/echo"
Expand Down
7 changes: 6 additions & 1 deletion Sources/SKSupport/LoggableMessageTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@ fileprivate extension Encodable {

// MARK: - DocumentURI

extension DocumentURI: CustomLogStringConvertible {
extension DocumentURI {
public var redactedDescription: String {
return "<DocumentURI length=\(description.count) hash=\(description.hashForLogging)>"
}
}
#if swift(<5.10)
extension DocumentURI: CustomLogStringConvertible {}
#else
extension DocumentURI: @retroactive CustomLogStringConvertible {}
#endif

// MARK: - RequestType

Expand Down
8 changes: 7 additions & 1 deletion Sources/SourceKitLSP/IndexStoreDB+MainFilesProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import LSPLogging
import LanguageServerProtocol
import SKCore

extension IndexStoreDB: MainFilesProvider {
extension IndexStoreDB {
public func mainFilesContainingFile(_ uri: DocumentURI) -> Set<DocumentURI> {
let mainFiles: Set<DocumentURI>
if let url = uri.fileURL {
Expand All @@ -30,3 +30,9 @@ extension IndexStoreDB: MainFilesProvider {
return mainFiles
}
}

#if swift(<5.10)
extension IndexStoreDB: MainFilesProvider {}
#else
extension IndexStoreDB: @retroactive MainFilesProvider {}
#endif
25 changes: 22 additions & 3 deletions Sources/sourcekit-lsp/SourceKitLSP.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import struct TSCBasic.AbsolutePath
import struct TSCBasic.RelativePath
import var TSCBasic.localFileSystem

extension AbsolutePath: ExpressibleByArgument {
extension AbsolutePath {
public init?(argument: String) {
let path: AbsolutePath?

Expand All @@ -48,8 +48,13 @@ extension AbsolutePath: ExpressibleByArgument {
.directory
}
}
#if swift(<5.10)
extension AbsolutePath: ExpressibleByArgument {}
#else
extension AbsolutePath: @retroactive ExpressibleByArgument {}
#endif

extension RelativePath: ExpressibleByArgument {
extension RelativePath {
public init?(argument: String) {
let path = try? RelativePath(validating: argument)

Expand All @@ -60,8 +65,13 @@ extension RelativePath: ExpressibleByArgument {
self = path
}
}
#if swift(<5.10)
extension RelativePath: ExpressibleByArgument {}
#else
extension RelativePath: @retroactive ExpressibleByArgument {}
#endif

extension PathPrefixMapping: ExpressibleByArgument {
extension PathPrefixMapping {
public init?(argument: String) {
guard let eqIndex = argument.firstIndex(of: "=") else { return nil }
self.init(
Expand All @@ -70,8 +80,17 @@ extension PathPrefixMapping: ExpressibleByArgument {
)
}
}
#if swift(<5.10)
extension PathPrefixMapping: ExpressibleByArgument {}
#else
extension PathPrefixMapping: @retroactive ExpressibleByArgument {}
#endif

#if swift(<5.10)
extension BuildConfiguration: ExpressibleByArgument {}
#else
extension BuildConfiguration: @retroactive ExpressibleByArgument {}
#endif

@main
struct SourceKitLSP: ParsableCommand {
Expand Down