TokenDiagnostic
If the token has an error that’s inherent to the token itself and not its surrounding structure, this defines the type of the error. byteOffset
specifies at which offset the error occurred.
struct TokenDiagnostic
If the token has an error that’s inherent to the token itself and not its surrounding structure, this defines the type of the error. byteOffset
specifies at which offset the error occurred.
struct TokenDiagnostic
import SwiftSyntax
A library for working with Swift code.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable : Equatable
A type that can be hashed into a Hasher
to produce an integer hash value.
protocol Sendable
A thread-safe type whose values can be shared across arbitrary concurrent contexts without introducing a risk of data races. Values of the type may have no shared mutable state, or they may protect that state with a lock or by forcing it to only be accessed from a specific actor.
init(_ kind: TokenDiagnostic.Kind, byteOffset: Int)
Construct a diagnostic of the given kind
that is anchored at byteOffset
, measured in UTF-8 bytes relative to the leading trivia start of the token this diagnostic will be attached to.
init(_ kind: TokenDiagnostic.Kind, byteOffset: UInt16)
Construct a diagnostic of the given kind
that is anchored at byteOffset
, measured in UTF-8 bytes relative to the leading trivia start of the token this diagnostic will be attached to.
init?(combining lhs: TokenDiagnostic?, _ rhs: TokenDiagnostic?)
Picks the more severe error of lhs
and rhs
, preferring lhs
if they have the same severity.
let byteOffset: UInt16
The offset at which the error is, in bytes relative to the token’s leading trivia start (i.e. relative to the token’s position
)
let kind: TokenDiagnostic.Kind
The unique kind of this diagnostic.
var severity: TokenDiagnostic.Severity { get }
The severity of the diagnostic, i.e. whether it’s a warning or error.
enum Kind
Each diagnostic kind is uniquely represented by a value in this enum.
enum Severity
static func != (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether two values are not equal.
import SwiftParserDiagnostics
func diagnosticMessage(in token: TokenSyntax) -> any DiagnosticMessage
tokenText
is the entire text of the token in which the TokenDiagnostic
occurred, including trivia.
func fixIts(in token: TokenSyntax) -> [FixIt]
func position(in token: TokenSyntax) -> AbsolutePosition