<commit_before>var acorn = require('acorn');

var hierarchy = {};
var nonHierarchicalNodes = [];

function isExpressionStatement (node) {
    return node.type === 'ExpressionStatement';
}

function isCallExpression (node) {
    return node.type === 'CallExpression';
}

function createHierarchyNode (parentName, childName) {
    if (hierarchy[childName] !== undefined) { return undefined; }

    hierarchy[childName] = {
        ast: null,
        filePath: '',
        children: [],
        parentName: parentName
    };
}

function createNonHierarchicalNode (content, filePath) {
    nonHierarchicalNodes.push({
        content: content,
        filePath: filePath
    });
}

function parseFile(grunt, filePath) {
    var content = grunt.file.read(filePath);

    var ast = acorn.parse(content, {
        sourceType: 'script',
        ecmaVersion: 6
    });

    if (filePath === 'js/Main.js') {
        if (!parseExtend(ast, filePath) && !parseClass(ast, filePath)) {
            createNonHierarchicalNode(content, filePath);
        }
    }
}

function parseExtend (ast, filePath) {
    for (var i = 0, max = ast.body.length; i < max; i++) {
        var node = ast.body[i];

        if (isExpressionStatement(node) && isCallExpression(node.expression)) {
            node = node.expression;

            if (node.callee.name === 'extend') {
                var parentName = node.arguments[0].value;
                var childName = node.arguments[1].value;

                createHierarchyNode('', parentName);
                createHierarchyNode(parentName, childName);

                hierarchy[parentName].children.push(childName);

                hierarchy[childName].ast = ast;
                hierarchy[childName].filePath = filePath;

                return true;
            }
        }
    }

    return false;
}

function parseClass (ast, filePath) {
    for (var i = 0, max = ast.body.length; i < max; i++) {

    }

    return false;
}

module.exports = function (grunt, task, taskData, tmpDir, files) {
    for (var i = 0, max = files.length; i < max; i++) {
        parseFile(grunt, files[i]);
    }
};<commit_msg>{Update: parse.js} Module restructure.<commit_after>var acorn = require('acorn');

var hierarchy = {};
var nonHierarchicalNodes = [];

function isExpressionStatement (node) {
    return node.type === 'ExpressionStatement';
}

function isCallExpression (node) {
    return node.type === 'CallExpression';
}

function isAssignmentExpression (node) {
    return node.type === 'AssignmentExpression' && node.operator === '=';
}

function isMemberExpression (node) {
    return node.type === 'MemberExpression';
}

function isIdentifier (node) {
    return node.type === 'Identifier';
}

function createHierarchyNode (name) {
    if (hierarchy[name] !== undefined) { return undefined; }

    hierarchy[name] = {
        append: null,
        children: [],
        filePath: '',
        parentName: '',
        constructor: null
    };
}

function createNonHierarchicalNode (content, filePath) {
    nonHierarchicalNodes.push({
        content: content,
        filePath: filePath
    });
}

function parseFile(grunt, filePath) {
    var content = grunt.file.read(filePath);

    var ast = acorn.parse(content, {
        sourceType: 'script',
        ecmaVersion: 6
    });

    if (filePath === 'js/Main.js') {
        var parseOne = parseExtend(ast);
        var parseTwo = parseClass(ast, filePath);

        if (!parseOne && !parseTwo) {
            createNonHierarchicalNode(content, filePath);
        }
    }
}

function parseExtend (ast) {
    for (var i = 0, max = ast.body.length; i < max; i++) {
        var node = ast.body[i];

        if (isExpressionStatement(node) && isCallExpression(node.expression)) {
            node = node.expression;

            if (node.callee.name === 'extend') {
                var parentName = node.arguments[0].value;
                var childName = node.arguments[1].value;

                createHierarchyNode(parentName);
                createHierarchyNode(childName);

                hierarchy[parentName].children.push(childName);

                hierarchy[childName].parentName = parentName;

                return true;
            }
        }
    }

    return false;
}

function parseClass (ast, filePath) {
    var append = null;
    var constructor = null;

    for (var i = 0, max = ast.body.length; i < max; i++) {
        var node = ast.body[i];

        if (isExpressionStatement(node) && isAssignmentExpression(node.expression)) {
            var node = node.expression;
        }
    }

    if (constructor === null || append === null) { return false; }

    var name = '';

    return true;
}

module.exports = function (grunt, task, taskData, tmpDir, files) {
    for (var i = 0, max = files.length; i < max; i++) {
        parseFile(grunt, files[i]);
    }
};
{'fraction_non_alphanumeric': 0.13158978583196046, 'fraction_numerical': 0.002471169686985173, 'mean_word_length': 2.42524682651622, 'pattern_counts': {'":': 0, '<': 9, '<?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': '2458270', 'n_tokens_mistral': 1469, 'n_tokens_neox': 1433, 'n_words': 332}