// SPDX-FileCopyrightText: 2025 The Project Pterodactyl Developers // // SPDX-License-Identifier: MPL-2.0 import Foundation import LanguageServerProtocol public enum Keyword: String, Codable, Sendable, CaseIterable { case theory = "theory" case `where` = "where" case `import` = "import" } public enum Punctuation: String, CaseIterable, Codable, Equatable, Sendable { case lparen = "(" case rparen = ")" case lbrace = "{" case rbrace = "}" case comma = "," case dot = "." case colon = ":" case doubleLeftArrow = "<=" case doubleRightArrow = "=>" case equal = "=" } public enum TokenKind: Codable, Equatable, Sendable, Hashable { case eof case keyword(Keyword) case punctuation(Punctuation) case error case identifier case newline case whitespace case blockBegin case blockEnd case blockSep case lineComment case blockComment(terminated: Bool) } extension TokenKind { public var isTrivia: Bool { switch self { case .whitespace, .newline, .lineComment, .blockComment: true default: false } } public var isVisible: Bool { switch self { case .whitespace, .blockBegin, .blockSep, .blockEnd, .newline: false default: true } } public var canDetermineLayoutColumn: Bool { switch self { case .whitespace, .eof: false default: true } } public var isBlockHerald: Bool { switch self { case .keyword(.where): true default: false } } } public final class SyntaxTreeKind: Codable, Equatable, Sendable { static let error: SyntaxTreeKind = .init(name: "error") public static func == (lhs: SyntaxTreeKind, rhs: SyntaxTreeKind) -> Bool { lhs === rhs } let name: String var description: String { name } required init(name: String) { self.name = name } } public struct TokenMetadata: Equatable, Codable, Sendable { public var semanticTokenType: SemanticTokenTypes public var semanticTokenModifiers: Set = [] public var delimitedFoldingRangeKind: FoldingRangeKind? = nil } public struct SyntaxTreeMetadata: Codable, Equatable, Sendable { public var delimitedFoldingRangeKind: FoldingRangeKind? = nil }