@lcap/nasl 2.18.0 → 2.20.0-beta.2
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.d.ts +1 -1
- package/out/automate/engine/index.js +4 -4
- package/out/automate/engine/index.js.map +1 -1
- package/out/automate/engine/uniqueName.d.ts +1 -1
- package/out/automate/engine/uniqueName.js +3 -3
- package/out/automate/engine/uniqueName.js.map +1 -1
- package/out/automate/template/myProcess.js +1 -1
- package/out/automate/template/myProcess.js.map +1 -1
- package/out/bak/translator.js +2 -1
- package/out/bak/translator.js.map +1 -1
- package/out/common/BaseNode.js +1 -0
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/AnonymousFunction__.d.ts +1 -0
- package/out/concepts/AnonymousFunction__.js +40 -2
- package/out/concepts/AnonymousFunction__.js.map +1 -1
- package/out/concepts/App__.d.ts +79 -261
- package/out/concepts/App__.js +241 -367
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/BatchAssignment__.d.ts +2 -0
- package/out/concepts/BatchAssignment__.js +108 -47
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts +5 -0
- package/out/concepts/BindAttribute__.js +15 -2
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.d.ts +5 -0
- package/out/concepts/BindDirective__.js +6 -0
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.d.ts +5 -0
- package/out/concepts/BindEvent__.js +6 -0
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BindStyle__.d.ts +5 -0
- package/out/concepts/BindStyle__.js +6 -0
- package/out/concepts/BindStyle__.js.map +1 -1
- package/out/concepts/CallFunction__.js +33 -14
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.js +2 -1
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +2 -1
- package/out/concepts/CallLogic__.js +112 -27
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.js +4 -1
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Constant__.d.ts +5 -0
- package/out/concepts/Constant__.js +6 -0
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/DataSource__.d.ts +2 -0
- package/out/concepts/DataSource__.js +55 -1
- package/out/concepts/DataSource__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +2 -1
- package/out/concepts/Destination__.js +98 -25
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/Frontend__.d.ts +370 -0
- package/out/concepts/Frontend__.js +669 -0
- package/out/concepts/Frontend__.js.map +1 -0
- package/out/concepts/Identifier__.d.ts +1 -0
- package/out/concepts/Identifier__.js +18 -7
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +6 -1
- package/out/concepts/LogicItem__.js +6 -0
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +85 -79
- package/out/concepts/Logic__.js +41 -23
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Match__.js +14 -9
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/NewComposite__.d.ts +345 -0
- package/out/concepts/NewComposite__.js +1068 -0
- package/out/concepts/NewComposite__.js.map +1 -0
- package/out/concepts/NewList__.d.ts +130 -0
- package/out/concepts/NewList__.js +349 -0
- package/out/concepts/NewList__.js.map +1 -0
- package/out/concepts/NewMap__.d.ts +221 -0
- package/out/concepts/NewMap__.js +480 -0
- package/out/concepts/NewMap__.js.map +1 -0
- package/out/concepts/New__.d.ts +19 -0
- package/out/concepts/New__.js +66 -0
- package/out/concepts/New__.js.map +1 -0
- package/out/concepts/Param__.d.ts +7 -0
- package/out/concepts/Param__.js +46 -3
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +42 -13
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/ProcessOutcomes__.d.ts +30 -0
- package/out/concepts/ProcessOutcomes__.js +87 -0
- package/out/concepts/ProcessOutcomes__.js.map +1 -0
- package/out/concepts/Process__.d.ts +4 -20
- package/out/concepts/Process__.js +0 -7
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/Return__.d.ts +5 -0
- package/out/concepts/Return__.js +8 -1
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/SelectMembers__.js +3 -3
- package/out/concepts/SelectMembers__.js.map +1 -1
- package/out/concepts/Transactional__.d.ts +5 -0
- package/out/concepts/Transactional__.js +6 -0
- package/out/concepts/Transactional__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +3 -0
- package/out/concepts/TypeAnnotation__.js +50 -11
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/ValidationRule__.js +1 -1
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.d.ts +5 -0
- package/out/concepts/Variable__.js +9 -2
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +5 -0
- package/out/concepts/ViewElement__.js +21 -3
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +6 -0
- package/out/concepts/View__.js +23 -3
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.auth.js +1 -1
- package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.logging.js +5 -0
- package/out/concepts/basics/stdlib/nasl.logging.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +2 -0
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +151 -19
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/index__.d.ts +7 -0
- package/out/concepts/index__.js +7 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/enums/KEYWORDS.d.ts +1 -0
- package/out/enums/KEYWORDS.js +9 -1
- package/out/enums/KEYWORDS.js.map +1 -1
- package/out/generator/genBundleFiles.d.ts +6 -3
- package/out/generator/genBundleFiles.js +54 -192
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.d.ts +2 -11
- package/out/generator/genMetaData.js +185 -51
- package/out/generator/genMetaData.js.map +1 -1
- package/out/generator/genReleaseBody.d.ts +18 -2
- package/out/generator/genReleaseBody.js +80 -40
- package/out/generator/genReleaseBody.js.map +1 -1
- package/out/generator/index.d.ts +1 -0
- package/out/generator/index.js +1 -0
- package/out/generator/index.js.map +1 -1
- package/out/generator/permission.d.ts +17 -0
- package/out/generator/permission.js +221 -0
- package/out/generator/permission.js.map +1 -0
- package/out/index.d.ts +1 -1
- package/out/index.js +3 -1
- package/out/index.js.map +1 -1
- package/out/server/entity2LogicNamespace.js +89 -9
- package/out/server/entity2LogicNamespace.js.map +1 -1
- package/out/server/extendBaseNode.js +33 -20
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/formatTsUtils.d.ts +1 -2
- package/out/server/formatTsUtils.js +36 -47
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getLogics.d.ts +2 -1
- package/out/server/getLogics.js +13 -2
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +4 -4
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.js +1 -1
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/naslServer.d.ts +3 -1
- package/out/server/naslServer.js +254 -65
- package/out/server/naslServer.js.map +1 -1
- package/out/server/process2LogicNamespace.js +8 -0
- package/out/server/process2LogicNamespace.js.map +1 -1
- package/out/server/translator.js +50 -5
- package/out/server/translator.js.map +1 -1
- package/out/service/creator/add.configs.js +4 -0
- package/out/service/creator/add.configs.js.map +1 -1
- package/out/service/datasource/api.d.ts +12 -0
- package/out/service/datasource/api.js +14 -0
- package/out/service/datasource/api.js.map +1 -0
- package/out/service/datasource/index.d.ts +2 -0
- package/out/service/datasource/index.js +10 -0
- package/out/service/datasource/index.js.map +1 -0
- package/out/service/storage/init.js +15 -4
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genEditTableBlock.js +4 -5
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +4 -3
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +16 -14
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +5 -5
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +6 -10
- package/out/templator/genTableBlock.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 +298 -650
- 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 +945 -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 +28 -26
- package/src/concepts/View__.ts +26 -26
- 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 +15 -3
- package/src/server/getMemberIdentifier.ts +5 -5
- package/src/server/getProcesses.ts +1 -1
- package/src/server/naslServer.ts +260 -77
- 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 +15 -4
- 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/MatchExpression__.d.ts +0 -97
- package/out/concepts/MatchExpression__.js +0 -281
- package/out/concepts/MatchExpression__.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
|
@@ -0,0 +1,1068 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
32
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
33
|
+
};
|
|
34
|
+
var NewComposite_1;
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.NewComposite = void 0;
|
|
37
|
+
const translator_1 = require("../translator");
|
|
38
|
+
const StructureProperty__1 = __importDefault(require("./StructureProperty__"));
|
|
39
|
+
const decorators_1 = require("../decorators");
|
|
40
|
+
const utils = __importStar(require("../utils"));
|
|
41
|
+
const classMap_1 = __importDefault(require("../common/classMap"));
|
|
42
|
+
const TypeAnnotation__1 = __importDefault(require("./TypeAnnotation__"));
|
|
43
|
+
const Identifier__1 = __importDefault(require("./Identifier__"));
|
|
44
|
+
const SelectMembers__1 = __importDefault(require("./SelectMembers__"));
|
|
45
|
+
const AssignmentLine__1 = __importDefault(require("./AssignmentLine__"));
|
|
46
|
+
const LogicItem__1 = __importDefault(require("./LogicItem__"));
|
|
47
|
+
/**
|
|
48
|
+
* 实体/(匿名)数据结构构造器
|
|
49
|
+
*/
|
|
50
|
+
let NewComposite = NewComposite_1 = class NewComposite extends LogicItem__1.default {
|
|
51
|
+
/**
|
|
52
|
+
* 产品概念
|
|
53
|
+
*/
|
|
54
|
+
concept = 'NewComposite';
|
|
55
|
+
/**
|
|
56
|
+
* 类型
|
|
57
|
+
*/
|
|
58
|
+
typeAnnotation = undefined;
|
|
59
|
+
/**
|
|
60
|
+
* 左边项
|
|
61
|
+
*/
|
|
62
|
+
properties = [];
|
|
63
|
+
/**
|
|
64
|
+
* 右边项
|
|
65
|
+
*/
|
|
66
|
+
rights = [];
|
|
67
|
+
/**
|
|
68
|
+
* 赋值线
|
|
69
|
+
*/
|
|
70
|
+
assignmentLines = [];
|
|
71
|
+
/**
|
|
72
|
+
* hideProperties
|
|
73
|
+
*/
|
|
74
|
+
hideProperties = false;
|
|
75
|
+
/**
|
|
76
|
+
* hideDefaults
|
|
77
|
+
*/
|
|
78
|
+
hideDefaults = false;
|
|
79
|
+
/**
|
|
80
|
+
* 自动连线
|
|
81
|
+
*/
|
|
82
|
+
autoConnection = true;
|
|
83
|
+
/**
|
|
84
|
+
* @param source 需要合并的部分参数
|
|
85
|
+
*/
|
|
86
|
+
constructor(source) {
|
|
87
|
+
source = Object.assign({}, NewComposite_1.getDefaultOptions(), source);
|
|
88
|
+
super(source);
|
|
89
|
+
super.subConstructor(source);
|
|
90
|
+
}
|
|
91
|
+
static from(source, parentNode, parentKey) {
|
|
92
|
+
return super.from(source, parentNode, parentKey);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* 设置类型
|
|
96
|
+
*/
|
|
97
|
+
setTypeAnnotation(typeAnnotation) {
|
|
98
|
+
typeAnnotation._delete();
|
|
99
|
+
const relationOptions = { parentNode: this, parentKey: 'typeAnnotation' };
|
|
100
|
+
Object.assign(typeAnnotation, relationOptions);
|
|
101
|
+
const object = {
|
|
102
|
+
typeAnnotation,
|
|
103
|
+
};
|
|
104
|
+
this.update({
|
|
105
|
+
...object,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 设置左边项
|
|
110
|
+
*/
|
|
111
|
+
setProperties(properties) {
|
|
112
|
+
const object = {
|
|
113
|
+
properties,
|
|
114
|
+
};
|
|
115
|
+
this.update({
|
|
116
|
+
...object,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* 设置右边项
|
|
121
|
+
*/
|
|
122
|
+
setRights(rights) {
|
|
123
|
+
const object = {
|
|
124
|
+
rights,
|
|
125
|
+
};
|
|
126
|
+
this.update({
|
|
127
|
+
...object,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* 设置赋值线
|
|
132
|
+
*/
|
|
133
|
+
setAssignmentLines(assignmentLines) {
|
|
134
|
+
const object = {
|
|
135
|
+
assignmentLines,
|
|
136
|
+
};
|
|
137
|
+
this.update({
|
|
138
|
+
...object,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* 设置hideProperties
|
|
143
|
+
*/
|
|
144
|
+
setHideProperties(hideProperties) {
|
|
145
|
+
const object = {
|
|
146
|
+
hideProperties,
|
|
147
|
+
};
|
|
148
|
+
this.update({
|
|
149
|
+
...object,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* 设置hideDefaults
|
|
154
|
+
*/
|
|
155
|
+
setHideDefaults(hideDefaults) {
|
|
156
|
+
const object = {
|
|
157
|
+
hideDefaults,
|
|
158
|
+
};
|
|
159
|
+
this.update({
|
|
160
|
+
...object,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* 设置自动连线
|
|
165
|
+
*/
|
|
166
|
+
setAutoConnection(autoConnection) {
|
|
167
|
+
const object = {
|
|
168
|
+
autoConnection,
|
|
169
|
+
};
|
|
170
|
+
this.update({
|
|
171
|
+
...object,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
getIdentifierExistingNames(excludedList = []) {
|
|
175
|
+
const excludedSet = new Set(excludedList);
|
|
176
|
+
return (this.properties || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
177
|
+
}
|
|
178
|
+
getIdentifierUniqueName(name = 'identifier1') {
|
|
179
|
+
return utils.unique(name, this.getIdentifierExistingNames(), undefined, false);
|
|
180
|
+
}
|
|
181
|
+
_insertIdentifierAt(options, index) {
|
|
182
|
+
const identifierOptions = {};
|
|
183
|
+
const relationOptions = { parentNode: this, parentKey: 'properties' };
|
|
184
|
+
let identifier;
|
|
185
|
+
if (!options) {
|
|
186
|
+
identifier = Identifier__1.default.from({
|
|
187
|
+
...identifierOptions,
|
|
188
|
+
name: this.getIdentifierUniqueName(),
|
|
189
|
+
}, this, 'properties');
|
|
190
|
+
}
|
|
191
|
+
else if (typeof options === 'string') {
|
|
192
|
+
identifier = Identifier__1.default.from({
|
|
193
|
+
...identifierOptions,
|
|
194
|
+
name: options,
|
|
195
|
+
}, this, 'properties');
|
|
196
|
+
}
|
|
197
|
+
else if (options instanceof Identifier__1.default) {
|
|
198
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
199
|
+
identifier = options;
|
|
200
|
+
Object.assign(identifier, relationOptions);
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
identifier = Identifier__1.default.from({
|
|
204
|
+
...identifierOptions,
|
|
205
|
+
...options,
|
|
206
|
+
}, this, 'properties');
|
|
207
|
+
}
|
|
208
|
+
this.properties.splice(index, 0, identifier);
|
|
209
|
+
return identifier;
|
|
210
|
+
}
|
|
211
|
+
insertIdentifierAt(options, index) {
|
|
212
|
+
const node = this._insertIdentifierAt(options, index);
|
|
213
|
+
node.create({
|
|
214
|
+
index,
|
|
215
|
+
parentNode: this,
|
|
216
|
+
parentKey: 'properties',
|
|
217
|
+
});
|
|
218
|
+
return node;
|
|
219
|
+
}
|
|
220
|
+
_addIdentifier(options) {
|
|
221
|
+
const index = this.properties.length;
|
|
222
|
+
return this._insertIdentifierAt(options, index);
|
|
223
|
+
}
|
|
224
|
+
addIdentifier(options) {
|
|
225
|
+
const node = this._addIdentifier(options);
|
|
226
|
+
const index = this.properties.indexOf(node);
|
|
227
|
+
node.create({
|
|
228
|
+
index,
|
|
229
|
+
parentNode: this,
|
|
230
|
+
parentKey: 'properties',
|
|
231
|
+
});
|
|
232
|
+
return node;
|
|
233
|
+
}
|
|
234
|
+
getSelectMembersExistingNames(excludedList = []) {
|
|
235
|
+
const excludedSet = new Set(excludedList);
|
|
236
|
+
return (this.rights || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
237
|
+
}
|
|
238
|
+
getSelectMembersUniqueName(name = 'selectMembers1') {
|
|
239
|
+
return utils.unique(name, this.getSelectMembersExistingNames(), undefined, false);
|
|
240
|
+
}
|
|
241
|
+
_insertSelectMembersAt(options, index) {
|
|
242
|
+
const selectMembersOptions = {};
|
|
243
|
+
const relationOptions = { parentNode: this, parentKey: 'rights' };
|
|
244
|
+
let selectMembers;
|
|
245
|
+
if (!options) {
|
|
246
|
+
selectMembers = SelectMembers__1.default.from({
|
|
247
|
+
...selectMembersOptions,
|
|
248
|
+
name: this.getSelectMembersUniqueName(),
|
|
249
|
+
}, this, 'rights');
|
|
250
|
+
}
|
|
251
|
+
else if (typeof options === 'string') {
|
|
252
|
+
selectMembers = SelectMembers__1.default.from({
|
|
253
|
+
...selectMembersOptions,
|
|
254
|
+
name: options,
|
|
255
|
+
}, this, 'rights');
|
|
256
|
+
}
|
|
257
|
+
else if (options instanceof SelectMembers__1.default) {
|
|
258
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
259
|
+
selectMembers = options;
|
|
260
|
+
Object.assign(selectMembers, relationOptions);
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
selectMembers = SelectMembers__1.default.from({
|
|
264
|
+
...selectMembersOptions,
|
|
265
|
+
...options,
|
|
266
|
+
}, this, 'rights');
|
|
267
|
+
}
|
|
268
|
+
this.rights.splice(index, 0, selectMembers);
|
|
269
|
+
return selectMembers;
|
|
270
|
+
}
|
|
271
|
+
insertSelectMembersAt(options, index) {
|
|
272
|
+
const node = this._insertSelectMembersAt(options, index);
|
|
273
|
+
node.create({
|
|
274
|
+
index,
|
|
275
|
+
parentNode: this,
|
|
276
|
+
parentKey: 'rights',
|
|
277
|
+
});
|
|
278
|
+
return node;
|
|
279
|
+
}
|
|
280
|
+
_addSelectMembers(options) {
|
|
281
|
+
const index = this.rights.length;
|
|
282
|
+
return this._insertSelectMembersAt(options, index);
|
|
283
|
+
}
|
|
284
|
+
addSelectMembers(options) {
|
|
285
|
+
const node = this._addSelectMembers(options);
|
|
286
|
+
const index = this.rights.indexOf(node);
|
|
287
|
+
node.create({
|
|
288
|
+
index,
|
|
289
|
+
parentNode: this,
|
|
290
|
+
parentKey: 'rights',
|
|
291
|
+
});
|
|
292
|
+
return node;
|
|
293
|
+
}
|
|
294
|
+
getAssignmentLineExistingNames(excludedList = []) {
|
|
295
|
+
const excludedSet = new Set(excludedList);
|
|
296
|
+
return (this.assignmentLines || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
297
|
+
}
|
|
298
|
+
getAssignmentLineUniqueName(name = 'assignmentLine1') {
|
|
299
|
+
return utils.unique(name, this.getAssignmentLineExistingNames(), undefined, false);
|
|
300
|
+
}
|
|
301
|
+
_insertAssignmentLineAt(options, index) {
|
|
302
|
+
const assignmentLineOptions = {};
|
|
303
|
+
const relationOptions = { parentNode: this, parentKey: 'assignmentLines' };
|
|
304
|
+
let assignmentLine;
|
|
305
|
+
if (!options) {
|
|
306
|
+
assignmentLine = AssignmentLine__1.default.from({
|
|
307
|
+
...assignmentLineOptions,
|
|
308
|
+
name: this.getAssignmentLineUniqueName(),
|
|
309
|
+
}, this, 'assignmentLines');
|
|
310
|
+
}
|
|
311
|
+
else if (typeof options === 'string') {
|
|
312
|
+
assignmentLine = AssignmentLine__1.default.from({
|
|
313
|
+
...assignmentLineOptions,
|
|
314
|
+
name: options,
|
|
315
|
+
}, this, 'assignmentLines');
|
|
316
|
+
}
|
|
317
|
+
else if (options instanceof AssignmentLine__1.default) {
|
|
318
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
319
|
+
assignmentLine = options;
|
|
320
|
+
Object.assign(assignmentLine, relationOptions);
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
assignmentLine = AssignmentLine__1.default.from({
|
|
324
|
+
...assignmentLineOptions,
|
|
325
|
+
...options,
|
|
326
|
+
}, this, 'assignmentLines');
|
|
327
|
+
}
|
|
328
|
+
this.assignmentLines.splice(index, 0, assignmentLine);
|
|
329
|
+
return assignmentLine;
|
|
330
|
+
}
|
|
331
|
+
insertAssignmentLineAt(options, index) {
|
|
332
|
+
const node = this._insertAssignmentLineAt(options, index);
|
|
333
|
+
node.create({
|
|
334
|
+
index,
|
|
335
|
+
parentNode: this,
|
|
336
|
+
parentKey: 'assignmentLines',
|
|
337
|
+
});
|
|
338
|
+
return node;
|
|
339
|
+
}
|
|
340
|
+
_addAssignmentLine(options) {
|
|
341
|
+
const index = this.assignmentLines.length;
|
|
342
|
+
return this._insertAssignmentLineAt(options, index);
|
|
343
|
+
}
|
|
344
|
+
addAssignmentLine(options) {
|
|
345
|
+
const node = this._addAssignmentLine(options);
|
|
346
|
+
const index = this.assignmentLines.indexOf(node);
|
|
347
|
+
node.create({
|
|
348
|
+
index,
|
|
349
|
+
parentNode: this,
|
|
350
|
+
parentKey: 'assignmentLines',
|
|
351
|
+
});
|
|
352
|
+
return node;
|
|
353
|
+
}
|
|
354
|
+
removeTypeAnnotation(options) {
|
|
355
|
+
let typeAnnotation;
|
|
356
|
+
if (typeof options === 'string') {
|
|
357
|
+
typeAnnotation = this.typeAnnotation;
|
|
358
|
+
if (!typeAnnotation) {
|
|
359
|
+
throw new Error('找不到类型标注 ' + options);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
else {
|
|
363
|
+
typeAnnotation = options;
|
|
364
|
+
}
|
|
365
|
+
return typeAnnotation.delete();
|
|
366
|
+
}
|
|
367
|
+
__removeTypeAnnotation(typeAnnotation) {
|
|
368
|
+
const parentKey = typeAnnotation.parentKey;
|
|
369
|
+
const params = {
|
|
370
|
+
parentNode: this,
|
|
371
|
+
parentKey,
|
|
372
|
+
index: -1,
|
|
373
|
+
object: null,
|
|
374
|
+
oldObject: typeAnnotation,
|
|
375
|
+
};
|
|
376
|
+
if (parentKey) {
|
|
377
|
+
params.parentKey = parentKey;
|
|
378
|
+
if (Array.isArray(this[parentKey])) {
|
|
379
|
+
const index = this[parentKey].indexOf(typeAnnotation);
|
|
380
|
+
~index && this[parentKey].splice(index, 1);
|
|
381
|
+
params.index = index;
|
|
382
|
+
}
|
|
383
|
+
else if (this[parentKey] === typeAnnotation) {
|
|
384
|
+
params.index = 0;
|
|
385
|
+
this[parentKey] = undefined;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return params;
|
|
389
|
+
}
|
|
390
|
+
removeIdentifier(options) {
|
|
391
|
+
let identifier;
|
|
392
|
+
if (typeof options === 'string') {
|
|
393
|
+
identifier = this.properties.find((item) => item.name === options);
|
|
394
|
+
if (!identifier) {
|
|
395
|
+
throw new Error('找不到标识符 ' + options);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
identifier = options;
|
|
400
|
+
}
|
|
401
|
+
return identifier.delete();
|
|
402
|
+
}
|
|
403
|
+
__removeLogicItem(logicItem) {
|
|
404
|
+
const parentKey = logicItem.parentKey;
|
|
405
|
+
const params = {
|
|
406
|
+
parentNode: this,
|
|
407
|
+
parentKey,
|
|
408
|
+
index: -1,
|
|
409
|
+
object: null,
|
|
410
|
+
oldObject: logicItem,
|
|
411
|
+
};
|
|
412
|
+
if (parentKey) {
|
|
413
|
+
params.parentKey = parentKey;
|
|
414
|
+
if (Array.isArray(this[parentKey])) {
|
|
415
|
+
const index = this[parentKey].indexOf(logicItem);
|
|
416
|
+
~index && this[parentKey].splice(index, 1);
|
|
417
|
+
params.index = index;
|
|
418
|
+
}
|
|
419
|
+
else if (this[parentKey] === logicItem) {
|
|
420
|
+
params.index = 0;
|
|
421
|
+
this[parentKey] = undefined;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
return params;
|
|
425
|
+
}
|
|
426
|
+
removeSelectMembers(options) {
|
|
427
|
+
let selectMembers;
|
|
428
|
+
if (typeof options === 'string') {
|
|
429
|
+
selectMembers = this.rights.find((item) => item.name === options);
|
|
430
|
+
if (!selectMembers) {
|
|
431
|
+
throw new Error('找不到选择成员 ' + options);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
else {
|
|
435
|
+
selectMembers = options;
|
|
436
|
+
}
|
|
437
|
+
return selectMembers.delete();
|
|
438
|
+
}
|
|
439
|
+
__removeSelectMembers(selectMembers) {
|
|
440
|
+
const parentKey = selectMembers.parentKey;
|
|
441
|
+
const params = {
|
|
442
|
+
parentNode: this,
|
|
443
|
+
parentKey,
|
|
444
|
+
index: -1,
|
|
445
|
+
object: null,
|
|
446
|
+
oldObject: selectMembers,
|
|
447
|
+
};
|
|
448
|
+
if (parentKey) {
|
|
449
|
+
params.parentKey = parentKey;
|
|
450
|
+
if (Array.isArray(this[parentKey])) {
|
|
451
|
+
const index = this[parentKey].indexOf(selectMembers);
|
|
452
|
+
~index && this[parentKey].splice(index, 1);
|
|
453
|
+
params.index = index;
|
|
454
|
+
}
|
|
455
|
+
else if (this[parentKey] === selectMembers) {
|
|
456
|
+
params.index = 0;
|
|
457
|
+
this[parentKey] = undefined;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
return params;
|
|
461
|
+
}
|
|
462
|
+
removeAssignmentLine(options) {
|
|
463
|
+
let assignmentLine;
|
|
464
|
+
if (typeof options === 'string') {
|
|
465
|
+
assignmentLine = this.assignmentLines.find((item) => item.name === options);
|
|
466
|
+
if (!assignmentLine) {
|
|
467
|
+
throw new Error('找不到赋值连线 ' + options);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
else {
|
|
471
|
+
assignmentLine = options;
|
|
472
|
+
}
|
|
473
|
+
return assignmentLine.delete();
|
|
474
|
+
}
|
|
475
|
+
__removeAssignmentLine(assignmentLine) {
|
|
476
|
+
const parentKey = assignmentLine.parentKey;
|
|
477
|
+
const params = {
|
|
478
|
+
parentNode: this,
|
|
479
|
+
parentKey,
|
|
480
|
+
index: -1,
|
|
481
|
+
object: null,
|
|
482
|
+
oldObject: assignmentLine,
|
|
483
|
+
};
|
|
484
|
+
if (parentKey) {
|
|
485
|
+
params.parentKey = parentKey;
|
|
486
|
+
if (Array.isArray(this[parentKey])) {
|
|
487
|
+
const index = this[parentKey].indexOf(assignmentLine);
|
|
488
|
+
~index && this[parentKey].splice(index, 1);
|
|
489
|
+
params.index = index;
|
|
490
|
+
}
|
|
491
|
+
else if (this[parentKey] === assignmentLine) {
|
|
492
|
+
params.index = 0;
|
|
493
|
+
this[parentKey] = undefined;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
return params;
|
|
497
|
+
}
|
|
498
|
+
//================================================================================
|
|
499
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
500
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
501
|
+
//================================================================================
|
|
502
|
+
get lines() {
|
|
503
|
+
return this.assignmentLines.length;
|
|
504
|
+
}
|
|
505
|
+
async newConnection(addRightIndex) {
|
|
506
|
+
const leftLineSet = new Set();
|
|
507
|
+
const lineArr = [];
|
|
508
|
+
const connectionArr = [];
|
|
509
|
+
// 系统属性不可自动连线
|
|
510
|
+
['id', 'createdTime', 'updatedTime', 'createdBy', 'updatedBy'].forEach((name) => leftLineSet.add(name));
|
|
511
|
+
// 左边已连线的下标
|
|
512
|
+
this.assignmentLines.forEach((line) => {
|
|
513
|
+
if (line.leftIndex.length > 1)
|
|
514
|
+
leftLineSet.add(Number(line.leftIndex[1]));
|
|
515
|
+
});
|
|
516
|
+
const autoConnection = () => {
|
|
517
|
+
let structure;
|
|
518
|
+
const isAnnotation = this.typeAnnotation.typeKind === 'anonymousStructure';
|
|
519
|
+
if (!isAnnotation)
|
|
520
|
+
structure = this.app.findNodeByCompleteName(this.typeAnnotation.typeNamespace + '.' + this.typeAnnotation.typeName);
|
|
521
|
+
this.app.emit('collect:start', {
|
|
522
|
+
actionMsg: '自动连线',
|
|
523
|
+
});
|
|
524
|
+
this.properties.forEach((property, leftSecondIndex) => {
|
|
525
|
+
const leftName = property.name;
|
|
526
|
+
const leftTypeAnnotation = !isAnnotation && structure.properties.find((p) => p.name === property.name).typeAnnotation;
|
|
527
|
+
const typeStruct = isAnnotation && this.typeAnnotation.properties[leftSecondIndex]; // 获取匿名数据结构typeAnnotation的具体property
|
|
528
|
+
if (leftLineSet.has(leftSecondIndex) || leftLineSet.has(leftName))
|
|
529
|
+
return;
|
|
530
|
+
this.rights.forEach((selectMember, rightFirstIndex) => {
|
|
531
|
+
const { members, expression } = selectMember;
|
|
532
|
+
if (leftLineSet.has(leftSecondIndex))
|
|
533
|
+
return;
|
|
534
|
+
if (addRightIndex !== -1 && addRightIndex !== rightFirstIndex)
|
|
535
|
+
return;
|
|
536
|
+
// 右侧父节点也不允许自动连线
|
|
537
|
+
const rightLineSet = new Set();
|
|
538
|
+
for (let i = 0; i < members.length - 1; i++) {
|
|
539
|
+
const completeName = members[i].completeName;
|
|
540
|
+
const preCompleteName = members[i + 1].completeName;
|
|
541
|
+
if (preCompleteName.includes(completeName) && completeName.split('.').length !== preCompleteName.split('.').length)
|
|
542
|
+
rightLineSet.add(i);
|
|
543
|
+
}
|
|
544
|
+
if (leftName === expression.name && (isAnnotation || expression.__TypeAnnotation.typeKind === leftTypeAnnotation.typeKind)) {
|
|
545
|
+
const Line = new AssignmentLine__1.default({
|
|
546
|
+
leftIndex: [0, leftSecondIndex],
|
|
547
|
+
rightIndex: [rightFirstIndex],
|
|
548
|
+
});
|
|
549
|
+
lineArr.push(Line);
|
|
550
|
+
connectionArr.push({
|
|
551
|
+
leftItem: typeStruct,
|
|
552
|
+
rightItem: expression,
|
|
553
|
+
});
|
|
554
|
+
leftLineSet.add(leftSecondIndex);
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
members.forEach((rightMember, rightSecondIndex) => {
|
|
558
|
+
const rightName = rightMember.property.name;
|
|
559
|
+
if (rightLineSet.has(rightSecondIndex))
|
|
560
|
+
return;
|
|
561
|
+
if (leftName === rightName) {
|
|
562
|
+
const rightTypeAnnotation = rightMember.__TypeAnnotation;
|
|
563
|
+
if (!isAnnotation && leftTypeAnnotation.typeKind !== rightTypeAnnotation.typeKind)
|
|
564
|
+
return;
|
|
565
|
+
const leftIndex = [0, leftSecondIndex];
|
|
566
|
+
const rightIndex = [rightFirstIndex, rightSecondIndex];
|
|
567
|
+
const Line = new AssignmentLine__1.default({ leftIndex, rightIndex });
|
|
568
|
+
lineArr.push(Line);
|
|
569
|
+
connectionArr.push({
|
|
570
|
+
leftItem: typeStruct,
|
|
571
|
+
rightItem: rightMember,
|
|
572
|
+
});
|
|
573
|
+
leftLineSet.add(leftSecondIndex);
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
});
|
|
577
|
+
});
|
|
578
|
+
lineArr.length && this.setAssignmentLines([...this.assignmentLines, ...lineArr]);
|
|
579
|
+
if (this.typeAnnotation.typeKind === 'anonymousStructure') {
|
|
580
|
+
connectionArr.forEach(({ leftItem, rightItem }) => {
|
|
581
|
+
if (rightItem.__TypeAnnotation) {
|
|
582
|
+
leftItem.update({
|
|
583
|
+
typeAnnotation: TypeAnnotation__1.default.from({ ...rightItem.__TypeAnnotation.toJSON() }),
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
this.app.emit('collect:end');
|
|
589
|
+
};
|
|
590
|
+
let count = 0;
|
|
591
|
+
const typeAnnotationEnd = () => {
|
|
592
|
+
const r = this.rights.every((right) => right.members.every((item) => item.__isCorrectTypeAnnotation));
|
|
593
|
+
count++;
|
|
594
|
+
if (r) {
|
|
595
|
+
autoConnection();
|
|
596
|
+
}
|
|
597
|
+
else if (count <= 10) {
|
|
598
|
+
setTimeout(() => {
|
|
599
|
+
typeAnnotationEnd();
|
|
600
|
+
}, 100);
|
|
601
|
+
}
|
|
602
|
+
};
|
|
603
|
+
typeAnnotationEnd();
|
|
604
|
+
}
|
|
605
|
+
connection(leftItem, rightItem, rightToLeft) {
|
|
606
|
+
let newLeftIndex = [0];
|
|
607
|
+
let newRightIndex = [];
|
|
608
|
+
let newLines = [...this.assignmentLines];
|
|
609
|
+
let newProperties = this.properties;
|
|
610
|
+
if (leftItem.concept === 'Identifier') {
|
|
611
|
+
const members = this.properties;
|
|
612
|
+
const secondIndex = members.findIndex((ident) => ident === leftItem);
|
|
613
|
+
// 连线左边的坐标。
|
|
614
|
+
newLeftIndex = [0, secondIndex];
|
|
615
|
+
}
|
|
616
|
+
else {
|
|
617
|
+
newLines = [];
|
|
618
|
+
newProperties = [];
|
|
619
|
+
}
|
|
620
|
+
if (rightItem.concept === 'SelectMembers') {
|
|
621
|
+
newRightIndex = [this.rights.findIndex((right) => right === rightItem)];
|
|
622
|
+
}
|
|
623
|
+
else {
|
|
624
|
+
const selectMember = rightItem.getAncestor('SelectMembers');
|
|
625
|
+
const firstIndex = this.rights.findIndex((right) => right === selectMember);
|
|
626
|
+
const secondIndex = this.rights[firstIndex].members.findIndex((exp) => exp === rightItem);
|
|
627
|
+
newRightIndex = [firstIndex, secondIndex];
|
|
628
|
+
}
|
|
629
|
+
// 左边同一个属性只能有一个连线
|
|
630
|
+
if (rightToLeft) {
|
|
631
|
+
newLines = newLines.filter(({ leftIndex: index }) => !(newLeftIndex[0] === index[0] && newLeftIndex[1] === index[1]));
|
|
632
|
+
}
|
|
633
|
+
const Line = new AssignmentLine__1.default({
|
|
634
|
+
leftIndex: newLeftIndex,
|
|
635
|
+
rightIndex: newRightIndex,
|
|
636
|
+
});
|
|
637
|
+
newLines.push(Line);
|
|
638
|
+
if (this.typeAnnotation.typeKind !== 'anonymousStructure') {
|
|
639
|
+
this.update({
|
|
640
|
+
assignmentLines: newLines,
|
|
641
|
+
properties: newProperties,
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
else {
|
|
645
|
+
this.app.emit('collect:start', {
|
|
646
|
+
actionMsg: '匿名数据结构连线',
|
|
647
|
+
});
|
|
648
|
+
// 匿名数据结构typeAnnotation变化
|
|
649
|
+
const structureProperty = this.typeAnnotation.properties.find(({ name }) => name === leftItem.name);
|
|
650
|
+
const exp = rightItem.concept === 'SelectMembers' ? rightItem.expression : rightItem;
|
|
651
|
+
// 场景:右侧连接是非匿名数据
|
|
652
|
+
if (exp.__TypeAnnotation && exp.__TypeAnnotation.typeKey !== 'nasl.core.Null') {
|
|
653
|
+
structureProperty.update({
|
|
654
|
+
typeAnnotation: TypeAnnotation__1.default.from({ ...exp.__TypeAnnotation.toJSON() }),
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
this.update({
|
|
658
|
+
assignmentLines: newLines,
|
|
659
|
+
properties: newProperties,
|
|
660
|
+
});
|
|
661
|
+
this.app.emit('collect:end');
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
deleteAssignmentLine(assignmentLine) {
|
|
665
|
+
const newLine = this.assignmentLines.filter((line) => line !== assignmentLine);
|
|
666
|
+
this.app.emit('collect:start', {
|
|
667
|
+
actionMsg: '删除连线',
|
|
668
|
+
});
|
|
669
|
+
if (this.typeAnnotation.typeKind === 'anonymousStructure') {
|
|
670
|
+
const typeStructureProperty = this.findMember(assignmentLine.leftIndex, 'left', true);
|
|
671
|
+
typeStructureProperty.update({
|
|
672
|
+
typeAnnotation: null,
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
this.update({
|
|
676
|
+
assignmentLines: newLine,
|
|
677
|
+
});
|
|
678
|
+
this.app.emit('collect:end');
|
|
679
|
+
}
|
|
680
|
+
changeLinesLocation(selectMember) {
|
|
681
|
+
if (selectMember.concept !== 'SelectMembers')
|
|
682
|
+
return;
|
|
683
|
+
if (this.rights.findIndex((member) => selectMember === member) !== -1) {
|
|
684
|
+
const index = this.rights.findIndex((member) => selectMember === member);
|
|
685
|
+
const newRights = this.rights.filter((member) => selectMember !== member);
|
|
686
|
+
const filterLine = this.assignmentLines.filter((line) => line.rightIndex[0] !== index);
|
|
687
|
+
const newLines = [];
|
|
688
|
+
const oldLines = this.assignmentLines.filter(({ rightIndex }) => rightIndex[0] === index);
|
|
689
|
+
filterLine.forEach((line) => {
|
|
690
|
+
if (line.rightIndex[0] > index) {
|
|
691
|
+
if (line.rightIndex[1] === undefined) {
|
|
692
|
+
const newLine = Object.assign({}, line, { rightIndex: [line.rightIndex[0] - 1] });
|
|
693
|
+
newLines.push(newLine);
|
|
694
|
+
}
|
|
695
|
+
else {
|
|
696
|
+
const newLine = Object.assign({}, line, { rightIndex: [line.rightIndex[0] - 1, line.rightIndex[1]] });
|
|
697
|
+
newLines.push(newLine);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
else {
|
|
701
|
+
newLines.push(line);
|
|
702
|
+
}
|
|
703
|
+
});
|
|
704
|
+
this.app.emit('collect:start', {
|
|
705
|
+
actionMsg: '匿名数据结构删除右侧变量',
|
|
706
|
+
});
|
|
707
|
+
if (this.typeAnnotation.typeKind === 'anonymousStructure') {
|
|
708
|
+
oldLines.forEach(({ leftIndex }) => {
|
|
709
|
+
const leftItem = this.typeAnnotation.properties[leftIndex[1]];
|
|
710
|
+
leftItem.update({
|
|
711
|
+
typeAnnotation: null,
|
|
712
|
+
});
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
this.update({
|
|
716
|
+
rights: newRights,
|
|
717
|
+
assignmentLines: newLines,
|
|
718
|
+
});
|
|
719
|
+
this.app.emit('collect:end');
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
changeMembers(oldNode, members, keepMembers, expression) {
|
|
723
|
+
this.app.emit('collect:start', {
|
|
724
|
+
actionMsg: 'New初始赋值修改变量',
|
|
725
|
+
});
|
|
726
|
+
const selectMember = oldNode.parentNode;
|
|
727
|
+
const autoConnectionIndex = this.rights.findIndex((right) => right === selectMember);
|
|
728
|
+
const newSelectMember = Object.assign({}, selectMember, { expression, members });
|
|
729
|
+
const splitIndex = this.rights.findIndex((right) => selectMember === right);
|
|
730
|
+
const newLines = this.assignmentLines.filter(({ rightIndex }) => rightIndex[0] !== splitIndex);
|
|
731
|
+
let oldLines = this.assignmentLines.filter(({ rightIndex }) => rightIndex[0] === splitIndex);
|
|
732
|
+
// 右侧变量改变后,修改连线
|
|
733
|
+
members.forEach((item, index) => {
|
|
734
|
+
if (keepMembers.has(item.completeName)) {
|
|
735
|
+
const lines = this.findlines(item, selectMember);
|
|
736
|
+
lines.forEach((line) => {
|
|
737
|
+
const newLine = Object.assign({}, line, { rightIndex: [line.rightIndex[0], index] });
|
|
738
|
+
newLines.push(newLine);
|
|
739
|
+
oldLines = oldLines.filter(({ leftIndex }) => leftIndex[1] !== line.leftIndex[1]);
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
});
|
|
743
|
+
if (this.typeAnnotation.typeKind === 'anonymousStructure') {
|
|
744
|
+
oldLines.forEach(({ leftIndex }) => {
|
|
745
|
+
const leftItem = this.typeAnnotation.properties[leftIndex[1]];
|
|
746
|
+
leftItem.update({
|
|
747
|
+
typeAnnotation: null,
|
|
748
|
+
});
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
this.update({
|
|
752
|
+
assignmentLines: newLines,
|
|
753
|
+
rights: [...this.rights.slice(0, splitIndex), newSelectMember, ...this.rights.slice(splitIndex + 1, this.rights.length)],
|
|
754
|
+
});
|
|
755
|
+
this.autoConnection && this.newConnection(autoConnectionIndex);
|
|
756
|
+
this.app.emit('collect:end');
|
|
757
|
+
}
|
|
758
|
+
findlines(member, selectMember) {
|
|
759
|
+
const lines = [];
|
|
760
|
+
// 根节点的情况
|
|
761
|
+
if (selectMember === this) {
|
|
762
|
+
if (member === this.typeAnnotation)
|
|
763
|
+
return this.assignmentLines;
|
|
764
|
+
else {
|
|
765
|
+
const index2 = this.properties.findIndex((item) => item.completeName === member.completeName);
|
|
766
|
+
this.assignmentLines.forEach((line) => {
|
|
767
|
+
if (line.leftIndex[1] === index2)
|
|
768
|
+
lines.push(line);
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
else {
|
|
773
|
+
const index1 = this.rights.findIndex((right) => right === selectMember);
|
|
774
|
+
const index2 = selectMember.members.findIndex((item) => item.completeName === member.completeName);
|
|
775
|
+
this.assignmentLines.forEach((line) => {
|
|
776
|
+
if (line.rightIndex[0] === index1 && line.rightIndex[1] === index2)
|
|
777
|
+
lines.push(line);
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
return lines;
|
|
781
|
+
}
|
|
782
|
+
findMember(arrIndex, place, isAnnotation) {
|
|
783
|
+
const [firstIndex, secondIndex] = [arrIndex[0], arrIndex[1]];
|
|
784
|
+
if (isAnnotation) {
|
|
785
|
+
return this.typeAnnotation.properties[secondIndex];
|
|
786
|
+
}
|
|
787
|
+
if (place === 'left') {
|
|
788
|
+
if (secondIndex === undefined) {
|
|
789
|
+
return this.typeAnnotation;
|
|
790
|
+
}
|
|
791
|
+
return this.properties[secondIndex];
|
|
792
|
+
}
|
|
793
|
+
else {
|
|
794
|
+
if (secondIndex === undefined) {
|
|
795
|
+
return this.rights[firstIndex].expression;
|
|
796
|
+
}
|
|
797
|
+
return this.rights[firstIndex].members[secondIndex];
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
toUI(state) {
|
|
801
|
+
let code = '';
|
|
802
|
+
const typeAnnotation = this.typeAnnotation;
|
|
803
|
+
const leftTopIndex = this.assignmentLines.findIndex(({ leftIndex }) => leftIndex[1] === undefined);
|
|
804
|
+
if (!this.typeAnnotation)
|
|
805
|
+
return null;
|
|
806
|
+
code += 'await (async () => { \n';
|
|
807
|
+
if (leftTopIndex !== -1) {
|
|
808
|
+
const rightIndex = this.assignmentLines[leftTopIndex].rightIndex;
|
|
809
|
+
const obj = rightIndex[1] !== undefined ? this.rights[rightIndex[0]].members[rightIndex[1]] : this.rights[rightIndex[0]].expression;
|
|
810
|
+
code += `return ${obj};\n`;
|
|
811
|
+
}
|
|
812
|
+
else if (typeAnnotation.typeKind !== 'anonymousStructure') {
|
|
813
|
+
code += `const obj = this.$genInitFromSchema('${typeAnnotation.sortedTypeKey}', this.$utils['New'](${typeAnnotation.toUI((0, translator_1.shiftState)(state, code, { inline: true }))}));\n`;
|
|
814
|
+
this.assignmentLines.forEach(({ leftIndex, rightIndex }, index) => {
|
|
815
|
+
const leftSecondIndex = leftIndex[1];
|
|
816
|
+
const [rightFirst, rightSecond] = [rightIndex[0], rightIndex[1]];
|
|
817
|
+
const leftItem = this.properties[leftSecondIndex];
|
|
818
|
+
const rightItem = rightSecond !== undefined ? this.rights[rightFirst].members[rightSecond] : this.rights[rightFirst].expression;
|
|
819
|
+
code += `obj.${leftItem.name} = ${rightItem.toUI((0, translator_1.shiftState)(state, code, { inline: true }))}`;
|
|
820
|
+
code += ';\n';
|
|
821
|
+
});
|
|
822
|
+
code += 'return obj;\n';
|
|
823
|
+
}
|
|
824
|
+
else {
|
|
825
|
+
code += `const obj = {};\n`;
|
|
826
|
+
this.properties.forEach((property) => {
|
|
827
|
+
code += `obj.${property.name} = null;\n`;
|
|
828
|
+
});
|
|
829
|
+
this.assignmentLines.forEach(({ leftIndex, rightIndex }, index) => {
|
|
830
|
+
const leftSecondIndex = leftIndex[1];
|
|
831
|
+
const [rightFirst, rightSecond] = [rightIndex[0], rightIndex[1]];
|
|
832
|
+
const leftItem = this.properties[leftSecondIndex];
|
|
833
|
+
const rightItem = rightSecond !== undefined ? this.rights[rightFirst].members[rightSecond] : this.rights[rightFirst].expression;
|
|
834
|
+
code += `obj.${leftItem.name} = ${rightItem.toUI((0, translator_1.shiftState)(state, code, { inline: true }))}`;
|
|
835
|
+
code += ';\n';
|
|
836
|
+
});
|
|
837
|
+
code += 'return obj;\n';
|
|
838
|
+
}
|
|
839
|
+
code += '})()';
|
|
840
|
+
return code;
|
|
841
|
+
}
|
|
842
|
+
toJS(state) {
|
|
843
|
+
let code = '';
|
|
844
|
+
const typeAnnotation = this.typeAnnotation;
|
|
845
|
+
const leftTopIndex = this.assignmentLines.findIndex(({ leftIndex }) => leftIndex[1] === undefined);
|
|
846
|
+
if (!this.typeAnnotation)
|
|
847
|
+
return null;
|
|
848
|
+
code += 'await (async () => { \n';
|
|
849
|
+
if (leftTopIndex !== -1) {
|
|
850
|
+
const rightIndex = this.assignmentLines[leftTopIndex].rightIndex;
|
|
851
|
+
const obj = rightIndex[1] !== undefined ? this.rights[rightIndex[0]].members[rightIndex[1]] : this.rights[rightIndex[0]].expression;
|
|
852
|
+
code += `return ${obj.toJS((0, translator_1.shiftState)(state, code, { inline: true }))};\n`;
|
|
853
|
+
}
|
|
854
|
+
else if (typeAnnotation.typeKind !== 'anonymousStructure') {
|
|
855
|
+
code += `const obj = this.$genInitFromSchema('${typeAnnotation.sortedTypeKey}', this.$utils['New'](${typeAnnotation.toJS((0, translator_1.shiftState)(state, code, { inline: true }))}));\n`;
|
|
856
|
+
this.assignmentLines.forEach(({ leftIndex, rightIndex }, index) => {
|
|
857
|
+
const leftSecondIndex = leftIndex[1];
|
|
858
|
+
const [rightFirst, rightSecond] = [rightIndex[0], rightIndex[1]];
|
|
859
|
+
const leftItem = this.properties[leftSecondIndex];
|
|
860
|
+
const rightItem = rightSecond !== undefined ? this.rights[rightFirst].members[rightSecond] : this.rights[rightFirst].expression;
|
|
861
|
+
code += `obj.${leftItem.name} = ${rightItem.toJS((0, translator_1.shiftState)(state, code, { inline: true }))}`;
|
|
862
|
+
code += ';\n';
|
|
863
|
+
});
|
|
864
|
+
code += 'return obj;\n';
|
|
865
|
+
}
|
|
866
|
+
else {
|
|
867
|
+
code += `const obj = {};\n`;
|
|
868
|
+
this.properties.forEach((property) => {
|
|
869
|
+
code += `obj.${property.name} = null;\n`;
|
|
870
|
+
});
|
|
871
|
+
this.assignmentLines.forEach(({ leftIndex, rightIndex }, index) => {
|
|
872
|
+
const leftSecondIndex = leftIndex[1];
|
|
873
|
+
const [rightFirst, rightSecond] = [rightIndex[0], rightIndex[1]];
|
|
874
|
+
const leftItem = this.properties[leftSecondIndex];
|
|
875
|
+
const rightItem = rightSecond !== undefined ? this.rights[rightFirst].members[rightSecond] : this.rights[rightFirst].expression;
|
|
876
|
+
code += `obj.${leftItem.name} = ${rightItem.toJS((0, translator_1.shiftState)(state, code, { inline: true }))}`;
|
|
877
|
+
code += ';\n';
|
|
878
|
+
});
|
|
879
|
+
code += 'return obj;\n';
|
|
880
|
+
}
|
|
881
|
+
code += '})()';
|
|
882
|
+
return code;
|
|
883
|
+
}
|
|
884
|
+
toEmbeddedTS(state) {
|
|
885
|
+
let code = '';
|
|
886
|
+
if (!this.typeAnnotation) {
|
|
887
|
+
code += '__IDENTIFIER__';
|
|
888
|
+
}
|
|
889
|
+
else if (this.typeAnnotation.typeKind !== 'anonymousStructure') {
|
|
890
|
+
const rightMap = new Map();
|
|
891
|
+
code += '(() => { \n';
|
|
892
|
+
// 提供sourcemap,获取类型标注和上下文可选变量
|
|
893
|
+
this.rights.forEach((right) => {
|
|
894
|
+
rightMap.set(right.expression, right.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true })));
|
|
895
|
+
code += rightMap.get(right.expression);
|
|
896
|
+
code += ';\n';
|
|
897
|
+
right.members.forEach((member) => {
|
|
898
|
+
rightMap.set(member, member.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true })));
|
|
899
|
+
code += rightMap.get(member);
|
|
900
|
+
code += '; ';
|
|
901
|
+
});
|
|
902
|
+
code += right.members.length ? '\n' : '';
|
|
903
|
+
});
|
|
904
|
+
// 方便ts报错检查
|
|
905
|
+
code += 'function __newComposite() {\n';
|
|
906
|
+
code += `let obj = nasl.util.New<${this.typeAnnotation.sortedTypeKey}>();`;
|
|
907
|
+
code += '\n';
|
|
908
|
+
// 是否是左边的顶层连线
|
|
909
|
+
const leftTopIndex = this.assignmentLines.findIndex(({ leftIndex }) => leftIndex[1] === undefined);
|
|
910
|
+
if (leftTopIndex !== -1) {
|
|
911
|
+
const rightIndex = this.assignmentLines[leftTopIndex].rightIndex;
|
|
912
|
+
const rightExpression = rightIndex[1] !== undefined ? this.rights[rightIndex[0]].members[rightIndex[1]] : this.rights[rightIndex[0]].expression;
|
|
913
|
+
code += `obj = ${rightExpression.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }))};`;
|
|
914
|
+
code += '\n';
|
|
915
|
+
}
|
|
916
|
+
else {
|
|
917
|
+
this.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
|
|
918
|
+
const leftSecondIndex = leftIndex[1];
|
|
919
|
+
const [rightFirst, rightSecond] = [rightIndex[0], rightIndex[1]];
|
|
920
|
+
const leftItem = this.properties[leftSecondIndex];
|
|
921
|
+
const rightItem = rightSecond !== undefined ? this.rights[rightFirst].members[rightSecond] : this.rights[rightFirst].expression;
|
|
922
|
+
const rightTs = rightMap.get(rightItem);
|
|
923
|
+
code += `obj.${leftItem.name} = ${['__IDENTIFIER__', '__IDENTIFIER__()'].includes(rightTs) ? 'null' : rightTs};`;
|
|
924
|
+
code += '\n';
|
|
925
|
+
});
|
|
926
|
+
// 左侧properties的identifier的类型标注
|
|
927
|
+
this.properties.forEach((item) => {
|
|
928
|
+
code += '{ const ';
|
|
929
|
+
const name = item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
|
|
930
|
+
code += `${name} = obj.${name};`;
|
|
931
|
+
code += '}\n';
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
code += 'return obj;\n';
|
|
935
|
+
code += '};\n';
|
|
936
|
+
code += 'return __newComposite();\n';
|
|
937
|
+
code += '})()';
|
|
938
|
+
}
|
|
939
|
+
else {
|
|
940
|
+
const nameMap = new Map();
|
|
941
|
+
const rightMap = new Map();
|
|
942
|
+
this.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
|
|
943
|
+
const leftSecondIndex = leftIndex[1];
|
|
944
|
+
const [rightFirst, rightSecond] = [rightIndex[0], rightIndex[1]];
|
|
945
|
+
const leftItem = this.properties[leftSecondIndex];
|
|
946
|
+
const rightItem = rightSecond !== undefined ? this.rights[rightFirst].members[rightSecond] : this.rights[rightFirst].expression;
|
|
947
|
+
nameMap.set(leftItem.name, rightItem);
|
|
948
|
+
rightMap.set(rightItem, null);
|
|
949
|
+
});
|
|
950
|
+
code += '(() => { \n';
|
|
951
|
+
// 提供sourcemap,获取类型标注和上下文可选变量
|
|
952
|
+
this.rights.forEach((right) => {
|
|
953
|
+
let ts = right.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
|
|
954
|
+
if (rightMap.has(right.expression))
|
|
955
|
+
rightMap.set(right.expression, ts);
|
|
956
|
+
code += ts;
|
|
957
|
+
code += ';\n';
|
|
958
|
+
right.members.forEach((member) => {
|
|
959
|
+
ts = member.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
|
|
960
|
+
if (rightMap.has(member))
|
|
961
|
+
rightMap.set(member, ts);
|
|
962
|
+
code += ts;
|
|
963
|
+
code += '; ';
|
|
964
|
+
});
|
|
965
|
+
code += right.members.length ? '\n' : '';
|
|
966
|
+
});
|
|
967
|
+
// 方便ts报错检查
|
|
968
|
+
code += 'function __newComposite(): ';
|
|
969
|
+
code += this.typeAnnotation.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
|
|
970
|
+
code += '{\n';
|
|
971
|
+
this.properties.forEach((property) => {
|
|
972
|
+
const name = property.name;
|
|
973
|
+
const rightItem = nameMap.get(name);
|
|
974
|
+
if (rightMap.get(rightItem) !== undefined) {
|
|
975
|
+
code += `{ const x = ${rightMap.get(rightItem)}; const `;
|
|
976
|
+
code += property.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
|
|
977
|
+
code += `: nasl.core.Incompatible<typeof x, void> = x`;
|
|
978
|
+
code += '; }\n';
|
|
979
|
+
}
|
|
980
|
+
else {
|
|
981
|
+
code += '{ const ';
|
|
982
|
+
code += property.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
|
|
983
|
+
code += '; }\n';
|
|
984
|
+
}
|
|
985
|
+
});
|
|
986
|
+
code += 'return;\n';
|
|
987
|
+
code += '};\n';
|
|
988
|
+
code += 'return __newComposite();\n';
|
|
989
|
+
code += '})()';
|
|
990
|
+
}
|
|
991
|
+
return code;
|
|
992
|
+
}
|
|
993
|
+
__addIdentifier(App) {
|
|
994
|
+
const app = this.app || App;
|
|
995
|
+
app.emit('collect:start', {
|
|
996
|
+
actionMsg: '添加匿名数据结构属性',
|
|
997
|
+
});
|
|
998
|
+
const node = this.addIdentifier({ name: this.getIdentifierUniqueName('property1') });
|
|
999
|
+
const struct = StructureProperty__1.default.from({
|
|
1000
|
+
name: node.name,
|
|
1001
|
+
typeAnnotation: null,
|
|
1002
|
+
});
|
|
1003
|
+
this.typeAnnotation.addStructureProperty(struct);
|
|
1004
|
+
app.emit('collect:end');
|
|
1005
|
+
}
|
|
1006
|
+
__deleteIdentifier(property) {
|
|
1007
|
+
const index = this.properties.findIndex((p) => p === property);
|
|
1008
|
+
const newLines = [];
|
|
1009
|
+
const newProperties = [...this.typeAnnotation.properties.slice(0, index), ...this.typeAnnotation.properties.slice(index + 1, this.properties.length)];
|
|
1010
|
+
this.assignmentLines.forEach((line) => {
|
|
1011
|
+
const { leftIndex } = line;
|
|
1012
|
+
if (leftIndex[1] < index) {
|
|
1013
|
+
newLines.push(line);
|
|
1014
|
+
}
|
|
1015
|
+
else if (leftIndex[1] > index) {
|
|
1016
|
+
const newLine = Object.assign({}, line, { leftIndex: [leftIndex[0], leftIndex[1] - 1] });
|
|
1017
|
+
newLines.push(newLine);
|
|
1018
|
+
}
|
|
1019
|
+
});
|
|
1020
|
+
this.app.emit('collect:start', {
|
|
1021
|
+
actionMsg: '删除匿名数据结属性',
|
|
1022
|
+
});
|
|
1023
|
+
this.setAssignmentLines(newLines);
|
|
1024
|
+
this.typeAnnotation.update({
|
|
1025
|
+
properties: newProperties,
|
|
1026
|
+
});
|
|
1027
|
+
property.delete();
|
|
1028
|
+
this.app.emit('collect:end');
|
|
1029
|
+
}
|
|
1030
|
+
};
|
|
1031
|
+
__decorate([
|
|
1032
|
+
(0, decorators_1.property)()
|
|
1033
|
+
], NewComposite.prototype, "concept", void 0);
|
|
1034
|
+
__decorate([
|
|
1035
|
+
(0, decorators_1.property)('TypeAnnotation')
|
|
1036
|
+
], NewComposite.prototype, "typeAnnotation", void 0);
|
|
1037
|
+
__decorate([
|
|
1038
|
+
(0, decorators_1.property)('Identifier')
|
|
1039
|
+
], NewComposite.prototype, "properties", void 0);
|
|
1040
|
+
__decorate([
|
|
1041
|
+
(0, decorators_1.property)('SelectMembers')
|
|
1042
|
+
], NewComposite.prototype, "rights", void 0);
|
|
1043
|
+
__decorate([
|
|
1044
|
+
(0, decorators_1.property)('AssignmentLine')
|
|
1045
|
+
], NewComposite.prototype, "assignmentLines", void 0);
|
|
1046
|
+
__decorate([
|
|
1047
|
+
(0, decorators_1.property)()
|
|
1048
|
+
], NewComposite.prototype, "hideProperties", void 0);
|
|
1049
|
+
__decorate([
|
|
1050
|
+
(0, decorators_1.property)()
|
|
1051
|
+
], NewComposite.prototype, "hideDefaults", void 0);
|
|
1052
|
+
__decorate([
|
|
1053
|
+
(0, decorators_1.property)()
|
|
1054
|
+
], NewComposite.prototype, "autoConnection", void 0);
|
|
1055
|
+
__decorate([
|
|
1056
|
+
(0, translator_1.withSourceMap)()
|
|
1057
|
+
], NewComposite.prototype, "toEmbeddedTS", null);
|
|
1058
|
+
NewComposite = NewComposite_1 = __decorate([
|
|
1059
|
+
(0, decorators_1.concept)('实体/(匿名)数据结构构造器')
|
|
1060
|
+
], NewComposite);
|
|
1061
|
+
exports.NewComposite = NewComposite;
|
|
1062
|
+
classMap_1.default.NewComposite = NewComposite;
|
|
1063
|
+
exports.default = NewComposite;
|
|
1064
|
+
//================================================================================
|
|
1065
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
1066
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
1067
|
+
//================================================================================
|
|
1068
|
+
//# sourceMappingURL=NewComposite__.js.map
|