SKCodeCompletionSession

open class SKCodeCompletionSession : NSObject

Represents a SourceKit code completion session, which can be filtered using update requests.

  • The session source file.

    Declaration

    Swift

    public let file: File
  • The byte offset of the code completion point inside the session’s source contents.

    Declaration

    Swift

    public let offset: Offset
  • The mutable code completion session options.

    These options can (should) be modified before sending an update().

    Declaration

    Swift

    public var options: SKCodeCompletionSession.Options?
  • Whether previous requests should be canceled if a new request is made that uses different options.

    Note

    The previous requests are not actually canceled (because they are asynchronous, and that ship has sailed); however, the completion handler will only be called with the response of the most recently sent request.

    Declaration

    Swift

    public var cancelOnSubsequentRequest: Bool
  • A closure that receives the code completion request responses.

    Declaration

    Swift

    public var completionHandler: SKCodeCompletionSession.CompletionHandler?
  • A closure that receives any code completion request errors.

    Declaration

    Swift

    public var errorHandler: SKCodeCompletionSession.ErrorHandler?
  • Whether the session is open.

    This boolean indicates whether the session has been opened (open()) and not closed (close()).

    Declaration

    Swift

    public internal(set) var isOpen: Bool
  • The most recent request response received in the session.

    Declaration

    Swift

    public internal(set) var latestResponse: SKCodeCompletionSession.Response?
  • Whether there are any outstanding session requests awaiting completion.

    Declaration

    Swift

    public var isActive: Bool { get }
  • Whether the session has been closed (close()).

    Note

    This property will also be false if the session has not yet been opened (open()).

    Declaration

    Swift

    public var isClosed: Bool { get }
  • The number of outstanding session requests awaiting completion.

    Declaration

    Swift

    public var queueRequestCount: Int { get }
  • Initializes a new SourceKit code completion session object.

    Note

    This request needs to be opened (via the open() method).

    Declaration

    Swift

    public init(file: File,
                offset: Offset,
                compilerArguments: [String])

    Parameters

    file

    The source file.

    offset

    The byte offset of the code completion point inside the source contents.

    compilerArguments

    The compiler arguments used to build the module.

  • Initializes a new SourceKit code completion session object.

    Note

    This request needs to be opened (via the open() method).

    Declaration

    Swift

    public convenience init(file: File,
                            offset: Offset,
                            sdkPath: String,
                            target: String? = nil)

    Parameters

    file

    The source file.

    offset

    The source code byte offset to use in the SourceKit request.

    sdkPath

    The path to the SDK to compile against.

    target

    The target (triple) architecture to generate completions for (e.g. "arm64-apple-ios12.1").

  • Initializes a new SourceKit code completion session object.

    Note

    This request needs to be opened (via the open() method).

    Declaration

    Swift

    public convenience init(filePath: String,
                            offset: Offset,
                            compilerArguments: [String])

    Parameters

    filePath

    The file path of the source file.

    offset

    The byte offset of code completion point inside the source contents.

    compilerArguments

    The compiler arguments used to build the module.

  • Initializes a new SourceKit code completion session object.

    Note

    This request needs to be opened (via the open() method).

    Declaration

    Swift

    public convenience init(contents: String,
                            offset: Offset,
                            compilerArguments: [String])

    Parameters

    contents

    The source code contents.

    offset

    The byte offset of code completion point inside the source contents.

    compilerArguments

    The compiler arguments used to build the module.

  • Initializes a new SourceKit code completion session object.

    Note

    This request needs to be opened (via the open() method).

    Declaration

    Swift

    public convenience init(filePath: String,
                            offset: Offset,
                            sdkPath: String,
                            target: String? = nil)

    Parameters

    filePath

    The file path of the source file.

    offset

    The byte offset of code completion point inside the source contents.

    sdkPath

    The path to the SDK to compile against.

    target

    The target (triple) architecture to generate completions for (e.g. "arm64-apple-ios12.1").

  • Initializes a new SourceKit code completion session object.

    Note

    This request needs to be opened (via the open() method).

    Declaration

    Swift

    public convenience init(contents: String,
                            offset: Offset,
                            sdkPath: String,
                            target: String? = nil)

    Parameters

    contents

    The source contents.

    offset

    The byte offset of code completion point inside the source contents.

    sdkPath

    The path to the SDK to compile against.

    target

    The target (triple) architecture to generate completions for (e.g. "arm64-apple-ios12.1").

  • Opens the code completion session for the file at the byte offset with the specified options.

    Declaration

    Swift

    public func open()
  • Updates an open code completion session with the specified options.

    Declaration

    Swift

    public func update()
  • Closes an opened code completion session.

    Declaration

    Swift

    public func close()