<commit_before>﻿/// New node structure
class ClassMapNode {
    constructor(public Name: string) {
        this.Children = new Array<ClassMapNode>();
    }

    Children: Array<ClassMapNode>
}

class ClassHierarchyMap {
    RootNode: ClassMapNode = new ClassMapNode("");

    /**
    Looks for an QObject name in the ClassHierarchyMap which is the closest ancestor.
    */
    findClosestParentClassName(oObject: QObject) : string {
        var currentNode = this.RootNode;
        if (oObject == undefined || (oObject instanceof (QObject)) == false) {
            throw String("QObject expected as a parameter");
        }

        do {
            var bNewParentFound: boolean = false;
            for (var i = 0; i < currentNode.Children.length; i++) {
                var sPotentialParentName: string = currentNode.Children[i].Name; 
                               
                if (oObject.inherits(sPotentialParentName) == true) {
                    currentNode = currentNode.Children[i];
                    bNewParentFound = true;
                    break;
                }                                
            }
        }
        while (bNewParentFound == true);

        return currentNode.Name;
    }
}<commit_msg>Extended ClassHierarchyMap functionality<commit_after>﻿/// New node structure
class ClassMapNode {
    constructor(public Name: string) {
        this.Children = new Array<ClassMapNode>();
    }

    Children: Array<ClassMapNode>
}

class ClassHierarchyMap {
    RootNode: ClassMapNode = new ClassMapNode("");

    /**
    Looks for an QObject name in the ClassHierarchyMap which is the closest ancestor.
    */
    findClosestParentClassName(oObject: QObject) : string {
        var currentNode = this.RootNode;
        if (oObject == undefined || (oObject instanceof (QObject)) == false) {
            throw String("QObject expected as a parameter");
        }

        do {
            var bNewParentFound: boolean = false;
            for (var i = 0; i < currentNode.Children.length; i++) {
                var sPotentialParentName: string = currentNode.Children[i].Name; 
                               
                if (oObject.inherits(sPotentialParentName) == true) {
                    currentNode = currentNode.Children[i];
                    bNewParentFound = true;
                    break;
                }                                
            }
        }
        while (bNewParentFound == true);

        return currentNode.Name;
    }

    /** Returns an Array<string> of classnames in the inheritance chain of the specified QObject name.
    @param sQObjectName the QObject class name to search for
    @param oSearchNode ClassMapNode to start the search from. If unspecified will search from RootNode
    */
    getHierarchyPath(sQObjectName: string, oSearchNode?: ClassMapNode): Array<string> {      
        if (oSearchNode == undefined) {
            oSearchNode = this.RootNode;
        }
        var aHierarchyPath: Array<string> = new Array<string>();
        var bTargetNodeFound: boolean = false;

        if (oSearchNode.Name == sQObjectName) {
            aHierarchyPath[0] = oSearchNode.Name;
            return aHierarchyPath;
        }            
        
        for (var i = 0; i < oSearchNode.Children.length; i++) {
            var oChildNode: ClassMapNode = oSearchNode.Children[i];        
            aHierarchyPath = this.getHierarchyPath(sQObjectName, oChildNode);
            if (aHierarchyPath.length > 0) {
                aHierarchyPath = (new Array<string>(oChildNode.Name)).concat(aHierarchyPath);
                return aHierarchyPath;
            }
        }
        return aHierarchyPath;        
    }
}
{'fraction_non_alphanumeric': 0.08906882591093117, 'fraction_numerical': 0.001349527665317139, 'mean_word_length': 1.8662026295436969, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7660870', 'n_tokens_mistral': 1009, 'n_tokens_neox': 967, 'n_words': 251}