// SPDX-FileCopyrightText: 2025 The Project Pterodactyl Developers // // SPDX-License-Identifier: MPL-2.0 import Foundation /// An abstract syntax view around a ``SyntaxCursor``. This is to be populated by extensions targetting specific `G`. struct SyntaxView { let cursor: SyntaxCursor init?(_ cursor: SyntaxCursor) { guard let kind = cursor.node.tree?.kind, G.kinds.contains(kind) else { return nil } self.cursor = cursor } func matchingSubview() -> SyntaxView? { return cursor.firstChild(mapping: SyntaxView.init) } func matchingSubviews() -> [SyntaxView] { return cursor.children(mapping: SyntaxView.init) } }