validateAndGetRoles = function(parsedContent, roles, range, entityName, entityType) {
    let newRoles = roles ? roles.split(',').map(item => item.replace(/[\'\"]/g, "").trim()) : [];
    // de-dupe roles
    newRoles = [...new Set(newRoles)];
    // entity roles need to unique within the application
    if(parsedContent.LUISJsonStructure.flatListOfEntityAndRoles) {
        // Duplicate entity names are not allowed
        // Entity name cannot be same as a role name
        verifyUniqueEntityName(parsedContent, entityName, entityType, range);

        newRoles.forEach(role => {
            let roleFound = parsedContent.LUISJsonStructure.flatListOfEntityAndRoles.find(item => item.roles.includes(role) || item.name === role);
            if (roleFound !== undefined) {
                // PL entities use roles for things like interchangeable, disabled, enabled for all models. There are really not 'dupes'.
                let hasBadNonPLRoles = (roleFound.roles || []).filter(item => item.toLowerCase() !== PLCONSTS.INTERCHANGEABLE && item.toLowerCase() !== PLCONSTS.ENABLEDFORALLMODELS && item.toLowerCase() !== PLCONSTS.DISABLED && item.toLowerCase() !== PLCONSTS.DISABLEDFORALLMODELS);
                if (hasBadNonPLRoles.length !== 0) {
                    let errorMsg = `Roles must be unique across entity types. Invalid role definition found "${entityName}". Prior definition - '@ ${roleFound.type} ${roleFound.name}${roleFound.roles.length > 0 ? ` hasRoles ${roleFound.roles.join(',')}` : ``}'`;
                    let error = BuildDiagnostic({
                        message: errorMsg,
                        range: range
                    })
                    throw (new exception(retCode.errorCode.INVALID_INPUT, error.toString(), [error]));
                } 
            } 
        });

        let oldEntity = parsedContent.LUISJsonStructure.flatListOfEntityAndRoles.find(item => item.name === entityName && item.type === entityType);
        if (oldEntity !== undefined) {
            oldEntity.addRoles(newRoles);
        } else {
            parsedContent.LUISJsonStructure.flatListOfEntityAndRoles.push(new helperClass.entityAndRoles(entityName, entityType, newRoles))
        }

    } else {
        parsedContent.LUISJsonStructure.flatListOfEntityAndRoles = new Array();
        parsedContent.LUISJsonStructure.flatListOfEntityAndRoles.push(new helperClass.entityAndRoles(entityName, entityType, newRoles));
    }
    return newRoles;
}
Helper function to validate that new roles being added are unique at the application level.
@param {Object} parsedContent with that contains list of additional files to parse, parsed LUIS object and parsed QnA object
@param {String[]} roles string array of new roles to be added
@param {String} range range
@param {String} entityName name of the entity being added.