Kind
Each diagnostic kind is uniquely represented by a value in this enum.
enum Kind
Each diagnostic kind is uniquely represented by a value in this enum.
enum Kind
import SwiftSyntax
A library for working with Swift code.
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.
case editorPlaceholder
case equalMustHaveConsistentWhitespaceOnBothSides
case expectedBinaryExponentInHexFloatLiteral
case expectedClosingBraceInUnicodeEscape
case expectedDigitInFloatLiteral
case expectedHexCodeInUnicodeEscape
case expectedHexDigitInHexLiteral
case extraneousLeadingWhitespaceError
case extraneousLeadingWhitespaceWarning
case extraneousTrailingWhitespaceError
case extraneousTrailingWhitespaceWarning
case insufficientIndentationInMultilineStringLiteral
case invalidBinaryDigitInIntegerLiteral
case invalidCharacter
case invalidDecimalDigitInIntegerLiteral
case invalidEscapeSequenceInStringLiteral
case invalidFloatingPointExponentCharacter
case invalidFloatingPointExponentDigit
case invalidHexDigitInIntegerLiteral
case invalidIdentifierStartCharacter
case invalidNumberOfHexDigitsInUnicodeEscape
case invalidOctalDigitInIntegerLiteral
case invalidUtf8
case multilineRegexClosingNotOnNewline
case nonBreakingSpace
case nulCharacter
case sourceConflictMarker
case spaceAtEndOfRegexLiteral
case spaceAtStartOfRegexLiteral
case tokenDiagnosticOffsetOverflow
The lexer discovered an error but was not able to represent the offset of the error because it would overflow LexerErrorOffset
.
case unexpectedBlockCommentEnd
case unicodeCurlyQuote
case unprintableAsciiCharacter
case unterminatedBlockComment
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 Severity
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.
static func != (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether two values are not equal.