<commit_before>define(['./joinId'], function (
           joinId) {

    var merge = function (target, source) {
        for (var k in source) {
            target[k] = source[k];
        }

        return target;
    };

    var localIds = function (index, root) {
        var types = {};

        root.getNestedNodes().forEach(function (node) {
            var id = joinId(node.getId());
            node = index[id];

            if (node.isStruct()) {
                types[id] = null;
                merge(types, localIds(index, node));
            } else if (node.isEnum()) {
                types[id] = null;
            }
        });

        return types;
    };

    var typeId = function (type) {
        var ids = {};

        if (type.isList()) {
            merge(ids, typeId(type.getList().getElementType()));
        } else if (type.isEnum()) {
            ids[joinId(type.getEnum().getTypeId())] = null;
        } else if (type.isStruct()) {
            ids[joinId(type.getStruct().getTypeId())] = null;
        }

        return ids;
    };

    var fieldIds = function (index, root) {
        if (root.isSlot()) {
            return typeId(root.getSlot().getType());
        } else if (root.isGroup()) {
            var node = index[joinId(root.getGroup().getTypeId())];
            var types = {};
            node.getStruct().getFields().forEach(function (field) {
                merge(types, fieldIds(index, field));
            });

            return types;
        }
    };

    var usedIds = function (index, root) {
        var types = {};

        root.getNestedNodes().forEach(function (node) {
            var id = joinId(node.getId());
            node = index[id];

            if (node.isStruct()) {
                node.getStruct().getFields().forEach(function (field) {
                    merge(types, fieldIds(index, field));
                });
                merge(types, usedIds(index, node));
            } else if (node.isEnum()) {
                types[joinId(node.getId())] = null;
            } else if (node.isConst()) {
                merge(types, typeId(node.getConst().getType()));
            }
        });

        return types;
    };

    return function (requestedFiles, nodes) {
        var index = {};
        nodes.forEach(function (node) {
            index[joinId(node.getId())] = node;
        });

        var fileIds = {}; // typeId -> fileId
        nodes.forEach(function (node) {
            if (node.isFile()) {
                var fileId = joinId(node.getId());
                for (var k in localIds(index, node)) {
                    fileIds[k] = fileId;
                }
            }
        });

        var usedTypes = {}; // fileId -> typeIds
        nodes.forEach(function (node) {
            if (node.isFile()) {
                var id = joinId(node.getId());
                usedTypes[id] = Object.keys(usedIds(index, node));
            }
        });

        var importers = {};
        requestedFiles.forEach(function (file) {
            var importPaths = {};
            file.getImports().forEach(function (i) {
                importPaths[joinId(i.getId())] = i.getName().asString();
            });

            var importerId = joinId(file.getId());

            var imports = {};<commit_msg>Use toString instead of asString<commit_after>define(['./joinId'], function (
           joinId) {

    var merge = function (target, source) {
        for (var k in source) {
            target[k] = source[k];
        }

        return target;
    };

    var localIds = function (index, root) {
        var types = {};

        root.getNestedNodes().forEach(function (node) {
            var id = joinId(node.getId());
            node = index[id];

            if (node.isStruct()) {
                types[id] = null;
                merge(types, localIds(index, node));
            } else if (node.isEnum()) {
                types[id] = null;
            }
        });

        return types;
    };

    var typeId = function (type) {
        var ids = {};

        if (type.isList()) {
            merge(ids, typeId(type.getList().getElementType()));
        } else if (type.isEnum()) {
            ids[joinId(type.getEnum().getTypeId())] = null;
        } else if (type.isStruct()) {
            ids[joinId(type.getStruct().getTypeId())] = null;
        }

        return ids;
    };

    var fieldIds = function (index, root) {
        if (root.isSlot()) {
            return typeId(root.getSlot().getType());
        } else if (root.isGroup()) {
            var node = index[joinId(root.getGroup().getTypeId())];
            var types = {};
            node.getStruct().getFields().forEach(function (field) {
                merge(types, fieldIds(index, field));
            });

            return types;
        }
    };

    var usedIds = function (index, root) {
        var types = {};

        root.getNestedNodes().forEach(function (node) {
            var id = joinId(node.getId());
            node = index[id];

            if (node.isStruct()) {
                node.getStruct().getFields().forEach(function (field) {
                    merge(types, fieldIds(index, field));
                });
                merge(types, usedIds(index, node));
            } else if (node.isEnum()) {
                types[joinId(node.getId())] = null;
            } else if (node.isConst()) {
                merge(types, typeId(node.getConst().getType()));
            }
        });

        return types;
    };

    return function (requestedFiles, nodes) {
        var index = {};
        nodes.forEach(function (node) {
            index[joinId(node.getId())] = node;
        });

        var fileIds = {}; // typeId -> fileId
        nodes.forEach(function (node) {
            if (node.isFile()) {
                var fileId = joinId(node.getId());
                for (var k in localIds(index, node)) {
                    fileIds[k] = fileId;
                }
            }
        });

        var usedTypes = {}; // fileId -> typeIds
        nodes.forEach(function (node) {
            if (node.isFile()) {
                var id = joinId(node.getId());
                usedTypes[id] = Object.keys(usedIds(index, node));
            }
        });

        var importers = {};
        requestedFiles.forEach(function (file) {
            var importPaths = {};
            file.getImports().forEach(function (i) {
                importPaths[joinId(i.getId())] = i.getName().toString();
            });

            var importerId = joinId(file.getId());

            var imports = {};
{'fraction_non_alphanumeric': 0.14908152421436163, 'fraction_numerical': 0.0, 'mean_word_length': 1.4832265359969845, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6372604', 'n_tokens_mistral': 1857, 'n_tokens_neox': 1807, 'n_words': 374}