export function isInString(code, position) {
    const normalizedCodigo = code.replace(/\r\n/g, '\n');
    const before = normalizedCodigo.substring(0, position);
    const singleQuotesBefore = (before.match(/(?<!\\)'/g) || []).length;
    const doubleQuotesBefore = (before.match(/(?<!\\)"/g) || []).length;
    const templateQuotesBefore = (before.match(/(?<!\\)`/g) || []).length;
    return singleQuotesBefore % 2 === 1 || doubleQuotesBefore % 2 === 1 || templateQuotesBefore % 2 === 1;
}
export function isInComment(code, position) {
    const normalizedCodigo = code.replace(/\r\n/g, '\n');
    const lines = normalizedCodigo.split('\n');
    let pos = 0;
    for (let indice = 0; indice < lines.length; indice++) {
        const line = lines[indice];
        const lineInicio = pos;
        const lineFim = pos + line.length;
        if (position >= lineInicio && position <= lineFim) {
            const posInLine = position - lineInicio;
            const commentInicio = line.indexOf('//');
            if (commentInicio !== -1 && posInLine >= commentInicio) {
                return true;
            }
            const blockInicio = normalizedCodigo.lastIndexOf('/*', position);
            const blockFim = normalizedCodigo.indexOf('*/', position);
            if (blockInicio !== -1 && (blockFim === -1 || blockFim > position)) {
                return true;
            }
            return false;
        }
        pos = lineFim + 1;
    }
    return false;
}
export function isInStringOrComment(code, position) {
    return isInString(code, position) || isInComment(code, position);
}
//# sourceMappingURL=context-utils.js.map