/**
 * Base Language Plugin
 *
 * Provides common functionality for all language plugins.
 */
/**
 * Abstract base class for language plugins.
 * Provides default implementations for common methods.
 */
export class BaseLanguagePlugin {
    parser = null;
    async initialize(parser) {
        this.parser = parser;
    }
    canHandle(filePath) {
        const lowerPath = filePath.toLowerCase();
        return this.extensions.some(ext => {
            const normalizedExt = ext.startsWith('.') ? ext : `.${ext}`;
            return lowerPath.endsWith(normalizedExt);
        });
    }
    // Default implementations for optional methods
    detectFramework(context) {
        return undefined;
    }
    getReceiverType(node, context) {
        return undefined;
    }
    isStringLiteral(node) {
        return node.type === 'string_literal' || node.type === 'string';
    }
    getStringValue(node) {
        if (!this.isStringLiteral(node))
            return undefined;
        const text = node.text;
        // Remove quotes
        if ((text.startsWith('"') && text.endsWith('"')) ||
            (text.startsWith("'") && text.endsWith("'"))) {
            return text.slice(1, -1);
        }
        return text;
    }
    /**
     * Helper to get text from a node
     */
    getNodeText(node) {
        return node.text;
    }
    /**
     * Helper to find all nodes of a given type
     */
    findNodes(root, type) {
        const nodes = [];
        const cursor = root.walk();
        const visit = () => {
            if (cursor.nodeType === type) {
                nodes.push(cursor.currentNode);
            }
            if (cursor.gotoFirstChild()) {
                do {
                    visit();
                } while (cursor.gotoNextSibling());
                cursor.gotoParent();
            }
        };
        visit();
        return nodes;
    }
    /**
     * Helper to find first child of given type
     */
    findChildByType(node, type) {
        for (let i = 0; i < node.childCount; i++) {
            const child = node.child(i);
            if (child?.type === type) {
                return child;
            }
        }
        return null;
    }
}
//# sourceMappingURL=base.js.map