|
|
@ -10,10 +10,24 @@ async function handle(filename) { |
|
|
|
let clzName; |
|
|
|
let clzName; |
|
|
|
if (inheritRegResult) { |
|
|
|
if (inheritRegResult) { |
|
|
|
clzName = inheritRegResult[1]; |
|
|
|
clzName = inheritRegResult[1]; |
|
|
|
|
|
|
|
// 把
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
const clzRegResult = /export\sclass\s(.*?)\sextend/.exec(code); |
|
|
|
const clzRegResult = /export\sclass\s(.*?)\sextend/.exec(code); |
|
|
|
|
|
|
|
|
|
|
|
if (clzRegResult) { |
|
|
|
if (clzRegResult) { |
|
|
|
clzName = clzRegResult[1]; |
|
|
|
clzName = clzRegResult[1]; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const xtypeResult = /static xtype = (.*?)(;|\s)/.exec(code); |
|
|
|
|
|
|
|
// 找一下 xtype
|
|
|
|
|
|
|
|
if (xtypeResult) { |
|
|
|
|
|
|
|
depts[xtypeResult[1]] = { |
|
|
|
|
|
|
|
clzName, |
|
|
|
|
|
|
|
clzPath: filename, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// console.log(`${filename} 没有 xtype`);
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
depts[clzName] = filename; |
|
|
|
depts[clzName] = filename; |
|
|
@ -43,13 +57,21 @@ async function initDepts() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function search(src, clzName) { |
|
|
|
function search(src, module) { |
|
|
|
|
|
|
|
let clzName = module; |
|
|
|
|
|
|
|
let clzPath = depts[module]; |
|
|
|
|
|
|
|
|
|
|
|
if (!depts[clzName]) { |
|
|
|
if (!depts[clzName]) { |
|
|
|
return ""; |
|
|
|
return ""; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const dstName = path.basename(depts[clzName]).replace(/.js$/g, ""); |
|
|
|
if (clzName.indexOf("\"") >= 0) { |
|
|
|
const dstPath = path.normalize(depts[clzName]).split("src")[1].split("\\").join("/").split("/"); |
|
|
|
clzName = depts[module].clzName; |
|
|
|
|
|
|
|
clzPath = depts[module].clzPath; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const dstName = path.basename(clzPath).replace(/.js$/g, ""); |
|
|
|
|
|
|
|
const dstPath = path.normalize(clzPath).split("src")[1].split("\\").join("/").split("/"); |
|
|
|
const srcPath = path.normalize(src).split("src")[1].split("\\").join("/").split("/"); |
|
|
|
const srcPath = path.normalize(src).split("src")[1].split("\\").join("/").split("/"); |
|
|
|
|
|
|
|
|
|
|
|
// console.log("src", src);
|
|
|
|
// console.log("src", src);
|
|
|
@ -60,8 +82,6 @@ function search(src, clzName) { |
|
|
|
srcPath.shift(); |
|
|
|
srcPath.shift(); |
|
|
|
srcPath.pop(); |
|
|
|
srcPath.pop(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const findDstIndexPath = (dstArr, startIndex) => { |
|
|
|
const findDstIndexPath = (dstArr, startIndex) => { |
|
|
|
let i = startIndex; |
|
|
|
let i = startIndex; |
|
|
|
|
|
|
|
|
|
|
@ -100,12 +120,6 @@ function search(src, clzName) { |
|
|
|
// dstPath 也没有了
|
|
|
|
// dstPath 也没有了
|
|
|
|
if (i < dstPath.length) { |
|
|
|
if (i < dstPath.length) { |
|
|
|
return result + findDstIndexPath(dstPath, i); |
|
|
|
return result + findDstIndexPath(dstPath, i); |
|
|
|
// 还有好多没有匹配完
|
|
|
|
|
|
|
|
// while (i < srcPath) {
|
|
|
|
|
|
|
|
// // exists(srcPath.slice(0, i).join())
|
|
|
|
|
|
|
|
// result += srcPath[i];
|
|
|
|
|
|
|
|
// i++;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
} else if (i === dstPath.length) { |
|
|
|
} else if (i === dstPath.length) { |
|
|
|
return `${result}${dstName}`; |
|
|
|
return `${result}${dstName}`; |
|
|
|
} |
|
|
|
} |
|
|
@ -124,6 +138,7 @@ function search(src, clzName) { |
|
|
|
|
|
|
|
|
|
|
|
exports.initDepts = initDepts; |
|
|
|
exports.initDepts = initDepts; |
|
|
|
exports.search = search; |
|
|
|
exports.search = search; |
|
|
|
|
|
|
|
exports.depts = depts; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|