@lcap/nasl-concepts 3.13.0-alpha.microapp-1 → 3.13.0-beta.10
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/common/BaseNode.d.ts +3 -3
- package/out/common/BaseNode.d.ts.map +1 -1
- package/out/common/BaseNode.js +11 -7
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/Abort__.js +1 -1
- package/out/concepts/Abort__.js.map +1 -1
- package/out/concepts/App__.d.ts +83 -0
- package/out/concepts/App__.d.ts.map +1 -1
- package/out/concepts/App__.js +106 -2
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/AuthLogicForCallInterface__.js +1 -1
- package/out/concepts/AuthLogicForCallInterface__.js.map +1 -1
- package/out/concepts/BackendVariable__.js +2 -2
- package/out/concepts/BackendVariable__.js.map +1 -1
- package/out/concepts/Backend__.js +1 -1
- package/out/concepts/Backend__.js.map +1 -1
- package/out/concepts/BatchAssignment__.d.ts +25 -2
- package/out/concepts/BatchAssignment__.d.ts.map +1 -1
- package/out/concepts/BatchAssignment__.js +436 -69
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts.map +1 -1
- package/out/concepts/BindAttribute__.js +9 -2
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.d.ts.map +1 -1
- package/out/concepts/BindDirective__.js +7 -1
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.js +1 -1
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/Break__.d.ts +33 -0
- package/out/concepts/Break__.d.ts.map +1 -0
- package/out/concepts/Break__.js +120 -0
- package/out/concepts/Break__.js.map +1 -0
- package/out/concepts/BusinessComponent__.d.ts.map +1 -1
- package/out/concepts/BusinessComponent__.js +3 -2
- package/out/concepts/BusinessComponent__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +1 -0
- package/out/concepts/CallLogic__.d.ts.map +1 -1
- package/out/concepts/CallLogic__.js +16 -3
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.d.ts +14 -5
- package/out/concepts/CallQueryComponent__.d.ts.map +1 -1
- package/out/concepts/CallQueryComponent__.js +90 -56
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/CompletionProperty__.d.ts.map +1 -1
- package/out/concepts/CompletionProperty__.js +7 -0
- package/out/concepts/CompletionProperty__.js.map +1 -1
- package/out/concepts/ConfigProperty__.js +2 -2
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Connection__.js +2 -2
- package/out/concepts/Connection__.js.map +1 -1
- package/out/concepts/ConnectorTrigger__.js +1 -1
- package/out/concepts/ConnectorTrigger__.js.map +1 -1
- package/out/concepts/Continue__.d.ts +33 -0
- package/out/concepts/Continue__.d.ts.map +1 -0
- package/out/concepts/Continue__.js +120 -0
- package/out/concepts/Continue__.js.map +1 -0
- package/out/concepts/DataSource__.d.ts +12 -1
- package/out/concepts/DataSource__.d.ts.map +1 -1
- package/out/concepts/DataSource__.js +58 -5
- package/out/concepts/DataSource__.js.map +1 -1
- package/out/concepts/DefaultValue__.d.ts +1 -0
- package/out/concepts/DefaultValue__.d.ts.map +1 -1
- package/out/concepts/DefaultValue__.js +9 -0
- package/out/concepts/DefaultValue__.js.map +1 -1
- package/out/concepts/Dependency__.js +1 -1
- package/out/concepts/Dependency__.js.map +1 -1
- package/out/concepts/Destination__.js +1 -1
- package/out/concepts/End__.d.ts.map +1 -1
- package/out/concepts/End__.js +34 -2
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +13 -0
- package/out/concepts/Entity__.d.ts.map +1 -1
- package/out/concepts/Entity__.js +49 -9
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/Enum__.js +2 -2
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/ExternalDestination__.js +1 -1
- package/out/concepts/ForEachStatement__.d.ts.map +1 -1
- package/out/concepts/ForEachStatement__.js +10 -8
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/FrontendType__.js +1 -1
- package/out/concepts/FrontendType__.js.map +1 -1
- package/out/concepts/Frontend__.d.ts +0 -3
- package/out/concepts/Frontend__.d.ts.map +1 -1
- package/out/concepts/Frontend__.js +1 -25
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/InterfaceParam__.d.ts +1 -0
- package/out/concepts/InterfaceParam__.d.ts.map +1 -1
- package/out/concepts/InterfaceParam__.js +35 -0
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/Interface__.d.ts +1 -0
- package/out/concepts/Interface__.d.ts.map +1 -1
- package/out/concepts/Interface__.js +45 -2
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/JSBlock__.d.ts.map +1 -1
- package/out/concepts/JSBlock__.js +1 -3
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +1 -1
- package/out/concepts/LogicItem__.d.ts.map +1 -1
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +12 -1
- package/out/concepts/Logic__.d.ts.map +1 -1
- package/out/concepts/Logic__.js +56 -21
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MemberExpression__.d.ts +4 -0
- package/out/concepts/MemberExpression__.d.ts.map +1 -1
- package/out/concepts/MemberExpression__.js +16 -0
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/MetadataType__.js +2 -2
- package/out/concepts/MetadataType__.js.map +1 -1
- package/out/concepts/Module__.d.ts +7 -1
- package/out/concepts/Module__.d.ts.map +1 -1
- package/out/concepts/Module__.js +40 -2
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/Namespace__.js +1 -1
- package/out/concepts/Namespace__.js.map +1 -1
- package/out/concepts/NewComposite__.d.ts +35 -3
- package/out/concepts/NewComposite__.d.ts.map +1 -1
- package/out/concepts/NewComposite__.js +465 -67
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/OperatePermissionV2__.d.ts +9 -1
- package/out/concepts/OperatePermissionV2__.d.ts.map +1 -1
- package/out/concepts/OperatePermissionV2__.js +24 -3
- package/out/concepts/OperatePermissionV2__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.d.ts +2 -0
- package/out/concepts/OqlQueryComponent__.d.ts.map +1 -1
- package/out/concepts/OqlQueryComponent__.js +10 -0
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/OverriddenLogic__.d.ts.map +1 -1
- package/out/concepts/OverriddenLogic__.js +2 -1
- package/out/concepts/OverriddenLogic__.js.map +1 -1
- package/out/concepts/Param__.d.ts +1 -0
- package/out/concepts/Param__.d.ts.map +1 -1
- package/out/concepts/Param__.js +38 -2
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/PermissionForSharedScope__.d.ts +34 -0
- package/out/concepts/PermissionForSharedScope__.d.ts.map +1 -0
- package/out/concepts/PermissionForSharedScope__.js +73 -0
- package/out/concepts/PermissionForSharedScope__.js.map +1 -0
- package/out/concepts/ProcessElementV2__.d.ts +4 -0
- package/out/concepts/ProcessElementV2__.d.ts.map +1 -1
- package/out/concepts/ProcessElementV2__.js +75 -10
- package/out/concepts/ProcessElementV2__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +1 -1
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/ProcessV2__.d.ts.map +1 -1
- package/out/concepts/ProcessV2__.js +1 -8
- package/out/concepts/ProcessV2__.js.map +1 -1
- package/out/concepts/Process__.js +1 -1
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/QueryFieldExpression__.d.ts +5 -0
- package/out/concepts/QueryFieldExpression__.d.ts.map +1 -1
- package/out/concepts/QueryFieldExpression__.js +15 -4
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.d.ts +1 -0
- package/out/concepts/QueryFromExpression__.d.ts.map +1 -1
- package/out/concepts/QueryFromExpression__.js +3 -0
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.d.ts +1 -0
- package/out/concepts/QueryJoinExpression__.d.ts.map +1 -1
- package/out/concepts/QueryJoinExpression__.js +3 -0
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/Return__.d.ts +1 -0
- package/out/concepts/Return__.d.ts.map +1 -1
- package/out/concepts/Return__.js +39 -2
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/Role__.js +1 -1
- package/out/concepts/Role__.js.map +1 -1
- package/out/concepts/SelectMembers__.d.ts +5 -0
- package/out/concepts/SelectMembers__.d.ts.map +1 -1
- package/out/concepts/SelectMembers__.js +66 -0
- package/out/concepts/SelectMembers__.js.map +1 -1
- package/out/concepts/SharedScope__.d.ts +38 -0
- package/out/concepts/SharedScope__.d.ts.map +1 -0
- package/out/concepts/SharedScope__.js +79 -0
- package/out/concepts/SharedScope__.js.map +1 -0
- package/out/concepts/StructureProperty__.d.ts +1 -0
- package/out/concepts/StructureProperty__.d.ts.map +1 -1
- package/out/concepts/StructureProperty__.js +37 -0
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.d.ts +1 -1
- package/out/concepts/Structure__.d.ts.map +1 -1
- package/out/concepts/Structure__.js +23 -30
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SubLogic__.d.ts +3 -1
- package/out/concepts/SubLogic__.d.ts.map +1 -1
- package/out/concepts/SubLogic__.js +127 -2
- package/out/concepts/SubLogic__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +21 -0
- package/out/concepts/TypeAnnotation__.d.ts.map +1 -1
- package/out/concepts/TypeAnnotation__.js +82 -0
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/TypeParam__.d.ts +1 -0
- package/out/concepts/TypeParam__.d.ts.map +1 -1
- package/out/concepts/TypeParam__.js +32 -0
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/Variable__.js +1 -1
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts.map +1 -1
- package/out/concepts/ViewElement__.js +29 -1
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts.map +1 -1
- package/out/concepts/View__.js +5 -2
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.processV2.d.ts.map +1 -1
- package/out/concepts/basics/stdlib/nasl.processV2.js +279 -129
- package/out/concepts/basics/stdlib/nasl.processV2.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.d.ts.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +238 -0
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/index__.d.ts +2 -0
- package/out/concepts/index__.d.ts.map +1 -1
- package/out/concepts/index__.js +2 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/concepts/utils/asserts.d.ts +204 -0
- package/out/concepts/utils/asserts.d.ts.map +1 -1
- package/out/concepts/utils/asserts.js +286 -15
- package/out/concepts/utils/asserts.js.map +1 -1
- package/out/concepts/utils/types.d.ts +16 -2
- package/out/concepts/utils/types.d.ts.map +1 -1
- package/out/semantics/localVarCollector.d.ts +11 -0
- package/out/semantics/localVarCollector.d.ts.map +1 -0
- package/out/semantics/localVarCollector.js +41 -0
- package/out/semantics/localVarCollector.js.map +1 -0
- package/out/semantics/semanticData.d.ts +6 -5
- package/out/semantics/semanticData.d.ts.map +1 -1
- package/out/semantics/semanticData.js +69 -62
- package/out/semantics/semanticData.js.map +1 -1
- package/out/service/engine.d.ts.map +1 -1
- package/out/service/engine.js +4 -0
- package/out/service/engine.js.map +1 -1
- package/out/service/entity2LogicNamespace.d.ts.map +1 -1
- package/out/service/entity2LogicNamespace.js +20 -9
- package/out/service/entity2LogicNamespace.js.map +1 -1
- package/out/service/formatTsUtils.d.ts +1 -1
- package/out/service/formatTsUtils.d.ts.map +1 -1
- package/out/service/formatTsUtils.js +38 -25
- package/out/service/formatTsUtils.js.map +1 -1
- package/out/service/genSlotVarRef.d.ts +3 -0
- package/out/service/genSlotVarRef.d.ts.map +1 -0
- package/out/service/genSlotVarRef.js +154 -0
- package/out/service/genSlotVarRef.js.map +1 -0
- package/out/service/getExtensionModules.d.ts.map +1 -1
- package/out/service/getExtensionModules.js +12 -0
- package/out/service/getExtensionModules.js.map +1 -1
- package/out/service/getLogics.d.ts.map +1 -1
- package/out/service/getLogics.js +24 -26
- package/out/service/getLogics.js.map +1 -1
- package/out/service/getMemberIdentifier.d.ts.map +1 -1
- package/out/service/getMemberIdentifier.js +104 -255
- package/out/service/getMemberIdentifier.js.map +1 -1
- package/out/service/getProcesses.d.ts.map +1 -1
- package/out/service/getProcesses.js +31 -29
- package/out/service/getProcesses.js.map +1 -1
- package/out/service/getProcessesV2.js +1 -1
- package/out/service/getProcessesV2.js.map +1 -1
- package/out/utils/traverse.d.ts +14 -2
- package/out/utils/traverse.d.ts.map +1 -1
- package/out/utils/traverse.js +28 -10
- package/out/utils/traverse.js.map +1 -1
- package/package.json +5 -5
|
@@ -36,6 +36,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.BatchAssignment = void 0;
|
|
37
37
|
const utils_1 = require("../utils");
|
|
38
38
|
const nasl_translator_1 = require("@lcap/nasl-translator");
|
|
39
|
+
var MatchingStrategies;
|
|
40
|
+
(function (MatchingStrategies) {
|
|
41
|
+
MatchingStrategies["BY_NAME"] = "BY_NAME";
|
|
42
|
+
MatchingStrategies["BY_TYPE"] = "BY_TYPE";
|
|
43
|
+
MatchingStrategies["BY_NAME_AND_TYPE"] = "BY_NAME_AND_TYPE";
|
|
44
|
+
MatchingStrategies["BY_TOP_DOWN"] = "BY_TOP_DOWN";
|
|
45
|
+
})(MatchingStrategies || (MatchingStrategies = {}));
|
|
39
46
|
const decorators_1 = require("../decorators");
|
|
40
47
|
const utils = __importStar(require("../utils"));
|
|
41
48
|
const asserts = __importStar(require("./utils/asserts"));
|
|
@@ -72,6 +79,8 @@ let BatchAssignment = class BatchAssignment extends LogicItem__1.default {
|
|
|
72
79
|
* 自动连线
|
|
73
80
|
*/
|
|
74
81
|
this.autoConnection = true;
|
|
82
|
+
// 匹配策略
|
|
83
|
+
this.matchingStrategy = MatchingStrategies.BY_NAME_AND_TYPE;
|
|
75
84
|
super.subConstructor(source);
|
|
76
85
|
}
|
|
77
86
|
static from(source, parentNode, parentKey) {
|
|
@@ -289,9 +298,219 @@ let BatchAssignment = class BatchAssignment extends LogicItem__1.default {
|
|
|
289
298
|
},
|
|
290
299
|
};
|
|
291
300
|
}
|
|
292
|
-
|
|
293
|
-
|
|
301
|
+
checkConditions({ leftName, rightName, leftTypeAnnotation, rightTypeAnnotation, }) {
|
|
302
|
+
// 条件数组
|
|
303
|
+
const conditions = [];
|
|
304
|
+
if ([
|
|
305
|
+
MatchingStrategies.BY_NAME,
|
|
306
|
+
MatchingStrategies.BY_NAME_AND_TYPE,
|
|
307
|
+
].includes(this.matchingStrategy)) {
|
|
308
|
+
conditions.push(() => {
|
|
309
|
+
return leftName === rightName;
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
if ([
|
|
313
|
+
MatchingStrategies.BY_TYPE,
|
|
314
|
+
MatchingStrategies.BY_NAME_AND_TYPE,
|
|
315
|
+
].includes(this.matchingStrategy)) {
|
|
316
|
+
conditions.push(() => {
|
|
317
|
+
return rightTypeAnnotation?.sortedTypeKey === leftTypeAnnotation.sortedTypeKey;
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
if ([
|
|
321
|
+
MatchingStrategies.BY_TOP_DOWN,
|
|
322
|
+
].includes(this.matchingStrategy)) {
|
|
323
|
+
conditions.push(() => {
|
|
324
|
+
return true;
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
return conditions.every(condition => condition());
|
|
328
|
+
}
|
|
329
|
+
// 替换变量
|
|
330
|
+
async replaceIdentifier(oldNode, expression, members) {
|
|
331
|
+
// 关闭定时
|
|
332
|
+
this.app._noTimer = true;
|
|
333
|
+
this.app.emit('collect:start', {
|
|
334
|
+
actionMsg: '替换变量',
|
|
335
|
+
});
|
|
336
|
+
// 被替换的第一层属性
|
|
337
|
+
const oldSelectMember = oldNode.parentNode;
|
|
338
|
+
const newSelectMember = {
|
|
339
|
+
...(oldSelectMember?.toJSON?.() ?? oldSelectMember),
|
|
340
|
+
expression,
|
|
341
|
+
members: [],
|
|
342
|
+
};
|
|
343
|
+
// 如果替换的是右侧
|
|
344
|
+
let firstRightIndex = -1;
|
|
345
|
+
const params = {};
|
|
346
|
+
// 待定的连线(保留的属性的连线也要保留)
|
|
347
|
+
const pendingLinesMap = new Map();
|
|
348
|
+
let newLines = [];
|
|
349
|
+
// 如果替换的是左侧
|
|
350
|
+
if (oldSelectMember.parentKey === 'left') {
|
|
351
|
+
params.left = newSelectMember;
|
|
352
|
+
newLines = this.assignmentLines.filter((line) => {
|
|
353
|
+
const { leftIndex } = line;
|
|
354
|
+
const [first, second] = leftIndex || [];
|
|
355
|
+
if (leftIndex.length === 2) {
|
|
356
|
+
if (!pendingLinesMap.get(second)) {
|
|
357
|
+
pendingLinesMap.set(second, []);
|
|
358
|
+
}
|
|
359
|
+
const lines = pendingLinesMap.get(second);
|
|
360
|
+
lines.push(line);
|
|
361
|
+
return false;
|
|
362
|
+
}
|
|
363
|
+
return true;
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
firstRightIndex = this.rights.findIndex((right) => {
|
|
368
|
+
return oldSelectMember === right;
|
|
369
|
+
});
|
|
370
|
+
params.rights = [
|
|
371
|
+
...this.rights.slice(0, firstRightIndex),
|
|
372
|
+
newSelectMember,
|
|
373
|
+
...this.rights.slice(firstRightIndex + 1, this.rights.length),
|
|
374
|
+
];
|
|
375
|
+
newLines = this.assignmentLines.filter((line) => {
|
|
376
|
+
const { rightIndex } = line;
|
|
377
|
+
const [first, second] = rightIndex || [];
|
|
378
|
+
if (rightIndex.length === 2 && first === firstRightIndex) {
|
|
379
|
+
if (!pendingLinesMap.get(second)) {
|
|
380
|
+
pendingLinesMap.set(second, []);
|
|
381
|
+
}
|
|
382
|
+
const lines = pendingLinesMap.get(second);
|
|
383
|
+
lines.push(line);
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
return true;
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
// 先用变量替换右侧的属性
|
|
390
|
+
this.update({
|
|
391
|
+
...params,
|
|
392
|
+
assignmentLines: newLines,
|
|
393
|
+
});
|
|
394
|
+
// 触发ts类型标注
|
|
395
|
+
this.app.naslServer?.embeddedTSEmitter.emit('change', {
|
|
396
|
+
value: [
|
|
397
|
+
{
|
|
398
|
+
originEvent: {
|
|
399
|
+
action: 'update',
|
|
400
|
+
target: this,
|
|
401
|
+
},
|
|
402
|
+
},
|
|
403
|
+
],
|
|
404
|
+
});
|
|
405
|
+
const memberInfoMap = new Map();
|
|
406
|
+
// 获取拖入表达式的类型
|
|
407
|
+
const currTypeAnnotation = await newSelectMember.expression?.getCurrentTypeAnnotation(30000);
|
|
408
|
+
// 当前类型下的所有属性(递归)
|
|
409
|
+
const propertyMap = currTypeAnnotation?.collectPropertyMap?.(this.app);
|
|
410
|
+
if (propertyMap) {
|
|
411
|
+
oldSelectMember?.members.forEach((member, index) => {
|
|
412
|
+
// 完整属性名
|
|
413
|
+
const oldCompletePropertyName = member.completePropertyName;
|
|
414
|
+
const { typeAnnotation, __TypeAnnotation } = member || {};
|
|
415
|
+
// 属性类型
|
|
416
|
+
const memberTypeAnnotation = typeAnnotation || __TypeAnnotation;
|
|
417
|
+
if (propertyMap.get(oldCompletePropertyName)?.typeKey === memberTypeAnnotation?.typeKey) {
|
|
418
|
+
memberInfoMap.set(oldCompletePropertyName, {
|
|
419
|
+
orginIndex: index,
|
|
420
|
+
member,
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
members.forEach((member) => {
|
|
426
|
+
const { completePropertyName } = member || {};
|
|
427
|
+
if (!memberInfoMap.has(completePropertyName)) {
|
|
428
|
+
memberInfoMap.set(completePropertyName, {
|
|
429
|
+
orginIndex: -1,
|
|
430
|
+
member,
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
const memberInfos = [...memberInfoMap.values()];
|
|
435
|
+
if (propertyMap) {
|
|
436
|
+
memberInfos.sort((member1, member2) => {
|
|
437
|
+
return propertyMap.get(member1?.member?.completePropertyName)?.index - propertyMap.get(member2?.member?.completePropertyName)?.index;
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
// 保留的左侧属性
|
|
441
|
+
const reservedLeftIndex = [];
|
|
442
|
+
// 保留的右侧属性
|
|
443
|
+
const reservedRightIndex = [];
|
|
444
|
+
let targetSelectMembers;
|
|
445
|
+
if (oldSelectMember.parentKey === 'left') {
|
|
446
|
+
memberInfos.forEach(({ orginIndex, }, index) => {
|
|
447
|
+
if (orginIndex !== -1) {
|
|
448
|
+
reservedLeftIndex.push(index);
|
|
449
|
+
const pendingLines = pendingLinesMap.get(orginIndex);
|
|
450
|
+
if (Array.isArray(pendingLines)) {
|
|
451
|
+
pendingLines.forEach((pendingLine) => {
|
|
452
|
+
const newLine = {
|
|
453
|
+
...(pendingLine?.toJSON?.() ?? pendingLine),
|
|
454
|
+
leftIndex: [0, index],
|
|
455
|
+
};
|
|
456
|
+
newLines.push(newLine);
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
targetSelectMembers = this.left;
|
|
462
|
+
}
|
|
463
|
+
else {
|
|
464
|
+
memberInfos.forEach(({ orginIndex, }, index) => {
|
|
465
|
+
if (orginIndex !== -1) {
|
|
466
|
+
reservedRightIndex.push(`${firstRightIndex}_${index}`);
|
|
467
|
+
const pendingLines = pendingLinesMap.get(orginIndex);
|
|
468
|
+
if (Array.isArray(pendingLines)) {
|
|
469
|
+
pendingLines.forEach((pendingLine) => {
|
|
470
|
+
const newLine = {
|
|
471
|
+
...(pendingLine?.toJSON?.() ?? pendingLine),
|
|
472
|
+
rightIndex: [pendingLine.rightIndex[0], index],
|
|
473
|
+
};
|
|
474
|
+
newLines.push(newLine);
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
targetSelectMembers = this.rights[firstRightIndex];
|
|
480
|
+
}
|
|
481
|
+
if (targetSelectMembers) {
|
|
482
|
+
const MemberExpression = (0, decorators_1.getConceptConstructor)('MemberExpression');
|
|
483
|
+
targetSelectMembers.update({
|
|
484
|
+
members: memberInfos.map(({ member, }) => {
|
|
485
|
+
return new MemberExpression({
|
|
486
|
+
...(member?.firstMemberExpressionNode?.()?.toJSON() || {}),
|
|
487
|
+
object: expression?.toJSON(),
|
|
488
|
+
});
|
|
489
|
+
}),
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
// 更新属性和连线
|
|
493
|
+
this.update({
|
|
494
|
+
assignmentLines: newLines,
|
|
495
|
+
});
|
|
496
|
+
this.autoConnection && this.batchAutoConnection({
|
|
497
|
+
targetRightIndex: firstRightIndex,
|
|
498
|
+
reservedRightIndex,
|
|
499
|
+
reservedLeftIndex,
|
|
500
|
+
});
|
|
501
|
+
this.app.emit('collect:end');
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* 自动连线算法
|
|
505
|
+
* @param param0
|
|
506
|
+
*/
|
|
507
|
+
batchAutoConnection({ targetRightIndex, reservedLeftIndex, reservedRightIndex, }) {
|
|
294
508
|
const leftLineSet = new Set();
|
|
509
|
+
if (Array.isArray(reservedLeftIndex)) {
|
|
510
|
+
reservedLeftIndex.forEach((index) => {
|
|
511
|
+
leftLineSet.add(index);
|
|
512
|
+
});
|
|
513
|
+
}
|
|
295
514
|
const lineArr = [];
|
|
296
515
|
const AssignmentLine = (0, decorators_1.getConceptConstructor)('AssignmentLine');
|
|
297
516
|
// 系统属性不可自动连线
|
|
@@ -314,72 +533,131 @@ let BatchAssignment = class BatchAssignment extends LogicItem__1.default {
|
|
|
314
533
|
this.app.emit('collect:start', {
|
|
315
534
|
actionMsg: '自动连线',
|
|
316
535
|
});
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
536
|
+
// 目标右侧
|
|
537
|
+
const targetRights = [-1, null, undefined].includes(targetRightIndex) ? this.rights.map((right, index) => {
|
|
538
|
+
return {
|
|
539
|
+
right,
|
|
540
|
+
index,
|
|
541
|
+
};
|
|
542
|
+
}) : [
|
|
543
|
+
{
|
|
544
|
+
right: this.rights?.[targetRightIndex],
|
|
545
|
+
index: targetRightIndex,
|
|
546
|
+
},
|
|
547
|
+
];
|
|
548
|
+
// 右侧父节点也不允许自动连线
|
|
549
|
+
const rightLineSet = new Set();
|
|
550
|
+
if (Array.isArray(reservedRightIndex) && reservedRightIndex.length) {
|
|
551
|
+
reservedRightIndex.forEach((rightIndex) => {
|
|
552
|
+
rightLineSet.add(rightIndex);
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
if (targetRights) {
|
|
556
|
+
targetRights.forEach(({ right: targetRight, index, }) => {
|
|
557
|
+
const { members } = targetRight;
|
|
331
558
|
for (let i = 0; i < members.length - 1; i++) {
|
|
332
559
|
const { completeName } = members[i];
|
|
333
560
|
const preCompleteName = members[i + 1].completeName;
|
|
334
561
|
if (preCompleteName.includes(completeName) &&
|
|
335
|
-
completeName.split('.').length !== preCompleteName.split('.').length)
|
|
336
|
-
rightLineSet.add(i);
|
|
562
|
+
completeName.split('.').length !== preCompleteName.split('.').length) {
|
|
563
|
+
rightLineSet.add(`${index}_${i}`);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
this.assignmentLines.forEach((assignmentLine) => {
|
|
569
|
+
const { rightIndex } = assignmentLine;
|
|
570
|
+
if (rightIndex.length === 1) {
|
|
571
|
+
rightLineSet.add(`${rightIndex?.[0]}`);
|
|
572
|
+
}
|
|
573
|
+
else if (rightIndex.length === 2) {
|
|
574
|
+
const [firstIndex, secondIndex] = rightIndex || [];
|
|
575
|
+
rightLineSet.add(`${firstIndex}_${secondIndex}`);
|
|
576
|
+
}
|
|
577
|
+
});
|
|
578
|
+
this.left.members.forEach((member, leftSecondIndex) => {
|
|
579
|
+
const leftName = member.property?.name;
|
|
580
|
+
const leftTypeAnnotation = member.__TypeAnnotation;
|
|
581
|
+
targetRights.forEach(({ right: targetRight, index: rightFirstIndex, }) => {
|
|
582
|
+
// 已经有连线的不需要自动连线
|
|
583
|
+
if (leftLineSet.has(leftSecondIndex) || leftLineSet.has(leftName)) {
|
|
584
|
+
return;
|
|
337
585
|
}
|
|
338
|
-
|
|
586
|
+
const { members, expression } = targetRight;
|
|
587
|
+
if (members?.length) {
|
|
588
|
+
members.forEach((rightMember, rightSecondIndex) => {
|
|
589
|
+
// 已经有连线的不需要自动连线
|
|
590
|
+
if (leftLineSet.has(leftSecondIndex) || leftLineSet.has(leftName)) {
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
if (rightLineSet.has(`${rightFirstIndex}_${rightSecondIndex}`)) {
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
const rightName = rightMember.property?.name;
|
|
597
|
+
if (rightLineSet.has(`${rightFirstIndex}_${rightSecondIndex}`) || leftLineSet.has(leftSecondIndex)) {
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
if (this.checkConditions({
|
|
601
|
+
leftName,
|
|
602
|
+
rightName,
|
|
603
|
+
leftTypeAnnotation,
|
|
604
|
+
rightTypeAnnotation: rightMember.__TypeAnnotation,
|
|
605
|
+
})) {
|
|
606
|
+
const leftIndex = [0, leftSecondIndex];
|
|
607
|
+
const rightIndex = [rightFirstIndex, rightSecondIndex];
|
|
608
|
+
const Line = new AssignmentLine({ leftIndex, rightIndex });
|
|
609
|
+
lineArr.push(Line);
|
|
610
|
+
leftLineSet.add(leftSecondIndex);
|
|
611
|
+
rightLineSet.add(`${rightFirstIndex}_${rightSecondIndex}`);
|
|
612
|
+
}
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
else if (this.checkConditions({
|
|
616
|
+
leftName,
|
|
617
|
+
rightName: expression.name,
|
|
618
|
+
leftTypeAnnotation,
|
|
619
|
+
rightTypeAnnotation: expression.__TypeAnnotation,
|
|
620
|
+
})) {
|
|
621
|
+
if (rightLineSet.has(`${rightFirstIndex}`)) {
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
339
624
|
const Line = new AssignmentLine({
|
|
340
625
|
leftIndex: [0, leftSecondIndex],
|
|
341
626
|
rightIndex: [rightFirstIndex],
|
|
342
627
|
});
|
|
343
628
|
lineArr.push(Line);
|
|
344
629
|
leftLineSet.add(leftSecondIndex);
|
|
345
|
-
|
|
630
|
+
rightLineSet.add(`${rightFirstIndex}`);
|
|
346
631
|
}
|
|
347
|
-
members.forEach((rightMember, rightSecondIndex) => {
|
|
348
|
-
const rightValue = rightMember.getValue();
|
|
349
|
-
const rightName = rightMember.property?.name;
|
|
350
|
-
if (rightLineSet.has(rightSecondIndex) || leftLineSet.has(leftSecondIndex))
|
|
351
|
-
return;
|
|
352
|
-
if (leftName === rightName && leftValue.split('.').length === rightValue.split('.').length) {
|
|
353
|
-
const rightTypeAnnotation = rightMember.__TypeAnnotation;
|
|
354
|
-
if (leftTypeAnnotation.typeName !== rightTypeAnnotation.typeName)
|
|
355
|
-
return;
|
|
356
|
-
const leftIndex = [0, leftSecondIndex];
|
|
357
|
-
const rightIndex = [rightFirstIndex, rightSecondIndex];
|
|
358
|
-
const Line = new AssignmentLine({ leftIndex, rightIndex });
|
|
359
|
-
lineArr.push(Line);
|
|
360
|
-
leftLineSet.add(leftSecondIndex);
|
|
361
|
-
}
|
|
362
|
-
});
|
|
363
632
|
});
|
|
364
633
|
});
|
|
365
634
|
lineArr.length && this.setAssignmentLines([...this.assignmentLines, ...lineArr]);
|
|
366
635
|
this.app.emit('collect:end');
|
|
367
636
|
};
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
637
|
+
// 跟类型相关的才需要等待
|
|
638
|
+
if ([
|
|
639
|
+
MatchingStrategies.BY_TYPE,
|
|
640
|
+
MatchingStrategies.BY_NAME_AND_TYPE,
|
|
641
|
+
].includes(this.matchingStrategy)) {
|
|
642
|
+
let count = 0;
|
|
643
|
+
const typeAnnotationEnd = () => {
|
|
644
|
+
const l = this.left.members.every((item) => item.__isCorrectTypeAnnotation);
|
|
645
|
+
const r = this.rights.every((right) => right.members.every((item) => item.__isCorrectTypeAnnotation) && right.expression.__isCorrectTypeAnnotation);
|
|
646
|
+
count++;
|
|
647
|
+
if (l && r) {
|
|
648
|
+
autoConnection();
|
|
649
|
+
}
|
|
650
|
+
else if (count <= 10) {
|
|
651
|
+
setTimeout(() => {
|
|
652
|
+
typeAnnotationEnd();
|
|
653
|
+
}, 100);
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
typeAnnotationEnd();
|
|
657
|
+
}
|
|
658
|
+
else {
|
|
659
|
+
autoConnection();
|
|
660
|
+
}
|
|
383
661
|
}
|
|
384
662
|
connection(leftItem, rightItem, rightToLeft) {
|
|
385
663
|
let newLeftIndex = [0];
|
|
@@ -506,19 +784,104 @@ let BatchAssignment = class BatchAssignment extends LogicItem__1.default {
|
|
|
506
784
|
});
|
|
507
785
|
}
|
|
508
786
|
}
|
|
509
|
-
changeMembers(oldNode, members,
|
|
787
|
+
async changeMembers(oldNode, members, expression) {
|
|
788
|
+
// 关闭定时
|
|
789
|
+
this.app._noTimer = true;
|
|
510
790
|
this.app.emit('collect:start', {
|
|
511
791
|
actionMsg: '批量赋值修改变量',
|
|
512
792
|
});
|
|
513
|
-
const
|
|
514
|
-
|
|
515
|
-
const
|
|
793
|
+
const oldSelectMember = oldNode.parentNode;
|
|
794
|
+
// 之前的结构属性
|
|
795
|
+
const keepPropertyMap = new Map();
|
|
796
|
+
oldSelectMember.members.forEach((member) => {
|
|
797
|
+
if (asserts.isMemberExpression(member)) {
|
|
798
|
+
const typeAnnotation = member?.__TypeAnnotation || member?.typeAnnotation;
|
|
799
|
+
const lines = this.findlines(member, oldSelectMember);
|
|
800
|
+
keepPropertyMap.set(member?.completePropertyName, {
|
|
801
|
+
member,
|
|
802
|
+
lines,
|
|
803
|
+
sortedTypeKey: typeAnnotation?.sortedTypeKey,
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
});
|
|
807
|
+
const targetRightIndex = this.rights.findIndex((right) => right === oldSelectMember);
|
|
808
|
+
const newSelectMemberJson = {
|
|
809
|
+
...oldSelectMember?.toJSON?.(),
|
|
810
|
+
expression,
|
|
811
|
+
members,
|
|
812
|
+
};
|
|
516
813
|
let newLines = [];
|
|
814
|
+
if (oldSelectMember.parentKey === 'left') {
|
|
815
|
+
this.update({
|
|
816
|
+
left: newSelectMemberJson,
|
|
817
|
+
assignmentLines: newLines,
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
else {
|
|
821
|
+
newLines = this.assignmentLines.filter(({ rightIndex, }) => {
|
|
822
|
+
return (rightIndex[0] !== targetRightIndex) || (rightIndex?.length === 1);
|
|
823
|
+
});
|
|
824
|
+
this.update({
|
|
825
|
+
rights: [
|
|
826
|
+
...this.rights.slice(0, targetRightIndex),
|
|
827
|
+
newSelectMemberJson,
|
|
828
|
+
...this.rights.slice(targetRightIndex + 1, this.rights.length),
|
|
829
|
+
],
|
|
830
|
+
assignmentLines: newLines,
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
// 触发ts类型标注
|
|
834
|
+
this.app.naslServer?.embeddedTSEmitter.emit('change', {
|
|
835
|
+
value: [
|
|
836
|
+
{
|
|
837
|
+
originEvent: {
|
|
838
|
+
action: 'update',
|
|
839
|
+
target: this,
|
|
840
|
+
},
|
|
841
|
+
},
|
|
842
|
+
],
|
|
843
|
+
});
|
|
844
|
+
// 表达式的类型
|
|
845
|
+
await expression?.getCurrentTypeAnnotation(30000);
|
|
846
|
+
const propertyMap = new Map();
|
|
847
|
+
if (asserts.isIdentifier(expression)) {
|
|
848
|
+
const { namespace, name } = expression;
|
|
849
|
+
const completeList = [];
|
|
850
|
+
if (namespace) {
|
|
851
|
+
completeList.push(namespace);
|
|
852
|
+
}
|
|
853
|
+
completeList.push(name);
|
|
854
|
+
const completeName = completeList.join('.');
|
|
855
|
+
const count = propertyMap.size;
|
|
856
|
+
// 获取类型注解并提取其结构
|
|
857
|
+
const typeAnnotation = expression?.__TypeAnnotation || expression?.typeAnnotation;
|
|
858
|
+
// 将完整属性名添加到属性映射表中
|
|
859
|
+
propertyMap.set(completeName, {
|
|
860
|
+
index: count,
|
|
861
|
+
typeKey: typeAnnotation?.typeKey,
|
|
862
|
+
});
|
|
863
|
+
let depth = 0;
|
|
864
|
+
typeAnnotation?.collectPropertyMap(this.app, completeName, propertyMap, depth);
|
|
865
|
+
}
|
|
866
|
+
if (propertyMap.size) {
|
|
867
|
+
members.sort((a, b) => {
|
|
868
|
+
return (propertyMap.get(a.completeName)?.index - propertyMap.get(b.completeName)?.index);
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
const reservedLeftIndex = [];
|
|
872
|
+
const reservedRightIndex = [];
|
|
517
873
|
// 修改连线
|
|
518
|
-
if (
|
|
874
|
+
if (oldSelectMember.parentKey === 'left') {
|
|
875
|
+
this.left.update({
|
|
876
|
+
members,
|
|
877
|
+
});
|
|
519
878
|
members.forEach((item, index) => {
|
|
520
|
-
|
|
521
|
-
|
|
879
|
+
const oldPropertyInfo = keepPropertyMap.get(item?.completePropertyName);
|
|
880
|
+
const { sortedTypeKey } = oldPropertyInfo || {};
|
|
881
|
+
const typeAnnotation = item?.__TypeAnnotation || item?.typeAnnotation;
|
|
882
|
+
if (sortedTypeKey === typeAnnotation?.sortedTypeKey) {
|
|
883
|
+
reservedLeftIndex.push(index);
|
|
884
|
+
const { lines } = oldPropertyInfo || {};
|
|
522
885
|
lines.forEach((line) => {
|
|
523
886
|
const newLine = { ...line?.toJSON(), leftIndex: [line.leftIndex[0], index] };
|
|
524
887
|
newLines.push(newLine);
|
|
@@ -527,15 +890,20 @@ let BatchAssignment = class BatchAssignment extends LogicItem__1.default {
|
|
|
527
890
|
});
|
|
528
891
|
this.update({
|
|
529
892
|
assignmentLines: newLines,
|
|
530
|
-
left: newSelectMember,
|
|
531
893
|
});
|
|
532
894
|
}
|
|
533
895
|
else {
|
|
534
|
-
const
|
|
535
|
-
|
|
896
|
+
const newSelectMember = this.rights.find((right, index) => index === targetRightIndex);
|
|
897
|
+
newSelectMember.update({
|
|
898
|
+
members,
|
|
899
|
+
});
|
|
536
900
|
members.forEach((item, index) => {
|
|
537
|
-
|
|
538
|
-
|
|
901
|
+
const oldPropertyInfo = keepPropertyMap.get(item?.completePropertyName);
|
|
902
|
+
const { sortedTypeKey } = oldPropertyInfo || {};
|
|
903
|
+
const typeAnnotation = item?.__TypeAnnotation || item?.typeAnnotation;
|
|
904
|
+
if (sortedTypeKey === typeAnnotation?.sortedTypeKey) {
|
|
905
|
+
reservedRightIndex.push(`${targetRightIndex}_${index}`);
|
|
906
|
+
const { lines } = oldPropertyInfo || {};
|
|
539
907
|
lines.forEach((line) => {
|
|
540
908
|
const newLine = { ...line?.toJSON(), rightIndex: [line.rightIndex[0], index] };
|
|
541
909
|
newLines.push(newLine);
|
|
@@ -544,14 +912,13 @@ let BatchAssignment = class BatchAssignment extends LogicItem__1.default {
|
|
|
544
912
|
});
|
|
545
913
|
this.update({
|
|
546
914
|
assignmentLines: newLines,
|
|
547
|
-
rights: [
|
|
548
|
-
...this.rights.slice(0, splitIndex),
|
|
549
|
-
newSelectMember,
|
|
550
|
-
...this.rights.slice(splitIndex + 1, this.rights.length),
|
|
551
|
-
],
|
|
552
915
|
});
|
|
553
916
|
}
|
|
554
|
-
this.autoConnection && this.batchAutoConnection(
|
|
917
|
+
this.autoConnection && this.batchAutoConnection({
|
|
918
|
+
targetRightIndex,
|
|
919
|
+
reservedLeftIndex,
|
|
920
|
+
reservedRightIndex,
|
|
921
|
+
});
|
|
555
922
|
this.app.emit('collect:end');
|
|
556
923
|
}
|
|
557
924
|
findMember(arrIndex, place) {
|