Location
public struct Location : CustomStringConvertible, Comparable, Codable, Sendable
The placement of a segment of Swift in a collection of source files.
-
The file path on disk for this location.
Declaration
Swift
public let file: String?
-
The line offset in the file for this location. 1-indexed.
Declaration
Swift
public let line: Int?
-
The character offset in the file for this location. 1-indexed.
Declaration
Swift
public let character: Int?
-
A lossless printable description of this location.
Declaration
Swift
public var description: String { get }
-
The file path for this location relative to the current working directory.
Declaration
Swift
public var relativeFile: String? { get }
-
Creates a
Location
by specifying its properties directly.Declaration
Swift
public init(file: String?, line: Int? = nil, character: Int? = nil)
Parameters
file
The file path on disk for this location.
line
The line offset in the file for this location. 1-indexed.
character
The character offset in the file for this location. 1-indexed.
-
Creates a
Location
based on aSwiftLintFile
and a byte-offset into the file. Fails if the specified offset was not a valid location in the file.Declaration
Swift
public init(file: SwiftLintFile, byteOffset offset: ByteCount)
Parameters
file
The file for this location.
offset
The offset in bytes into the file for this location.
-
Creates a
Location
based on aSwiftLintFile
and a SwiftSyntaxAbsolutePosition
into the file. Fails if the specified offset was not a valid location in the file.Declaration
Swift
public init(file: SwiftLintFile, position: AbsolutePosition)
Parameters
file
The file for this location.
position
The absolute position returned from SwiftSyntax.
-
Creates a
Location
based on aSwiftLintFile
and a UTF8 character-offset into the file. Fails if the specified offset was not a valid location in the file.Declaration
Swift
public init(file: SwiftLintFile, characterOffset offset: Int)
Parameters
file
The file for this location.
offset
The offset in UTF8 fragments into the file for this location.
-
Declaration
Swift
public static func < (lhs: `Self`, rhs: `Self`) -> Bool