func inherits()

in Generator/Sources/NeedleFramework/Utilities/SwiftSyntaxExtensions.swift [29:39]


    func inherits(from typeName: String) -> Bool {
        
        let inheritedTypeSyntax = inheritanceClause?.inheritedTypeCollection.first?.typeName
        // Usually, first token is the inherited type name. But sometimes it could also be the module prefix.
        // In that case, we need to look for the actual type name by checking for `MemberTypeIdentifierSyntax`
        if inheritedTypeSyntax?.firstToken?.nextToken?.tokenKind != TokenKind.period {
            return inheritedTypeSyntax?.firstToken?.text == typeName
        } else {
            return inheritedTypeSyntax?.as(MemberTypeIdentifierSyntax.self)?.name.text == typeName
        }
    }