<commit_before>/* @internal */
namespace ts.codefix {
    const fixId = "addMissingConstInForLoop";
    const errorCodes = [
        Diagnostics.Cannot_find_name_0.code, 
        Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.code
    ];

    registerCodeFix({
        errorCodes,
        getCodeActions: (context) => {
            const changes = textChanges.ChangeTracker.with(context, t => makeChange(t, context.sourceFile, context.span.start));
            if (changes.length > 0) {
                return [createCodeFixAction(fixId, changes, Diagnostics.Add_const_to_unresolved_variable, fixId, Diagnostics.Add_const_to_all_unresolved_variables)];
            }
        },
        fixIds: [fixId],
        getAllCodeActions: context => {
            const fixedNodes = new NodeSet();
            return codeFixAll(context, errorCodes, (changes, diag) => makeChange(changes, diag.file, diag.start, fixedNodes));
        },
    });

    function makeChange(changeTracker: textChanges.ChangeTracker, sourceFile: SourceFile, pos: number, fixedNodes?: NodeSet<Node>) {
        const forInitializer = findAncestor(getTokenAtPosition(sourceFile, pos), node =>
            isForInOrOfStatement(node.parent) ? node.parent.initializer === node
                : isPossiblyPartOfDestructuring(node) ? false : "quit");
        if (!forInitializer) return;
        if (!fixedNodes || fixedNodes.tryAdd(forInitializer)) {
            changeTracker.insertNodeBefore(sourceFile, forInitializer, createToken(SyntaxKind.ConstKeyword));
        }
    }
<commit_msg>Fix whitespace issue in codefix file<commit_after>/* @internal */
namespace ts.codefix {
    const fixId = "addMissingConstInForLoop";
    const errorCodes = [
        Diagnostics.Cannot_find_name_0.code,
        Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.code
    ];

    registerCodeFix({
        errorCodes,
        getCodeActions: (context) => {
            const changes = textChanges.ChangeTracker.with(context, t => makeChange(t, context.sourceFile, context.span.start));
            if (changes.length > 0) {
                return [createCodeFixAction(fixId, changes, Diagnostics.Add_const_to_unresolved_variable, fixId, Diagnostics.Add_const_to_all_unresolved_variables)];
            }
        },
        fixIds: [fixId],
        getAllCodeActions: context => {
            const fixedNodes = new NodeSet();
            return codeFixAll(context, errorCodes, (changes, diag) => makeChange(changes, diag.file, diag.start, fixedNodes));
        },
    });

    function makeChange(changeTracker: textChanges.ChangeTracker, sourceFile: SourceFile, pos: number, fixedNodes?: NodeSet<Node>) {
        const forInitializer = findAncestor(getTokenAtPosition(sourceFile, pos), node =>
            isForInOrOfStatement(node.parent) ? node.parent.initializer === node
                : isPossiblyPartOfDestructuring(node) ? false : "quit");
        if (!forInitializer) return;
        if (!fixedNodes || fixedNodes.tryAdd(forInitializer)) {
            changeTracker.insertNodeBefore(sourceFile, forInitializer, createToken(SyntaxKind.ConstKeyword));
        }
    }

{'fraction_non_alphanumeric': 0.1014760147601476, 'fraction_numerical': 0.0018450184501845018, 'mean_word_length': 3.297225891677675, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '7552406', 'n_tokens_mistral': 937, 'n_tokens_neox': 918, 'n_words': 159}