@lcap/nasl 2.22.0-beta.5 → 3.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/docs/classes/Module.html +15 -15
- package/docs/classes/Namespace.html +15 -15
- package/docs/classes/ViewComponent.html +19 -19
- package/out/automate/engine/utils.js +4 -0
- package/out/automate/engine/utils.js.map +1 -1
- package/out/breakpoint/generator/AfterStartNode.d.ts +7 -0
- package/out/breakpoint/generator/AfterStartNode.js +27 -0
- package/out/breakpoint/generator/AfterStartNode.js.map +1 -0
- package/out/breakpoint/generator/BeforeEndNode.d.ts +7 -0
- package/out/breakpoint/generator/BeforeEndNode.js +27 -0
- package/out/breakpoint/generator/BeforeEndNode.js.map +1 -0
- package/out/breakpoint/generator/BreakpointNode.d.ts +14 -0
- package/out/breakpoint/generator/BreakpointNode.js +166 -0
- package/out/breakpoint/generator/BreakpointNode.js.map +1 -0
- package/out/breakpoint/generator/index.d.ts +4 -0
- package/out/breakpoint/generator/index.js +98 -0
- package/out/breakpoint/generator/index.js.map +1 -0
- package/out/breakpoint/index.d.ts +3 -0
- package/out/breakpoint/index.js +20 -0
- package/out/breakpoint/index.js.map +1 -0
- package/out/breakpoint/shared/constants.d.ts +30 -0
- package/out/breakpoint/shared/constants.js +87 -0
- package/out/breakpoint/shared/constants.js.map +1 -0
- package/out/breakpoint/shared/index.d.ts +3 -0
- package/out/breakpoint/shared/index.js +33 -0
- package/out/breakpoint/shared/index.js.map +1 -0
- package/out/breakpoint/shared/operations.d.ts +10 -0
- package/out/breakpoint/shared/operations.js +25 -0
- package/out/breakpoint/shared/operations.js.map +1 -0
- package/out/breakpoint/shared/socket.d.ts +47 -0
- package/out/breakpoint/shared/socket.js +210 -0
- package/out/breakpoint/shared/socket.js.map +1 -0
- package/out/breakpoint/shared/utils.d.ts +20 -0
- package/out/breakpoint/shared/utils.js +133 -0
- package/out/breakpoint/shared/utils.js.map +1 -0
- package/out/breakpoint/store/core.d.ts +30 -0
- package/out/breakpoint/store/core.js +341 -0
- package/out/breakpoint/store/core.js.map +1 -0
- package/out/breakpoint/store/dock.d.ts +1 -0
- package/out/breakpoint/store/dock.js +127 -0
- package/out/breakpoint/store/dock.js.map +1 -0
- package/out/breakpoint/store/index.d.ts +2 -0
- package/out/breakpoint/store/index.js +19 -0
- package/out/breakpoint/store/index.js.map +1 -0
- package/out/common/BaseNode.d.ts +8 -0
- package/out/common/BaseNode.js +19 -0
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/App__.d.ts +365 -16
- package/out/concepts/App__.js +431 -10
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Assignment__.js +1 -1
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/AuthInterface__.d.ts +37 -0
- package/out/concepts/AuthInterface__.js +141 -0
- package/out/concepts/AuthInterface__.js.map +1 -0
- package/out/concepts/AuthLogicForCallInterface__.d.ts +138 -0
- package/out/concepts/AuthLogicForCallInterface__.js +493 -0
- package/out/concepts/AuthLogicForCallInterface__.js.map +1 -0
- package/out/concepts/AuthLogic__.d.ts +66 -0
- package/out/concepts/AuthLogic__.js +206 -0
- package/out/concepts/AuthLogic__.js.map +1 -0
- package/out/concepts/BackendVariable__.d.ts +137 -0
- package/out/concepts/BackendVariable__.js +422 -0
- package/out/concepts/BackendVariable__.js.map +1 -0
- package/out/concepts/Backend__.d.ts +134 -0
- package/out/concepts/Backend__.js +274 -0
- package/out/concepts/Backend__.js.map +1 -0
- package/out/concepts/BindAttribute__.d.ts +1 -1
- package/out/concepts/BindAttribute__.js +3 -1
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindEvent__.d.ts +12 -0
- package/out/concepts/BindEvent__.js +68 -0
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/CallAuthInterface__.d.ts +126 -0
- package/out/concepts/CallAuthInterface__.js +408 -0
- package/out/concepts/CallAuthInterface__.js.map +1 -0
- package/out/concepts/CallInterface__.d.ts +6 -1
- package/out/concepts/CallInterface__.js +9 -1
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.js +3 -1
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.js +9 -7
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Destination__.js +1 -1
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +29 -2
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +1 -2
- package/out/concepts/Entity__.js +1 -31
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +9 -4
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/FrontendLibrary__.d.ts +29 -29
- package/out/concepts/FrontendLibrary__.js +2 -2
- package/out/concepts/FrontendVariable__.d.ts +21 -0
- package/out/concepts/FrontendVariable__.js +64 -0
- package/out/concepts/FrontendVariable__.js.map +1 -0
- package/out/concepts/Frontend__.d.ts +151 -47
- package/out/concepts/Frontend__.js +188 -32
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/Function__.js +1 -1
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.js +1 -1
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/Interface__.d.ts +1 -1
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +18 -3
- package/out/concepts/LogicItem__.js +22 -4
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +14 -9
- package/out/concepts/Logic__.js +43 -5
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/Namespace__.d.ts +29 -29
- package/out/concepts/Namespace__.js +2 -2
- package/out/concepts/NewComposite__.js +2 -2
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/OverriddenLogic__.d.ts +643 -0
- package/out/concepts/OverriddenLogic__.js +1602 -0
- package/out/concepts/OverriddenLogic__.js.map +1 -0
- package/out/concepts/Param__.d.ts +6 -0
- package/out/concepts/Param__.js +10 -0
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/QueryFieldExpression__.d.ts +2 -0
- package/out/concepts/QueryFieldExpression__.js +9 -0
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QuerySelectExpression__.d.ts +2 -2
- package/out/concepts/QuerySelectExpression__.js +2 -2
- package/out/concepts/QuerySelectExpression__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.js +6 -6
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/Variable__.d.ts +10 -0
- package/out/concepts/Variable__.js +12 -0
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewComponent__.d.ts +33 -33
- package/out/concepts/ViewComponent__.js +7 -7
- package/out/concepts/ViewElement__.d.ts +6 -0
- package/out/concepts/ViewElement__.js +104 -1
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.js +2 -2
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/basics/stdlib/index.js +2 -1
- package/out/concepts/basics/stdlib/index.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.auth.js +24 -0
- package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.http.d.ts +7 -0
- package/out/concepts/basics/stdlib/nasl.http.js +167 -0
- package/out/concepts/basics/stdlib/nasl.http.js.map +1 -0
- package/out/concepts/basics/stdlib/nasl.process.js +68 -0
- package/out/concepts/basics/stdlib/nasl.process.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +4 -19
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +83 -17
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/basics/types/index.d.ts +1 -0
- package/out/concepts/basics/types/index.js +4 -1
- package/out/concepts/basics/types/index.js.map +1 -1
- package/out/concepts/index__.d.ts +8 -0
- package/out/concepts/index__.js +8 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/enums/KEYWORDS.js +0 -1
- package/out/enums/KEYWORDS.js.map +1 -1
- package/out/generator/genBundleFiles.d.ts +1 -0
- package/out/generator/genBundleFiles.js +27 -0
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.d.ts +4 -1
- package/out/generator/genMetaData.js +14 -0
- package/out/generator/genMetaData.js.map +1 -1
- package/out/generator/genReleaseBody.d.ts +2 -1
- package/out/generator/genReleaseBody.js +2 -1
- package/out/generator/genReleaseBody.js.map +1 -1
- package/out/index.d.ts +2 -1
- package/out/index.js +3 -1
- package/out/index.js.map +1 -1
- package/out/server/extendBaseNode.js +16 -4
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/formatTsUtils.d.ts +2 -1
- package/out/server/formatTsUtils.js +39 -4
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getExtensionModules.d.ts +2 -2
- package/out/server/getExtensionModules.js +16 -2
- package/out/server/getExtensionModules.js.map +1 -1
- package/out/server/getLogics.js +5 -5
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.d.ts +1 -0
- package/out/server/getMemberIdentifier.js +34 -7
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/naslServer.d.ts +64 -64
- package/out/server/naslServer.js +249 -121
- package/out/server/naslServer.js.map +1 -1
- package/out/server/naslStdlibMap.js +2 -0
- package/out/server/naslStdlibMap.js.map +1 -1
- package/out/server/translator.d.ts +1 -0
- package/out/server/translator.js +67 -2
- package/out/server/translator.js.map +1 -1
- package/out/service/defaultErrorMessage.json +1 -0
- package/out/service/storage/api.d.ts +10 -1
- package/out/service/storage/api.js +6 -0
- package/out/service/storage/api.js.map +1 -1
- package/out/service/storage/init.d.ts +4 -0
- package/out/service/storage/init.js +55 -35
- package/out/service/storage/init.js.map +1 -1
- package/out/service/storage/service.d.ts +3 -0
- package/out/service/storage/service.js +14 -0
- package/out/service/storage/service.js.map +1 -1
- package/out/utils/sortTsString.d.ts +1 -0
- package/out/utils/sortTsString.js +36 -0
- package/out/utils/sortTsString.js.map +1 -0
- package/out/utils/traverse.js +2 -2
- package/out/utils/traverse.js.map +1 -1
- package/package.json +7 -2
- package/sandbox/stdlib/nasl.auth.ts +8 -4
- package/sandbox/stdlib/nasl.core.d.ts +206 -0
- package/sandbox/stdlib/nasl.core.js +1 -0
- package/sandbox/stdlib/nasl.core.js.map +1 -0
- package/sandbox/stdlib/nasl.http.ts +35 -0
- package/sandbox/stdlib/nasl.process.ts +13 -0
- package/sandbox/stdlib/nasl.ui.ts +0 -5
- package/src/automate/engine/utils.js +4 -1
- package/src/breakpoint/generator/AfterStartNode.ts +27 -0
- package/src/breakpoint/generator/BeforeEndNode.ts +27 -0
- package/src/breakpoint/generator/BreakpointNode.ts +228 -0
- package/src/breakpoint/generator/index.ts +114 -0
- package/src/breakpoint/index.ts +3 -0
- package/src/breakpoint/shared/constants.ts +95 -0
- package/src/breakpoint/shared/index.ts +3 -0
- package/src/breakpoint/shared/operations.ts +25 -0
- package/src/breakpoint/shared/socket.ts +326 -0
- package/src/breakpoint/shared/utils.ts +195 -0
- package/src/breakpoint/store/core.ts +411 -0
- package/src/breakpoint/store/dock.ts +166 -0
- package/src/breakpoint/store/index.ts +2 -0
- package/src/breakpoint/types/index.d.ts +19 -0
- package/src/common/BaseNode.ts +19 -1
- package/src/concepts/App__.ts +828 -26
- package/src/concepts/Assignment__.ts +1 -1
- package/src/concepts/AuthInterface__.ts +148 -0
- package/src/concepts/AuthLogicForCallInterface__.ts +573 -0
- package/src/concepts/AuthLogic__.ts +225 -0
- package/src/concepts/BackendVariable__.ts +466 -0
- package/src/concepts/Backend__.ts +347 -0
- package/src/concepts/BindAttribute__.ts +4 -3
- package/src/concepts/BindEvent__.ts +71 -2
- package/src/concepts/CallAuthInterface__.ts +490 -0
- package/src/concepts/CallInterface__.ts +10 -2
- package/src/concepts/CallLogic__.ts +3 -1
- package/src/concepts/CallQueryComponent__.ts +67 -7
- package/src/concepts/Destination__.ts +19 -1
- package/src/concepts/End__.ts +31 -3
- package/src/concepts/EntityProperty__.ts +6 -0
- package/src/concepts/Entity__.ts +8 -31
- package/src/concepts/ForEachStatement__.ts +9 -4
- package/src/concepts/FrontendLibrary__.ts +30 -30
- package/src/concepts/FrontendVariable__.ts +76 -0
- package/src/concepts/Frontend__.ts +352 -89
- package/src/concepts/Function__.ts +1 -1
- package/src/concepts/Identifier__.ts +5 -5
- package/src/concepts/Interface__.ts +1 -1
- package/src/concepts/LogicItem__.ts +26 -6
- package/src/concepts/Logic__.ts +86 -8
- package/src/concepts/Module__.ts +32 -2
- package/src/concepts/Namespace__.ts +30 -30
- package/src/concepts/NewComposite__.ts +2 -3
- package/src/concepts/OverriddenLogic__.ts +2165 -0
- package/src/concepts/Param__.ts +13 -3
- package/src/concepts/QueryFieldExpression__.ts +18 -0
- package/src/concepts/QuerySelectExpression__.ts +11 -3
- package/src/concepts/TypeAnnotation__.ts +45 -6
- package/src/concepts/Variable__.ts +14 -0
- package/src/concepts/ViewComponent__.ts +35 -35
- package/src/concepts/ViewElement__.ts +104 -1
- package/src/concepts/View__.ts +24 -2
- package/src/concepts/basics/stdlib/index.ts +2 -1
- package/src/concepts/basics/stdlib/nasl.auth.ts +24 -0
- package/src/concepts/basics/stdlib/nasl.http.ts +166 -0
- package/src/concepts/basics/stdlib/nasl.process.ts +68 -0
- package/src/concepts/basics/stdlib/nasl.ui.ts +4 -19
- package/src/concepts/basics/stdlib/nasl.util.ts +83 -17
- package/src/concepts/basics/types/index.ts +5 -4
- package/src/concepts/index__.ts +8 -0
- package/src/enums/KEYWORDS.ts +0 -1
- package/src/generator/genBundleFiles.ts +36 -2
- package/src/generator/genMetaData.ts +16 -1
- package/src/generator/genReleaseBody.ts +4 -1
- package/src/index.ts +2 -1
- package/src/server/extendBaseNode.ts +18 -7
- package/src/server/formatTsUtils.ts +37 -5
- package/src/server/getExtensionModules.ts +18 -3
- package/src/server/getLogics.ts +6 -6
- package/src/server/getMemberIdentifier.ts +35 -9
- package/src/server/naslServer.ts +250 -124
- package/src/server/naslStdlibMap.ts +2 -0
- package/src/server/translator.ts +67 -1
- package/src/service/defaultErrorMessage.json +1 -0
- package/src/service/storage/api.js +7 -1
- package/src/service/storage/init.ts +66 -35
- package/src/service/storage/service.ts +18 -2
- package/src/utils/sortTsString.ts +32 -0
- package/src/utils/traverse.ts +2 -2
- package/test/examples/app-simple.json +73635 -0
- package/ts-worker/lib/tsserver.js +3 -3
- package/ts-worker/package.json +1 -1
package/out/server/naslServer.js
CHANGED
|
@@ -56,6 +56,8 @@ const EmbeddedTSFileLineMap = {
|
|
|
56
56
|
};
|
|
57
57
|
const EmbeddedTSFileOffsetMap = {
|
|
58
58
|
Variable: 12,
|
|
59
|
+
// Backend:12,
|
|
60
|
+
BackendVariable: 12,
|
|
59
61
|
ConfigProperty: 12,
|
|
60
62
|
};
|
|
61
63
|
const SentryMessager = (0, sentry_1.sentryMonitorTSWorkerMessager)(Messager_1.default);
|
|
@@ -162,8 +164,8 @@ class NaslServer {
|
|
|
162
164
|
/**
|
|
163
165
|
* 多个行为进行合并
|
|
164
166
|
* 合并规则是
|
|
165
|
-
* 1.[a,b,c,c] 在cc的时候,在已有一个c,又来一个c
|
|
166
|
-
*
|
|
167
|
+
* 1.[a,b,c,c] 在cc的时候,在已有一个c,又来一个c的时候,file级别的节点
|
|
168
|
+
* 就可以前面的内容去掉,只保留最后一个, 但是如果前面那个有携带file
|
|
167
169
|
* 2.[a,b,c,b,c] 在bc已存在,又来了bc 这就都要保留,因为可能顺序有相关性,不能去掉
|
|
168
170
|
* 理论上只处理同时几个操作 合并,
|
|
169
171
|
* 3.有field的也直接保留
|
|
@@ -172,13 +174,22 @@ class NaslServer {
|
|
|
172
174
|
const changeEvent = item.originEvent;
|
|
173
175
|
const changeNode = changeEvent.target;
|
|
174
176
|
const { fileNode } = this.getCurrentSource(changeNode);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
177
|
+
// 这个方法是 5.0 加入标准库的,但是这里 ts 版本是 4.x,ci 会挂,所以需要忽略
|
|
178
|
+
// @ts-ignore
|
|
179
|
+
const findLastIndex = this.changeStackList.findLastIndex((changeStackItem) => {
|
|
180
|
+
const target = changeStackItem.target;
|
|
181
|
+
const { fileNode: targetFileNode } = this.getCurrentSource(target);
|
|
182
|
+
return targetFileNode === fileNode;
|
|
183
|
+
});
|
|
184
|
+
// 如果当前找到了节点,而且节点在数组的最后一项,说明此次可以合并
|
|
185
|
+
if (findLastIndex !== -1 && findLastIndex === this.changeStackList.length - 1) {
|
|
186
|
+
// 最后一项有field就直接保留,新的也不塞,直接return
|
|
187
|
+
if (this.changeStackList[findLastIndex]?.field) {
|
|
188
|
+
// 如果当前列表里有,这个文件节点,最后一个是field的话,直接return掉,不用塞这个update了
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
// 如果最后一项是普通的update的话,就可以去掉,后面那个会在塞过来
|
|
182
193
|
this.changeStackList.pop();
|
|
183
194
|
}
|
|
184
195
|
}
|
|
@@ -235,6 +246,31 @@ class NaslServer {
|
|
|
235
246
|
}
|
|
236
247
|
});
|
|
237
248
|
if (module instanceof concepts_1.App) {
|
|
249
|
+
module.overriddenLogics?.forEach?.((logic) => {
|
|
250
|
+
try {
|
|
251
|
+
if (!(logic instanceof concepts_1.OverriddenLogic))
|
|
252
|
+
return;
|
|
253
|
+
const result = logic.toEmbeddedTSFile();
|
|
254
|
+
results.push(result);
|
|
255
|
+
logic.sourceMap = result.sourceMap;
|
|
256
|
+
this.file2NodeMap.set(result.filePath, logic);
|
|
257
|
+
}
|
|
258
|
+
catch (err) {
|
|
259
|
+
console.error('err: ', err);
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
module?.backend?.variables?.forEach((backdndVariable) => {
|
|
263
|
+
try {
|
|
264
|
+
const result = backdndVariable.toEmbeddedTSFile();
|
|
265
|
+
results.push(result);
|
|
266
|
+
// sourceMap都存在目录级别内容下,在页面层级下去找
|
|
267
|
+
backdndVariable.sourceMap = result.sourceMap;
|
|
268
|
+
this.file2NodeMap.set(result.filePath, backdndVariable);
|
|
269
|
+
}
|
|
270
|
+
catch (err) {
|
|
271
|
+
console.error(err);
|
|
272
|
+
}
|
|
273
|
+
});
|
|
238
274
|
module.frontends?.forEach((frontend) => {
|
|
239
275
|
try {
|
|
240
276
|
const result = frontend.toEmbeddedTSFile();
|
|
@@ -258,6 +294,21 @@ class NaslServer {
|
|
|
258
294
|
console.log(err);
|
|
259
295
|
}
|
|
260
296
|
});
|
|
297
|
+
frontend.bindEvents.forEach((bindEvent) => {
|
|
298
|
+
if (bindEvent?.logics && bindEvent?.logics?.length > 0) {
|
|
299
|
+
bindEvent.logics.forEach((logic) => {
|
|
300
|
+
try {
|
|
301
|
+
const result = logic.toEmbeddedTSFile();
|
|
302
|
+
results.push(result);
|
|
303
|
+
logic.sourceMap = result.sourceMap;
|
|
304
|
+
this.file2NodeMap.set(result.filePath, logic);
|
|
305
|
+
}
|
|
306
|
+
catch (err) {
|
|
307
|
+
console.error('err: ', err);
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
});
|
|
261
312
|
// view的生成
|
|
262
313
|
if (!config_1.config.closeViews) {
|
|
263
314
|
this.view2TSFile(frontend.views, results);
|
|
@@ -338,6 +389,30 @@ class NaslServer {
|
|
|
338
389
|
catch (err) {
|
|
339
390
|
}
|
|
340
391
|
});
|
|
392
|
+
module?.authLogics?.forEach?.((logic) => {
|
|
393
|
+
try {
|
|
394
|
+
if (!(logic instanceof concepts_1.Logic))
|
|
395
|
+
return;
|
|
396
|
+
const result = logic.toEmbeddedTSFile();
|
|
397
|
+
results.push(result);
|
|
398
|
+
logic.sourceMap = result.sourceMap;
|
|
399
|
+
this.file2NodeMap.set(result.filePath, logic);
|
|
400
|
+
}
|
|
401
|
+
catch (err) {
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
module?.authLogicsForCallInterface?.forEach?.((logic) => {
|
|
405
|
+
try {
|
|
406
|
+
if (!(logic instanceof concepts_1.Logic))
|
|
407
|
+
return;
|
|
408
|
+
const result = logic.toEmbeddedTSFile();
|
|
409
|
+
results.push(result);
|
|
410
|
+
logic.sourceMap = result.sourceMap;
|
|
411
|
+
this.file2NodeMap.set(result.filePath, logic);
|
|
412
|
+
}
|
|
413
|
+
catch (err) {
|
|
414
|
+
}
|
|
415
|
+
});
|
|
341
416
|
module.processes.forEach((process) => {
|
|
342
417
|
try {
|
|
343
418
|
const result = process.toEmbeddedTSFile();
|
|
@@ -425,6 +500,8 @@ class NaslServer {
|
|
|
425
500
|
async refreshApp(app) {
|
|
426
501
|
// 清除所有问题
|
|
427
502
|
this.diagnosticManager.clear();
|
|
503
|
+
// 刷新要清除文件列表
|
|
504
|
+
this.file2NodeMap.clear();
|
|
428
505
|
await this.deleteDirectoryFiles({ directoryName: '/embedded' });
|
|
429
506
|
// 清楚check count的数量
|
|
430
507
|
await this.messager.requestCommand('_clearTimeout');
|
|
@@ -435,29 +512,29 @@ class NaslServer {
|
|
|
435
512
|
// check内容后,会自动走增量类型标注完善全部类型
|
|
436
513
|
}
|
|
437
514
|
/**
|
|
438
|
-
|
|
439
|
-
|
|
515
|
+
* 初始化之前添加文件
|
|
516
|
+
*/
|
|
440
517
|
addFile(file) {
|
|
441
518
|
return this.messager.requestCommand('addFile', file);
|
|
442
519
|
}
|
|
443
|
-
/**
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
520
|
+
/**u
|
|
521
|
+
* 只新增文件
|
|
522
|
+
* @param {*} files
|
|
523
|
+
*/
|
|
447
524
|
writeFiles(files) {
|
|
448
525
|
return this.messager.requestCommand('writeFiles', files);
|
|
449
526
|
}
|
|
450
527
|
/**
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
528
|
+
* 新增、修改
|
|
529
|
+
* 删除文件 文件用修改内容为空模拟,防止报错
|
|
530
|
+
* @param {*} args
|
|
531
|
+
*/
|
|
455
532
|
updateFiles(args) {
|
|
456
533
|
return this.messager.requestCommand('updateFiles', args);
|
|
457
534
|
}
|
|
458
535
|
/**
|
|
459
|
-
|
|
460
|
-
|
|
536
|
+
* 清除一个目录下的所有文件
|
|
537
|
+
*/
|
|
461
538
|
deleteDirectoryFiles(args) {
|
|
462
539
|
return this.messager.requestCommand('deleteDirectoryFiles', args);
|
|
463
540
|
}
|
|
@@ -500,6 +577,7 @@ class NaslServer {
|
|
|
500
577
|
return this.messager.requestCommand('fileReferences', filePath);
|
|
501
578
|
}
|
|
502
579
|
async references(args) {
|
|
580
|
+
// debugger
|
|
503
581
|
return (await this.messager.requestCommand('references', args))?.response;
|
|
504
582
|
}
|
|
505
583
|
getValueSelectCompletion(node, value, noFilterList) {
|
|
@@ -532,10 +610,10 @@ class NaslServer {
|
|
|
532
610
|
if (node && node instanceof concepts_1.BaseNode) {
|
|
533
611
|
const callFunction = node.parentNode.parentNode;
|
|
534
612
|
/**
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
613
|
+
* currentSource callFunction 的节点,要去到当前节点的位置
|
|
614
|
+
* nasl.util.Convert(xxx),所以取到的位置要 + `nasl.util.C` 的长度
|
|
615
|
+
* fileNode
|
|
616
|
+
*/
|
|
539
617
|
const { currentSource, fileNode } = this.getCurrentSource(callFunction);
|
|
540
618
|
if (!currentSource) {
|
|
541
619
|
return [];
|
|
@@ -692,10 +770,10 @@ class NaslServer {
|
|
|
692
770
|
}
|
|
693
771
|
}
|
|
694
772
|
/**
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
773
|
+
* ts的 quickInfo方法,查询指定位置的详情
|
|
774
|
+
* @param args 文件信息数组
|
|
775
|
+
* @returns 查询到的
|
|
776
|
+
*/
|
|
699
777
|
_getTypeQuickinfo(args) {
|
|
700
778
|
return this.messager.requestCommand('quickInfo', args);
|
|
701
779
|
}
|
|
@@ -727,11 +805,11 @@ class NaslServer {
|
|
|
727
805
|
return result;
|
|
728
806
|
}
|
|
729
807
|
/**
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
808
|
+
* 获取已经选中的内容的 下一级的内容
|
|
809
|
+
* @param node 已经选中的内容
|
|
810
|
+
* @param noFilterList 不过滤的key 的数据
|
|
811
|
+
* @returns 可以选择的数据数组
|
|
812
|
+
*/
|
|
735
813
|
getSelectNextCompletion(node, noFilterList) {
|
|
736
814
|
const { currentSource, fileNode } = this.getCurrentSource(node);
|
|
737
815
|
// console.log(currentSource, fileNode);
|
|
@@ -767,8 +845,8 @@ class NaslServer {
|
|
|
767
845
|
// diagnosticManager.pushAll(records);
|
|
768
846
|
}
|
|
769
847
|
/**
|
|
770
|
-
|
|
771
|
-
|
|
848
|
+
* 节点异常是只能挂载单个,如果已经了就不赋值了
|
|
849
|
+
*/
|
|
772
850
|
baseNodeAssignmentTsError(node, tsErrorDetail) {
|
|
773
851
|
if (node.tsErrorDetail)
|
|
774
852
|
return;
|
|
@@ -823,6 +901,7 @@ class NaslServer {
|
|
|
823
901
|
}
|
|
824
902
|
});
|
|
825
903
|
}
|
|
904
|
+
record.semanticDiagnostics.forEach((diag) => (0, translator_2.checkAStructure_)(diag.text));
|
|
826
905
|
record.semanticDiagnostics = record.semanticDiagnostics
|
|
827
906
|
.map((diag) => this._resolveDiagnostic(diag, node, record))
|
|
828
907
|
.filter((diag) => !!diag);
|
|
@@ -1201,6 +1280,9 @@ class NaslServer {
|
|
|
1201
1280
|
if (node.code === `location.href = '/';`) {
|
|
1202
1281
|
return null;
|
|
1203
1282
|
}
|
|
1283
|
+
if (node?.code?.includes('use JSBlock')) {
|
|
1284
|
+
return null;
|
|
1285
|
+
}
|
|
1204
1286
|
const diagnostic = {
|
|
1205
1287
|
node,
|
|
1206
1288
|
severity: 'warning',
|
|
@@ -1303,10 +1385,10 @@ class NaslServer {
|
|
|
1303
1385
|
return flag;
|
|
1304
1386
|
}
|
|
1305
1387
|
/**
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1388
|
+
* 额外的诊断
|
|
1389
|
+
* @param fileNode 文件级别的节点
|
|
1390
|
+
* @returns 诊断结果
|
|
1391
|
+
*/
|
|
1310
1392
|
_attachDiagnostics(fileNode) {
|
|
1311
1393
|
// 每次诊断前先清空这个Set
|
|
1312
1394
|
this.logicSetWithComponentLogic = new Set();
|
|
@@ -1975,18 +2057,18 @@ class NaslServer {
|
|
|
1975
2057
|
diagnostics.push(diagnostic);
|
|
1976
2058
|
}
|
|
1977
2059
|
/**
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
2060
|
+
* 如果节点是内置函数
|
|
2061
|
+
* 穷举在线上的情况,不在线上就void报错, callinterface 因为原来有报错,所以就忽略掉
|
|
2062
|
+
* && 他在父级中,不在body
|
|
2063
|
+
* && 也不再 if的线上
|
|
2064
|
+
* && 也不再 switch的线上consequent
|
|
2065
|
+
* && 也不再草稿区域
|
|
2066
|
+
* && 不在 parentNode.parentNode(只用处理两层的,超过两层上就需要报错,只用直接是参数位第一层的需要) 是 callfunction 和 callInfterfase中,因为这两本身有强制类型,内置函数或者一些带T的声明那种,
|
|
2067
|
+
* && 而且也没有类型,就说明在槽位里,就需要报错
|
|
2068
|
+
*
|
|
2069
|
+
* 如果是内置函数而且也不在线上
|
|
2070
|
+
* 只有下面自己实现的函数才会报错
|
|
2071
|
+
*/
|
|
1990
2072
|
if (node instanceof concepts_1.CallFunction && node.parentKey !== 'body' && node.parentKey !== 'alternate' && node.parentKey !== 'playground' && node.parentKey !== 'consequent' && node.parentNode?.parentNode?.concept !== 'CallInterface' && !node.__TypeAnnotation) {
|
|
1991
2073
|
let showErr = false;
|
|
1992
2074
|
if (node.parentNode?.parentNode?.concept === 'CallLogic') {
|
|
@@ -2117,11 +2199,11 @@ class NaslServer {
|
|
|
2117
2199
|
}
|
|
2118
2200
|
}
|
|
2119
2201
|
/**
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2202
|
+
* 单个问题的诊断处理
|
|
2203
|
+
* @param diagnostic 诊断问题
|
|
2204
|
+
* @param fileNode 页面节点
|
|
2205
|
+
* @returns 处理后的结果
|
|
2206
|
+
*/
|
|
2125
2207
|
_resolveDiagnostic(diagnostic, fileNode, record) {
|
|
2126
2208
|
// 拓展模块中的翻译先过滤掉,因为有错用户也不能修改
|
|
2127
2209
|
if (fileNode.module && !(fileNode instanceof concepts_1.ConfigProperty)) {
|
|
@@ -2131,6 +2213,9 @@ class NaslServer {
|
|
|
2131
2213
|
// if ('compilerInfoMap' in fileNode && (fileNode as any).compilerInfoMap?.java) {
|
|
2132
2214
|
// return;
|
|
2133
2215
|
// }
|
|
2216
|
+
if (fileNode.concept === 'OverriddenLogic' && diagnostic.text === `'__LogicEmpty' is declared but its value is never read.`) {
|
|
2217
|
+
return;
|
|
2218
|
+
}
|
|
2134
2219
|
const minRange = this._findMinRange(diagnostic, fileNode);
|
|
2135
2220
|
const tsErrorDetail = {
|
|
2136
2221
|
severity: diagnostic.category === 'error' ? 'error' : 'warning',
|
|
@@ -2152,11 +2237,11 @@ class NaslServer {
|
|
|
2152
2237
|
return result;
|
|
2153
2238
|
}
|
|
2154
2239
|
/**
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2240
|
+
* 通过节点诊断反过来查找节点
|
|
2241
|
+
* @param diagnostic 诊断信息
|
|
2242
|
+
* @param fileNode 文件级别节点
|
|
2243
|
+
* @returns 找到的节点
|
|
2244
|
+
*/
|
|
2160
2245
|
_findMinRange(diagnostic, fileNode) {
|
|
2161
2246
|
let minRange;
|
|
2162
2247
|
const sourceMap = fileNode.sourceMap;
|
|
@@ -2199,7 +2284,14 @@ class NaslServer {
|
|
|
2199
2284
|
}
|
|
2200
2285
|
}
|
|
2201
2286
|
else if (item.range.end.line - item.range.start.line <= minRange.item.range.end.line - minRange.item.range.start.line) {
|
|
2202
|
-
|
|
2287
|
+
// 行都一致 ,比较列
|
|
2288
|
+
if (minRange.item.range.start.line === item.range.start.line && minRange.item.range.end.line === item.range.end.line) {
|
|
2289
|
+
// 如果两个起始和结束的行都一样,那么就比较开始列, 要比原来大,说明更精准
|
|
2290
|
+
if (item.range.start.character > minRange.item.range.start.character) {
|
|
2291
|
+
minRange = { node, item };
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2294
|
+
else {
|
|
2203
2295
|
minRange = { node, item };
|
|
2204
2296
|
}
|
|
2205
2297
|
}
|
|
@@ -2223,8 +2315,8 @@ class NaslServer {
|
|
|
2223
2315
|
const { currentSource, fileNode } = this.getCurrentSource(node);
|
|
2224
2316
|
let refsList = [];
|
|
2225
2317
|
/**
|
|
2226
|
-
|
|
2227
|
-
|
|
2318
|
+
* 未完成创建的节点 ,或者异常情况 可能找不到节点
|
|
2319
|
+
*/
|
|
2228
2320
|
if (currentSource) {
|
|
2229
2321
|
const newRefs = await this.references({
|
|
2230
2322
|
file: fileNode.getEmbeddedFilePath(),
|
|
@@ -2260,12 +2352,12 @@ class NaslServer {
|
|
|
2260
2352
|
const dataSourceFile = fileNode.getEmbeddedFilePath();
|
|
2261
2353
|
const entityFilePrefix = dataSourceFile.replace('.ts', '');
|
|
2262
2354
|
/**
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2355
|
+
* 特殊处理,因为关联属性或者关联实体等等都是在实体里,在实体中因为自己不可以是自己的类型
|
|
2356
|
+
* 所以全部过滤掉了,
|
|
2357
|
+
* 但是在datasource里面在实体里会有大量的引用,不需要全部修改.只需要处理除了11个函数之外的引用
|
|
2358
|
+
* 所以底部内容是11个函数,所以这里就 用entity的行数 减去11个函数的行数,然后其余的在进行处理
|
|
2359
|
+
* 进行过滤
|
|
2360
|
+
*/
|
|
2269
2361
|
// 不要数据源下面的实体里的引用 ,保留原始的节点内容
|
|
2270
2362
|
let flag = false;
|
|
2271
2363
|
if (item.file.includes(entityFilePrefix)) {
|
|
@@ -2324,12 +2416,12 @@ class NaslServer {
|
|
|
2324
2416
|
refsList = [...refsList, ...filterViewRefs];
|
|
2325
2417
|
}
|
|
2326
2418
|
/**
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2419
|
+
* 暂时不要了, 因为生成的结构发生了变化
|
|
2420
|
+
* view 因为不是嵌套的,所以不能用最前面的变量查找,所以要单独处理一下
|
|
2421
|
+
* 找到第一个 { 之前的变量 进行修改
|
|
2422
|
+
* 如果是VIew的查找,比较特殊,他查的是当前抛出的 {} 大括号前的
|
|
2423
|
+
* 最后一个,因为生成的规则不一样
|
|
2424
|
+
*/
|
|
2333
2425
|
// if (node instanceof View) {
|
|
2334
2426
|
// const code = currentSource.code;
|
|
2335
2427
|
// const viewIndex = code.indexOf(' {');
|
|
@@ -2341,8 +2433,8 @@ class NaslServer {
|
|
|
2341
2433
|
// refsList = [...viewRefs.refs];
|
|
2342
2434
|
// }
|
|
2343
2435
|
/**
|
|
2344
|
-
|
|
2345
|
-
|
|
2436
|
+
* elements 需要查的是__elements.后面的那个内容,过滤两个为了生成内容的节点
|
|
2437
|
+
*/
|
|
2346
2438
|
if (node instanceof concepts_1.ViewElement) {
|
|
2347
2439
|
if (currentSource) {
|
|
2348
2440
|
const code = currentSource.code;
|
|
@@ -2480,13 +2572,13 @@ class NaslServer {
|
|
|
2480
2572
|
return refsList;
|
|
2481
2573
|
}
|
|
2482
2574
|
/**
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2575
|
+
* 查找引用,并且做一些 修改前的准备工作,
|
|
2576
|
+
* 有引用有的话,就返回集合
|
|
2577
|
+
* @param node 当前重命名的节点
|
|
2578
|
+
* @param newValue 传递过来的新值,给MemberExpression用的比较特殊
|
|
2579
|
+
* 而且,这个新值不一定会用到,MemberExpression在批量更新的时候,可以取到新的value, 这里需要位置信息防止 a.a.a.a 中的一个a发生修改
|
|
2580
|
+
* @returns 找到的引用
|
|
2581
|
+
*/
|
|
2490
2582
|
_renamePrepare(node, refsList, newValue) {
|
|
2491
2583
|
const oldName = node?.name;
|
|
2492
2584
|
const result = refsList
|
|
@@ -2631,7 +2723,10 @@ class NaslServer {
|
|
|
2631
2723
|
if (minRange.node instanceof concepts_1.EntityProperty) {
|
|
2632
2724
|
minRange.setTypeMethods = 'setRelationEntity';
|
|
2633
2725
|
}
|
|
2634
|
-
else if (minRange.node instanceof concepts_1.QueryFieldExpression
|
|
2726
|
+
else if (minRange.node instanceof concepts_1.QueryFieldExpression) {
|
|
2727
|
+
minRange.setTypeMethods = 'setEntityAsNameAndEffect';
|
|
2728
|
+
}
|
|
2729
|
+
else if (minRange.node instanceof concepts_1.QueryGroupByExpression) {
|
|
2635
2730
|
minRange.setTypeMethods = 'setEntityAsName';
|
|
2636
2731
|
}
|
|
2637
2732
|
else if (minRange.node instanceof concepts_1.QueryFromExpression || minRange.node instanceof concepts_1.QueryJoinExpression) {
|
|
@@ -2861,12 +2956,15 @@ class NaslServer {
|
|
|
2861
2956
|
if (minRange.node instanceof concepts_1.BindEvent && node instanceof concepts_1.Param) {
|
|
2862
2957
|
return null;
|
|
2863
2958
|
}
|
|
2959
|
+
if (minRange.node instanceof concepts_1.Argument && node instanceof concepts_1.Param) {
|
|
2960
|
+
minRange.setTypeMethods = 'setKeyword';
|
|
2961
|
+
}
|
|
2864
2962
|
/**
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2963
|
+
* 理论上 logic setName只能自己触发,别的地方查到引用都不用重命名
|
|
2964
|
+
* 流程改名不触发Logic改名
|
|
2965
|
+
* 如果是修改param查找到logic就不操作
|
|
2966
|
+
* 除非想在内部修改别的内容所以暂时屏蔽掉
|
|
2967
|
+
*/
|
|
2870
2968
|
if (minRange.node instanceof concepts_1.Logic && node !== minRange.node) {
|
|
2871
2969
|
return null;
|
|
2872
2970
|
}
|
|
@@ -2914,7 +3012,18 @@ class NaslServer {
|
|
|
2914
3012
|
return minRange;
|
|
2915
3013
|
})
|
|
2916
3014
|
// 过滤掉不需要操作的
|
|
2917
|
-
.filter((item) => !!item)
|
|
3015
|
+
.filter((item) => !!item)
|
|
3016
|
+
// 排序:
|
|
3017
|
+
// QueryFieldExpression依赖Entity,把Entity放在QueryFieldExpression前,
|
|
3018
|
+
.sort((a, b) => {
|
|
3019
|
+
if (a.node.concept === 'QueryFieldExpression') {
|
|
3020
|
+
return 1;
|
|
3021
|
+
}
|
|
3022
|
+
else if (b.node.concept === 'QueryFieldExpression') {
|
|
3023
|
+
return -1;
|
|
3024
|
+
}
|
|
3025
|
+
return 0;
|
|
3026
|
+
});
|
|
2918
3027
|
return result;
|
|
2919
3028
|
}
|
|
2920
3029
|
// 增加参数的副作用,用于更新logic和view
|
|
@@ -2927,8 +3036,21 @@ class NaslServer {
|
|
|
2927
3036
|
const minRange = this._findMinRange(record, fileNode);
|
|
2928
3037
|
if (minRange) {
|
|
2929
3038
|
// 如果找到节点是callLogic就去更新
|
|
2930
|
-
if (
|
|
2931
|
-
minRange.node.
|
|
3039
|
+
if (node instanceof concepts_1.Param) {
|
|
3040
|
+
if (minRange.node instanceof concepts_1.CallLogic) {
|
|
3041
|
+
minRange.node.addCalleeArg(parantNode);
|
|
3042
|
+
}
|
|
3043
|
+
else if (minRange.node instanceof concepts_1.Destination) {
|
|
3044
|
+
// 跳转页面,可能在父级下增加参数,子的跳转页面也可以查找到引用
|
|
3045
|
+
// 精准匹配子页面的内容
|
|
3046
|
+
const viewNode = node.parentNode;
|
|
3047
|
+
if (viewNode instanceof concepts_1.View) {
|
|
3048
|
+
const viewNamespace = viewNode.getNamespace();
|
|
3049
|
+
if (viewNamespace === minRange.node.viewNamespace && viewNode.name === minRange.node.viewName) {
|
|
3050
|
+
minRange.node.addCalleeArg(parantNode);
|
|
3051
|
+
}
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
2932
3054
|
}
|
|
2933
3055
|
}
|
|
2934
3056
|
});
|
|
@@ -3094,11 +3216,11 @@ class NaslServer {
|
|
|
3094
3216
|
return treeNodeMap;
|
|
3095
3217
|
}
|
|
3096
3218
|
/**
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3219
|
+
* 处理tree的队列,把相同节点进行合并
|
|
3220
|
+
* 这里把当前二维数组进行一个整合
|
|
3221
|
+
* @param arr 当前页面下的queue的二维数组,一个数组下有多条链路
|
|
3222
|
+
* @returns 最后要使用到的节点和对应的子集
|
|
3223
|
+
*/
|
|
3102
3224
|
handleTreeQueue(queueLists) {
|
|
3103
3225
|
const map = new Map();
|
|
3104
3226
|
let root = null;
|
|
@@ -3126,11 +3248,11 @@ class NaslServer {
|
|
|
3126
3248
|
return children;
|
|
3127
3249
|
}
|
|
3128
3250
|
/**
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3251
|
+
* 递归调用输出结果
|
|
3252
|
+
* @param root 一个根节点
|
|
3253
|
+
* @param map 当前所有节点的map对象
|
|
3254
|
+
* @returns 当前节点,最后输出所有节点
|
|
3255
|
+
*/
|
|
3134
3256
|
_recursionCreateResult(root, map) {
|
|
3135
3257
|
const children = (map.get(root) || []).map((item) => this._recursionCreateResult(item, map));
|
|
3136
3258
|
if (children && children.length) {
|
|
@@ -3139,9 +3261,9 @@ class NaslServer {
|
|
|
3139
3261
|
return root;
|
|
3140
3262
|
}
|
|
3141
3263
|
/**
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3264
|
+
* 获取
|
|
3265
|
+
* 当前this上下文 的Source 和 父级文件级别的节点
|
|
3266
|
+
*/
|
|
3145
3267
|
getCurrentSource(node) {
|
|
3146
3268
|
if (node instanceof concepts_1.App || node instanceof concepts_1.Theme)
|
|
3147
3269
|
return { fileNode: null };
|
|
@@ -3157,6 +3279,7 @@ class NaslServer {
|
|
|
3157
3279
|
&& !(fileNode.parentNode instanceof concepts_1.Module)
|
|
3158
3280
|
&& !(fileNode.parentNode instanceof concepts_1.DataSource)
|
|
3159
3281
|
&& !(fileNode.parentNode instanceof concepts_1.Frontend)
|
|
3282
|
+
&& !(fileNode.parentNode instanceof concepts_1.Backend)
|
|
3160
3283
|
&& !(fileNode instanceof concepts_1.View)
|
|
3161
3284
|
&& !(fileNode instanceof concepts_1.ConfigProperty)) {
|
|
3162
3285
|
fileNode = fileNode.parentNode;
|
|
@@ -3242,9 +3365,9 @@ class NaslServer {
|
|
|
3242
3365
|
return [...fileNodes];
|
|
3243
3366
|
}
|
|
3244
3367
|
/**获取当前节点的已知类型
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3368
|
+
* @param node 当前要获取类型的节点
|
|
3369
|
+
* @returns 不需要去查就可以返回类型的节点
|
|
3370
|
+
*/
|
|
3248
3371
|
getCurrentNodeKnownTypeAnnotation(node) {
|
|
3249
3372
|
if (node.concept === 'StringLiteral' || node.concept === 'StringInterpolation' || node.concept === 'BooleanLiteral' || node.concept === 'NullLiteral') {
|
|
3250
3373
|
let type = 'String';
|
|
@@ -3355,6 +3478,11 @@ class NaslServer {
|
|
|
3355
3478
|
'QueryFieldExpression',
|
|
3356
3479
|
'QueryGroupByExpression',
|
|
3357
3480
|
'Param',
|
|
3481
|
+
'AuthLogic',
|
|
3482
|
+
'AuthLogic',
|
|
3483
|
+
'BackendVariable',
|
|
3484
|
+
'AuthLogicForCallInterface',
|
|
3485
|
+
'CallAuthInterface',
|
|
3358
3486
|
].includes(node.concept))
|
|
3359
3487
|
return;
|
|
3360
3488
|
// 要去ls那边获取的
|
|
@@ -3693,17 +3821,17 @@ class NaslServer {
|
|
|
3693
3821
|
jsonNode.typeAnnotation = value.toJSON();
|
|
3694
3822
|
}
|
|
3695
3823
|
}
|
|
3696
|
-
if (node instanceof concepts_1.NewComposite && node.typeAnnotation?.typeKind === 'anonymousStructure') {
|
|
3824
|
+
if (node instanceof concepts_1.NewComposite && (node.typeAnnotation?.typeKind === 'anonymousStructure' || node.typeAnnotation?.typeKind === 'generic')) {
|
|
3697
3825
|
const jsonNode = jsoner.queryNodeByPath(json, node.getNodePath(false));
|
|
3698
3826
|
jsonNode.typeAnnotation = value.toJSON();
|
|
3699
3827
|
}
|
|
3700
3828
|
});
|
|
3701
3829
|
}
|
|
3702
3830
|
/**
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3831
|
+
* 获取getArgument的参数位的类型
|
|
3832
|
+
* 如果内部表达式的,就用表达式的,如果没有就试试用默认值的
|
|
3833
|
+
* 获取logic的默认值和原来Arg的类型和默认值对应
|
|
3834
|
+
*/
|
|
3707
3835
|
getArgumentTypeAnnotation(node, QuickInfoNodes, types) {
|
|
3708
3836
|
// 直接复用内部expression的type类型
|
|
3709
3837
|
if (node.parentNode instanceof concepts_1.CallLogic && node.parentNode.calleeNamespace?.includes('entities') && node.parentNode.calleeNamespace?.includes('logics') && node.parentNode.calleeName === 'delete') {
|
|
@@ -3825,8 +3953,8 @@ class NaslServer {
|
|
|
3825
3953
|
const filePath = fileNode.getEmbeddedFilePath();
|
|
3826
3954
|
// 如果要删除,而且当前要删Logic就直接删除并且清除错误
|
|
3827
3955
|
/**
|
|
3828
|
-
|
|
3829
|
-
|
|
3956
|
+
* 删除节点中的一个内容,删除了以后,就查一下引用的地方一起查一下异常
|
|
3957
|
+
*/
|
|
3830
3958
|
let outputFiles = [];
|
|
3831
3959
|
// 删除之前先查一下内容的依赖
|
|
3832
3960
|
const newRefs = await this.references({
|
|
@@ -3943,7 +4071,7 @@ class NaslServer {
|
|
|
3943
4071
|
}
|
|
3944
4072
|
else if (targetNode instanceof concepts_1.ViewElement) {
|
|
3945
4073
|
/**
|
|
3946
|
-
*
|
|
4074
|
+
* 因为平台类型比较特殊
|
|
3947
4075
|
* 修改之后只用查页面本身就好了
|
|
3948
4076
|
*/
|
|
3949
4077
|
// 更新文件之后
|
|
@@ -4071,8 +4199,8 @@ class NaslServer {
|
|
|
4071
4199
|
}
|
|
4072
4200
|
}
|
|
4073
4201
|
/**
|
|
4074
|
-
|
|
4075
|
-
|
|
4202
|
+
* DataSource只会重命名时候,需要把子集全部重新生成一下
|
|
4203
|
+
*/
|
|
4076
4204
|
if (fileNode instanceof concepts_1.DataSource) {
|
|
4077
4205
|
fileNode.entities.forEach(async (entity) => {
|
|
4078
4206
|
try {
|