@lcap/nasl 2.18.0 → 2.20.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/automate/engine/index.js +3 -3
- package/out/automate/engine/index.js.map +1 -1
- package/out/bak/translator.js +85 -37
- package/out/bak/translator.js.map +1 -1
- package/out/common/BaseNode.d.ts +6 -10
- package/out/common/BaseNode.js +7 -52
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/AnonymousFunction__.js.map +1 -1
- package/out/concepts/App__.d.ts +0 -10
- package/out/concepts/App__.js +0 -74
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Assignee__.js.map +1 -1
- package/out/concepts/AssignmentLine__.d.ts +5 -5
- package/out/concepts/AssignmentLine__.js +6 -6
- package/out/concepts/AssignmentLine__.js.map +1 -1
- package/out/concepts/Assignment__.js +2 -1
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/BatchAssignment__.d.ts +60 -60
- package/out/concepts/BatchAssignment__.js +11 -21
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts +0 -19
- package/out/concepts/BindAttribute__.js +2 -39
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BindStyle__.d.ts +2 -2
- package/out/concepts/BindStyle__.js +3 -3
- package/out/concepts/BindStyle__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.js +8 -0
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/CallFunction__.js +25 -58
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.d.ts +0 -7
- package/out/concepts/CallInterface__.js +7 -53
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.js +14 -63
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.js +1 -13
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/CompletionProperty__.js +0 -3
- package/out/concepts/CompletionProperty__.js.map +1 -1
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Configuration__.js.map +1 -1
- package/out/concepts/DataSource__.d.ts +0 -6
- package/out/concepts/DataSource__.js +0 -41
- package/out/concepts/DataSource__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +1 -9
- package/out/concepts/Destination__.js +29 -61
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +8 -21
- package/out/concepts/EntityProperty__.js +23 -109
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +0 -32
- package/out/concepts/Entity__.js +2 -117
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/Enum__.js +4 -0
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/ForEachStatement__.d.ts +4 -0
- package/out/concepts/ForEachStatement__.js +8 -4
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.js +4 -16
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.d.ts +0 -8
- package/out/concepts/IfStatement__.js +0 -22
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +1 -1
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +1 -6
- package/out/concepts/Logic__.js +43 -144
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MatchCase__.d.ts +1 -1
- package/out/concepts/MatchCase__.js +8 -15
- package/out/concepts/MatchCase__.js.map +1 -1
- package/out/concepts/Match__.d.ts +19 -21
- package/out/concepts/Match__.js +25 -112
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/MemberExpression__.d.ts +1 -4
- package/out/concepts/MemberExpression__.js +15 -30
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/Namespace__.js.map +1 -1
- package/out/concepts/NumericLiteral__.js +1 -1
- package/out/concepts/NumericLiteral__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.d.ts +3 -7
- package/out/concepts/OqlQueryComponent__.js +95 -56
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/Param__.d.ts +1 -1
- package/out/concepts/Param__.js +4 -40
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessComponent__.js.map +1 -1
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/QueryOrderByExpression__.d.ts +3 -3
- package/out/concepts/QueryOrderByExpression__.js +3 -3
- package/out/concepts/QueryOrderByExpression__.js.map +1 -1
- package/out/concepts/QuerySelectExpression__.js.map +1 -1
- package/out/concepts/Return__.js +2 -38
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/SelectMembers__.d.ts +1 -1
- package/out/concepts/SelectMembers__.js +2 -2
- package/out/concepts/SelectMembers__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.d.ts +4 -2
- package/out/concepts/SqlQueryComponent__.js +88 -9
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/StringLiteral__.js +7 -0
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +0 -1
- package/out/concepts/TypeAnnotation__.js +12 -25
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/TypeParam__.d.ts +0 -1
- package/out/concepts/TypeParam__.js +0 -2
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/UnaryExpression__.js +9 -6
- package/out/concepts/UnaryExpression__.js.map +1 -1
- package/out/concepts/ValidationRule__.js +23 -88
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.js +2 -38
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewComponent__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +29 -30
- package/out/concepts/ViewElement__.js +51 -117
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +3 -4
- package/out/concepts/View__.js +83 -93
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.js +1 -1
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.browser.js +0 -50
- package/out/concepts/basics/stdlib/nasl.browser.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +4 -36
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +43 -63
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/index__.d.ts +0 -2
- package/out/concepts/index__.js +0 -2
- package/out/concepts/index__.js.map +1 -1
- package/out/generator/genBundleFiles.d.ts +2 -5
- package/out/generator/genBundleFiles.js +45 -148
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/index.d.ts +0 -1
- package/out/generator/index.js +0 -1
- package/out/generator/index.js.map +1 -1
- package/out/index.d.ts +2 -3
- package/out/index.js +1 -5
- package/out/index.js.map +1 -1
- package/out/server/entity2LogicNamespace.js +11 -11
- package/out/server/entity2LogicNamespace.js.map +1 -1
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/formatTsUtils.js +17 -10
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getLogics.js +6 -13
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +7 -7
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.d.ts +1 -1
- package/out/server/index.d.ts +1 -0
- package/out/server/index.js +27 -2
- package/out/server/index.js.map +1 -1
- package/out/server/naslServer.d.ts +7 -47
- package/out/server/naslServer.js +393 -591
- package/out/server/naslServer.js.map +1 -1
- package/out/server/naslStdlibMap.js +28 -30
- package/out/server/naslStdlibMap.js.map +1 -1
- package/out/server/translator.js +7 -40
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.js +3 -33
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +4 -6
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +4 -7
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +5 -7
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEnumSelectBlock.js +2 -5
- package/out/templator/genEnumSelectBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +2 -2
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +2 -2
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genQueryComponent.d.ts +2 -2
- package/out/templator/genQueryComponent.js +1 -4
- package/out/templator/genQueryComponent.js.map +1 -1
- package/out/templator/genTableBlock.js +2 -2
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +3 -4
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.js +1 -1
- package/out/templator/utils.js.map +1 -1
- package/out/test/integration/node-nasl-server.js +38 -10
- package/out/test/integration/node-nasl-server.js.map +1 -1
- package/out/translator/index.d.ts +0 -1
- package/out/translator/index.js +1 -1
- package/out/translator/index.js.map +1 -1
- package/out/utils/index.d.ts +0 -1
- package/out/utils/index.js +1 -38
- package/out/utils/index.js.map +1 -1
- package/out/utils/string.d.ts +2 -15
- package/out/utils/string.js +3 -18
- package/out/utils/string.js.map +1 -1
- package/package.json +2 -2
- package/sandbox/stdlib/nasl.auth.ts +1 -1
- package/sandbox/stdlib/nasl.core.ts +1 -0
- package/sandbox/stdlib/nasl.logging.ts +4 -4
- package/sandbox/stdlib/nasl.util.ts +9 -5
- package/src/automate/engine/index.js +4 -4
- package/src/automate/engine/uniqueName.js +3 -3
- package/src/automate/template/myProcess.js +1 -1
- package/src/automate/upgrader/2.20.js +41 -0
- package/src/bak/translator.js +4 -1
- package/src/common/BaseNode.ts +1 -0
- package/src/concepts/AnonymousFunction__.ts +48 -2
- package/src/concepts/App__.ts +288 -615
- package/src/concepts/BatchAssignment__.ts +111 -51
- package/src/concepts/BindAttribute__.ts +18 -25
- package/src/concepts/BindDirective__.ts +7 -0
- package/src/concepts/BindEvent__.ts +7 -0
- package/src/concepts/BindStyle__.ts +7 -0
- package/src/concepts/CallFunction__.ts +34 -45
- package/src/concepts/CallInterface__.ts +2 -1
- package/src/concepts/CallLogic__.ts +87 -55
- package/src/concepts/CallQueryComponent__.ts +4 -1
- package/src/concepts/Constant__.ts +7 -0
- package/src/concepts/DataSource__.ts +57 -5
- package/src/concepts/Destination__.ts +100 -43
- package/src/concepts/Frontend__.ts +937 -0
- package/src/concepts/Identifier__.ts +18 -16
- package/src/concepts/LogicItem__.ts +8 -1
- package/src/concepts/Logic__.ts +134 -149
- package/src/concepts/Match__.ts +13 -29
- package/src/concepts/NewComposite__.ts +1357 -0
- package/src/concepts/NewList__.ts +440 -0
- package/src/concepts/NewMap__.ts +666 -0
- package/src/concepts/New__.ts +73 -0
- package/src/concepts/Param__.ts +245 -199
- package/src/concepts/ProcessElement__.ts +43 -36
- package/src/concepts/ProcessOutcomes__.ts +90 -0
- package/src/concepts/Process__.ts +1 -23
- package/src/concepts/Return__.ts +11 -1
- package/src/concepts/SelectMembers__.ts +3 -3
- package/src/concepts/Transactional__.ts +7 -0
- package/src/concepts/TypeAnnotation__.ts +54 -49
- package/src/concepts/ValidationRule__.ts +19 -1
- package/src/concepts/Variable__.ts +12 -6
- package/src/concepts/ViewElement__.ts +26 -3
- package/src/concepts/View__.ts +25 -25
- package/src/concepts/basics/stdlib/nasl.auth.ts +1 -1
- package/src/concepts/basics/stdlib/nasl.logging.ts +5 -0
- package/src/concepts/basics/stdlib/nasl.ui.ts +2 -0
- package/src/concepts/basics/stdlib/nasl.util.ts +153 -19
- package/src/concepts/index__.ts +7 -0
- package/src/enums/KEYWORDS.ts +9 -0
- package/src/generator/genBundleFiles.ts +74 -245
- package/src/generator/genMetaData.ts +178 -78
- package/src/generator/genReleaseBody.ts +87 -44
- package/src/generator/index.ts +1 -0
- package/src/generator/permission.ts +261 -0
- package/src/index.ts +1 -1
- package/src/server/entity2LogicNamespace.ts +90 -10
- package/src/server/extendBaseNode.ts +33 -22
- package/src/server/formatTsUtils.ts +36 -46
- package/src/server/getLogics.ts +13 -1
- package/src/server/getMemberIdentifier.ts +5 -5
- package/src/server/getProcesses.ts +1 -1
- package/src/server/naslServer.ts +254 -71
- package/src/server/process2LogicNamespace.ts +8 -0
- package/src/server/translator.ts +51 -5
- package/src/service/creator/add.configs.js +4 -0
- package/src/service/datasource/api.js +11 -0
- package/src/service/datasource/index.js +6 -0
- package/src/service/storage/init.ts +12 -0
- package/src/service/video/VideoTranscribe.js +1 -0
- package/src/templator/genEditTableBlock.ts +8 -16
- package/src/templator/genGetBlock.ts +18 -19
- package/src/templator/genGridViewBlock.ts +18 -18
- package/src/templator/genListViewBlock.ts +8 -11
- package/src/templator/genTableBlock.ts +6 -10
- package/ts-worker/lib/tsserver.js +8 -1
- package/out/automate/engine/2.14-components.d.ts +0 -1115
- package/out/automate/engine/2.14-components.js +0 -1087
- package/out/automate/engine/2.14-components.js.map +0 -1
- package/out/concepts/ExternalDestination__.d.ts +0 -73
- package/out/concepts/ExternalDestination__.js +0 -264
- package/out/concepts/ExternalDestination__.js.map +0 -1
- package/out/concepts/MatchExpression__.d.ts +0 -97
- package/out/concepts/MatchExpression__.js +0 -281
- package/out/concepts/MatchExpression__.js.map +0 -1
- package/out/concepts/StringInterpolation__.d.ts +0 -113
- package/out/concepts/StringInterpolation__.js +0 -227
- package/out/concepts/StringInterpolation__.js.map +0 -1
- package/out/generator/genReleaseBody.d.ts +0 -41
- package/out/generator/genReleaseBody.js +0 -340
- package/out/generator/genReleaseBody.js.map +0 -1
- package/out/service/defaultErrorMessage.json +0 -97
- package/out/service/logic/api.d.ts +0 -9
- package/out/service/logic/api.js +0 -11
- package/out/service/logic/api.js.map +0 -1
- package/out/service/logic/index.d.ts +0 -2
- package/out/service/logic/index.js +0 -10
- package/out/service/logic/index.js.map +0 -1
- package/src/automate/engine/dist/index.dev.js +0 -517
- package/src/common/dist/BaseNode.js +0 -1101
- package/src/concepts/basics/stdlib/dist/reference2TypeAnnotationList.js +0 -24
- package/src/concepts/dist/Anchor__.js +0 -179
- package/src/concepts/dist/Assignment__.js +0 -301
- package/src/concepts/dist/CallFunction__.js +0 -473
- package/src/concepts/dist/CallInterface__.js +0 -533
- package/src/concepts/dist/CallLogic__.js +0 -864
- package/src/concepts/dist/ForEachStatement__.js +0 -426
- package/src/concepts/dist/MatchCase__.js +0 -587
- package/src/concepts/dist/MemberExpression__.js +0 -348
- package/src/concepts/dist/Param__.js +0 -537
- package/src/concepts/dist/Return__.js +0 -493
- package/src/generator/dist/genBundleFiles.js +0 -414
- package/src/server/dist/formatTsUtils.js +0 -683
- package/src/server/dist/naslServer.js +0 -3396
- package/src/service/storage/dist/init.js +0 -541
- package/ts-worker/dist/webpack.config.dev.js +0 -104
- package/ts-worker/lib/dist/tsserver.dev.js +0 -22953
- package/ts-worker/sources/lib/dist/tsserver.dev.js +0 -22912
package/out/server/naslServer.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.NaslServer =
|
|
29
|
+
exports.NaslServer = void 0;
|
|
30
30
|
/// #if process.env.BUILD_TARGET === 'node'
|
|
31
31
|
const fs = __importStar(require("fs-extra"));
|
|
32
32
|
const path = __importStar(require("path"));
|
|
@@ -46,7 +46,6 @@ const coreTypeList_1 = require("../concepts/basics/types/coreTypeList");
|
|
|
46
46
|
const formatTsUtils_1 = require("./formatTsUtils");
|
|
47
47
|
const naslStdlibMap_1 = __importDefault(require("./naslStdlibMap"));
|
|
48
48
|
const jsoner = __importStar(require("../service/storage/jsoner"));
|
|
49
|
-
const EventEmitter_1 = require("../common/EventEmitter");
|
|
50
49
|
const EmbeddedTSFileLineMap = {
|
|
51
50
|
Entity: 3,
|
|
52
51
|
};
|
|
@@ -55,40 +54,9 @@ const EmbeddedTSFileOffsetMap = {
|
|
|
55
54
|
};
|
|
56
55
|
// 要Check的文件
|
|
57
56
|
const filesToCheck = new Set();
|
|
58
|
-
// 单个文件正在change,不允许同时两个文件一起change
|
|
59
|
-
let singleFileChangeIng = false;
|
|
60
57
|
let isChangeInterface = false; //判断是否导入接口
|
|
61
58
|
let actionArr = []; //用于导入接口收集更改的节点
|
|
62
59
|
let timer = null; //超时器用于收集导入接口相关
|
|
63
|
-
// 联合类型切割取出类型
|
|
64
|
-
function getDisplayString2Type(displayString) {
|
|
65
|
-
// 取出匹配的内容
|
|
66
|
-
const reg = /<([^()]+)>/g;
|
|
67
|
-
// 解决extends 导致类型缺失的问题
|
|
68
|
-
displayString = displayString?.replace('T extends ', '') || '';
|
|
69
|
-
const types = reg.exec(displayString);
|
|
70
|
-
// 取出提示的类型,组成是数组
|
|
71
|
-
const typeList = types[1].split(' | ').map((item) => {
|
|
72
|
-
if (/<([^()]+)>/g.exec(item)) {
|
|
73
|
-
return item;
|
|
74
|
-
}
|
|
75
|
-
else if (item.includes(' ')) {
|
|
76
|
-
const strs = item.split(' ');
|
|
77
|
-
const type = strs[strs.length - 1];
|
|
78
|
-
return type;
|
|
79
|
-
}
|
|
80
|
-
else if (item.includes('.')) {
|
|
81
|
-
const strs = item.split('.');
|
|
82
|
-
const type = strs[strs.length - 1];
|
|
83
|
-
return type;
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
return item;
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
return typeList;
|
|
90
|
-
}
|
|
91
|
-
exports.getDisplayString2Type = getDisplayString2Type;
|
|
92
60
|
class NaslServer {
|
|
93
61
|
messager = undefined;
|
|
94
62
|
worker = undefined;
|
|
@@ -101,9 +69,6 @@ class NaslServer {
|
|
|
101
69
|
elementsLogic = {};
|
|
102
70
|
// 错误日志收集
|
|
103
71
|
diagnosticManager = undefined;
|
|
104
|
-
embeddedTSEmitter = undefined;
|
|
105
|
-
// 需要执行修改的文件
|
|
106
|
-
changeStackList = [];
|
|
107
72
|
constructor() {
|
|
108
73
|
/// #if process.env.BUILD_TARGET === 'node'
|
|
109
74
|
if (globalThis.process) // For TS build
|
|
@@ -128,26 +93,10 @@ class NaslServer {
|
|
|
128
93
|
}
|
|
129
94
|
},
|
|
130
95
|
});
|
|
131
|
-
// 监听所有改变操作
|
|
132
|
-
this.embeddedTSEmitter = new EventEmitter_1.EventEmitter();
|
|
133
|
-
this.embeddedTSEmitter.on('change', ($event) => {
|
|
134
|
-
// 收集到一个行为集合
|
|
135
|
-
const eventValue = $event.value;
|
|
136
|
-
eventValue.forEach(async (item) => {
|
|
137
|
-
this.changeStackList.push(item.originEvent);
|
|
138
|
-
});
|
|
139
|
-
// 如果有长度开始执行状态机
|
|
140
|
-
if (this.changeStackList.length) {
|
|
141
|
-
this.changeFileNext();
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
96
|
}
|
|
145
97
|
start() {
|
|
146
98
|
return this.messager.requestCommand('start');
|
|
147
99
|
}
|
|
148
|
-
terminate() {
|
|
149
|
-
this.worker.terminate();
|
|
150
|
-
}
|
|
151
100
|
async createUiTs(allComponent) {
|
|
152
101
|
const { code, elementsLogic } = await (0, createUiTs_1.default)(allComponent);
|
|
153
102
|
// 放入生產的uits文件
|
|
@@ -422,6 +371,32 @@ class NaslServer {
|
|
|
422
371
|
_getValueSelectCompletion(args) {
|
|
423
372
|
return this.messager.requestCommand('getValueSelectCompletion', args);
|
|
424
373
|
}
|
|
374
|
+
// 联合类型切割取出类型
|
|
375
|
+
getDisplayString2Type(displayString) {
|
|
376
|
+
// 取出匹配的内容
|
|
377
|
+
const reg = /<([^()]+)>/g;
|
|
378
|
+
const types = reg.exec(displayString);
|
|
379
|
+
// 取出提示的类型,组成是数组
|
|
380
|
+
const typeList = types[1].split(' | ').map((item) => {
|
|
381
|
+
if (/<([^()]+)>/g.exec(item)) {
|
|
382
|
+
return item;
|
|
383
|
+
}
|
|
384
|
+
else if (item.includes(' ')) {
|
|
385
|
+
const strs = item.split(' ');
|
|
386
|
+
const type = strs[strs.length - 1];
|
|
387
|
+
return type;
|
|
388
|
+
}
|
|
389
|
+
else if (item.includes('.')) {
|
|
390
|
+
const strs = item.split('.');
|
|
391
|
+
const type = strs[strs.length - 1];
|
|
392
|
+
return type;
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
return item;
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
return typeList;
|
|
399
|
+
}
|
|
425
400
|
/**
|
|
426
401
|
* 获取 Convert 的可选类型
|
|
427
402
|
* @param node 传入当前已经选择的变量
|
|
@@ -444,7 +419,7 @@ class NaslServer {
|
|
|
444
419
|
});
|
|
445
420
|
if (quickInfo.responseRequired) {
|
|
446
421
|
const displayString = quickInfo?.response?.displayString || '';
|
|
447
|
-
const typeList = getDisplayString2Type(displayString);
|
|
422
|
+
const typeList = this.getDisplayString2Type(displayString);
|
|
448
423
|
const res = [];
|
|
449
424
|
typeList.forEach((type) => {
|
|
450
425
|
const typeAnnotation = coreTypeList_1.primitiveTypeList.find((typeAnnotation) => typeAnnotation.typeName === type);
|
|
@@ -502,17 +477,6 @@ class NaslServer {
|
|
|
502
477
|
.replace(/__name:"AStructure_\w{8}";/g, '')
|
|
503
478
|
.replace(/dataSources.([^.]+).entities.([^;]+)/g, ($1, $2, $3) => (`${$3}(${$2})`));
|
|
504
479
|
}
|
|
505
|
-
else if (typeStr.startsWith('{') && typeStr.endsWith('}')) {
|
|
506
|
-
/**
|
|
507
|
-
* {
|
|
508
|
-
text: nasl.core.String;
|
|
509
|
-
value: nasl.core.String;
|
|
510
|
-
}
|
|
511
|
-
*/
|
|
512
|
-
return typeStr.replaceAll(' ', '')
|
|
513
|
-
.replaceAll('\n', '')
|
|
514
|
-
.replaceAll('nasl.core.', '');
|
|
515
|
-
}
|
|
516
480
|
let str = '';
|
|
517
481
|
// 取出T的值
|
|
518
482
|
typeStr = (0, formatTsUtils_1.getPlatformType)(typeStr);
|
|
@@ -538,49 +502,6 @@ class NaslServer {
|
|
|
538
502
|
}
|
|
539
503
|
return '';
|
|
540
504
|
}
|
|
541
|
-
async getDataSchemaStructureOrTypeAnnotation(node) {
|
|
542
|
-
if (!(node instanceof concepts_1.ViewElement))
|
|
543
|
-
return;
|
|
544
|
-
const { currentSource, fileNode } = this.getCurrentSource(node);
|
|
545
|
-
const quickInfo = await this._getTypeQuickinfo({
|
|
546
|
-
file: fileNode.getEmbeddedFilePath(),
|
|
547
|
-
line: (0, translator_1.lsp2tspNumber)(currentSource.range.start.line),
|
|
548
|
-
offset: (0, translator_1.lsp2tspNumber)(currentSource.range.start.character) + `new nasl.ui.`.length,
|
|
549
|
-
});
|
|
550
|
-
if (quickInfo.responseRequired) {
|
|
551
|
-
const displayString = quickInfo?.response?.displayString || '';
|
|
552
|
-
const flag = displayString.includes('<') && displayString.includes('>');
|
|
553
|
-
if (!flag)
|
|
554
|
-
return;
|
|
555
|
-
const types = /\<([^()]+)\>/g.exec(displayString);
|
|
556
|
-
let typeStr = types && types[1];
|
|
557
|
-
const app = node.app;
|
|
558
|
-
if (typeStr.includes('__name: "AStructure_')) {
|
|
559
|
-
const properties = [];
|
|
560
|
-
typeStr
|
|
561
|
-
.replace(/([^:\s]+):\s+([^;]+);/g, ($1, name, typeKey) => {
|
|
562
|
-
if (name === '__name')
|
|
563
|
-
return;
|
|
564
|
-
typeKey = `app.${typeKey}`;
|
|
565
|
-
const keys = typeKey.split('.');
|
|
566
|
-
const typeName = keys.pop();
|
|
567
|
-
const typeNamespace = keys.join('.');
|
|
568
|
-
properties.push(concepts_1.StructureProperty.from({
|
|
569
|
-
name,
|
|
570
|
-
typeAnnotation: concepts_1.TypeAnnotation.from({
|
|
571
|
-
typeKind: 'reference',
|
|
572
|
-
typeName,
|
|
573
|
-
typeNamespace,
|
|
574
|
-
})
|
|
575
|
-
}));
|
|
576
|
-
return '';
|
|
577
|
-
});
|
|
578
|
-
return concepts_1.TypeAnnotation.createTypeAnonymousStructure(properties);
|
|
579
|
-
}
|
|
580
|
-
else if (typeStr.startsWith('structures'))
|
|
581
|
-
return app.findNodeByCompleteName(`app.${typeStr}`);
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
505
|
/**
|
|
585
506
|
* ts的 quickInfo方法,查询指定位置的详情
|
|
586
507
|
* @param args 文件信息数组
|
|
@@ -694,17 +615,6 @@ class NaslServer {
|
|
|
694
615
|
if (isChangeInterface) {
|
|
695
616
|
this.existStructureFix(record.semanticDiagnostics, node, this);
|
|
696
617
|
}
|
|
697
|
-
// 单独处理 oql 语义错误提示
|
|
698
|
-
if (record.node instanceof concepts_1.Logic) {
|
|
699
|
-
record?.syntaxDiagnostics.forEach((item) => {
|
|
700
|
-
const minRange = this._findMinRange(item, record.node);
|
|
701
|
-
if (minRange.node instanceof concepts_1.OqlQueryComponent) {
|
|
702
|
-
if (item.text === 'Invalid character.') {
|
|
703
|
-
record.semanticDiagnostics.push(item);
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
});
|
|
707
|
-
}
|
|
708
618
|
record.semanticDiagnostics = record.semanticDiagnostics
|
|
709
619
|
.map((diag) => this._resolveDiagnostic(diag, node, record))
|
|
710
620
|
.filter((diag) => !!diag);
|
|
@@ -804,7 +714,7 @@ class NaslServer {
|
|
|
804
714
|
}),
|
|
805
715
|
];
|
|
806
716
|
}
|
|
807
|
-
if (Array.isArray(enumerableItems)
|
|
717
|
+
if (Array.isArray(enumerableItems)) {
|
|
808
718
|
const map = {};
|
|
809
719
|
cases.forEach((caseItem) => {
|
|
810
720
|
const { patterns } = caseItem || {};
|
|
@@ -903,33 +813,18 @@ class NaslServer {
|
|
|
903
813
|
}
|
|
904
814
|
if (removed)
|
|
905
815
|
return diagnostics;
|
|
906
|
-
fileNode
|
|
816
|
+
fileNode.traverseChildren((node) => {
|
|
907
817
|
if (node instanceof concepts_1.ViewElement && node.view === fileNode) {
|
|
908
818
|
if (node.tag) {
|
|
909
819
|
node.bindAttrs.forEach((bindAttr) => {
|
|
910
|
-
if ((bindAttr.model || bindAttr.sync) && bindAttr.expression) {
|
|
911
|
-
const
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
};
|
|
919
|
-
}
|
|
920
|
-
else {
|
|
921
|
-
if (bindExpression.isEnum()) {
|
|
922
|
-
diagnostic = {
|
|
923
|
-
node: bindAttr,
|
|
924
|
-
severity: 'error',
|
|
925
|
-
message: '页面元素双向绑定:只允许绑定可赋值的变量和属性。',
|
|
926
|
-
};
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
if (diagnostic) {
|
|
930
|
-
bindAttr.tsErrorDetail = diagnostic;
|
|
931
|
-
diagnostics.push(diagnostic);
|
|
932
|
-
}
|
|
820
|
+
if ((bindAttr.model || bindAttr.sync) && bindAttr.expression && bindAttr.expression.concept !== 'Identifier' && bindAttr.expression.concept !== 'MemberExpression') {
|
|
821
|
+
const diagnostic = {
|
|
822
|
+
node: bindAttr,
|
|
823
|
+
severity: 'error',
|
|
824
|
+
message: '页面元素双向绑定:只允许绑定可赋值的变量和属性。',
|
|
825
|
+
};
|
|
826
|
+
bindAttr.tsErrorDetail = diagnostic;
|
|
827
|
+
diagnostics.push(diagnostic);
|
|
933
828
|
}
|
|
934
829
|
});
|
|
935
830
|
}
|
|
@@ -947,37 +842,30 @@ class NaslServer {
|
|
|
947
842
|
const jsCode = nodeIn.toJS();
|
|
948
843
|
if (!jsCode.includes(`${node.name} = `))
|
|
949
844
|
return;
|
|
950
|
-
//
|
|
845
|
+
// 逻辑内局部变量、输出参数、输入参数过滤
|
|
846
|
+
if ((nodeIn.logic?.variables || []).find((lVar) => jsCode.includes(`${lVar.name} = `))
|
|
847
|
+
|| (nodeIn.logic?.returns || []).find((lRet) => jsCode.includes(`${lRet.name} = `))
|
|
848
|
+
|| (nodeIn.logic?.params || []).find((lPar) => jsCode.includes(`${lPar.name} = `)))
|
|
849
|
+
return;
|
|
951
850
|
if (node instanceof concepts_1.Variable && node.parentNode instanceof concepts_1.View) {
|
|
952
|
-
// 跟页面局部变量无关的赋值过滤
|
|
953
|
-
if (!jsCode.includes(`this.${node.name} = `))
|
|
954
|
-
return;
|
|
955
851
|
// 直接赋值 logic 内局部变量、输入参数直接提示系统无法推断类型
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
diagnostics.push(diagnostic);
|
|
967
|
-
}
|
|
968
|
-
msg = '系统无法推断类型。';
|
|
852
|
+
let hasVar = false;
|
|
853
|
+
nodeIn.logic?.params.forEach((param) => {
|
|
854
|
+
if (jsCode.includes(param.name))
|
|
855
|
+
hasVar = true;
|
|
856
|
+
});
|
|
857
|
+
if (!hasVar) {
|
|
858
|
+
nodeIn.logic?.variables.forEach((variable) => {
|
|
859
|
+
if (jsCode.includes(variable.name))
|
|
860
|
+
hasVar = true;
|
|
861
|
+
});
|
|
969
862
|
}
|
|
863
|
+
if (hasVar)
|
|
864
|
+
msg = '系统无法推断类型。';
|
|
970
865
|
}
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
node: nodeIn,
|
|
974
|
-
severity: 'error',
|
|
975
|
-
message: `${nodeIn.label}左边 ${node.name} 未设置类型,右边必须为有返回值的内容。`,
|
|
976
|
-
};
|
|
977
|
-
nodeIn.tsErrorDetail = diagnostic;
|
|
978
|
-
diagnostics.push(diagnostic);
|
|
866
|
+
else {
|
|
867
|
+
msg = '必须赋值有返回值的内容。';
|
|
979
868
|
}
|
|
980
|
-
msg = '必须赋值有返回值的内容。';
|
|
981
869
|
}
|
|
982
870
|
});
|
|
983
871
|
if (!msg)
|
|
@@ -990,9 +878,12 @@ class NaslServer {
|
|
|
990
878
|
node.tsErrorDetail = diagnostic;
|
|
991
879
|
diagnostics.push(diagnostic);
|
|
992
880
|
}
|
|
881
|
+
else {
|
|
882
|
+
node.tsErrorDetail = undefined;
|
|
883
|
+
}
|
|
993
884
|
}
|
|
994
885
|
else {
|
|
995
|
-
this.
|
|
886
|
+
this.checkMatchError(node, diagnostics);
|
|
996
887
|
}
|
|
997
888
|
});
|
|
998
889
|
}
|
|
@@ -1042,19 +933,10 @@ class NaslServer {
|
|
|
1042
933
|
const nodeTypeName = node.concept === 'Return' ? '输出参数' : '局部变量';
|
|
1043
934
|
let used = false;
|
|
1044
935
|
fileNode?.sourceMap.forEach((valueIn, nodeIn) => {
|
|
1045
|
-
if (
|
|
936
|
+
if (nodeIn
|
|
1046
937
|
&& (nodeIn instanceof concepts_1.BatchAssignment || (nodeIn instanceof concepts_1.Assignment && nodeIn.left?.name))
|
|
1047
938
|
&& nodeIn.toJS().includes(`${node.name} = `)) {
|
|
1048
939
|
used = true;
|
|
1049
|
-
if (!nodeIn.tsErrorDetail) {
|
|
1050
|
-
const diagnostic = {
|
|
1051
|
-
node: nodeIn,
|
|
1052
|
-
severity: 'error',
|
|
1053
|
-
message: `${nodeIn.label}左边 ${node.name} 未设置类型,右边必须为有返回值的内容。`,
|
|
1054
|
-
};
|
|
1055
|
-
nodeIn.tsErrorDetail = diagnostic;
|
|
1056
|
-
diagnostics.push(diagnostic);
|
|
1057
|
-
}
|
|
1058
940
|
}
|
|
1059
941
|
});
|
|
1060
942
|
const msg = used ? '必须赋值有返回值的内容。' : '未设置类型或未赋值。直接赋值系统可以自动推断类型。';
|
|
@@ -1070,56 +952,31 @@ class NaslServer {
|
|
|
1070
952
|
node.tsErrorDetail = undefined;
|
|
1071
953
|
}
|
|
1072
954
|
}
|
|
1073
|
-
this.
|
|
955
|
+
this.checkMatchError(node, diagnostics);
|
|
1074
956
|
});
|
|
1075
957
|
}
|
|
1076
958
|
return diagnostics;
|
|
1077
959
|
}
|
|
1078
|
-
|
|
960
|
+
checkMatchError(node, diagnostics) {
|
|
1079
961
|
if (!node)
|
|
1080
962
|
return;
|
|
1081
963
|
// 如果节点是match的看看节点里是不是有重复的
|
|
1082
964
|
if (node instanceof concepts_1.Match) {
|
|
1083
965
|
const typeMap = {};
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
else {
|
|
1095
|
-
typeMap[pattern.sortedTypeKey] = [pattern];
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
else if (pattern instanceof concepts_1.MemberExpression) {
|
|
1099
|
-
if (pattern.completeName && pattern.object?.namespace?.endsWith('enums')) {
|
|
1100
|
-
const onlyKey = pattern.completeName;
|
|
1101
|
-
if (typeMap[onlyKey]) {
|
|
1102
|
-
typeMap[onlyKey].push(pattern);
|
|
1103
|
-
}
|
|
1104
|
-
else {
|
|
1105
|
-
typeMap[onlyKey] = [pattern];
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
else if (pattern instanceof concepts_1.BooleanLiteral) {
|
|
1110
|
-
const onlyKey = pattern.concept + pattern.value;
|
|
1111
|
-
if (typeMap[onlyKey]) {
|
|
1112
|
-
typeMap[onlyKey].push(pattern);
|
|
1113
|
-
}
|
|
1114
|
-
else {
|
|
1115
|
-
typeMap[onlyKey] = [pattern];
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
});
|
|
966
|
+
node.cases.forEach((item) => {
|
|
967
|
+
if (Array.isArray(item.patterns)) {
|
|
968
|
+
item.patterns.forEach((pattern) => {
|
|
969
|
+
if (pattern instanceof concepts_1.TypeAnnotation) {
|
|
970
|
+
if (typeMap[pattern.sortedTypeKey]) {
|
|
971
|
+
typeMap[pattern.sortedTypeKey].push(pattern);
|
|
972
|
+
}
|
|
973
|
+
else {
|
|
974
|
+
typeMap[pattern.sortedTypeKey] = [pattern];
|
|
975
|
+
}
|
|
1119
976
|
}
|
|
1120
977
|
});
|
|
1121
978
|
}
|
|
1122
|
-
}
|
|
979
|
+
});
|
|
1123
980
|
Object.keys(typeMap).forEach((item) => {
|
|
1124
981
|
if (typeMap[item].length > 1) {
|
|
1125
982
|
typeMap[item].forEach((nodeItem) => {
|
|
@@ -1136,7 +993,7 @@ class NaslServer {
|
|
|
1136
993
|
});
|
|
1137
994
|
}
|
|
1138
995
|
// 如果节点是match的patterns 里的
|
|
1139
|
-
if (node
|
|
996
|
+
if (node.parentNode instanceof concepts_1.MatchCase && node.parentNode.patterns.includes(node)) {
|
|
1140
997
|
const matchNode = node.getAncestor('Match');
|
|
1141
998
|
const matchExpressionType = matchNode?.expression?.__TypeAnnotation;
|
|
1142
999
|
// 判断union类型是不是重复
|
|
@@ -1155,6 +1012,7 @@ class NaslServer {
|
|
|
1155
1012
|
}
|
|
1156
1013
|
}
|
|
1157
1014
|
if (node.tsErrorDetail) {
|
|
1015
|
+
// console.log(matchExpressionType);
|
|
1158
1016
|
if (matchExpressionType?.typeNamespace?.includes('enums')) {
|
|
1159
1017
|
node.tsErrorDetail.titleTip = '该枚举值已被删除';
|
|
1160
1018
|
}
|
|
@@ -1163,16 +1021,6 @@ class NaslServer {
|
|
|
1163
1021
|
}
|
|
1164
1022
|
}
|
|
1165
1023
|
}
|
|
1166
|
-
// 如果forEach 中的each的内容是union类型就要提示报错
|
|
1167
|
-
if (node?.parentKey === 'each' && node?.__TypeAnnotation?.typeKind === 'union') {
|
|
1168
|
-
const diagnostic = {
|
|
1169
|
-
node,
|
|
1170
|
-
severity: 'error',
|
|
1171
|
-
message: 'ForEach:参数类型不一致!传入类型:联合类型。接受类型:List类型。',
|
|
1172
|
-
};
|
|
1173
|
-
node.tsErrorDetail = diagnostic;
|
|
1174
|
-
diagnostics.push(diagnostic);
|
|
1175
|
-
}
|
|
1176
1024
|
}
|
|
1177
1025
|
/* 接口导入查找 */
|
|
1178
1026
|
existStructureFix(semanticDiagnostics, node, that) {
|
|
@@ -1480,10 +1328,6 @@ class NaslServer {
|
|
|
1480
1328
|
return null;
|
|
1481
1329
|
const minRange = this._findMinRange(record, fileNode);
|
|
1482
1330
|
if (minRange) {
|
|
1483
|
-
// 节点上ts临时变量标识,如果有这个就不rename
|
|
1484
|
-
if (minRange.node.noTsReName) {
|
|
1485
|
-
return null;
|
|
1486
|
-
}
|
|
1487
1331
|
// 如果节点是TypeAnnotation类型,
|
|
1488
1332
|
// 很复杂,可能是多级嵌套结构
|
|
1489
1333
|
// 不一定只修改typeName
|
|
@@ -1570,16 +1414,10 @@ class NaslServer {
|
|
|
1570
1414
|
minRange.newValue = newTextValue;
|
|
1571
1415
|
}
|
|
1572
1416
|
}
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
minRange.setTypeMethods = 'setName';
|
|
1578
|
-
}
|
|
1579
|
-
else if (minRange.node instanceof concepts_1.EntityProperty) {
|
|
1580
|
-
// 如果枚举自己改名引用到了实体字段,而不是实体字段下的类型,就说明是默认值,默认值可以不处理
|
|
1581
|
-
return null;
|
|
1582
|
-
}
|
|
1417
|
+
// 如果是枚举修改,枚举的值刚好在Identifier 中选了 就修改值
|
|
1418
|
+
if (minRange.node instanceof concepts_1.Identifier && node instanceof concepts_1.Enum) {
|
|
1419
|
+
minRange.newValue = newValue;
|
|
1420
|
+
minRange.setTypeMethods = 'setName';
|
|
1583
1421
|
}
|
|
1584
1422
|
// 如果修改逻辑,改到了Identifier表达式,只能说明是在属性里有使用了
|
|
1585
1423
|
if (minRange.node instanceof concepts_1.Identifier && node instanceof concepts_1.Logic) {
|
|
@@ -1798,7 +1636,7 @@ class NaslServer {
|
|
|
1798
1636
|
minRange.newValue = newValue;
|
|
1799
1637
|
}
|
|
1800
1638
|
else if (minRange.node instanceof concepts_1.SqlQueryComponent || minRange.node instanceof concepts_1.OqlQueryComponent) {
|
|
1801
|
-
minRange.setTypeMethods = '
|
|
1639
|
+
minRange.setTypeMethods = 'setDataSource';
|
|
1802
1640
|
}
|
|
1803
1641
|
}
|
|
1804
1642
|
if (minRange.node instanceof concepts_1.QueryFieldExpression && node instanceof concepts_1.EntityProperty) {
|
|
@@ -1875,7 +1713,8 @@ class NaslServer {
|
|
|
1875
1713
|
}
|
|
1876
1714
|
}
|
|
1877
1715
|
else {
|
|
1878
|
-
console.log('没找到节点需要排查'
|
|
1716
|
+
console.log('没找到节点需要排查');
|
|
1717
|
+
console.log(record, fileNode.sourceMap);
|
|
1879
1718
|
}
|
|
1880
1719
|
return minRange;
|
|
1881
1720
|
})
|
|
@@ -2204,34 +2043,18 @@ class NaslServer {
|
|
|
2204
2043
|
if (node instanceof concepts_1.BinaryExpression && (['==', '!=', '>', '<', '>=', '<='].includes(node.operator))) {
|
|
2205
2044
|
return concepts_1.TypeAnnotation.createPrimitive('Boolean');
|
|
2206
2045
|
}
|
|
2207
|
-
// Convert
|
|
2208
|
-
if (node instanceof concepts_1.CallFunction && node.calleeNamespace === 'nasl.util' &&
|
|
2209
|
-
if (node.typeArguments.length) {
|
|
2210
|
-
return node.typeArguments[0];
|
|
2211
|
-
}
|
|
2212
|
-
}
|
|
2213
|
-
// Convert和new都是自身携带类型的,就不进行修改
|
|
2214
|
-
if (node instanceof concepts_1.CallLogic && node.calleeNamespace === 'nasl.util' && (node.calleeName === 'jsonDeserialize')) {
|
|
2046
|
+
// Convert是
|
|
2047
|
+
if (node instanceof concepts_1.CallFunction && node.calleeNamespace === 'nasl.util' && node.calleeName === 'Convert') {
|
|
2215
2048
|
if (node.typeArguments.length) {
|
|
2216
2049
|
return node.typeArguments[0];
|
|
2217
2050
|
}
|
|
2218
2051
|
}
|
|
2219
|
-
//
|
|
2220
|
-
if (node instanceof concepts_1.Param) {
|
|
2221
|
-
// index在nasl foreach上有脏数据
|
|
2222
|
-
if (node.parentKey === 'index' && node.parentNode instanceof concepts_1.ForEachStatement) {
|
|
2223
|
-
return concepts_1.TypeAnnotation.createPrimitive('Integer');
|
|
2224
|
-
}
|
|
2225
|
-
}
|
|
2052
|
+
// --------------------------------下面的都是为了获取节点类型的, 全量标注走不进来------------------------------------------------------------------
|
|
2226
2053
|
if (node instanceof concepts_1.CallQueryComponent || node instanceof concepts_1.SqlQueryComponent || node instanceof concepts_1.OqlQueryComponent) {
|
|
2227
2054
|
return node.typeAnnotation;
|
|
2228
2055
|
}
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
return concepts_1.TypeAnnotation.from({
|
|
2232
|
-
...node.typeAnnotation?.toJSON(),
|
|
2233
|
-
typeKind: 'primitive',
|
|
2234
|
-
});
|
|
2056
|
+
if (node instanceof concepts_1.NumericLiteral) {
|
|
2057
|
+
return node.typeAnnotation;
|
|
2235
2058
|
}
|
|
2236
2059
|
}
|
|
2237
2060
|
/**
|
|
@@ -2257,6 +2080,7 @@ class NaslServer {
|
|
|
2257
2080
|
const nodeTypeAnnotation = this.getCurrentNodeKnownTypeAnnotation(node);
|
|
2258
2081
|
if (nodeTypeAnnotation) {
|
|
2259
2082
|
types.set(node, nodeTypeAnnotation);
|
|
2083
|
+
node.__TypeAnnotation = nodeTypeAnnotation;
|
|
2260
2084
|
return;
|
|
2261
2085
|
}
|
|
2262
2086
|
// 要通过自己或者依赖关系拿的,二次遍历
|
|
@@ -2271,7 +2095,7 @@ class NaslServer {
|
|
|
2271
2095
|
'Return',
|
|
2272
2096
|
'Variable',
|
|
2273
2097
|
].includes(node.concept) && node.typeAnnotation) {
|
|
2274
|
-
|
|
2098
|
+
node.__TypeAnnotation = node.typeAnnotation;
|
|
2275
2099
|
return;
|
|
2276
2100
|
}
|
|
2277
2101
|
if (![
|
|
@@ -2301,13 +2125,12 @@ class NaslServer {
|
|
|
2301
2125
|
// 如果没有括号 ,括号就在外面,就 -1
|
|
2302
2126
|
// 有括号就找到括号的位置 然后 -1
|
|
2303
2127
|
let indexOf = 0;
|
|
2304
|
-
if (
|
|
2128
|
+
if (item.code.indexOf('(') === -1) {
|
|
2305
2129
|
indexOf = -1;
|
|
2306
2130
|
}
|
|
2307
2131
|
else {
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
indexOf = Math.min(item.code.indexOf('<'), item.code.indexOf('('));
|
|
2132
|
+
if (item.code.includes('>(')) {
|
|
2133
|
+
indexOf = item.code.indexOf('<');
|
|
2311
2134
|
}
|
|
2312
2135
|
else {
|
|
2313
2136
|
indexOf = item.code.indexOf('(');
|
|
@@ -2338,12 +2161,9 @@ class NaslServer {
|
|
|
2338
2161
|
}
|
|
2339
2162
|
args.push(fileDetail);
|
|
2340
2163
|
});
|
|
2341
|
-
console.time('请求');
|
|
2342
2164
|
const resultMap = (await this.getNaslNodeTypeFull(args)).response;
|
|
2343
|
-
console.timeEnd('请求');
|
|
2344
2165
|
// console.log(resultMap);
|
|
2345
2166
|
// const result = (await this.getNaslNodeQuickInfoFull(args)).response;
|
|
2346
|
-
// console.log(result);
|
|
2347
2167
|
args.forEach((arg, index) => {
|
|
2348
2168
|
const { file, line, offset } = arg;
|
|
2349
2169
|
const item = resultMap?.[file]?.[line]?.[offset];
|
|
@@ -2352,21 +2172,24 @@ class NaslServer {
|
|
|
2352
2172
|
// console.log('原始:', displayString);
|
|
2353
2173
|
// console.log('方案2:', item?.[0]?.nodeType);
|
|
2354
2174
|
const nodeTypeAnnotation = (0, formatTsUtils_1.type2TypeAnnotation)(item?.[0]?.nodeType);
|
|
2355
|
-
// console.log(newQuickInfoNodes[index].node, nodeTypeAnnotation,
|
|
2175
|
+
// console.log(newQuickInfoNodes[index].node, nodeTypeAnnotation, item?.[0]?.nodeType);
|
|
2356
2176
|
types.set(newQuickInfoNodes[index].node, nodeTypeAnnotation);
|
|
2357
|
-
newQuickInfoNodes[index].node.
|
|
2177
|
+
newQuickInfoNodes[index].node.__TypeAnnotation = nodeTypeAnnotation;
|
|
2178
|
+
newQuickInfoNodes[index].node.__nodeType = item?.[0]?.nodeType;
|
|
2358
2179
|
// console.log('方案1:', displayString1);
|
|
2359
2180
|
});
|
|
2360
2181
|
getFromOthers.forEach((type, node) => {
|
|
2361
2182
|
if (node instanceof concepts_1.Assignment) {
|
|
2362
2183
|
if (!types.get(node.left)) {
|
|
2363
2184
|
types.set(node.left, types.get(node.right));
|
|
2185
|
+
node.left.__TypeAnnotation = types.get(node.right);
|
|
2364
2186
|
}
|
|
2365
2187
|
}
|
|
2366
2188
|
else if (node instanceof concepts_1.Argument) {
|
|
2367
2189
|
// 如果Argument,但是没可以用的类型,就用原来logic的参数类型
|
|
2368
2190
|
const argType = this.getArgumentTypeAnnotation(node, newQuickInfoNodes, types);
|
|
2369
2191
|
types.set(node, argType);
|
|
2192
|
+
node.__TypeAnnotation = argType.typeAnnotation;
|
|
2370
2193
|
}
|
|
2371
2194
|
else if (node instanceof concepts_1.MatchCase) {
|
|
2372
2195
|
// matchCase的类型
|
|
@@ -2375,22 +2198,11 @@ class NaslServer {
|
|
|
2375
2198
|
const last = node.body[node.body.length - 1];
|
|
2376
2199
|
if (last.__TypeAnnotation) {
|
|
2377
2200
|
types.set(node, last.__TypeAnnotation);
|
|
2201
|
+
node.__TypeAnnotation = last.__TypeAnnotation;
|
|
2378
2202
|
}
|
|
2379
2203
|
}
|
|
2380
2204
|
}
|
|
2381
2205
|
});
|
|
2382
|
-
// 重置类型状态
|
|
2383
|
-
types.forEach((value, node) => {
|
|
2384
|
-
node.__isCorrectTypeAnnotation = true;
|
|
2385
|
-
if (value) {
|
|
2386
|
-
if (value instanceof concepts_1.TypeAnnotation) {
|
|
2387
|
-
node.__TypeAnnotation = Object.freeze(value);
|
|
2388
|
-
}
|
|
2389
|
-
else if (value.typeAnnotation) {
|
|
2390
|
-
node.__TypeAnnotation = Object.freeze(value.typeAnnotation);
|
|
2391
|
-
}
|
|
2392
|
-
}
|
|
2393
|
-
});
|
|
2394
2206
|
// newQuickInfoNodes.forEach((itemDetail, index) => {
|
|
2395
2207
|
// const { node, filePath } = itemDetail;
|
|
2396
2208
|
// if (!result[index] || node.concept === 'Argument')
|
|
@@ -2438,10 +2250,12 @@ class NaslServer {
|
|
|
2438
2250
|
// types.set(node, argType);
|
|
2439
2251
|
// }
|
|
2440
2252
|
// });
|
|
2253
|
+
console.timeEnd('批量请求');
|
|
2441
2254
|
return types;
|
|
2442
2255
|
}
|
|
2443
|
-
//
|
|
2256
|
+
// 全量标注
|
|
2444
2257
|
async getNaslAnnotatedJSON(app, releaseFlag) {
|
|
2258
|
+
// 全量标注
|
|
2445
2259
|
console.time('全量标注');
|
|
2446
2260
|
const nodes = [];
|
|
2447
2261
|
this.file2NodeMap.forEach((fileNode, filePath) => {
|
|
@@ -2463,13 +2277,14 @@ class NaslServer {
|
|
|
2463
2277
|
const json = app.toJSON();
|
|
2464
2278
|
if (releaseFlag) {
|
|
2465
2279
|
// 全量标注后对json进行一些修改,为了服务端翻译处理
|
|
2466
|
-
this.
|
|
2280
|
+
this.annitationToJson(typesMap, json);
|
|
2467
2281
|
}
|
|
2468
2282
|
return json;
|
|
2469
2283
|
}
|
|
2470
2284
|
// 加载全量nasl节点标注
|
|
2471
2285
|
async createdNaslAnnotatedJSON(app) {
|
|
2472
2286
|
// 全量标注
|
|
2287
|
+
console.time('全量标注');
|
|
2473
2288
|
const nodes = [];
|
|
2474
2289
|
this.file2NodeMap.forEach((fileNode, filePath) => {
|
|
2475
2290
|
// 先不排除view,传递给后端的时候,去除views下的标注
|
|
@@ -2484,10 +2299,10 @@ class NaslServer {
|
|
|
2484
2299
|
}
|
|
2485
2300
|
});
|
|
2486
2301
|
await this.getQuickInfoNodesTypeMap(nodes, true);
|
|
2302
|
+
console.timeEnd('全量标注');
|
|
2487
2303
|
}
|
|
2488
2304
|
// 增量标注
|
|
2489
2305
|
async IncrementalAnnotationJSON(records) {
|
|
2490
|
-
console.time('增量标注');
|
|
2491
2306
|
const nodes = [];
|
|
2492
2307
|
records.forEach((record) => {
|
|
2493
2308
|
const fileNode = this.file2NodeMap.get(record.filePath);
|
|
@@ -2506,9 +2321,8 @@ class NaslServer {
|
|
|
2506
2321
|
}
|
|
2507
2322
|
});
|
|
2508
2323
|
await this.getQuickInfoNodesTypeMap(nodes);
|
|
2509
|
-
console.timeEnd('增量标注');
|
|
2510
2324
|
}
|
|
2511
|
-
|
|
2325
|
+
annitationToJson(typesMap, json) {
|
|
2512
2326
|
typesMap.forEach((value, node) => {
|
|
2513
2327
|
// 如果节点本身有类型就不去在塞一遍了
|
|
2514
2328
|
// 有值而且没有类型再去设置
|
|
@@ -2525,8 +2339,8 @@ class NaslServer {
|
|
|
2525
2339
|
}
|
|
2526
2340
|
}
|
|
2527
2341
|
}
|
|
2528
|
-
|
|
2529
|
-
|
|
2342
|
+
if (node instanceof concepts_1.CallQueryComponent && node.ideVersion !== '2.11' && node.typeAnnotation.properties
|
|
2343
|
+
&& (node.typeAnnotation.properties.length !== 2 || node.typeAnnotation.properties[0].name !== 'list')) {
|
|
2530
2344
|
const jsonNode = jsoner.queryNodeByPath(json, node.getNodePath(false));
|
|
2531
2345
|
jsonNode.typeAnnotation = {
|
|
2532
2346
|
concept: 'TypeAnnotation',
|
|
@@ -2569,14 +2383,6 @@ class NaslServer {
|
|
|
2569
2383
|
}],
|
|
2570
2384
|
};
|
|
2571
2385
|
}
|
|
2572
|
-
// 特殊处理param有类型错误的
|
|
2573
|
-
if (node instanceof concepts_1.Param) {
|
|
2574
|
-
// index在nasl foreach上有脏数据
|
|
2575
|
-
if (node.parentKey === 'index' && node.parentNode instanceof concepts_1.ForEachStatement) {
|
|
2576
|
-
const jsonNode = jsoner.queryNodeByPath(json, node.getNodePath(false));
|
|
2577
|
-
jsonNode.typeAnnotation = concepts_1.TypeAnnotation.createPrimitive('Integer').toJSON();
|
|
2578
|
-
}
|
|
2579
|
-
}
|
|
2580
2386
|
if (node instanceof concepts_1.Match) {
|
|
2581
2387
|
const matchExpression = node.expression;
|
|
2582
2388
|
if (matchExpression?.__TypeAnnotation?.typeKind === 'union' && (matchExpression instanceof concepts_1.Identifier || matchExpression instanceof concepts_1.MemberExpression)) {
|
|
@@ -2589,14 +2395,6 @@ class NaslServer {
|
|
|
2589
2395
|
});
|
|
2590
2396
|
}
|
|
2591
2397
|
}
|
|
2592
|
-
// 特殊处理param有类型错误的
|
|
2593
|
-
if (node instanceof concepts_1.Param && value) {
|
|
2594
|
-
// index在nasl foreach上有脏数据
|
|
2595
|
-
if (node.parentKey === 'index' && node.parentNode instanceof concepts_1.ForEachStatement) {
|
|
2596
|
-
const jsonNode = jsoner.queryNodeByPath(json, node.getNodePath(false));
|
|
2597
|
-
jsonNode.typeAnnotation = value.toJSON();
|
|
2598
|
-
}
|
|
2599
|
-
}
|
|
2600
2398
|
});
|
|
2601
2399
|
}
|
|
2602
2400
|
/**
|
|
@@ -2635,7 +2433,7 @@ class NaslServer {
|
|
|
2635
2433
|
// 用户自己声明的用用户的
|
|
2636
2434
|
const callObj = App.findNodeByCompleteName(parent.calleeNamespace + '.' + parent.calleeName);
|
|
2637
2435
|
const index = parent.arguments.indexOf(node);
|
|
2638
|
-
const param = callObj?.params
|
|
2436
|
+
const param = callObj?.params[index] || {};
|
|
2639
2437
|
// 取出参数的类型
|
|
2640
2438
|
// 设置类型
|
|
2641
2439
|
return {
|
|
@@ -2650,18 +2448,13 @@ class NaslServer {
|
|
|
2650
2448
|
}
|
|
2651
2449
|
return new Promise((resolve, reject) => {
|
|
2652
2450
|
const myTimer = setTimeout(() => {
|
|
2653
|
-
console.
|
|
2451
|
+
console.log(node, '没有获取到类型');
|
|
2654
2452
|
clearTimeout(myTimer);
|
|
2655
2453
|
clearInterval(mySetInterval);
|
|
2656
|
-
|
|
2657
|
-
resolve(node.__TypeAnnotation);
|
|
2658
|
-
}
|
|
2659
|
-
else {
|
|
2660
|
-
resolve(null);
|
|
2661
|
-
}
|
|
2454
|
+
resolve(node.__TypeAnnotation);
|
|
2662
2455
|
}, 600);
|
|
2663
2456
|
const mySetInterval = setInterval(() => {
|
|
2664
|
-
if (node.
|
|
2457
|
+
if (node.__TypeAnnotation) {
|
|
2665
2458
|
resolve(node.__TypeAnnotation);
|
|
2666
2459
|
clearInterval(mySetInterval);
|
|
2667
2460
|
clearTimeout(myTimer);
|
|
@@ -2715,311 +2508,320 @@ class NaslServer {
|
|
|
2715
2508
|
const result = await this._getTypeStrFull(args);
|
|
2716
2509
|
return result;
|
|
2717
2510
|
}
|
|
2511
|
+
}
|
|
2512
|
+
exports.NaslServer = NaslServer;
|
|
2513
|
+
const naslServer = new NaslServer();
|
|
2514
|
+
/**
|
|
2515
|
+
* 处理删除节点
|
|
2516
|
+
* @param fileNode 当前删除节点的文件级别节点
|
|
2517
|
+
* @param targetNode 当前操作的节点
|
|
2518
|
+
* @param result toTs生成的内容
|
|
2519
|
+
*/
|
|
2520
|
+
async function handleDelete(fileNode, targetNode, result) {
|
|
2521
|
+
const filePath = fileNode.getEmbeddedFilePath();
|
|
2522
|
+
// 如果要删除,而且当前要删Logic就直接删除并且清除错误
|
|
2718
2523
|
/**
|
|
2719
|
-
*
|
|
2720
|
-
* @param fileNode 当前删除节点的文件级别节点
|
|
2721
|
-
* @param targetNode 当前操作的节点
|
|
2722
|
-
* @param result toTs生成的内容
|
|
2524
|
+
* 删除节点中的一个内容,删除了以后,就查一下引用的地方一起查一下异常
|
|
2723
2525
|
*/
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2526
|
+
let outputFiles = [];
|
|
2527
|
+
// 删除之前先查一下内容的依赖
|
|
2528
|
+
const newRefs = await naslServer.references({
|
|
2529
|
+
file: result.filePath,
|
|
2530
|
+
line: EmbeddedTSFileLineMap[fileNode.concept] ?? 2,
|
|
2531
|
+
offset: EmbeddedTSFileOffsetMap[fileNode.concept] ?? 6,
|
|
2532
|
+
});
|
|
2533
|
+
// 如果是要删除的内容,就是当前的file节点,要关闭当前文件,就把内容置为空
|
|
2534
|
+
if (fileNode === targetNode) {
|
|
2535
|
+
outputFiles = [{ file: filePath, fileContent: '' }];
|
|
2536
|
+
}
|
|
2537
|
+
else {
|
|
2538
|
+
// 如果是要删除logic一个小内容,要覆盖全部内容
|
|
2539
|
+
// 其余要删除的都是把原来的file节点的内容全部覆盖一把
|
|
2540
|
+
outputFiles = [{ file: result.filePath, fileContent: result.code }];
|
|
2541
|
+
}
|
|
2542
|
+
// 更新文件之后
|
|
2543
|
+
await naslServer.updateFiles({ outputFiles });
|
|
2544
|
+
newRefs.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
2545
|
+
}
|
|
2546
|
+
/**
|
|
2547
|
+
* 除去rename场景下的更新
|
|
2548
|
+
* @param fileNode 文件级别的节点
|
|
2549
|
+
* @param targetNode 触发修改的节点
|
|
2550
|
+
* @param result 生成代码的code 和位置信息
|
|
2551
|
+
*/
|
|
2552
|
+
async function handleChange(fileNode, targetNode, result, action) {
|
|
2553
|
+
naslServer.file2NodeMap.set(result.filePath, fileNode);
|
|
2554
|
+
const outputFiles = [{ file: result.filePath, fileContent: result.code }];
|
|
2555
|
+
// 创建和更新都用update,内部会做判断
|
|
2556
|
+
await naslServer.updateFiles({ outputFiles });
|
|
2557
|
+
// 查一下新函数名的依赖
|
|
2558
|
+
const newRefs = await naslServer.references({
|
|
2559
|
+
file: result.filePath,
|
|
2560
|
+
line: EmbeddedTSFileLineMap[fileNode.concept] ?? 2,
|
|
2561
|
+
offset: EmbeddedTSFileOffsetMap[fileNode.concept] ?? 6,
|
|
2562
|
+
});
|
|
2563
|
+
newRefs.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
2564
|
+
// 唤起建立连接弹框
|
|
2565
|
+
// 文件级别的建立连接采取提醒
|
|
2566
|
+
if (action === 'create' && targetNode.__init) {
|
|
2567
|
+
// 清除临时状态, 完成本次创建
|
|
2568
|
+
delete targetNode.__init;
|
|
2569
|
+
if (fileNode === targetNode && filesToCheck.size > 1) {
|
|
2570
|
+
const confirmParms = {
|
|
2571
|
+
actionType: 'createEstablishConnection',
|
|
2572
|
+
node: fileNode,
|
|
2573
|
+
icon: 'success',
|
|
2574
|
+
};
|
|
2575
|
+
(0, common_1.invokeCommand)('tsConfirm.open', confirmParms, () => { });
|
|
2576
|
+
}
|
|
2577
|
+
}
|
|
2578
|
+
}
|
|
2579
|
+
/**
|
|
2580
|
+
* 重命名的更新
|
|
2581
|
+
* @param fileNode 文件级别的节点
|
|
2582
|
+
* @param targetNode 触发修改的节点
|
|
2583
|
+
* @param result 生成代码的code 和位置信息
|
|
2584
|
+
* @param isRename 是不是修改名字
|
|
2585
|
+
* @param oldFilePath 如果是改名,文件级别的才会有这个参数,用于文件新增替换
|
|
2586
|
+
*/
|
|
2587
|
+
async function handleRename(fileNode, targetNode, result, oldFilePath) {
|
|
2588
|
+
// rename 场景
|
|
2589
|
+
const outputFiles = [{ file: result.filePath, fileContent: result.code }];
|
|
2590
|
+
// 如果是要修改顶级文件名
|
|
2591
|
+
// file节点和当前改得是同一节点
|
|
2592
|
+
if (fileNode === targetNode) {
|
|
2593
|
+
naslServer.file2NodeMap.delete(oldFilePath);
|
|
2594
|
+
naslServer.file2NodeMap.set(result.filePath, fileNode);
|
|
2595
|
+
// 修改名字新的添加进去,旧的置为空
|
|
2596
|
+
outputFiles.unshift({ file: oldFilePath, fileContent: '' });
|
|
2597
|
+
// 查一下旧文件名的依赖
|
|
2598
|
+
const oldRefs = await naslServer.references({
|
|
2599
|
+
file: oldFilePath,
|
|
2734
2600
|
line: EmbeddedTSFileLineMap[fileNode.concept] ?? 2,
|
|
2735
2601
|
offset: EmbeddedTSFileOffsetMap[fileNode.concept] ?? 6,
|
|
2736
2602
|
});
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
outputFiles = [{ file: filePath, fileContent: '' }];
|
|
2740
|
-
}
|
|
2741
|
-
else {
|
|
2742
|
-
// 如果是要删除logic一个小内容,要覆盖全部内容
|
|
2743
|
-
// 其余要删除的都是把原来的file节点的内容全部覆盖一把
|
|
2744
|
-
outputFiles = [{ file: result.filePath, fileContent: result.code }];
|
|
2745
|
-
}
|
|
2603
|
+
oldRefs.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
2604
|
+
filesToCheck.delete(oldFilePath);
|
|
2746
2605
|
// 更新文件之后
|
|
2747
|
-
await
|
|
2748
|
-
newRefs.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
2749
|
-
}
|
|
2750
|
-
/**
|
|
2751
|
-
* 除去rename场景下的更新
|
|
2752
|
-
* @param fileNode 文件级别的节点
|
|
2753
|
-
* @param targetNode 触发修改的节点
|
|
2754
|
-
* @param result 生成代码的code 和位置信息
|
|
2755
|
-
*/
|
|
2756
|
-
async handleChange(fileNode, targetNode, result, action) {
|
|
2757
|
-
this.file2NodeMap.set(result.filePath, fileNode);
|
|
2758
|
-
const outputFiles = [{ file: result.filePath, fileContent: result.code }];
|
|
2759
|
-
// 创建和更新都用update,内部会做判断
|
|
2760
|
-
await this.updateFiles({ outputFiles });
|
|
2606
|
+
await naslServer.updateFiles({ outputFiles });
|
|
2761
2607
|
// 查一下新函数名的依赖
|
|
2762
|
-
const newRefs = await
|
|
2608
|
+
const newRefs = await naslServer.references({
|
|
2763
2609
|
file: result.filePath,
|
|
2764
2610
|
line: EmbeddedTSFileLineMap[fileNode.concept] ?? 2,
|
|
2765
2611
|
offset: EmbeddedTSFileOffsetMap[fileNode.concept] ?? 6,
|
|
2766
2612
|
});
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
}
|
|
2613
|
+
const newRefFileList = new Set();
|
|
2614
|
+
newRefs.refs.forEach((ref) => {
|
|
2615
|
+
filesToCheck.add(ref.file);
|
|
2616
|
+
newRefFileList.add(ref.file);
|
|
2617
|
+
});
|
|
2618
|
+
// 文件级别重命名,有依赖才唤起弹框
|
|
2619
|
+
// 唤起重命名,提示有连接弹框
|
|
2620
|
+
// 重命名建立连接先不展示弹框了
|
|
2621
|
+
// if (newRefFileList.size > 1) {
|
|
2622
|
+
// const confirmParms = {
|
|
2623
|
+
// actionType: 'renameEstablishConnection',
|
|
2624
|
+
// node: fileNode,
|
|
2625
|
+
// icon: 'success',
|
|
2626
|
+
// };
|
|
2627
|
+
// invokeCommand('tsConfirm.open', confirmParms, () => {});
|
|
2628
|
+
// }
|
|
2782
2629
|
}
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
const oldRefs = await this.references({
|
|
2803
|
-
file: oldFilePath,
|
|
2804
|
-
line: EmbeddedTSFileLineMap[fileNode.concept] ?? 2,
|
|
2805
|
-
offset: EmbeddedTSFileOffsetMap[fileNode.concept] ?? 6,
|
|
2806
|
-
});
|
|
2807
|
-
oldRefs.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
2808
|
-
filesToCheck.delete(oldFilePath);
|
|
2809
|
-
// 更新文件之后
|
|
2810
|
-
await this.updateFiles({ outputFiles });
|
|
2811
|
-
// 查一下新函数名的依赖
|
|
2812
|
-
const newRefs = await this.references({
|
|
2813
|
-
file: result.filePath,
|
|
2814
|
-
line: EmbeddedTSFileLineMap[fileNode.concept] ?? 2,
|
|
2815
|
-
offset: EmbeddedTSFileOffsetMap[fileNode.concept] ?? 6,
|
|
2816
|
-
});
|
|
2817
|
-
const newRefFileList = new Set();
|
|
2818
|
-
newRefs.refs.forEach((ref) => {
|
|
2819
|
-
filesToCheck.add(ref.file);
|
|
2820
|
-
newRefFileList.add(ref.file);
|
|
2821
|
-
});
|
|
2822
|
-
// 文件级别重命名,有依赖才唤起弹框
|
|
2823
|
-
// 唤起重命名,提示有连接弹框
|
|
2824
|
-
// 重命名建立连接先不展示弹框了
|
|
2825
|
-
// if (newRefFileList.size > 1) {
|
|
2826
|
-
// const confirmParms = {
|
|
2827
|
-
// actionType: 'renameEstablishConnection',
|
|
2828
|
-
// node: fileNode,
|
|
2829
|
-
// icon: 'success',
|
|
2830
|
-
// };
|
|
2831
|
-
// invokeCommand('tsConfirm.open', confirmParms, () => {});
|
|
2832
|
-
// }
|
|
2833
|
-
}
|
|
2834
|
-
else if (targetNode instanceof concepts_1.ViewElement) {
|
|
2630
|
+
else if (targetNode instanceof concepts_1.ViewElement) {
|
|
2631
|
+
/**
|
|
2632
|
+
* 因为页面组件比较特殊
|
|
2633
|
+
* 修改之后只用查页面本身就好了
|
|
2634
|
+
*/
|
|
2635
|
+
// 更新文件之后
|
|
2636
|
+
await naslServer.updateFiles({ outputFiles });
|
|
2637
|
+
const newRefs2 = await naslServer.references({
|
|
2638
|
+
file: fileNode.getEmbeddedFilePath(),
|
|
2639
|
+
line: EmbeddedTSFileLineMap[fileNode.concept] ?? 2,
|
|
2640
|
+
offset: EmbeddedTSFileOffsetMap[fileNode.concept] ?? 6,
|
|
2641
|
+
});
|
|
2642
|
+
newRefs2.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
2643
|
+
}
|
|
2644
|
+
else {
|
|
2645
|
+
// 查一下当前属性依赖的文件
|
|
2646
|
+
const { currentSource, fileNode } = naslServer.getCurrentSource(targetNode);
|
|
2647
|
+
// 如果当前节点存在
|
|
2648
|
+
if (currentSource) {
|
|
2835
2649
|
/**
|
|
2836
|
-
*
|
|
2837
|
-
* 修改之后只用查页面本身就好了
|
|
2650
|
+
* 其余的节点修改之后直接查本身就可以了
|
|
2838
2651
|
*/
|
|
2652
|
+
const oldRefs = await naslServer.references({
|
|
2653
|
+
file: fileNode.getEmbeddedFilePath(),
|
|
2654
|
+
line: (0, translator_1.lsp2tspNumber)(currentSource.range.start.line),
|
|
2655
|
+
offset: (0, translator_1.lsp2tspNumber)(currentSource.range.start.character),
|
|
2656
|
+
});
|
|
2657
|
+
oldRefs.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
2839
2658
|
// 更新文件之后
|
|
2840
|
-
await
|
|
2841
|
-
const newRefs2 = await
|
|
2659
|
+
await naslServer.updateFiles({ outputFiles });
|
|
2660
|
+
const newRefs2 = await naslServer.references({
|
|
2842
2661
|
file: fileNode.getEmbeddedFilePath(),
|
|
2843
|
-
line:
|
|
2844
|
-
offset:
|
|
2662
|
+
line: (0, translator_1.lsp2tspNumber)(currentSource.range.start.line),
|
|
2663
|
+
offset: (0, translator_1.lsp2tspNumber)(currentSource.range.start.character),
|
|
2845
2664
|
});
|
|
2846
2665
|
newRefs2.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
2847
2666
|
}
|
|
2848
|
-
else {
|
|
2849
|
-
// 查一下当前属性依赖的文件
|
|
2850
|
-
const { currentSource, fileNode } = this.getCurrentSource(targetNode);
|
|
2851
|
-
// 如果当前节点存在
|
|
2852
|
-
if (currentSource) {
|
|
2853
|
-
/**
|
|
2854
|
-
* 其余的节点修改之后直接查本身就可以了
|
|
2855
|
-
*/
|
|
2856
|
-
const oldRefs = await this.references({
|
|
2857
|
-
file: fileNode.getEmbeddedFilePath(),
|
|
2858
|
-
line: (0, translator_1.lsp2tspNumber)(currentSource.range.start.line),
|
|
2859
|
-
offset: (0, translator_1.lsp2tspNumber)(currentSource.range.start.character),
|
|
2860
|
-
});
|
|
2861
|
-
oldRefs.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
2862
|
-
// 更新文件之后
|
|
2863
|
-
await this.updateFiles({ outputFiles });
|
|
2864
|
-
const newRefs2 = await this.references({
|
|
2865
|
-
file: fileNode.getEmbeddedFilePath(),
|
|
2866
|
-
line: (0, translator_1.lsp2tspNumber)(currentSource.range.start.line),
|
|
2867
|
-
offset: (0, translator_1.lsp2tspNumber)(currentSource.range.start.character),
|
|
2868
|
-
});
|
|
2869
|
-
newRefs2.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
2870
|
-
}
|
|
2871
|
-
}
|
|
2872
2667
|
}
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2668
|
+
}
|
|
2669
|
+
/**
|
|
2670
|
+
* 处理一些节点操作,子节点需要更新并且check的场景
|
|
2671
|
+
* 因为删除,新增父页面,或者重命名会一起
|
|
2672
|
+
* 删除或者新增view而且他有子集 就要执行同样的操作
|
|
2673
|
+
* @param action 当前操作类型
|
|
2674
|
+
* @param fileNode 文件节点
|
|
2675
|
+
* @param targetNode 操作节点 这里要两个相等才会走家去面对哦逻辑
|
|
2676
|
+
* @param oldpath 触发内容的oldpath
|
|
2677
|
+
*/
|
|
2678
|
+
async function incidentalAction(action, fileNode, targetNode, oldpath) {
|
|
2679
|
+
if ((action === 'create' || action === 'delete' || (action === 'update' && oldpath)) && fileNode === targetNode) {
|
|
2680
|
+
// 删除或者新增页面
|
|
2681
|
+
if (fileNode instanceof concepts_1.View && fileNode.children?.length) {
|
|
2682
|
+
const fileNodeChildren = fileNode.children;
|
|
2683
|
+
for (let i = 0; i < fileNodeChildren.length; i++) {
|
|
2684
|
+
const fileNodeItem = fileNodeChildren[i];
|
|
2685
|
+
const result = fileNodeItem.toEmbeddedTSFile();
|
|
2686
|
+
fileNodeItem.sourceMap = result.sourceMap;
|
|
2687
|
+
if (action === 'create') {
|
|
2688
|
+
await handleChange(fileNodeItem, fileNodeItem, result, action);
|
|
2689
|
+
await incidentalAction(action, fileNodeItem, fileNodeItem);
|
|
2690
|
+
}
|
|
2691
|
+
else if (action === 'delete') {
|
|
2692
|
+
await handleDelete(fileNodeItem, fileNodeItem, result);
|
|
2693
|
+
await incidentalAction(action, fileNodeItem, fileNodeItem);
|
|
2694
|
+
}
|
|
2695
|
+
else if (action === 'update' && oldpath) {
|
|
2696
|
+
const parentPath = oldpath.replace('.ts', '/');
|
|
2697
|
+
const currentOldPath = parentPath + fileNodeItem.name + '.ts';
|
|
2698
|
+
// 因为重命名这里只有当前修改父级的 旧名称, 所以他的子集也要根据旧名称去查依赖 更新内容
|
|
2699
|
+
await handleRename(fileNodeItem, fileNodeItem, result, currentOldPath);
|
|
2700
|
+
await incidentalAction(action, fileNodeItem, fileNodeItem, currentOldPath);
|
|
2701
|
+
}
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2704
|
+
// 删除或新增模块
|
|
2705
|
+
// 需要把下面的哦内容全部都更新一遍
|
|
2706
|
+
if (fileNode instanceof concepts_1.Module) {
|
|
2707
|
+
if (fileNode.type === 'interface' && fileNode.isAdd && action === 'create') {
|
|
2708
|
+
isChangeInterface = true;
|
|
2709
|
+
}
|
|
2710
|
+
const module = targetNode;
|
|
2711
|
+
const results = [];
|
|
2712
|
+
naslServer.contentToFile(module, results);
|
|
2713
|
+
for (let i = 0; i < results.length; i++) {
|
|
2714
|
+
const result = results[i];
|
|
2715
|
+
const node = naslServer.file2NodeMap.get(result.filePath);
|
|
2716
|
+
if (action === 'create') {
|
|
2717
|
+
await handleChange(node, node, result, action);
|
|
2718
|
+
}
|
|
2719
|
+
else {
|
|
2720
|
+
await handleDelete(node, node, result);
|
|
2906
2721
|
}
|
|
2907
2722
|
}
|
|
2908
|
-
//
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
}
|
|
2914
|
-
const module = targetNode;
|
|
2915
|
-
const results = [];
|
|
2916
|
-
this.contentToFile(module, results);
|
|
2917
|
-
for (let i = 0; i < results.length; i++) {
|
|
2918
|
-
const result = results[i];
|
|
2919
|
-
const node = this.file2NodeMap.get(result.filePath);
|
|
2920
|
-
if (action === 'create') {
|
|
2921
|
-
await this.handleChange(node, node, result, action);
|
|
2922
|
-
}
|
|
2923
|
-
else {
|
|
2924
|
-
await this.handleDelete(node, node, result);
|
|
2925
|
-
}
|
|
2723
|
+
// 删除模块通知更新列表
|
|
2724
|
+
if (action === 'delete') {
|
|
2725
|
+
try {
|
|
2726
|
+
// 如果已经
|
|
2727
|
+
(0, common_1.invokeCommand)('module.delete', true);
|
|
2926
2728
|
}
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
try {
|
|
2930
|
-
// 如果已经
|
|
2931
|
-
(0, common_1.invokeCommand)('module.delete', true);
|
|
2932
|
-
}
|
|
2933
|
-
catch (err) {
|
|
2934
|
-
console.log('module.delete', '组件销毁了,不用唤起了');
|
|
2935
|
-
}
|
|
2729
|
+
catch (err) {
|
|
2730
|
+
console.log('module.delete', '组件销毁了,不用唤起了');
|
|
2936
2731
|
}
|
|
2937
2732
|
}
|
|
2938
|
-
|
|
2733
|
+
}
|
|
2734
|
+
/**
|
|
2939
2735
|
* DataSource只会重命名时候,需要把子集全部重新生成一下
|
|
2940
2736
|
*/
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
}
|
|
2737
|
+
if (fileNode instanceof concepts_1.DataSource) {
|
|
2738
|
+
fileNode.entities.forEach(async (entity) => {
|
|
2739
|
+
try {
|
|
2740
|
+
const result = entity.toEmbeddedTSFile();
|
|
2741
|
+
const parentPath = oldpath.replace('.ts', '/');
|
|
2742
|
+
const currentOldPath = parentPath + '/entities/' + entity.name + '.ts';
|
|
2743
|
+
// 因为重命名这里只有当前修改父级的 旧名称, 所以他的子集也要根据旧名称去查依赖 更新内容
|
|
2744
|
+
await handleRename(entity, entity, result, currentOldPath);
|
|
2745
|
+
}
|
|
2746
|
+
catch (err) {
|
|
2747
|
+
console.log(err);
|
|
2748
|
+
}
|
|
2749
|
+
});
|
|
2955
2750
|
}
|
|
2956
2751
|
}
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2752
|
+
}
|
|
2753
|
+
async function receiveHandleChange($event) {
|
|
2754
|
+
// 行为
|
|
2755
|
+
const action = $event.action;
|
|
2756
|
+
const targetNode = $event.target;
|
|
2757
|
+
// 当前操作的文件节点
|
|
2758
|
+
const { fileNode } = naslServer.getCurrentSource(targetNode);
|
|
2759
|
+
// 如果是导入模块就,就引入对应模块,先不处理module和Configuration,下面的内容会自动创建
|
|
2760
|
+
if (!fileNode || fileNode instanceof concepts_1.Module || fileNode instanceof concepts_1.Configuration) {
|
|
2761
|
+
// module单独处理
|
|
2762
|
+
if (fileNode instanceof concepts_1.Module) {
|
|
2763
|
+
await incidentalAction(action, fileNode, targetNode);
|
|
2764
|
+
}
|
|
2765
|
+
return;
|
|
2766
|
+
}
|
|
2767
|
+
const result = fileNode.toEmbeddedTSFile();
|
|
2768
|
+
// 当前操作的节点
|
|
2769
|
+
// 如果当前没有生成tsFile
|
|
2770
|
+
if (!result) {
|
|
2771
|
+
return;
|
|
2772
|
+
}
|
|
2773
|
+
// 修改触发修改文件
|
|
2774
|
+
naslServer._debugInFileStorage($event.currentTarget, [
|
|
2775
|
+
{
|
|
2776
|
+
file: result.filePath,
|
|
2777
|
+
fileContent: result.code,
|
|
2778
|
+
},
|
|
2779
|
+
]);
|
|
2780
|
+
fileNode.sourceMap = result.sourceMap;
|
|
2781
|
+
if (action === 'update' || action === 'create') {
|
|
2782
|
+
if ($event?.field !== 'name') {
|
|
2783
|
+
await handleChange(fileNode, targetNode, result, action);
|
|
2784
|
+
await incidentalAction(action, fileNode, targetNode);
|
|
2971
2785
|
}
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
return;
|
|
2786
|
+
else {
|
|
2787
|
+
const oldpath = fileNode.getEmbeddedFilePath($event.oldObject.name);
|
|
2788
|
+
await handleRename(fileNode, targetNode, result, oldpath);
|
|
2789
|
+
await incidentalAction(action, fileNode, targetNode, oldpath);
|
|
2977
2790
|
}
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2791
|
+
}
|
|
2792
|
+
// 删除
|
|
2793
|
+
if (action === 'delete') {
|
|
2794
|
+
await incidentalAction(action, fileNode, targetNode);
|
|
2795
|
+
await handleDelete(fileNode, targetNode, result);
|
|
2796
|
+
}
|
|
2797
|
+
return true;
|
|
2798
|
+
}
|
|
2799
|
+
// 监听所有改变操作
|
|
2800
|
+
translator_1.embeddedTSEmitter.on('change', ($event) => {
|
|
2801
|
+
// 收集到一个行为集合
|
|
2802
|
+
const eventValue = $event.value;
|
|
2803
|
+
const stackList = [];
|
|
2804
|
+
eventValue.forEach(async (item) => {
|
|
2805
|
+
stackList.push(item.originEvent);
|
|
2806
|
+
});
|
|
2807
|
+
// 异步状态机,一个完成了在执行下一个
|
|
2808
|
+
function next() {
|
|
2809
|
+
const item = stackList.shift();
|
|
2810
|
+
receiveHandleChange(item).then(async () => {
|
|
2811
|
+
if (stackList.length) {
|
|
2812
|
+
next();
|
|
2990
2813
|
}
|
|
2991
2814
|
else {
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
await this.incidentalAction(action, fileNode, targetNode, oldpath);
|
|
2815
|
+
await naslServer.getDiagnosticRecordsAndPushAll(Array.from(filesToCheck));
|
|
2816
|
+
filesToCheck.clear();
|
|
2995
2817
|
}
|
|
2996
|
-
}
|
|
2997
|
-
// 删除
|
|
2998
|
-
if (action === 'delete') {
|
|
2999
|
-
await this.incidentalAction(action, fileNode, targetNode);
|
|
3000
|
-
await this.handleDelete(fileNode, targetNode, result);
|
|
3001
|
-
}
|
|
3002
|
-
return true;
|
|
2818
|
+
});
|
|
3003
2819
|
}
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
this.receiveHandleChange(item).catch((err) => {
|
|
3008
|
-
console.log(err, 'receiveHandleChangeErr');
|
|
3009
|
-
}).finally(async () => {
|
|
3010
|
-
// 每一个文件与change接触就把状态置为false,让下一个进入
|
|
3011
|
-
singleFileChangeIng = false;
|
|
3012
|
-
if (this.changeStackList.length) {
|
|
3013
|
-
this.changeFileNext();
|
|
3014
|
-
}
|
|
3015
|
-
else {
|
|
3016
|
-
console.log(Array.from(filesToCheck));
|
|
3017
|
-
await this.getDiagnosticRecordsAndPushAll(Array.from(filesToCheck));
|
|
3018
|
-
filesToCheck.clear();
|
|
3019
|
-
}
|
|
3020
|
-
});
|
|
3021
|
-
}
|
|
2820
|
+
// 如果有长度开始执行状态机
|
|
2821
|
+
if (stackList.length) {
|
|
2822
|
+
next();
|
|
3022
2823
|
}
|
|
3023
|
-
}
|
|
3024
|
-
|
|
2824
|
+
});
|
|
2825
|
+
// naslServer.messager.options.context = naslServer;
|
|
2826
|
+
exports.default = naslServer;
|
|
3025
2827
|
//# sourceMappingURL=naslServer.js.map
|