mirror of
https://gitee.com/openharmony/napi_generator
synced 2024-11-23 08:20:01 +00:00
重构超大深度函数
Signed-off-by: gou-jingjing <goujingjing@kaihong.com>
This commit is contained in:
parent
ddb21b8dc8
commit
26373fcbdd
@ -315,20 +315,7 @@ class AnalyzeCommand {
|
||||
return true;
|
||||
}
|
||||
if (e.endsWith(".rsp")) {
|
||||
console.log(Tool.CURRENT_DIR);
|
||||
let rspth = path.join(Tool.CURRENT_DIR, e.substring(1));
|
||||
let data = fs.readFileSync(rspth, { encoding: "utf8" });
|
||||
if (data.endsWith("\r\n")) {
|
||||
data = data.substring(0, data.length - 2);
|
||||
}
|
||||
let datas = data.split(" ");
|
||||
for (let d of datas) {
|
||||
for (let s of ss) {
|
||||
if (d.endsWith(s)) {
|
||||
local.ret.inputs.push(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
clangCheck7RspEnds(e, local);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -635,6 +622,24 @@ class AnalyzeCommand {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function clangCheck7RspEnds(e, local) {
|
||||
console.log(Tool.CURRENT_DIR);
|
||||
let rspth = path.join(Tool.CURRENT_DIR, e.substring(1));
|
||||
let data = fs.readFileSync(rspth, { encoding: "utf8" });
|
||||
if (data.endsWith("\r\n")) {
|
||||
data = data.substring(0, data.length - 2);
|
||||
}
|
||||
let datas = data.split(" ");
|
||||
for (let d of datas) {
|
||||
for (let s of ss) {
|
||||
if (d.endsWith(s)) {
|
||||
local.ret.inputs.push(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
AnalyzeCommand
|
||||
}
|
@ -70,15 +70,7 @@ class AnalyzeMake {
|
||||
acmd += l;
|
||||
}
|
||||
else {
|
||||
acmd += l;
|
||||
if (acmd.length > 0) {
|
||||
cmdlist.push(acmd);
|
||||
let ret = AnalyzeCommand.analyze(acmd);
|
||||
if (ret.length > 0) {
|
||||
analyzeResult.push(...ret);
|
||||
}
|
||||
}
|
||||
acmd = "";
|
||||
acmd = getAcmd(acmd, l);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -120,6 +112,19 @@ class AnalyzeMake {
|
||||
}
|
||||
}
|
||||
|
||||
function getAcmd(acmd, l) {
|
||||
acmd += l;
|
||||
if (acmd.length > 0) {
|
||||
cmdlist.push(acmd);
|
||||
let ret = AnalyzeCommand.analyze(acmd);
|
||||
if (ret.length > 0) {
|
||||
analyzeResult.push(...ret);
|
||||
}
|
||||
}
|
||||
acmd = "";
|
||||
return acmd;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
AnalyzeMake
|
||||
AnalyzeMake
|
||||
}
|
@ -29,31 +29,35 @@ function saveMockData(projectPath, analyzeResult) {
|
||||
|
||||
function preProcessResult(analyzeResult) {//把所有路径搞成绝对路径
|
||||
for (let r of analyzeResult) {
|
||||
if (!r.target.startsWith("/")) {
|
||||
if (!path.isAbsolute(r.target)) {
|
||||
r.target = path.join(r.workDir, r.target);
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < r.inputs.length; i++) {
|
||||
if (r.inputs[i].startsWith('"') && r.inputs[i].endsWith('"')) {
|
||||
r.inputs[i] = r.inputs[i].substring(1, r.inputs[i].length - 1);
|
||||
}
|
||||
if (!r.inputs[i].startsWith("/")) {
|
||||
if (!path.isAbsolute(r.inputs[i])) {
|
||||
r.inputs[i] = path.join(r.workDir, r.inputs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < r.includes.length; i++) {
|
||||
if (!r.includes[i].startsWith("/")) {
|
||||
if (!path.isAbsolute(r.includes[i])) {
|
||||
r.includes[i] = path.join(r.workDir, r.includes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
changePathToAbs(r);
|
||||
}
|
||||
}
|
||||
|
||||
function changePathToAbs(r) {
|
||||
if (!r.target.startsWith("/")) {
|
||||
if (!path.isAbsolute(r.target)) {
|
||||
r.target = path.join(r.workDir, r.target);
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < r.inputs.length; i++) {
|
||||
if (r.inputs[i].startsWith('"') && r.inputs[i].endsWith('"')) {
|
||||
r.inputs[i] = r.inputs[i].substring(1, r.inputs[i].length - 1);
|
||||
}
|
||||
if (!r.inputs[i].startsWith("/")) {
|
||||
if (!path.isAbsolute(r.inputs[i])) {
|
||||
r.inputs[i] = path.join(r.workDir, r.inputs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < r.includes.length; i++) {
|
||||
if (!r.includes[i].startsWith("/")) {
|
||||
if (!path.isAbsolute(r.includes[i])) {
|
||||
r.includes[i] = path.join(r.workDir, r.includes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkoutLibName(name) {//比如/home/libabc.so,返回["dynamic",abc]
|
||||
let pn = path.parse(name);
|
||||
let tname = pn.base;
|
||||
|
@ -39,23 +39,26 @@ function analyzeSubInterface(data) {
|
||||
if (t === "") break // 如果t为空直接返回
|
||||
let tt = re.match(" *([a-zA-Z0-9_]+) *: *([a-zA-Z_0-9<>,:{}[\\] ]+)", t)
|
||||
if (tt) { // 变量
|
||||
|
||||
let valueName = re.getReg(t, tt.regs[1])
|
||||
let valueType = re.getReg(t, tt.regs[2])
|
||||
let index = valueType.indexOf("number")
|
||||
while (index !== -1) {
|
||||
valueType = valueType.replace("number", "NUMBER_TYPE_" + NumberIncrease.getAndIncrease())
|
||||
index = valueType.indexOf("number")
|
||||
}
|
||||
result.value.push({
|
||||
name: valueName,
|
||||
type: valueType
|
||||
})
|
||||
analyzeSubInterfaceVal(t, tt, result);
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
function analyzeSubInterfaceVal(t, tt, result) {
|
||||
let valueName = re.getReg(t, tt.regs[1]);
|
||||
let valueType = re.getReg(t, tt.regs[2]);
|
||||
let index = valueType.indexOf("number");
|
||||
while (index !== -1) {
|
||||
valueType = valueType.replace("number", "NUMBER_TYPE_" + NumberIncrease.getAndIncrease());
|
||||
index = valueType.indexOf("number");
|
||||
}
|
||||
result.value.push({
|
||||
name: valueName,
|
||||
type: valueType
|
||||
});
|
||||
}
|
||||
|
||||
function getFuncParaType(v, interfaceName, data, results) {
|
||||
let arrayType = re.match("(Async)*Callback<(Array<([a-zA-Z_0-9]+)>)>", v["type"])
|
||||
let parameter = v["type"]
|
||||
|
@ -72,32 +72,12 @@ function analyzeInterface(data, rsltInterface = null, results, interfaceName = '
|
||||
if (t == "") break // 如果t为空直接返回
|
||||
let tt = re.match(" *([a-zA-Z0-9_]+)(\\?*)*: *([a-zA-Z_0-9<>,:{}[\\]| ]+)", t)
|
||||
if (tt && t.indexOf("=>") < 0) { // 接口成员变量, 但不包括带'=>'的成员,带'=>'的接口成员需要按函数处理
|
||||
let valueName = re.getReg(t, tt.regs[1])
|
||||
let valueType = re.getReg(t, tt.regs[3])
|
||||
let index = valueType.indexOf("number")
|
||||
let optionalFlag = re.getReg(t, tt.regs[2]) == '?' ? true : false;
|
||||
while (index !== -1) {
|
||||
valueType = valueType.replace("number", "NUMBER_TYPE_" + NumberIncrease.getAndIncrease())
|
||||
index = valueType.indexOf("number")
|
||||
}
|
||||
valueType = analyzeNoNameInterface(valueType, valueName, rsltInterface)
|
||||
result.value.push({
|
||||
name: valueName,
|
||||
type: valueType,
|
||||
realType: valueType,
|
||||
optional: optionalFlag
|
||||
})
|
||||
analyzeInterfaceVariable(t, tt, rsltInterface, result);
|
||||
}
|
||||
tt = re.match("(static )* *(\\$*[A-Za-z0-9_]+) *[:]? *\\(([\n 'a-zA-Z\'\'\"\":;=,_0-9?<>{}()=>|[\\]]*)\\)"
|
||||
+ " *(:|=>)? *([A-Za-z0-9_<>{}:;, .[\\]]+)?", t)
|
||||
if (tt) { // 接口函数成员
|
||||
let ret = re.getReg(t, tt.regs[5]) == ''? 'void': re.getReg(t, tt.regs[5])
|
||||
let funcDetail = analyzeFunction(data, re.getReg(t, tt.regs[1]) != '', re.getReg(t, tt.regs[2]),
|
||||
re.getReg(t, tt.regs[3]), ret, results, interfaceName)
|
||||
if (funcDetail != null) {
|
||||
// 完全一样的方法不重复添加 (如同名同参的AsyncCallback和Promise方法)
|
||||
addUniqFunc2List(funcDetail, result.function)
|
||||
}
|
||||
analyzeInterfaceFunction(t, tt, data, results, interfaceName, result);
|
||||
}
|
||||
}
|
||||
return result
|
||||
@ -106,4 +86,32 @@ function analyzeInterface(data, rsltInterface = null, results, interfaceName = '
|
||||
module.exports = {
|
||||
analyzeInterface,
|
||||
parseNotes
|
||||
}
|
||||
}
|
||||
|
||||
function analyzeInterfaceFunction(t, tt, data, results, interfaceName, result) {
|
||||
let ret = re.getReg(t, tt.regs[5]) == '' ? 'void' : re.getReg(t, tt.regs[5]);
|
||||
let funcDetail = analyzeFunction(data, re.getReg(t, tt.regs[1]) != '', re.getReg(t, tt.regs[2]),
|
||||
re.getReg(t, tt.regs[3]), ret, results, interfaceName);
|
||||
if (funcDetail != null) {
|
||||
// 完全一样的方法不重复添加 (如同名同参的AsyncCallback和Promise方法)
|
||||
addUniqFunc2List(funcDetail, result.function);
|
||||
}
|
||||
}
|
||||
|
||||
function analyzeInterfaceVariable(t, tt, rsltInterface, result) {
|
||||
let valueName = re.getReg(t, tt.regs[1]);
|
||||
let valueType = re.getReg(t, tt.regs[3]);
|
||||
let index = valueType.indexOf("number");
|
||||
let optionalFlag = re.getReg(t, tt.regs[2]) == '?' ? true : false;
|
||||
while (index !== -1) {
|
||||
valueType = valueType.replace("number", "NUMBER_TYPE_" + NumberIncrease.getAndIncrease());
|
||||
index = valueType.indexOf("number");
|
||||
}
|
||||
valueType = analyzeNoNameInterface(valueType, valueName, rsltInterface);
|
||||
result.value.push({
|
||||
name: valueName,
|
||||
type: valueType,
|
||||
realType: valueType,
|
||||
optional: optionalFlag
|
||||
});
|
||||
}
|
||||
|
@ -48,24 +48,28 @@ function analyzeType(data, rsltInterface = null) { // same as class
|
||||
if (t == "") break // 如果t为空直接返回
|
||||
let tt = re.match(" *([a-zA-Z0-9_]+)(\\?*)*: *([a-zA-Z_0-9<>,:{}[\\]| ]+)", t)
|
||||
if (tt && t.indexOf("=>") < 0) { // 接口成员变量, 但不包括带'=>'的成员,带'=>'的接口成员需要按函数处理
|
||||
let valueName = re.getReg(t, tt.regs[1])
|
||||
let valueType = re.getReg(t, tt.regs[3])
|
||||
let index = valueType.indexOf("number")
|
||||
let optionalFlag = re.getReg(t, tt.regs[2]) == '?' ? true : false;
|
||||
while (index !== -1) {
|
||||
valueType = valueType.replace("number", "NUMBER_TYPE_" + NumberIncrease.getAndIncrease())
|
||||
index = valueType.indexOf("number")
|
||||
}
|
||||
result.value.push({
|
||||
name: valueName,
|
||||
type: valueType,
|
||||
optional: optionalFlag
|
||||
})
|
||||
analyzeTypeVariable(t, tt, result);
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
function analyzeTypeVariable(t, tt, result) {
|
||||
let valueName = re.getReg(t, tt.regs[1]);
|
||||
let valueType = re.getReg(t, tt.regs[3]);
|
||||
let index = valueType.indexOf("number");
|
||||
let optionalFlag = re.getReg(t, tt.regs[2]) == '?' ? true : false;
|
||||
while (index !== -1) {
|
||||
valueType = valueType.replace("number", "NUMBER_TYPE_" + NumberIncrease.getAndIncrease());
|
||||
index = valueType.indexOf("number");
|
||||
}
|
||||
result.value.push({
|
||||
name: valueName,
|
||||
type: valueType,
|
||||
optional: optionalFlag
|
||||
});
|
||||
}
|
||||
|
||||
function analyzeType2(data) {
|
||||
let body = re.replaceAll(data, " ", "").split("'|'")
|
||||
let result = {
|
||||
|
@ -39,12 +39,7 @@ function generateGYP(destDir, implName, license, bindingCpp) {
|
||||
let s2 = license.substring(2, license.length - 2).split("\n");
|
||||
license = "";
|
||||
for (let i = 1; i < s2.length; i++) {
|
||||
if (s2[i].length > 0) {
|
||||
while (s2[i][0] == " ") s2[i] = s2[i].substring(1);
|
||||
if (s2[i].length > 3 && s2[i][0] == "*") {
|
||||
license += "#" + s2[i].substring(1) + "\n";
|
||||
}
|
||||
}
|
||||
license = getLicense(s2, i, license);
|
||||
}
|
||||
}
|
||||
writeFile(re.pathJoin(destDir, "binding.gyp"), null != license ? (license + "\n" + ss) : ss)
|
||||
@ -53,6 +48,17 @@ function generateGYP(destDir, implName, license, bindingCpp) {
|
||||
|
||||
}
|
||||
|
||||
function getLicense(s2, i, license) {
|
||||
if (s2[i].length > 0) {
|
||||
while (s2[i][0] == " ")
|
||||
s2[i] = s2[i].substring(1);
|
||||
if (s2[i].length > 3 && s2[i][0] == "*") {
|
||||
license += "#" + s2[i].substring(1) + "\n";
|
||||
}
|
||||
}
|
||||
return license;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
generateGYP
|
||||
generateGYP
|
||||
}
|
@ -56,20 +56,26 @@ function generateGN(destDir, implName, license, partName, buildCpp) {
|
||||
gnFile = gnFile.replaceAll("[subsystemName]", subsystemName);
|
||||
gnFile = gnFile.replaceAll("[partName]", partName);
|
||||
if (license) {
|
||||
let s2 = license.substring(2, license.length - 2).split("\n");
|
||||
license = "";
|
||||
for (let i = 1; i < s2.length; i++) {
|
||||
if (s2[i].length > 0) {
|
||||
while (s2[i][0] == " ") s2[i] = s2[i].substring(1);
|
||||
if (s2[i].length > 3 && s2[i][0] == "*") {
|
||||
license += "#" + s2[i].substring(1) + "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
license = getGnLicense(license);
|
||||
}
|
||||
writeFile(re.pathJoin(destDir, "BUILD.gn"), null != license ? (license + "\n" + gnFile) : gnFile)
|
||||
}
|
||||
|
||||
function getGnLicense(license) {
|
||||
let s2 = license.substring(2, license.length - 2).split("\n");
|
||||
license = "";
|
||||
for (let i = 1; i < s2.length; i++) {
|
||||
if (s2[i].length > 0) {
|
||||
while (s2[i][0] == " ")
|
||||
s2[i] = s2[i].substring(1);
|
||||
if (s2[i].length > 3 && s2[i][0] == "*") {
|
||||
license += "#" + s2[i].substring(1) + "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
return license;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
generateGN
|
||||
generateGN
|
||||
}
|
@ -39,23 +39,26 @@ function analyzeSubInterface(data) {
|
||||
if (t === "") break // 如果t为空直接返回
|
||||
let tt = re.match(" *([a-zA-Z0-9_]+) *: *([a-zA-Z_0-9<>,:{}[\\] ]+)", t)
|
||||
if (tt) { // 变量
|
||||
|
||||
let valueName = re.getReg(t, tt.regs[1])
|
||||
let valueType = re.getReg(t, tt.regs[2])
|
||||
let index = valueType.indexOf("number")
|
||||
while (index !== -1) {
|
||||
valueType = valueType.replace("number", "NUMBER_TYPE_" + NumberIncrease.getAndIncrease())
|
||||
index = valueType.indexOf("number")
|
||||
}
|
||||
result.value.push({
|
||||
name: valueName,
|
||||
type: valueType
|
||||
})
|
||||
analyzeSubInterfaceVariable(t, tt, result);
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
function analyzeSubInterfaceVariable(t, tt, result) {
|
||||
let valueName = re.getReg(t, tt.regs[1]);
|
||||
let valueType = re.getReg(t, tt.regs[2]);
|
||||
let index = valueType.indexOf("number");
|
||||
while (index !== -1) {
|
||||
valueType = valueType.replace("number", "NUMBER_TYPE_" + NumberIncrease.getAndIncrease());
|
||||
index = valueType.indexOf("number");
|
||||
}
|
||||
result.value.push({
|
||||
name: valueName,
|
||||
type: valueType
|
||||
});
|
||||
}
|
||||
|
||||
function getFuncParaType(v, interfaceName, data, results) {
|
||||
let arrayType = re.match("(Async)*Callback<(Array<([a-zA-Z_0-9]+)>)>", v["type"])
|
||||
let parameter = v["type"]
|
||||
|
@ -72,31 +72,12 @@ function analyzeInterface(data, rsltInterface = null, results, interfaceName = '
|
||||
if (t == "") break // 如果t为空直接返回
|
||||
let tt = re.match(" *([a-zA-Z0-9_]+)(\\?*)*: *([a-zA-Z_0-9<>,:{}[\\]| ]+)", t)
|
||||
if (tt && t.indexOf("=>") < 0) { // 接口成员变量, 但不包括带'=>'的成员,带'=>'的接口成员需要按函数处理
|
||||
let valueName = re.getReg(t, tt.regs[1])
|
||||
let valueType = re.getReg(t, tt.regs[3])
|
||||
let index = valueType.indexOf("number")
|
||||
let optionalFlag = re.getReg(t, tt.regs[2]) == '?' ? true : false;
|
||||
while (index !== -1) {
|
||||
valueType = valueType.replace("number", "NUMBER_TYPE_" + NumberIncrease.getAndIncrease())
|
||||
index = valueType.indexOf("number")
|
||||
}
|
||||
valueType = analyzeNoNameInterface(valueType, valueName, rsltInterface)
|
||||
result.value.push({
|
||||
name: valueName,
|
||||
type: valueType,
|
||||
optional: optionalFlag
|
||||
})
|
||||
analyzeInterfaceVariable(t, tt, rsltInterface, result);
|
||||
}
|
||||
tt = re.match("(static )* *(\\$*[A-Za-z0-9_]+) *[:]? *\\(([\n 'a-zA-Z\'\'\"\":;=,_0-9?<>{}()=>|[\\]]*)\\)"
|
||||
+ " *(:|=>)? *([A-Za-z0-9_<>{}:;, .[\\]]+)?", t)
|
||||
if (tt) { // 接口函数成员
|
||||
let ret = re.getReg(t, tt.regs[5]) == ''? 'void': re.getReg(t, tt.regs[5])
|
||||
let funcDetail = analyzeFunction(data, re.getReg(t, tt.regs[1]) != '', re.getReg(t, tt.regs[2]),
|
||||
re.getReg(t, tt.regs[3]), ret, results, interfaceName)
|
||||
if (funcDetail != null) {
|
||||
// 完全一样的方法不重复添加 (如同名同参的AsyncCallback和Promise方法)
|
||||
addUniqFunc2List(funcDetail, result.function)
|
||||
}
|
||||
analyzeInterfaceFunction(t, tt, data, results, interfaceName, result);
|
||||
}
|
||||
}
|
||||
return result
|
||||
@ -105,4 +86,31 @@ function analyzeInterface(data, rsltInterface = null, results, interfaceName = '
|
||||
module.exports = {
|
||||
analyzeInterface,
|
||||
parseNotes
|
||||
}
|
||||
}
|
||||
|
||||
function analyzeInterfaceFunction(t, tt, data, results, interfaceName, result) {
|
||||
let ret = re.getReg(t, tt.regs[5]) == '' ? 'void' : re.getReg(t, tt.regs[5]);
|
||||
let funcDetail = analyzeFunction(data, re.getReg(t, tt.regs[1]) != '', re.getReg(t, tt.regs[2]),
|
||||
re.getReg(t, tt.regs[3]), ret, results, interfaceName);
|
||||
if (funcDetail != null) {
|
||||
// 完全一样的方法不重复添加 (如同名同参的AsyncCallback和Promise方法)
|
||||
addUniqFunc2List(funcDetail, result.function);
|
||||
}
|
||||
}
|
||||
|
||||
function analyzeInterfaceVariable(t, tt, rsltInterface, result) {
|
||||
let valueName = re.getReg(t, tt.regs[1]);
|
||||
let valueType = re.getReg(t, tt.regs[3]);
|
||||
let index = valueType.indexOf("number");
|
||||
let optionalFlag = re.getReg(t, tt.regs[2]) == '?' ? true : false;
|
||||
while (index !== -1) {
|
||||
valueType = valueType.replace("number", "NUMBER_TYPE_" + NumberIncrease.getAndIncrease());
|
||||
index = valueType.indexOf("number");
|
||||
}
|
||||
valueType = analyzeNoNameInterface(valueType, valueName, rsltInterface);
|
||||
result.value.push({
|
||||
name: valueName,
|
||||
type: valueType,
|
||||
optional: optionalFlag
|
||||
});
|
||||
}
|
||||
|
@ -48,24 +48,28 @@ function analyzeType(data, rsltInterface = null) { // same as class
|
||||
if (t == "") break // 如果t为空直接返回
|
||||
let tt = re.match(" *([a-zA-Z0-9_]+)(\\?*)*: *([a-zA-Z_0-9<>,:{}[\\]| ]+)", t)
|
||||
if (tt && t.indexOf("=>") < 0) { // 接口成员变量, 但不包括带'=>'的成员,带'=>'的接口成员需要按函数处理
|
||||
let valueName = re.getReg(t, tt.regs[1])
|
||||
let valueType = re.getReg(t, tt.regs[3])
|
||||
let index = valueType.indexOf("number")
|
||||
let optionalFlag = re.getReg(t, tt.regs[2]) == '?' ? true : false;
|
||||
while (index !== -1) {
|
||||
valueType = valueType.replace("number", "NUMBER_TYPE_" + NumberIncrease.getAndIncrease())
|
||||
index = valueType.indexOf("number")
|
||||
}
|
||||
result.value.push({
|
||||
name: valueName,
|
||||
type: valueType,
|
||||
optional: optionalFlag
|
||||
})
|
||||
analyzeTypeVariable(t, tt, result);
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
function analyzeTypeVariable(t, tt, result) {
|
||||
let valueName = re.getReg(t, tt.regs[1]);
|
||||
let valueType = re.getReg(t, tt.regs[3]);
|
||||
let index = valueType.indexOf("number");
|
||||
let optionalFlag = re.getReg(t, tt.regs[2]) == '?' ? true : false;
|
||||
while (index !== -1) {
|
||||
valueType = valueType.replace("number", "NUMBER_TYPE_" + NumberIncrease.getAndIncrease());
|
||||
index = valueType.indexOf("number");
|
||||
}
|
||||
result.value.push({
|
||||
name: valueName,
|
||||
type: valueType,
|
||||
optional: optionalFlag
|
||||
});
|
||||
}
|
||||
|
||||
function analyzeType2(data) {
|
||||
let body = re.replaceAll(data, " ", "").split("'|'")
|
||||
let result = {
|
||||
|
@ -21,13 +21,13 @@ const re = require("./gen/tools/VsPluginRe");
|
||||
const { VsPluginLog } = require("./gen/tools/VsPluginLog");
|
||||
const { detectPlatform, readFile } = require('./gen/tools/VsPluginTool');
|
||||
const path = require('path');
|
||||
var exeFilePath = null;
|
||||
let exeFilePath = null;
|
||||
const dirCache={};
|
||||
var globalPanel = null;
|
||||
let globalPanel = null;
|
||||
|
||||
var importToolChain = false;
|
||||
var extensionIds = [];
|
||||
var nextPluginId = null;
|
||||
let importToolChain = false;
|
||||
let extensionIds = [];
|
||||
let nextPluginId = null;
|
||||
// this method is called when your extension is activated
|
||||
// your extension is activated the very first time the command is executed
|
||||
|
||||
@ -42,7 +42,7 @@ function activate(context) {
|
||||
let disposableMenu = register(context, 'api_scan_menu');
|
||||
context.subscriptions.push(disposable);
|
||||
context.subscriptions.push(disposableMenu);
|
||||
var platform = detectPlatform();
|
||||
let platform = detectPlatform();
|
||||
if (platform == 'win') {
|
||||
exeFilePath = __dirname + "/search-win.exe";
|
||||
} else if (platform == 'mac') {
|
||||
@ -56,8 +56,8 @@ function executorApiscan(name, genDir) {
|
||||
if (genDir == "" || genDir == null) {
|
||||
genDir = name;
|
||||
}
|
||||
var command = exeFilePath + " -d " + name + " -o " + genDir;
|
||||
var exec = require('child_process').exec;
|
||||
let command = exeFilePath + " -d " + name + " -o " + genDir;
|
||||
let exec = require('child_process').exec;
|
||||
exec(command, function (error, stdout, stderr) {
|
||||
VsPluginLog.logInfo('VsPlugin: stdout =' + stdout + ", stderr =" + stderr);
|
||||
if (error || stdout.indexOf("errno") > 0) {
|
||||
@ -89,21 +89,7 @@ function register(context, command) {
|
||||
}
|
||||
);
|
||||
|
||||
if (typeof(boolValue) == 'boolean' && Array.isArray(items)) {
|
||||
if (boolValue == true) {
|
||||
//遍历数组item,查看当前插件id是数组的第几个元素,并拿出下一个元素,并判断当前id是否是最后一个元素并做相应处理
|
||||
let myExtensionId = 'kaihong.ApiScan';
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
if (myExtensionId == items[i] && (i == items.length - 1)) {
|
||||
importToolChain = false;
|
||||
} else if (myExtensionId == items[i] && (i != items.length - 1)) {
|
||||
importToolChain = boolValue;
|
||||
nextPluginId = items[i + 1];
|
||||
}
|
||||
extensionIds.push(items[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
checkBoolval(boolValue, items);
|
||||
|
||||
globalPanel.webview.html = getWebviewContent(context, importToolChain);
|
||||
let msg;
|
||||
@ -122,7 +108,7 @@ function register(context, command) {
|
||||
if (uri.fsPath !== undefined) {
|
||||
let fn = re.getFileInPath(uri.fsPath);
|
||||
let tt = re.match("[a-zA-Z_0-9]", fn);
|
||||
var result = {
|
||||
let result = {
|
||||
msg: "selectASFilePath",
|
||||
path: tt ? uri.fsPath : ""
|
||||
}
|
||||
@ -132,6 +118,28 @@ function register(context, command) {
|
||||
return disposable;
|
||||
}
|
||||
|
||||
function checkBoolval(boolValue, items) {
|
||||
if (typeof (boolValue) == 'boolean' && Array.isArray(items)) {
|
||||
if (boolValue == true) {
|
||||
//遍历数组item,查看当前插件id是数组的第几个元素,并拿出下一个元素,并判断当前id是否是最后一个元素并做相应处理
|
||||
getNextPlugin(items, boolValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getNextPlugin(items, boolValue) {
|
||||
let myExtensionId = 'kaihong.ApiScan';
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
if (myExtensionId == items[i] && (i == items.length - 1)) {
|
||||
importToolChain = false;
|
||||
} else if (myExtensionId == items[i] && (i != items.length - 1)) {
|
||||
importToolChain = boolValue;
|
||||
nextPluginId = items[i + 1];
|
||||
}
|
||||
extensionIds.push(items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
function checkReceiveMsg(message) {
|
||||
let name = message.fileNames;
|
||||
let genDir = message.genDir;
|
||||
@ -202,7 +210,7 @@ function selectPath(panel, message) {
|
||||
for (let index = 0; index < fileUri.length; index++) {
|
||||
filePath += fileUri[index].fsPath.concat(",");
|
||||
}
|
||||
var result = {
|
||||
let result = {
|
||||
msg: message.msg,
|
||||
path: filePath.length > 0 ? filePath.substring(0, filePath.length - 1) : filePath
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { readFile } = require('./util/VsPluginTool');
|
||||
|
||||
var extensionIds = [];
|
||||
var importCheck = false;
|
||||
let extensionIds = [];
|
||||
let importCheck = false;
|
||||
|
||||
// This method is called when your extension is activated
|
||||
// Your extension is activated the very first time the command is executed
|
||||
@ -171,30 +171,11 @@ function wait(ms) {
|
||||
async function installStartExtension(extensionId) {
|
||||
const extension = vscode.extensions.getExtension(extensionId);
|
||||
if (!extension) {
|
||||
try {
|
||||
// 下载插件
|
||||
vscode.window.showInformationMessage(`Extension ${extensionId} installing...`);
|
||||
setTimeout(() => {
|
||||
const active = vscode.window.activeInformationMessage;
|
||||
if (active && active.message === `Extension ${extensionId} installing...`) {
|
||||
active.dispose();
|
||||
}
|
||||
}, 8000);
|
||||
await vscode.commands.executeCommand('workbench.extensions.installExtension', extensionId);
|
||||
vscode.window.showInformationMessage(`Extension ${extensionId} installed successfully.`);
|
||||
vscode.window.showInformationMessage(`Extension ${extensionId} activating...`);
|
||||
console.log(`Extension ${extensionId} activating...`);
|
||||
await wait(1000); // 等待下载插件初始化
|
||||
const extensionDone = vscode.extensions.getExtension(extensionId);
|
||||
if (extensionDone && extensionDone.isActive) {
|
||||
vscode.window.showInformationMessage(`Extension ${extensionId} activated successfully.`);
|
||||
console.log(`Extension ${extensionId} activated successfully.`);
|
||||
} else {
|
||||
console.log('请等待插件初始化完成')
|
||||
await wait(1000);
|
||||
}
|
||||
try {
|
||||
// 下载插件
|
||||
await downloadPlugin(extensionId);
|
||||
} catch (error) {
|
||||
console.log(`Failed to install extension ${extensionId}: ${error.message}`);
|
||||
console.log(`Failed to install extension ${extensionId}: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -215,6 +196,29 @@ async function installStartExtension(extensionId) {
|
||||
}
|
||||
}
|
||||
|
||||
async function downloadPlugin(extensionId) {
|
||||
vscode.window.showInformationMessage(`Extension ${extensionId} installing...`);
|
||||
setTimeout(() => {
|
||||
const active = vscode.window.activeInformationMessage;
|
||||
if (active && active.message === `Extension ${extensionId} installing...`) {
|
||||
active.dispose();
|
||||
}
|
||||
}, 8000);
|
||||
await vscode.commands.executeCommand('workbench.extensions.installExtension', extensionId);
|
||||
vscode.window.showInformationMessage(`Extension ${extensionId} installed successfully.`);
|
||||
vscode.window.showInformationMessage(`Extension ${extensionId} activating...`);
|
||||
console.log(`Extension ${extensionId} activating...`);
|
||||
await wait(1000); // 等待下载插件初始化
|
||||
const extensionDone = vscode.extensions.getExtension(extensionId);
|
||||
if (extensionDone && extensionDone.isActive) {
|
||||
vscode.window.showInformationMessage(`Extension ${extensionId} activated successfully.`);
|
||||
console.log(`Extension ${extensionId} activated successfully.`);
|
||||
} else {
|
||||
console.log('请等待插件初始化完成');
|
||||
await wait(1000);
|
||||
}
|
||||
}
|
||||
|
||||
function getWebviewContent(context) {
|
||||
let data = readFile(__dirname + '/vs_plugin_view.html');
|
||||
data = getWebViewContent(context, '/vs_plugin_view.html');
|
||||
|
@ -22,14 +22,14 @@ const { VsPluginLog } = require("./gen/tools/VsPluginLog");
|
||||
const { detectPlatform, readFile, writeFile } = require('./gen/tools/VsPluginTool');
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
var exeFilePath = null;
|
||||
var flag = "";
|
||||
var isTrue = false;
|
||||
var globalPanel = null;
|
||||
let exeFilePath = null;
|
||||
let flag = "";
|
||||
let isTrue = false;
|
||||
let globalPanel = null;
|
||||
|
||||
var importToolChain = false;
|
||||
var extensionIds = [];
|
||||
var nextPluginId = null;
|
||||
let importToolChain = false;
|
||||
let extensionIds = [];
|
||||
let nextPluginId = null;
|
||||
// this method is called when your extension is activated
|
||||
// your extension is activated the very first time the command is executed
|
||||
|
||||
@ -44,7 +44,7 @@ function activate(context) {
|
||||
let disposableMenu = register(context, 'generate_gn_menu');
|
||||
context.subscriptions.push(disposable);
|
||||
context.subscriptions.push(disposableMenu);
|
||||
var platform = detectPlatform();
|
||||
let platform = detectPlatform();
|
||||
if (platform == 'win') {
|
||||
exeFilePath = __dirname + "/gn-gen-win.exe";
|
||||
} else if (platform == 'mac') {
|
||||
@ -53,7 +53,7 @@ function activate(context) {
|
||||
exeFilePath = __dirname + "/gn-gen-linux";
|
||||
}
|
||||
vscode.window.onDidChangeActiveColorTheme(colorTheme => {
|
||||
var result = {
|
||||
let result = {
|
||||
msg: "colorThemeChanged"
|
||||
}
|
||||
globalPanel.webview.postMessage(result);
|
||||
@ -62,7 +62,7 @@ function activate(context) {
|
||||
|
||||
function gnexecutor(outputCodeDir, originCodeDir, inputScriptDir, scriptType, transplantDir,
|
||||
subsystemName, componentName, compileOptions) {
|
||||
var exec = require('child_process').exec;
|
||||
let exec = require('child_process').exec;
|
||||
exec(genGnCommand(outputCodeDir, originCodeDir, inputScriptDir, scriptType, transplantDir,
|
||||
subsystemName, componentName, compileOptions),
|
||||
{
|
||||
@ -81,7 +81,7 @@ function gnexecutor(outputCodeDir, originCodeDir, inputScriptDir, scriptType, tr
|
||||
|
||||
function genGnCommand(outputCodeDir, originCodeDir, inputScriptDir, scriptType,
|
||||
transplantDir, subsystemName, componentName, compileOptions) {
|
||||
var command = exeFilePath + " -o " + outputCodeDir + " -p " + originCodeDir + " -f " + inputScriptDir
|
||||
let command = exeFilePath + " -o " + outputCodeDir + " -p " + originCodeDir + " -f " + inputScriptDir
|
||||
+ " -t " + scriptType + " -s " + subsystemName + " -m " + componentName + " -d " + transplantDir;
|
||||
if (compileOptions != "") {
|
||||
command += " -a " + "\"" + compileOptions + "\"";
|
||||
@ -128,21 +128,7 @@ function register(context, command) {
|
||||
retainContextWhenHidden: true, // Keep the WebView state when it is hidden to avoid being reset
|
||||
}
|
||||
);
|
||||
if (typeof(boolValue) == 'boolean' && Array.isArray(items)) {
|
||||
if (boolValue == true) {
|
||||
//遍历数组item,查看当前插件id是数组的第几个元素,并拿出下一个元素,并判断当前id是否是最后一个元素并做相应处理
|
||||
let myExtensionId = 'kaihong.gn-gen';
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
if (myExtensionId == items[i] && (i == items.length - 1)) {
|
||||
importToolChain = false;
|
||||
} else if (myExtensionId == items[i] && (i != items.length - 1)) {
|
||||
importToolChain = boolValue;
|
||||
nextPluginId = items[i + 1];
|
||||
}
|
||||
extensionIds.push(items[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
checkBoolval(boolValue, items);
|
||||
globalPanel.webview.html = getWebviewContent(context, importToolChain);
|
||||
let msg;
|
||||
globalPanel.webview.onDidReceiveMessage(message => {
|
||||
@ -159,7 +145,7 @@ function register(context, command) {
|
||||
if (uri.fsPath !== undefined) {
|
||||
let fn = re.getFileInPath(uri.fsPath);
|
||||
let tt = re.match("([a-zA-Z_0-9]+.[a-zA-Z_0-9])", fn);
|
||||
var result = {
|
||||
let result = {
|
||||
msg: "selectinputScriptDir",
|
||||
path: tt ? uri.fsPath : ""
|
||||
}
|
||||
@ -169,6 +155,28 @@ function register(context, command) {
|
||||
return disposable;
|
||||
}
|
||||
|
||||
function checkBoolval(boolValue, items) {
|
||||
if (typeof (boolValue) == 'boolean' && Array.isArray(items)) {
|
||||
if (boolValue == true) {
|
||||
//遍历数组item,查看当前插件id是数组的第几个元素,并拿出下一个元素,并判断当前id是否是最后一个元素并做相应处理
|
||||
getNextPlugin(items, boolValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getNextPlugin(items, boolValue) {
|
||||
let myExtensionId = 'kaihong.gn-gen';
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
if (myExtensionId == items[i] && (i == items.length - 1)) {
|
||||
importToolChain = false;
|
||||
} else if (myExtensionId == items[i] && (i != items.length - 1)) {
|
||||
importToolChain = boolValue;
|
||||
nextPluginId = items[i + 1];
|
||||
}
|
||||
extensionIds.push(items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
function checkReceiveMsg(message) {
|
||||
let outputCodeDir = message.outputCodeDir;
|
||||
let originCodeDir = message.originCodeDir;
|
||||
@ -245,14 +253,14 @@ function startNextPlugin() {
|
||||
return vscode.window.showOpenDialog(options).then(fileUri => {
|
||||
if (fileUri && fileUri[0]) {
|
||||
console.log('Selected file: ' + fileUri[0].fsPath);
|
||||
var filePath = "";
|
||||
let filePath = "";
|
||||
filePath = fileUri[0].fsPath.concat(',');
|
||||
filePath = re.replaceAll(filePath, '\\\\', '/');
|
||||
if (filePath.substring(1,2) == ":") {
|
||||
let filePathTemp = filePath.substring(0,1).toUpperCase()
|
||||
filePath = filePathTemp + filePath.substring(1,filePath.length)
|
||||
}
|
||||
var result = {
|
||||
let result = {
|
||||
msg: message.msg,
|
||||
path: filePath.length > 0 ? filePath.substring(0, filePath.length - 1) : filePath
|
||||
}
|
||||
|
@ -23,12 +23,12 @@ const { detectPlatform, readFile } = require('./gen/tools/VsPluginTool');
|
||||
const path = require('path');
|
||||
const INVALID_INDEX = -1;
|
||||
const SELECT_H_FILE = 2; // 选择.h文件
|
||||
var exeFilePath = null;
|
||||
var globalPanel = null;
|
||||
var showInfoPanel = null;
|
||||
var importToolChain = false;
|
||||
var extensionIds = [];
|
||||
var nextPluginId = null;
|
||||
let exeFilePath = null;
|
||||
let globalPanel = null;
|
||||
let showInfoPanel = null;
|
||||
let importToolChain = false;
|
||||
let extensionIds = [];
|
||||
let nextPluginId = null;
|
||||
let configList = new Array();
|
||||
let generateDir = '';
|
||||
let cfgPath = '';
|
||||
@ -47,7 +47,7 @@ function activate(context) {
|
||||
let disposableMenu = register(context, 'generate_napi_menu');
|
||||
context.subscriptions.push(disposable);
|
||||
context.subscriptions.push(disposableMenu);
|
||||
var platform = detectPlatform();
|
||||
let platform = detectPlatform();
|
||||
if (platform == 'win') {
|
||||
exeFilePath = __dirname + '/napi_generator-win.exe';
|
||||
} else if (platform == 'mac') {
|
||||
@ -58,7 +58,7 @@ function activate(context) {
|
||||
}
|
||||
|
||||
function executor(name, genDir, mode, numberType, importIsCheck) {
|
||||
var exec = require('child_process').exec;
|
||||
let exec = require('child_process').exec;
|
||||
exec(genCommand(name, genDir, mode, numberType, importIsCheck), function (error, stdout, stderr) {
|
||||
VsPluginLog.logInfo('VsPlugin: stdout =' + stdout + ', stderr =' + stderr);
|
||||
if (error || stdout.indexOf('success') < 0) {
|
||||
@ -70,7 +70,7 @@ function executor(name, genDir, mode, numberType, importIsCheck) {
|
||||
}
|
||||
|
||||
function genCommand(name, genDir, mode, numberType, importIsCheck) {
|
||||
var genFileMode = mode == 0 ? ' -f ' : ' -d ';
|
||||
let genFileMode = mode == 0 ? ' -f ' : ' -d ';
|
||||
|
||||
let genServiceCode = '';
|
||||
console.log('cfgPath: ' + cfgPath);
|
||||
@ -107,21 +107,7 @@ function register(context, command) {
|
||||
}
|
||||
);
|
||||
|
||||
if (typeof(boolValue) == 'boolean' && Array.isArray(items)) {
|
||||
if (boolValue == true) {
|
||||
//遍历数组item,查看当前插件id是数组的第几个元素,并拿出下一个元素,并判断当前id是否是最后一个元素并做相应处理
|
||||
let myExtensionId = 'kaihong.napi-gen';
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
if (myExtensionId == items[i] && (i == items.length - 1)) {
|
||||
importToolChain = false;
|
||||
} else if (myExtensionId == items[i] && (i != items.length - 1)) {
|
||||
importToolChain = boolValue;
|
||||
nextPluginId = items[i + 1];
|
||||
}
|
||||
extensionIds.push(items[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
checkBoolval(boolValue, items);
|
||||
globalPanel.webview.html = getWebviewContent(context, importToolChain);
|
||||
let msg;
|
||||
globalPanel.webview.onDidReceiveMessage(message => {
|
||||
@ -135,15 +121,7 @@ function register(context, command) {
|
||||
checkReceiveMsg(message);
|
||||
} else if (msg === 'config') {
|
||||
// 若选择文件夹或者选择了多个文件则不能配置业务代码
|
||||
if (message.mode !== 0 || message.interFile.indexOf(',') > 0) {
|
||||
vscode.window.showInformationMessage('选择文件夹或者多个文件时不能配置业务代码,请选择单个文件');
|
||||
console.error('选择文件夹或者多个文件时不能配置业务代码,请选择单个文件');
|
||||
} else if (trimAll(message.genDir).length <= 0) {
|
||||
vscode.window.showInformationMessage('请输入生成框架路径!');
|
||||
console.error('请输入生成框架路径!');
|
||||
} else {
|
||||
configServiceCode(message, context);
|
||||
}
|
||||
getMsgCfg(message, context);
|
||||
} else {
|
||||
selectPath(globalPanel, message);
|
||||
}
|
||||
@ -152,7 +130,7 @@ function register(context, command) {
|
||||
if (uri.fsPath !== undefined) {
|
||||
let fn = re.getFileInPath(uri.fsPath);
|
||||
let tt = re.match("((@ohos\.)*[a-zA-Z_0-9]+.d.ts)", fn);
|
||||
var result = {
|
||||
let result = {
|
||||
msg: "selectInterPath",
|
||||
path: tt ? uri.fsPath : ""
|
||||
}
|
||||
@ -162,6 +140,40 @@ function register(context, command) {
|
||||
return disposable;
|
||||
}
|
||||
|
||||
function getMsgCfg(message, context) {
|
||||
if (message.mode !== 0 || message.interFile.indexOf(',') > 0) {
|
||||
vscode.window.showInformationMessage('选择文件夹或者多个文件时不能配置业务代码,请选择单个文件');
|
||||
console.error('选择文件夹或者多个文件时不能配置业务代码,请选择单个文件');
|
||||
} else if (trimAll(message.genDir).length <= 0) {
|
||||
vscode.window.showInformationMessage('请输入生成框架路径!');
|
||||
console.error('请输入生成框架路径!');
|
||||
} else {
|
||||
configServiceCode(message, context);
|
||||
}
|
||||
}
|
||||
|
||||
function checkBoolval(boolValue, items) {
|
||||
if (typeof (boolValue) == 'boolean' && Array.isArray(items)) {
|
||||
if (boolValue == true) {
|
||||
//遍历数组item,查看当前插件id是数组的第几个元素,并拿出下一个元素,并判断当前id是否是最后一个元素并做相应处理
|
||||
getNextPlugin(items, boolValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getNextPlugin(items, boolValue) {
|
||||
let myExtensionId = 'kaihong.napi-gen';
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
if (myExtensionId == items[i] && (i == items.length - 1)) {
|
||||
importToolChain = false;
|
||||
} else if (myExtensionId == items[i] && (i != items.length - 1)) {
|
||||
importToolChain = boolValue;
|
||||
nextPluginId = items[i + 1];
|
||||
}
|
||||
extensionIds.push(items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// 去除字符串空格
|
||||
function trimAll(str) {
|
||||
return str.split(/[\t\r\f\n\s]*/g).join('');
|
||||
@ -386,7 +398,7 @@ function selectConfigPath(panel, message, generateDir) {
|
||||
// 获取相对路径 相对于生成框架路径
|
||||
let filePath = path.relative(generateDir, fileObsPath);
|
||||
console.log('relative filePath: ' + filePath);
|
||||
var result = {
|
||||
let result = {
|
||||
msg: message.msg,
|
||||
path: filePath,
|
||||
};
|
||||
@ -421,7 +433,7 @@ function selectPath(panel, message) {
|
||||
for (let index = 0; index < fileUri.length; index++) {
|
||||
filePath += fileUri[index].fsPath.concat(',');
|
||||
}
|
||||
var result = {
|
||||
let result = {
|
||||
msg: message.msg,
|
||||
path: filePath.length > 0? filePath.substring(0, filePath.length - 1): filePath,
|
||||
};
|
||||
|
@ -21,12 +21,12 @@ const re = require("./gen/tools/VsPluginRe");
|
||||
const { VsPluginLog } = require("./gen/tools/VsPluginLog");
|
||||
const { detectPlatform, readFile } = require('./gen/tools/VsPluginTool');
|
||||
const path = require('path');
|
||||
var exeFilePath = null;
|
||||
var globalPanel = null;
|
||||
let exeFilePath = null;
|
||||
let globalPanel = null;
|
||||
|
||||
var importToolChain = false;
|
||||
var extensionIds = [];
|
||||
var nextPluginId = null;
|
||||
let importToolChain = false;
|
||||
let extensionIds = [];
|
||||
let nextPluginId = null;
|
||||
// this method is called when your extension is activated
|
||||
// your extension is activated the very first time the command is executed
|
||||
|
||||
@ -42,7 +42,7 @@ function activate(context) {
|
||||
context.subscriptions.push(disposable);
|
||||
context.subscriptions.push(disposableMenu);
|
||||
|
||||
var platform = detectPlatform();
|
||||
let platform = detectPlatform();
|
||||
if (platform == 'win') {
|
||||
exeFilePath = __dirname + "/napi_generator-win.exe";
|
||||
} else if (platform == 'mac') {
|
||||
@ -53,8 +53,8 @@ function activate(context) {
|
||||
}
|
||||
|
||||
function executorH2Ts(name, genDir) {
|
||||
var command = exeFilePath + " -f " + name + " -o " + genDir + " -t true";
|
||||
var exec = require('child_process').exec;
|
||||
let command = exeFilePath + " -f " + name + " -o " + genDir + " -t true";
|
||||
let exec = require('child_process').exec;
|
||||
exec(command, function (error, stdout, stderr) {
|
||||
VsPluginLog.logInfo('VsPlugin: stdout =' + stdout + ", stderr =" + stderr);
|
||||
if (error || stdout.indexOf("success") < 0) {
|
||||
@ -85,21 +85,7 @@ function register(context, command) {
|
||||
retainContextWhenHidden: true, // Keep the WebView state when it is hidden to avoid being reset
|
||||
}
|
||||
);
|
||||
if (typeof(boolValue) == 'boolean' && Array.isArray(items)) {
|
||||
if (boolValue == true) {
|
||||
//遍历数组item,查看当前插件id是数组的第几个元素,并拿出下一个元素,并判断当前id是否是最后一个元素并做相应处理
|
||||
let myExtensionId = 'kaihong.ts-gen';
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
if (myExtensionId == items[i] && (i == items.length - 1)) {
|
||||
importToolChain = false;
|
||||
} else if (myExtensionId == items[i] && (i != items.length - 1)) {
|
||||
importToolChain = boolValue;
|
||||
nextPluginId = items[i + 1];
|
||||
}
|
||||
extensionIds.push(items[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
checkBoolval(boolValue, items);
|
||||
globalPanel.webview.html = getWebviewContent(context, importToolChain);
|
||||
let msg;
|
||||
globalPanel.webview.onDidReceiveMessage(message => {
|
||||
@ -117,7 +103,7 @@ function register(context, command) {
|
||||
if (uri.fsPath !== undefined) {
|
||||
let fn = re.getFileInPath(uri.fsPath);
|
||||
let tt = re.match("([a-zA-Z_0-9]+.h)", fn);
|
||||
var result = {
|
||||
let result = {
|
||||
msg: "selectHFilePath",
|
||||
path: tt ? uri.fsPath : ""
|
||||
}
|
||||
@ -127,6 +113,28 @@ function register(context, command) {
|
||||
return disposable;
|
||||
}
|
||||
|
||||
function checkBoolval(boolValue, items) {
|
||||
if (typeof (boolValue) == 'boolean' && Array.isArray(items)) {
|
||||
if (boolValue == true) {
|
||||
//遍历数组item,查看当前插件id是数组的第几个元素,并拿出下一个元素,并判断当前id是否是最后一个元素并做相应处理
|
||||
getNextPlugin(items, boolValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getNextPlugin(items, boolValue) {
|
||||
let myExtensionId = 'kaihong.ts-gen';
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
if (myExtensionId == items[i] && (i == items.length - 1)) {
|
||||
importToolChain = false;
|
||||
} else if (myExtensionId == items[i] && (i != items.length - 1)) {
|
||||
importToolChain = boolValue;
|
||||
nextPluginId = items[i + 1];
|
||||
}
|
||||
extensionIds.push(items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
function checkReceiveMsg(message) {
|
||||
let name = message.fileNames;
|
||||
let genDir = message.genDir;
|
||||
@ -206,7 +214,7 @@ function startNextPlugin() {
|
||||
for (let index = 0; index < fileUri.length; index++) {
|
||||
filePath += fileUri[index].fsPath.concat(",");
|
||||
}
|
||||
var result = {
|
||||
let result = {
|
||||
msg: message.msg,
|
||||
path: filePath.length > 0 ? filePath.substring(0, filePath.length - 1) : filePath
|
||||
}
|
||||
|
@ -21,12 +21,12 @@ const re = require("./gen/tools/VsPluginRe");
|
||||
const { VsPluginLog } = require("./gen/tools/VsPluginLog");
|
||||
const { detectPlatform, readFile } = require('./gen/tools/VsPluginTool');
|
||||
const path = require('path');
|
||||
var exeFilePath = null;
|
||||
var globalPanel = null;
|
||||
let exeFilePath = null;
|
||||
let globalPanel = null;
|
||||
|
||||
var importToolChain = false;
|
||||
var extensionIds = [];
|
||||
var nextPluginId = null;
|
||||
let importToolChain = false;
|
||||
let extensionIds = [];
|
||||
let nextPluginId = null;
|
||||
// this method is called when your extension is activated
|
||||
// your extension is activated the very first time the command is executed
|
||||
|
||||
@ -41,7 +41,7 @@ function activate(context) {
|
||||
let disposableMenu = register(context, 'generate_service_menu');
|
||||
context.subscriptions.push(disposable);
|
||||
context.subscriptions.push(disposableMenu);
|
||||
var platform = detectPlatform();
|
||||
let platform = detectPlatform();
|
||||
if (platform == 'win') {
|
||||
exeFilePath = __dirname + "/service-gen-win.exe";
|
||||
} else if (platform == 'mac') {
|
||||
@ -50,7 +50,7 @@ function activate(context) {
|
||||
exeFilePath = __dirname + "/service-gen-linux";
|
||||
}
|
||||
vscode.window.onDidChangeActiveColorTheme(colorTheme => {
|
||||
var result = {
|
||||
let result = {
|
||||
msg: "colorThemeChanged"
|
||||
}
|
||||
globalPanel.webview.postMessage(result);
|
||||
@ -58,8 +58,8 @@ function activate(context) {
|
||||
}
|
||||
|
||||
function executorService(name, genDir, serviceId) {
|
||||
var command = exeFilePath + " -f " + name + " -o " + genDir + " -s " + serviceId;
|
||||
var exec = require('child_process').exec;
|
||||
let command = exeFilePath + " -f " + name + " -o " + genDir + " -s " + serviceId;
|
||||
let exec = require('child_process').exec;
|
||||
exec(command, function (error, stdout, stderr) {
|
||||
VsPluginLog.logInfo('VsPlugin: stdout =' + stdout + ", stderr =" + stderr);
|
||||
if (error || stdout.indexOf("success") < 0) {
|
||||
@ -90,21 +90,7 @@ function register(context, command) {
|
||||
retainContextWhenHidden: true, // Keep the WebView state when it is hidden to avoid being reset
|
||||
}
|
||||
);
|
||||
if (typeof(boolValue) == 'boolean' && Array.isArray(items)) {
|
||||
if (boolValue == true) {
|
||||
//遍历数组item,查看当前插件id是数组的第几个元素,并拿出下一个元素,并判断当前id是否是最后一个元素并做相应处理
|
||||
let myExtensionId = 'kaihong.service-gen';
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
if (myExtensionId == items[i] && (i == items.length - 1)) {
|
||||
importToolChain = false;
|
||||
} else if (myExtensionId == items[i] && (i != items.length - 1)) {
|
||||
importToolChain = boolValue;
|
||||
nextPluginId = items[i + 1];
|
||||
}
|
||||
extensionIds.push(items[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
checkBoolval(boolValue, items);
|
||||
globalPanel.webview.html = getWebviewContent(context, importToolChain);
|
||||
let msg;
|
||||
globalPanel.webview.onDidReceiveMessage(message => {
|
||||
@ -121,7 +107,7 @@ function register(context, command) {
|
||||
if (uri.fsPath !== undefined) {
|
||||
let fn = re.getFileInPath(uri.fsPath);
|
||||
let tt = re.match("([a-zA-Z_0-9]+.h)", fn);
|
||||
var result = {
|
||||
let result = {
|
||||
msg: "selectHFilePath",
|
||||
path: tt ? uri.fsPath : ""
|
||||
}
|
||||
@ -131,6 +117,28 @@ function register(context, command) {
|
||||
return disposable;
|
||||
}
|
||||
|
||||
function checkBoolval(boolValue, items) {
|
||||
if (typeof (boolValue) == 'boolean' && Array.isArray(items)) {
|
||||
if (boolValue == true) {
|
||||
//遍历数组item,查看当前插件id是数组的第几个元素,并拿出下一个元素,并判断当前id是否是最后一个元素并做相应处理
|
||||
getNextPlugin(items, boolValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getNextPlugin(items, boolValue) {
|
||||
let myExtensionId = 'kaihong.service-gen';
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
if (myExtensionId == items[i] && (i == items.length - 1)) {
|
||||
importToolChain = false;
|
||||
} else if (myExtensionId == items[i] && (i != items.length - 1)) {
|
||||
importToolChain = boolValue;
|
||||
nextPluginId = items[i + 1];
|
||||
}
|
||||
extensionIds.push(items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
function checkReceiveMsg(message) {
|
||||
let name = message.fileNames;
|
||||
let genDir = message.genDir;
|
||||
@ -210,7 +218,7 @@ function startNextPlugin() {
|
||||
for (let index = 0; index < fileUri.length; index++) {
|
||||
filePath += fileUri[index].fsPath.concat(",");
|
||||
}
|
||||
var result = {
|
||||
let result = {
|
||||
msg: message.msg,
|
||||
path: filePath.length > 0 ? filePath.substring(0, filePath.length - 1) : filePath
|
||||
}
|
||||
|
@ -51,7 +51,6 @@ describe('interface_no_name', function () {
|
||||
// 测试:function fun4(input: string): { read: number; written: number };
|
||||
it('test interface_no_name fun4', function () {
|
||||
let ret = fun4("name");
|
||||
//assert.strictEqual(ret.read, 0);
|
||||
});
|
||||
|
||||
// 测试:function fun5(value: {xOffset: number, animation: { duration: number, curve: string}});
|
||||
|
Loading…
Reference in New Issue
Block a user