function toCamelCase(paramStr) {
return paramStr.toLowerCase().replace(/_[a-z]/g, str => str[1].toUpperCase());
}
function hasTable($txaBefore, asisTableName) {
return $txaBefore.value.includes(asisTableName);
}
function replaceWord(paramStr, asis, tobe, isTable, tobeColumnComment, afterColumnList, tobeTableNmae) {
if (isTable) {
tobe = TABLE_SCHEMA + '.' + tobe;
}
if (tobe.includes(NOT_EXIST_TEXT) {
tobe = `${asis} /* ${asis}(AS-IS) ${NOT_EXIST_TEXT} in ${tobeTableName}(TO-BE) */`;
tobeColumnComment = '';
}
if (!isTable) {
const regExpStrForComment = `(?<=([^_A-Za-z]))${asis}[ ]*?(?=([\\n]))`;
const regExpForComment = new RegExp(regExpStrForComment, 'g');
const regExpStrForCommentTobe = `(?<=([^_A-Za-z]))${tobe}[ ]*?(?=([\\n]))`;
const regExpForCommentTobe = new RegExp(regExpStrForCommentTobe, 'g');
if (tobeColumnComment != null && tobeColumnComment.length > 0) {
paramStr = paramStr.replace(regExpForComment, tobe + ` /* ${tobeColumnComment} */ `);
paramStr = paramStr.replace(regExpForCommentTobe, tobe + ` /* ${tobeColumnComment} */`);
}
const regExpStr = `(?<=([^_A-Za-z]))${asis}?(?=([\\s}\\)\\,]))`;
const regExp = new RegExp(regExpStr, 'g');
paramStr = paramStr.replace(regExp, tobe);
const regExpTobe = `(?<=([^_A-Za-z]))${tobe}?(?=([\\s}\\)\\,]))`;
if (afterColumnList != null && paramStr.search(regExpTobe) >= 0 && !tobe.includes(NOT_EXIST_TEXT)) {
const contains = afterColumnList.some(item => item.substring(0, toCamelCase(tobe).length) == toCamelCase(tobe));
if (!contains) {
afterColumnList.push(`${toCamelCase(tobe)}(${tobeColumnComment}`);
}
}
}
return paramStr
}