<commit_before>const AbstractRecursivePass = Jymfony.Component.DependencyInjection.Compiler.AbstractRecursivePass;
const Reference = Jymfony.Component.DependencyInjection.Reference;

/**
 * @memberOf Jymfony.Component.DependencyInjection.Compiler
 */
module.exports = class ReplaceAliasByActualDefinitionPass extends AbstractRecursivePass {
    process(container) {
        // First collect all alias targets that need to be replaced
        const seenAliasTargets = {};
        const replacements = {};
        for (const [ definitionId, target ] of __jymfony.getEntries(container.getAliases())) {
            const targetId = target.toString();

            // Special case: leave this target alone
            if ('service_container' === targetId) {
                continue;
            }

            // Check if target needs to be replaces
            if (replacements[targetId]) {
                container.setAlias(definitionId, replacements[targetId]);
            }

            // No need to process the same target twice
            if (seenAliasTargets[targetId]) {
                continue;
            }

            // Process new target
            seenAliasTargets[targetId] = true;

            let definition;
            try {
                definition = container.getDefinition(targetId);
            } catch (e) {
                throw new InvalidArgumentException(`Unable to replace alias "${definitionId}" with actual definition "${targetId}".`, e);
            }

            if (definition.isPublic()) {
                continue;
            }

            // Remove private definition and schedule for replacement
            definition.setPublic(true);
            container.setDefinition(definitionId, definition);
            container.removeDefinition(targetId);

            replacements[targetId] = definitionId;
        }

        this._replacements = replacements;

        super.process(container);
        this._replacements = {};
    }

    _processValue(value, isRoot = false) {
        if (value instanceof Reference && undefined !== this._replacements[value.toString()]) {
            // Perform the replacement.
            const newId = this._replacements[value.toString()];
            const value = new Reference(newId, value.invalidBehavior);
            this._container.log(this, __jymfony.sprintf('Changed reference of service "%s" previously pointing to "%s" to "%s".', this._currentId, value.toString(), newId));
        }

        return super._processValue(value, isRoot);
    }
};<commit_msg>[HttpServer] handle exceptions correctly<commit_after>const AbstractRecursivePass = Jymfony.Component.DependencyInjection.Compiler.AbstractRecursivePass;
const Reference = Jymfony.Component.DependencyInjection.Reference;

/**
 * @memberOf Jymfony.Component.DependencyInjection.Compiler
 */
module.exports = class ReplaceAliasByActualDefinitionPass extends AbstractRecursivePass {
    process(container) {
        // First collect all alias targets that need to be replaced
        const seenAliasTargets = {};
        const replacements = {};
        for (const [ definitionId, target ] of __jymfony.getEntries(container.getAliases())) {
            const targetId = target.toString();

            // Special case: leave this target alone
            if ('service_container' === targetId) {
                continue;
            }

            // Check if target needs to be replaces
            if (replacements[targetId]) {
                container.setAlias(definitionId, replacements[targetId]);
            }

            // No need to process the same target twice
            if (seenAliasTargets[targetId]) {
                continue;
            }

            // Process new target
            seenAliasTargets[targetId] = true;

            let definition;
            try {
                definition = container.getDefinition(targetId);
            } catch (e) {
                throw new InvalidArgumentException(`Unable to replace alias "${definitionId}" with actual definition "${targetId}".`, e);
            }

            if (definition.isPublic()) {
                continue;
            }

            // Remove private definition and schedule for replacement
            definition.setPublic(true);
            container.setDefinition(definitionId, definition);
            container.removeDefinition(targetId);

            replacements[targetId] = definitionId;
        }

        this._replacements = replacements;

        super.process(container);
        this._replacements = {};
    }

    _processValue(value, isRoot = false) {
        if (value instanceof Reference && undefined !== this._replacements[value.toString()]) {
            // Perform the replacement.
            const newId = this._replacements[value.toString()];
            value = new Reference(newId, value.invalidBehavior);

            this._container.log(this, __jymfony.sprintf('Changed reference of service "%s" previously pointing to "%s" to "%s".', this._currentId, value.toString(), newId));
        }

        return super._processValue(value, isRoot);
    }
};
{'fraction_non_alphanumeric': 0.09538702111024237, 'fraction_numerical': 0.0, 'mean_word_length': 2.206140350877193, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '409442', 'n_tokens_mistral': 1239, 'n_tokens_neox': 1184, 'n_words': 304}