@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
|
@@ -47,6 +47,8 @@ export declare class NaslServer {
|
|
|
47
47
|
diagnosticManager: DiagnosticManager;
|
|
48
48
|
embeddedTSEmitter: EventEmitter;
|
|
49
49
|
changeStackList: Array<EventPayload>;
|
|
50
|
+
filesToCheck: Set<string>;
|
|
51
|
+
singleFileChangeIng: Boolean;
|
|
50
52
|
constructor();
|
|
51
53
|
start(): Promise<unknown>;
|
|
52
54
|
terminate(): void;
|
|
@@ -293,7 +295,7 @@ export declare class NaslServer {
|
|
|
293
295
|
defaultValue: any;
|
|
294
296
|
};
|
|
295
297
|
};
|
|
296
|
-
getCurrentTypeAnnotation(node: BaseNode): Promise<unknown>;
|
|
298
|
+
getCurrentTypeAnnotation(node: BaseNode, outTime?: number): Promise<unknown>;
|
|
297
299
|
getBaseNodesTypeMap(nodes: Array<BaseNode>): Promise<Map<BaseNode, TypeAnnotation | {
|
|
298
300
|
typeAnnotation: TypeAnnotation;
|
|
299
301
|
option: any;
|
package/out/server/naslServer.js
CHANGED
|
@@ -53,10 +53,6 @@ const EmbeddedTSFileLineMap = {
|
|
|
53
53
|
const EmbeddedTSFileOffsetMap = {
|
|
54
54
|
Variable: 12,
|
|
55
55
|
};
|
|
56
|
-
// 要Check的文件
|
|
57
|
-
const filesToCheck = new Set();
|
|
58
|
-
// 单个文件正在change,不允许同时两个文件一起change
|
|
59
|
-
let singleFileChangeIng = false;
|
|
60
56
|
let isChangeInterface = false; //判断是否导入接口
|
|
61
57
|
let actionArr = []; //用于导入接口收集更改的节点
|
|
62
58
|
let timer = null; //超时器用于收集导入接口相关
|
|
@@ -104,6 +100,8 @@ class NaslServer {
|
|
|
104
100
|
embeddedTSEmitter = undefined;
|
|
105
101
|
// 需要执行修改的文件
|
|
106
102
|
changeStackList = [];
|
|
103
|
+
filesToCheck;
|
|
104
|
+
singleFileChangeIng;
|
|
107
105
|
constructor() {
|
|
108
106
|
/// #if process.env.BUILD_TARGET === 'node'
|
|
109
107
|
if (globalThis.process) // For TS build
|
|
@@ -114,6 +112,10 @@ class NaslServer {
|
|
|
114
112
|
if (globalThis.window) // For TS build
|
|
115
113
|
this.worker = new worker_threads_1.Worker('/ts-worker.js');
|
|
116
114
|
/// #endif
|
|
115
|
+
// 要Check的文件
|
|
116
|
+
this.filesToCheck = new Set();
|
|
117
|
+
// 单个文件正在change,不允许同时两个文件一起change
|
|
118
|
+
this.singleFileChangeIng = false;
|
|
117
119
|
this.diagnosticManager = new diagnostic_1.DiagnosticManager();
|
|
118
120
|
this.messager = new Messager_1.default({
|
|
119
121
|
protocol: 'ts-worker',
|
|
@@ -134,7 +136,35 @@ class NaslServer {
|
|
|
134
136
|
// 收集到一个行为集合
|
|
135
137
|
const eventValue = $event.value;
|
|
136
138
|
eventValue.forEach(async (item) => {
|
|
137
|
-
|
|
139
|
+
/**
|
|
140
|
+
* 多个行为进行合并
|
|
141
|
+
* 合并规则是
|
|
142
|
+
* 1.[a,b,c,c] 在cc的时候,在已有一个c,又来一个c的时候,如果他们不都是file级别的节点
|
|
143
|
+
* 就可以前面的内容去掉,只保留最后一个
|
|
144
|
+
* 2.[a,b,c,b,c] 在bc已存在,又来了bc 这就都要保留,因为可能顺序有相关性,不能去掉
|
|
145
|
+
* 理论上只处理同时几个操作 合并,
|
|
146
|
+
* 3.有field的也直接保留
|
|
147
|
+
*/
|
|
148
|
+
try {
|
|
149
|
+
const changeEvent = item.originEvent;
|
|
150
|
+
const changeNode = changeEvent.target;
|
|
151
|
+
const { fileNode } = this.getCurrentSource(changeNode);
|
|
152
|
+
if (changeNode !== fileNode || !changeEvent.field) {
|
|
153
|
+
const findIndex = this.changeStackList.findIndex((changeStackItem) => {
|
|
154
|
+
const target = changeStackItem.target;
|
|
155
|
+
const { fileNode: targetFileNode } = this.getCurrentSource(target);
|
|
156
|
+
return targetFileNode === fileNode;
|
|
157
|
+
});
|
|
158
|
+
if (findIndex === this.changeStackList.length - 1) {
|
|
159
|
+
this.changeStackList.pop();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
this.changeStackList.push(item.originEvent);
|
|
163
|
+
}
|
|
164
|
+
catch (err) {
|
|
165
|
+
console.log(err);
|
|
166
|
+
this.changeStackList.push(item.originEvent);
|
|
167
|
+
}
|
|
138
168
|
});
|
|
139
169
|
// 如果有长度开始执行状态机
|
|
140
170
|
if (this.changeStackList.length) {
|
|
@@ -177,17 +207,34 @@ class NaslServer {
|
|
|
177
207
|
catch (err) {
|
|
178
208
|
}
|
|
179
209
|
});
|
|
180
|
-
module.
|
|
210
|
+
module.frontends?.forEach((frontend) => {
|
|
181
211
|
try {
|
|
182
|
-
const result =
|
|
212
|
+
const result = frontend.toEmbeddedTSFile();
|
|
183
213
|
results.push(result);
|
|
184
214
|
// sourceMap都存在目录级别内容下,在页面层级下去找
|
|
185
|
-
|
|
186
|
-
this.file2NodeMap.set(result.filePath,
|
|
215
|
+
frontend.sourceMap = result.sourceMap;
|
|
216
|
+
this.file2NodeMap.set(result.filePath, frontend);
|
|
187
217
|
}
|
|
188
218
|
catch (err) {
|
|
189
219
|
console.log(err);
|
|
190
220
|
}
|
|
221
|
+
frontend.variables?.forEach((frontendVariable) => {
|
|
222
|
+
try {
|
|
223
|
+
const result = frontendVariable.toEmbeddedTSFile();
|
|
224
|
+
results.push(result);
|
|
225
|
+
// sourceMap都存在目录级别内容下,在页面层级下去找
|
|
226
|
+
frontendVariable.sourceMap = result.sourceMap;
|
|
227
|
+
this.file2NodeMap.set(result.filePath, frontendVariable);
|
|
228
|
+
}
|
|
229
|
+
catch (err) {
|
|
230
|
+
console.log(err);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
// view的生成
|
|
234
|
+
if (!config_1.config.closeViews) {
|
|
235
|
+
this.view2TSFile(frontend.views, results);
|
|
236
|
+
}
|
|
237
|
+
frontend.componentDependencies?.forEach((item) => this.contentToFile(item, results));
|
|
191
238
|
});
|
|
192
239
|
module.dataSources?.forEach((dataSource) => {
|
|
193
240
|
// 本身dataSource也要生成一个文件用于改名
|
|
@@ -246,10 +293,6 @@ class NaslServer {
|
|
|
246
293
|
catch (err) {
|
|
247
294
|
}
|
|
248
295
|
});
|
|
249
|
-
// view的生成
|
|
250
|
-
if (!config_1.config.closeViews) {
|
|
251
|
-
this.view2TSFile(module.views, results);
|
|
252
|
-
}
|
|
253
296
|
module.processes.forEach((process) => {
|
|
254
297
|
try {
|
|
255
298
|
const result = process.toEmbeddedTSFile();
|
|
@@ -300,7 +343,6 @@ class NaslServer {
|
|
|
300
343
|
// 其他模块的创建内容
|
|
301
344
|
app.dependencies.forEach((item) => this.contentToFile(item, results));
|
|
302
345
|
app.interfaceDependencies.forEach((item) => this.contentToFile(item, results));
|
|
303
|
-
app.componentDependencies.forEach((item) => this.contentToFile(item, results));
|
|
304
346
|
}
|
|
305
347
|
catch (err) {
|
|
306
348
|
console.log(err);
|
|
@@ -553,7 +595,7 @@ class NaslServer {
|
|
|
553
595
|
if (!flag)
|
|
554
596
|
return;
|
|
555
597
|
const types = /\<([^()]+)\>/g.exec(displayString);
|
|
556
|
-
|
|
598
|
+
const typeStr = types && types[1];
|
|
557
599
|
const app = node.app;
|
|
558
600
|
if (typeStr.includes('__name: "AStructure_')) {
|
|
559
601
|
const properties = [];
|
|
@@ -571,7 +613,7 @@ class NaslServer {
|
|
|
571
613
|
typeKind: 'reference',
|
|
572
614
|
typeName,
|
|
573
615
|
typeNamespace,
|
|
574
|
-
})
|
|
616
|
+
}),
|
|
575
617
|
}));
|
|
576
618
|
return '';
|
|
577
619
|
});
|
|
@@ -723,7 +765,8 @@ class NaslServer {
|
|
|
723
765
|
// record.suggestionDiagnostics = record.suggestionDiagnostics.filter((item) => !item.text.includes(`implicitly has an 'any' type, but a better type may be inferred from usage.`));
|
|
724
766
|
// }
|
|
725
767
|
record.suggestionDiagnostics = record.suggestionDiagnostics
|
|
726
|
-
.filter((item) => [`'__LogicEmpty' is declared but its value is never read.`, `'__destinationEmpty__' is declared but its value is never read
|
|
768
|
+
.filter((item) => [`'__LogicEmpty' is declared but its value is never read.`, `'__destinationEmpty__' is declared but its value is never read.`,
|
|
769
|
+
`'__UpdateNoProperty__' is declared but its value is never read.`].includes(item.text))
|
|
727
770
|
.map((diag) => this._resolveDiagnostic(diag, node, record))
|
|
728
771
|
.filter((diag) => !!diag);
|
|
729
772
|
record.suggestionDiagnostics.push(...this._attachSuggestionDiagnostics(node));
|
|
@@ -747,14 +790,14 @@ class NaslServer {
|
|
|
747
790
|
// 递归检查,防止从顶层页面开始删除影响子页面内容检查
|
|
748
791
|
while (curNode instanceof concepts_1.View && !removed) {
|
|
749
792
|
if (curNode.parentNode instanceof concepts_1.View && !curNode.parentNode.children.includes(curNode)
|
|
750
|
-
|| curNode.parentNode instanceof concepts_1.
|
|
793
|
+
|| curNode.parentNode instanceof concepts_1.Frontend && !curNode.parentNode.views.includes(curNode)) {
|
|
751
794
|
removed = true;
|
|
752
795
|
}
|
|
753
796
|
curNode = curNode.parentNode;
|
|
754
797
|
}
|
|
755
798
|
if (removed)
|
|
756
799
|
return diagnostics;
|
|
757
|
-
fileNode?.sourceMap.forEach(
|
|
800
|
+
fileNode?.sourceMap.forEach((value, node) => {
|
|
758
801
|
if (node instanceof concepts_1.Match) {
|
|
759
802
|
const { cases, expression } = node || {};
|
|
760
803
|
const typeAnnotationMap = {};
|
|
@@ -764,7 +807,7 @@ class NaslServer {
|
|
|
764
807
|
count: 0,
|
|
765
808
|
};
|
|
766
809
|
if (Array.isArray(cases)) {
|
|
767
|
-
cases.forEach(
|
|
810
|
+
cases.forEach((caseItem, index) => {
|
|
768
811
|
let isDisabled = false;
|
|
769
812
|
// 是最后一项
|
|
770
813
|
if (index === cases.length - 1) {
|
|
@@ -896,14 +939,14 @@ class NaslServer {
|
|
|
896
939
|
// 递归检查,防止从顶层页面开始删除影响子页面内容检查
|
|
897
940
|
while (curNode instanceof concepts_1.View && !removed) {
|
|
898
941
|
if (curNode.parentNode instanceof concepts_1.View && !curNode.parentNode.children.includes(curNode)
|
|
899
|
-
|| curNode.parentNode instanceof concepts_1.
|
|
942
|
+
|| curNode.parentNode instanceof concepts_1.Frontend && !curNode.parentNode.views.includes(curNode)) {
|
|
900
943
|
removed = true;
|
|
901
944
|
}
|
|
902
945
|
curNode = curNode.parentNode;
|
|
903
946
|
}
|
|
904
947
|
if (removed)
|
|
905
948
|
return diagnostics;
|
|
906
|
-
fileNode?.sourceMap.forEach(
|
|
949
|
+
fileNode?.sourceMap.forEach((value, node) => {
|
|
907
950
|
if (node instanceof concepts_1.ViewElement && node.view === fileNode) {
|
|
908
951
|
if (node.tag) {
|
|
909
952
|
node.bindAttrs.forEach((bindAttr) => {
|
|
@@ -943,6 +986,9 @@ class NaslServer {
|
|
|
943
986
|
// 子页面内部逻辑过滤
|
|
944
987
|
if (nodeIn.view !== fileNode)
|
|
945
988
|
return;
|
|
989
|
+
// 当局部变量、输出参数属于页面内逻辑时,需过滤同页面下不同逻辑下的同名变量
|
|
990
|
+
if (node.logic && node.logic !== nodeIn.logic)
|
|
991
|
+
return;
|
|
946
992
|
// 跟变量无关的赋值过滤
|
|
947
993
|
const jsCode = nodeIn.toJS();
|
|
948
994
|
if (!jsCode.includes(`${node.name} = `))
|
|
@@ -1018,6 +1064,44 @@ class NaslServer {
|
|
|
1018
1064
|
};
|
|
1019
1065
|
diagnostics.push(diagnostic);
|
|
1020
1066
|
}
|
|
1067
|
+
else if (propertyValue.value) {
|
|
1068
|
+
const dataSource = fileNode;
|
|
1069
|
+
// 数据源有连接错误
|
|
1070
|
+
let envText;
|
|
1071
|
+
if (propertyValue.env === 'dev') {
|
|
1072
|
+
if (dataSource.__devConnectError) {
|
|
1073
|
+
envText = '开发';
|
|
1074
|
+
}
|
|
1075
|
+
else if (dataSource.__devConnectError === false) {
|
|
1076
|
+
return;
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
else if (propertyValue.env === 'online') {
|
|
1080
|
+
if (dataSource.__onlineConnectError) {
|
|
1081
|
+
envText = '生产';
|
|
1082
|
+
}
|
|
1083
|
+
else if (dataSource.__onlineConnectError === false) {
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
// 手动插入报错
|
|
1088
|
+
if (envText) {
|
|
1089
|
+
const diagnostic = {
|
|
1090
|
+
node: fileNode,
|
|
1091
|
+
severity: 'error',
|
|
1092
|
+
message: `数据源配置:数据源 ${property.name} ${envText}环境数据源连接不通,请先检查${envText}环境数据源配置`,
|
|
1093
|
+
// 保留原来的内容方便查询一些问题
|
|
1094
|
+
originalDiagnostic: {
|
|
1095
|
+
fileName: '',
|
|
1096
|
+
start: null,
|
|
1097
|
+
end: null,
|
|
1098
|
+
category: 'error',
|
|
1099
|
+
text: `DataSource connection error`,
|
|
1100
|
+
},
|
|
1101
|
+
};
|
|
1102
|
+
return diagnostics.push(diagnostic);
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1021
1105
|
});
|
|
1022
1106
|
}
|
|
1023
1107
|
}
|
|
@@ -1026,17 +1110,18 @@ class NaslServer {
|
|
|
1026
1110
|
// 判断逻辑是否已经删除
|
|
1027
1111
|
if (fileNode.parentNode instanceof concepts_1.App && !fileNode.parentNode.logics.includes(fileNode))
|
|
1028
1112
|
return diagnostics;
|
|
1029
|
-
fileNode?.sourceMap.forEach(
|
|
1113
|
+
fileNode?.sourceMap.forEach((value, node) => {
|
|
1114
|
+
//OQL支持返回复合类型数据了
|
|
1030
1115
|
// SqlQueryComponent内部返回值类型,如果是嵌套的就需要报错
|
|
1031
|
-
if ((node instanceof
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
}
|
|
1116
|
+
// if ((node instanceof OqlQueryComponent || node instanceof SqlQueryComponent) && (node as SqlQueryComponent).getTypeBanError()) {
|
|
1117
|
+
// const diagnostic = {
|
|
1118
|
+
// node,
|
|
1119
|
+
// severity: 'error',
|
|
1120
|
+
// message: 'SQL查询:返回类型内部,不支持复杂类型。',
|
|
1121
|
+
// };
|
|
1122
|
+
// node.tsErrorDetail = diagnostic;
|
|
1123
|
+
// diagnostics.push(diagnostic);
|
|
1124
|
+
// }
|
|
1040
1125
|
if (node instanceof concepts_1.Return || node instanceof concepts_1.Variable) {
|
|
1041
1126
|
if (!node.typeAnnotation && !node.__TypeAnnotation) {
|
|
1042
1127
|
const nodeTypeName = node.concept === 'Return' ? '输出参数' : '局部变量';
|
|
@@ -1073,6 +1158,11 @@ class NaslServer {
|
|
|
1073
1158
|
this.checkNodeError(node, diagnostics);
|
|
1074
1159
|
});
|
|
1075
1160
|
}
|
|
1161
|
+
if (fileNode instanceof concepts_1.Process) {
|
|
1162
|
+
fileNode?.sourceMap.forEach((value, node) => {
|
|
1163
|
+
this.checkNodeError(node, diagnostics);
|
|
1164
|
+
});
|
|
1165
|
+
}
|
|
1076
1166
|
return diagnostics;
|
|
1077
1167
|
}
|
|
1078
1168
|
checkNodeError(node, diagnostics) {
|
|
@@ -1153,9 +1243,32 @@ class NaslServer {
|
|
|
1153
1243
|
node.tsErrorDetail = diagnostic;
|
|
1154
1244
|
diagnostics.push(diagnostic);
|
|
1155
1245
|
}
|
|
1246
|
+
// 如果TypeAnnotation 还存在,但是本身已经不是union类型,就是已经从union换别的类型了就都要报错
|
|
1247
|
+
}
|
|
1248
|
+
else if (node instanceof concepts_1.TypeAnnotation && matchExpressionType?.typeKind !== 'union') {
|
|
1249
|
+
const diagnostic = {
|
|
1250
|
+
node,
|
|
1251
|
+
severity: 'error',
|
|
1252
|
+
message: '匹配:选择类型不存在',
|
|
1253
|
+
titleTip: '该类型已被删除',
|
|
1254
|
+
};
|
|
1255
|
+
node.tsErrorDetail = diagnostic;
|
|
1256
|
+
diagnostics.push(diagnostic);
|
|
1257
|
+
// 如果可枚举变量的 ,变量 还存在,但是本身已经是union类型,就是已经从别的类型 换了union就都要报错
|
|
1258
|
+
}
|
|
1259
|
+
else if (!(node instanceof concepts_1.TypeAnnotation) && matchExpressionType?.typeKind === 'union') {
|
|
1260
|
+
const diagnostic = {
|
|
1261
|
+
node,
|
|
1262
|
+
severity: 'error',
|
|
1263
|
+
message: '匹配:选择值不存在',
|
|
1264
|
+
titleTip: '该值无法匹配,请重新选择类型',
|
|
1265
|
+
};
|
|
1266
|
+
node.tsErrorDetail = diagnostic;
|
|
1267
|
+
diagnostics.push(diagnostic);
|
|
1156
1268
|
}
|
|
1157
1269
|
if (node.tsErrorDetail) {
|
|
1158
|
-
|
|
1270
|
+
// 如果父级是枚举,而且子集选的是变量,就提示枚举值已被删除
|
|
1271
|
+
if (matchExpressionType?.typeNamespace?.includes('enums') && (node instanceof concepts_1.MemberExpression)) {
|
|
1159
1272
|
node.tsErrorDetail.titleTip = '该枚举值已被删除';
|
|
1160
1273
|
}
|
|
1161
1274
|
else if (!node.tsErrorDetail.titleTip) {
|
|
@@ -1173,6 +1286,25 @@ class NaslServer {
|
|
|
1173
1286
|
node.tsErrorDetail = diagnostic;
|
|
1174
1287
|
diagnostics.push(diagnostic);
|
|
1175
1288
|
}
|
|
1289
|
+
/**
|
|
1290
|
+
* 如果节点是内置函数
|
|
1291
|
+
* 穷举在线上的情况,不在线上就void报错, calllogic 和 callinterface 因为原来有报错,所以就忽略掉
|
|
1292
|
+
* && 他在父级中,不在body
|
|
1293
|
+
* && 也不再 if的线上
|
|
1294
|
+
* && 也不再 switch的线上consequent
|
|
1295
|
+
* && 也不再草稿区域
|
|
1296
|
+
* && 不在 parentNode.parentNode(只用处理两层的,超过两层上就需要报错,只用直接是参数位第一层的需要) 是 callfunction 和 callInfterfase中,因为这两本身有强制类型,内置函数或者一些带T的声明那种,
|
|
1297
|
+
* && 而且也没有类型,就说明在槽位里,就需要报错
|
|
1298
|
+
*/
|
|
1299
|
+
if (node instanceof concepts_1.CallFunction && node.parentKey !== 'body' && node.parentKey !== 'alternate' && node.parentKey !== 'playground' && node.parentKey !== 'consequent' && node.parentNode?.parentNode?.concept !== 'CallLogic' && node.parentNode?.parentNode?.concept !== 'CallInterface' && !node.__TypeAnnotation) {
|
|
1300
|
+
const diagnostic = {
|
|
1301
|
+
node,
|
|
1302
|
+
severity: 'error',
|
|
1303
|
+
message: `类型不一致,当前内置函数${node.calleeName || ''}无返回值。`,
|
|
1304
|
+
};
|
|
1305
|
+
node.tsErrorDetail = diagnostic;
|
|
1306
|
+
diagnostics.push(diagnostic);
|
|
1307
|
+
}
|
|
1176
1308
|
}
|
|
1177
1309
|
/* 接口导入查找 */
|
|
1178
1310
|
existStructureFix(semanticDiagnostics, node, that) {
|
|
@@ -1556,7 +1688,7 @@ class NaslServer {
|
|
|
1556
1688
|
// 因为要用下面的点位信息
|
|
1557
1689
|
const name = minRange.node.name;
|
|
1558
1690
|
// 如果name不改,那就是要改命名空间
|
|
1559
|
-
if (newValue === name) {
|
|
1691
|
+
if (node instanceof concepts_1.Frontend || newValue === name) {
|
|
1560
1692
|
const namespace = minRange.node.namespace;
|
|
1561
1693
|
// 先看下标位置
|
|
1562
1694
|
const lineText = record.lineText;
|
|
@@ -1679,6 +1811,24 @@ class NaslServer {
|
|
|
1679
1811
|
minRange.newValue = newTsNameSpace;
|
|
1680
1812
|
}
|
|
1681
1813
|
}
|
|
1814
|
+
if (node instanceof concepts_1.Frontend && minRange.node instanceof concepts_1.Destination) {
|
|
1815
|
+
const tsCalleeNamespace = minRange.node.tsCalleeNamespace;
|
|
1816
|
+
const tsName = minRange.node.tsName;
|
|
1817
|
+
const oldValue = tsCalleeNamespace + '.' + tsName;
|
|
1818
|
+
// 先看下标位置
|
|
1819
|
+
const lineText = record.lineText;
|
|
1820
|
+
const index = lineText.indexOf(oldValue);
|
|
1821
|
+
// 在把开始结束位置的-开始位置,来知道是哪里要替换
|
|
1822
|
+
const start = record.start.offset - index - 1;
|
|
1823
|
+
const end = record.end.offset - index - 1;
|
|
1824
|
+
if (start <= tsCalleeNamespace.length) {
|
|
1825
|
+
// 新的完整的value
|
|
1826
|
+
let newTsNameSpace = tsCalleeNamespace.substring(0, start) + newValue + tsCalleeNamespace.substring(end, tsCalleeNamespace.length);
|
|
1827
|
+
minRange.setTypeMethods = 'setViewNamespace';
|
|
1828
|
+
newTsNameSpace = newTsNameSpace.replace(/\.\$/g, '.');
|
|
1829
|
+
minRange.newValue = newTsNameSpace;
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1682
1832
|
// 如果是事件修改
|
|
1683
1833
|
// 如果是view也需要加前缀
|
|
1684
1834
|
// logic 和 views名称修改 可能会触发bindEvent修改
|
|
@@ -1893,12 +2043,8 @@ class NaslServer {
|
|
|
1893
2043
|
const minRange = this._findMinRange(record, fileNode);
|
|
1894
2044
|
if (minRange) {
|
|
1895
2045
|
// 如果找到节点是callLogic就去更新
|
|
1896
|
-
if (minRange.node instanceof concepts_1.CallLogic && node instanceof concepts_1.Param) {
|
|
1897
|
-
minRange.node.
|
|
1898
|
-
}
|
|
1899
|
-
// 如果节点参数增加页面也要更新
|
|
1900
|
-
if (minRange.node instanceof concepts_1.Destination && node instanceof concepts_1.Param) {
|
|
1901
|
-
minRange.node.setViewArgument(parantNode);
|
|
2046
|
+
if ((minRange.node instanceof concepts_1.CallLogic || minRange.node instanceof concepts_1.Destination) && node instanceof concepts_1.Param) {
|
|
2047
|
+
minRange.node.addCalleeArg(parantNode);
|
|
1902
2048
|
}
|
|
1903
2049
|
}
|
|
1904
2050
|
});
|
|
@@ -2205,7 +2351,7 @@ class NaslServer {
|
|
|
2205
2351
|
return concepts_1.TypeAnnotation.createPrimitive('Boolean');
|
|
2206
2352
|
}
|
|
2207
2353
|
// Convert和new都是自身携带类型的,就不进行修改
|
|
2208
|
-
if (node instanceof concepts_1.CallFunction && node.calleeNamespace === 'nasl.util' && (
|
|
2354
|
+
if (node instanceof concepts_1.CallFunction && node.calleeNamespace === 'nasl.util' && (['Convert', 'New', 'FromString'].includes(node.calleeName))) {
|
|
2209
2355
|
if (node.typeArguments.length) {
|
|
2210
2356
|
return node.typeArguments[0];
|
|
2211
2357
|
}
|
|
@@ -2285,6 +2431,9 @@ class NaslServer {
|
|
|
2285
2431
|
'Return',
|
|
2286
2432
|
'Variable',
|
|
2287
2433
|
'Match',
|
|
2434
|
+
'NewComposite',
|
|
2435
|
+
'NewList',
|
|
2436
|
+
'NewMap',
|
|
2288
2437
|
].includes(node.concept))
|
|
2289
2438
|
return;
|
|
2290
2439
|
// 要去ls那边获取的
|
|
@@ -2336,6 +2485,13 @@ class NaslServer {
|
|
|
2336
2485
|
newCode = newCode.substring(newCode.lastIndexOf('\n'), indexOf);
|
|
2337
2486
|
fileDetail.offset = newCode.length + 'return '.length;
|
|
2338
2487
|
}
|
|
2488
|
+
else if (['NewComposite', 'NewList', 'NewMap'].includes(node.concept)) {
|
|
2489
|
+
fileDetail.line = item.range.end.line;
|
|
2490
|
+
const indexOf = item.code.indexOf('return __newComposite');
|
|
2491
|
+
let newCode = item.code.substring(0, indexOf);
|
|
2492
|
+
newCode = newCode.substring(newCode.lastIndexOf('\n'), indexOf);
|
|
2493
|
+
fileDetail.offset = newCode.length + 'return '.length;
|
|
2494
|
+
}
|
|
2339
2495
|
args.push(fileDetail);
|
|
2340
2496
|
});
|
|
2341
2497
|
console.time('请求');
|
|
@@ -2379,15 +2535,23 @@ class NaslServer {
|
|
|
2379
2535
|
}
|
|
2380
2536
|
}
|
|
2381
2537
|
});
|
|
2382
|
-
//
|
|
2538
|
+
// 重置类型状态, 并且赋值
|
|
2383
2539
|
types.forEach((value, node) => {
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2540
|
+
try {
|
|
2541
|
+
// 因为node可能是经过处理的TypeAnnotation
|
|
2542
|
+
node.__isCorrectTypeAnnotation = true;
|
|
2543
|
+
if (value) {
|
|
2544
|
+
if (value instanceof concepts_1.TypeAnnotation) {
|
|
2545
|
+
node.__TypeAnnotation = Object.freeze(value);
|
|
2546
|
+
}
|
|
2547
|
+
else if (value.typeAnnotation) {
|
|
2548
|
+
node.__TypeAnnotation = Object.freeze(value.typeAnnotation);
|
|
2549
|
+
}
|
|
2388
2550
|
}
|
|
2389
|
-
|
|
2390
|
-
|
|
2551
|
+
}
|
|
2552
|
+
catch (err) {
|
|
2553
|
+
if (globalThis.window) {
|
|
2554
|
+
console.log(err);
|
|
2391
2555
|
}
|
|
2392
2556
|
}
|
|
2393
2557
|
});
|
|
@@ -2644,7 +2808,7 @@ class NaslServer {
|
|
|
2644
2808
|
option: { defaultValue: param.defaultValue },
|
|
2645
2809
|
};
|
|
2646
2810
|
}
|
|
2647
|
-
async getCurrentTypeAnnotation(node) {
|
|
2811
|
+
async getCurrentTypeAnnotation(node, outTime = 600) {
|
|
2648
2812
|
if (node.__TypeAnnotation) {
|
|
2649
2813
|
return node.__TypeAnnotation;
|
|
2650
2814
|
}
|
|
@@ -2659,7 +2823,7 @@ class NaslServer {
|
|
|
2659
2823
|
else {
|
|
2660
2824
|
resolve(null);
|
|
2661
2825
|
}
|
|
2662
|
-
},
|
|
2826
|
+
}, outTime);
|
|
2663
2827
|
const mySetInterval = setInterval(() => {
|
|
2664
2828
|
if (node.__isCorrectTypeAnnotation) {
|
|
2665
2829
|
resolve(node.__TypeAnnotation);
|
|
@@ -2745,7 +2909,7 @@ class NaslServer {
|
|
|
2745
2909
|
}
|
|
2746
2910
|
// 更新文件之后
|
|
2747
2911
|
await this.updateFiles({ outputFiles });
|
|
2748
|
-
newRefs.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
2912
|
+
newRefs.refs.forEach((ref) => this.filesToCheck.add(ref.file));
|
|
2749
2913
|
}
|
|
2750
2914
|
/**
|
|
2751
2915
|
* 除去rename场景下的更新
|
|
@@ -2764,13 +2928,13 @@ class NaslServer {
|
|
|
2764
2928
|
line: EmbeddedTSFileLineMap[fileNode.concept] ?? 2,
|
|
2765
2929
|
offset: EmbeddedTSFileOffsetMap[fileNode.concept] ?? 6,
|
|
2766
2930
|
});
|
|
2767
|
-
newRefs.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
2931
|
+
newRefs.refs.forEach((ref) => this.filesToCheck.add(ref.file));
|
|
2768
2932
|
// 唤起建立连接弹框
|
|
2769
2933
|
// 文件级别的建立连接采取提醒
|
|
2770
2934
|
if (action === 'create' && targetNode.__init) {
|
|
2771
2935
|
// 清除临时状态, 完成本次创建
|
|
2772
2936
|
delete targetNode.__init;
|
|
2773
|
-
if (fileNode === targetNode && filesToCheck.size > 1) {
|
|
2937
|
+
if (fileNode === targetNode && this.filesToCheck.size > 1) {
|
|
2774
2938
|
const confirmParms = {
|
|
2775
2939
|
actionType: 'createEstablishConnection',
|
|
2776
2940
|
node: fileNode,
|
|
@@ -2804,8 +2968,8 @@ class NaslServer {
|
|
|
2804
2968
|
line: EmbeddedTSFileLineMap[fileNode.concept] ?? 2,
|
|
2805
2969
|
offset: EmbeddedTSFileOffsetMap[fileNode.concept] ?? 6,
|
|
2806
2970
|
});
|
|
2807
|
-
oldRefs.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
2808
|
-
filesToCheck.delete(oldFilePath);
|
|
2971
|
+
oldRefs.refs.forEach((ref) => this.filesToCheck.add(ref.file));
|
|
2972
|
+
this.filesToCheck.delete(oldFilePath);
|
|
2809
2973
|
// 更新文件之后
|
|
2810
2974
|
await this.updateFiles({ outputFiles });
|
|
2811
2975
|
// 查一下新函数名的依赖
|
|
@@ -2816,7 +2980,7 @@ class NaslServer {
|
|
|
2816
2980
|
});
|
|
2817
2981
|
const newRefFileList = new Set();
|
|
2818
2982
|
newRefs.refs.forEach((ref) => {
|
|
2819
|
-
filesToCheck.add(ref.file);
|
|
2983
|
+
this.filesToCheck.add(ref.file);
|
|
2820
2984
|
newRefFileList.add(ref.file);
|
|
2821
2985
|
});
|
|
2822
2986
|
// 文件级别重命名,有依赖才唤起弹框
|
|
@@ -2843,7 +3007,7 @@ class NaslServer {
|
|
|
2843
3007
|
line: EmbeddedTSFileLineMap[fileNode.concept] ?? 2,
|
|
2844
3008
|
offset: EmbeddedTSFileOffsetMap[fileNode.concept] ?? 6,
|
|
2845
3009
|
});
|
|
2846
|
-
newRefs2.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
3010
|
+
newRefs2.refs.forEach((ref) => this.filesToCheck.add(ref.file));
|
|
2847
3011
|
}
|
|
2848
3012
|
else {
|
|
2849
3013
|
// 查一下当前属性依赖的文件
|
|
@@ -2858,7 +3022,7 @@ class NaslServer {
|
|
|
2858
3022
|
line: (0, translator_1.lsp2tspNumber)(currentSource.range.start.line),
|
|
2859
3023
|
offset: (0, translator_1.lsp2tspNumber)(currentSource.range.start.character),
|
|
2860
3024
|
});
|
|
2861
|
-
oldRefs.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
3025
|
+
oldRefs.refs.forEach((ref) => this.filesToCheck.add(ref.file));
|
|
2862
3026
|
// 更新文件之后
|
|
2863
3027
|
await this.updateFiles({ outputFiles });
|
|
2864
3028
|
const newRefs2 = await this.references({
|
|
@@ -2866,7 +3030,7 @@ class NaslServer {
|
|
|
2866
3030
|
line: (0, translator_1.lsp2tspNumber)(currentSource.range.start.line),
|
|
2867
3031
|
offset: (0, translator_1.lsp2tspNumber)(currentSource.range.start.character),
|
|
2868
3032
|
});
|
|
2869
|
-
newRefs2.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
3033
|
+
newRefs2.refs.forEach((ref) => this.filesToCheck.add(ref.file));
|
|
2870
3034
|
}
|
|
2871
3035
|
}
|
|
2872
3036
|
}
|
|
@@ -2881,6 +3045,31 @@ class NaslServer {
|
|
|
2881
3045
|
*/
|
|
2882
3046
|
async incidentalAction(action, fileNode, targetNode, oldpath) {
|
|
2883
3047
|
if ((action === 'create' || action === 'delete' || (action === 'update' && oldpath)) && fileNode === targetNode) {
|
|
3048
|
+
//删除、更改、新增端
|
|
3049
|
+
if (fileNode instanceof concepts_1.Frontend && (fileNode.views?.length || fileNode.variables?.length)) {
|
|
3050
|
+
const fileNodeChildren = [...fileNode.views, ...fileNode.variables];
|
|
3051
|
+
for (let i = 0; i < fileNodeChildren.length; i++) {
|
|
3052
|
+
const fileNodeItem = fileNodeChildren[i];
|
|
3053
|
+
const result = fileNodeItem.toEmbeddedTSFile();
|
|
3054
|
+
fileNodeItem.sourceMap = result.sourceMap;
|
|
3055
|
+
if (action === 'create') {
|
|
3056
|
+
await this.handleChange(fileNodeItem, fileNodeItem, result, action);
|
|
3057
|
+
await this.incidentalAction(action, fileNodeItem, fileNodeItem);
|
|
3058
|
+
}
|
|
3059
|
+
else if (action === 'delete') {
|
|
3060
|
+
await this.handleDelete(fileNodeItem, fileNodeItem, result);
|
|
3061
|
+
await this.incidentalAction(action, fileNodeItem, fileNodeItem);
|
|
3062
|
+
}
|
|
3063
|
+
else if (action === 'update' && oldpath) {
|
|
3064
|
+
const parentPath = oldpath.replace('.ts', '/');
|
|
3065
|
+
const foldName = fileNodeItem.concept === 'View' ? 'views' : 'variables';
|
|
3066
|
+
const currentOldPath = parentPath + foldName + '/' + fileNodeItem.name + '.ts';
|
|
3067
|
+
// 因为重命名这里只有当前修改父级的 旧名称, 所以他的子集也要根据旧名称去查依赖 更新内容
|
|
3068
|
+
await this.handleRename(fileNodeItem, fileNodeItem, result, currentOldPath);
|
|
3069
|
+
await this.incidentalAction(action, fileNodeItem, fileNodeItem, currentOldPath);
|
|
3070
|
+
}
|
|
3071
|
+
}
|
|
3072
|
+
}
|
|
2884
3073
|
// 删除或者新增页面
|
|
2885
3074
|
if (fileNode instanceof concepts_1.View && fileNode.children?.length) {
|
|
2886
3075
|
const fileNodeChildren = fileNode.children;
|
|
@@ -2955,7 +3144,7 @@ class NaslServer {
|
|
|
2955
3144
|
}
|
|
2956
3145
|
}
|
|
2957
3146
|
async receiveHandleChange($event) {
|
|
2958
|
-
singleFileChangeIng = true;
|
|
3147
|
+
this.singleFileChangeIng = true;
|
|
2959
3148
|
// 行为
|
|
2960
3149
|
const action = $event.action;
|
|
2961
3150
|
const targetNode = $event.target;
|
|
@@ -3002,20 +3191,20 @@ class NaslServer {
|
|
|
3002
3191
|
return true;
|
|
3003
3192
|
}
|
|
3004
3193
|
changeFileNext() {
|
|
3005
|
-
if (!singleFileChangeIng) {
|
|
3194
|
+
if (!this.singleFileChangeIng) {
|
|
3006
3195
|
const item = this.changeStackList.shift();
|
|
3007
3196
|
this.receiveHandleChange(item).catch((err) => {
|
|
3008
3197
|
console.log(err, 'receiveHandleChangeErr');
|
|
3009
3198
|
}).finally(async () => {
|
|
3010
3199
|
// 每一个文件与change接触就把状态置为false,让下一个进入
|
|
3011
|
-
singleFileChangeIng = false;
|
|
3200
|
+
this.singleFileChangeIng = false;
|
|
3012
3201
|
if (this.changeStackList.length) {
|
|
3013
3202
|
this.changeFileNext();
|
|
3014
3203
|
}
|
|
3015
3204
|
else {
|
|
3016
|
-
console.log(Array.from(filesToCheck));
|
|
3017
|
-
await this.getDiagnosticRecordsAndPushAll(Array.from(filesToCheck));
|
|
3018
|
-
filesToCheck.clear();
|
|
3205
|
+
console.log(Array.from(this.filesToCheck));
|
|
3206
|
+
await this.getDiagnosticRecordsAndPushAll(Array.from(this.filesToCheck));
|
|
3207
|
+
this.filesToCheck.clear();
|
|
3019
3208
|
}
|
|
3020
3209
|
});
|
|
3021
3210
|
}
|