@lcap/nasl 2.18.0-beta.7 → 2.20.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/automate/engine/index.js +3 -3
- package/out/automate/engine/index.js.map +1 -1
- package/out/bak/translator.js +85 -37
- package/out/bak/translator.js.map +1 -1
- package/out/common/BaseNode.d.ts +6 -10
- package/out/common/BaseNode.js +7 -53
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/AnonymousFunction__.js.map +1 -1
- package/out/concepts/App__.d.ts +0 -10
- package/out/concepts/App__.js +0 -74
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Assignee__.js.map +1 -1
- package/out/concepts/AssignmentLine__.d.ts +5 -5
- package/out/concepts/AssignmentLine__.js +6 -6
- package/out/concepts/AssignmentLine__.js.map +1 -1
- package/out/concepts/Assignment__.js +2 -1
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/BatchAssignment__.d.ts +60 -60
- package/out/concepts/BatchAssignment__.js +41 -68
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts +0 -19
- package/out/concepts/BindAttribute__.js +2 -39
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BindStyle__.d.ts +2 -2
- package/out/concepts/BindStyle__.js +3 -3
- package/out/concepts/BindStyle__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.js +8 -0
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/CallFunction__.js +25 -58
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.d.ts +0 -7
- package/out/concepts/CallInterface__.js +7 -53
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +1 -2
- package/out/concepts/CallLogic__.js +25 -89
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.js +1 -13
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/CompletionProperty__.js +0 -3
- package/out/concepts/CompletionProperty__.js.map +1 -1
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Configuration__.js.map +1 -1
- package/out/concepts/DataSource__.d.ts +0 -6
- package/out/concepts/DataSource__.js +0 -41
- package/out/concepts/DataSource__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +2 -11
- package/out/concepts/Destination__.js +48 -148
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +8 -21
- package/out/concepts/EntityProperty__.js +23 -109
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +0 -32
- package/out/concepts/Entity__.js +2 -117
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/Enum__.js +4 -0
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/ForEachStatement__.d.ts +4 -0
- package/out/concepts/ForEachStatement__.js +8 -4
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.js +4 -16
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.d.ts +0 -8
- package/out/concepts/IfStatement__.js +0 -22
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +1 -1
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +1 -6
- package/out/concepts/Logic__.js +50 -150
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MatchCase__.d.ts +1 -1
- package/out/concepts/MatchCase__.js +8 -15
- package/out/concepts/MatchCase__.js.map +1 -1
- package/out/concepts/Match__.d.ts +19 -21
- package/out/concepts/Match__.js +25 -112
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/MemberExpression__.d.ts +1 -4
- package/out/concepts/MemberExpression__.js +15 -30
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/Namespace__.js.map +1 -1
- package/out/concepts/NumericLiteral__.js +1 -1
- package/out/concepts/NumericLiteral__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.d.ts +3 -7
- package/out/concepts/OqlQueryComponent__.js +95 -56
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/Param__.d.ts +1 -1
- package/out/concepts/Param__.js +4 -40
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessComponent__.js.map +1 -1
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/QueryOrderByExpression__.d.ts +3 -3
- package/out/concepts/QueryOrderByExpression__.js +3 -3
- package/out/concepts/QueryOrderByExpression__.js.map +1 -1
- package/out/concepts/QuerySelectExpression__.js.map +1 -1
- package/out/concepts/Return__.js +2 -38
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/SelectMembers__.d.ts +1 -1
- package/out/concepts/SelectMembers__.js +2 -2
- package/out/concepts/SelectMembers__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.d.ts +4 -2
- package/out/concepts/SqlQueryComponent__.js +88 -9
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/StringLiteral__.js +7 -0
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +0 -1
- package/out/concepts/TypeAnnotation__.js +12 -25
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/TypeParam__.d.ts +0 -1
- package/out/concepts/TypeParam__.js +0 -2
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/UnaryExpression__.js +9 -6
- package/out/concepts/UnaryExpression__.js.map +1 -1
- package/out/concepts/ValidationRule__.js +23 -88
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.js +2 -38
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewComponent__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +29 -30
- package/out/concepts/ViewElement__.js +52 -118
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +3 -4
- package/out/concepts/View__.js +83 -97
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.js +1 -1
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.browser.js +0 -50
- package/out/concepts/basics/stdlib/nasl.browser.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +4 -36
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +43 -63
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/index__.d.ts +0 -2
- package/out/concepts/index__.js +0 -2
- package/out/concepts/index__.js.map +1 -1
- package/out/generator/genBundleFiles.d.ts +2 -5
- package/out/generator/genBundleFiles.js +155 -108
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.d.ts +10 -1
- package/out/generator/genMetaData.js +50 -189
- package/out/generator/genMetaData.js.map +1 -1
- package/out/generator/index.d.ts +0 -1
- package/out/generator/index.js +0 -1
- package/out/generator/index.js.map +1 -1
- package/out/index.d.ts +2 -3
- package/out/index.js +1 -5
- package/out/index.js.map +1 -1
- package/out/server/entity2LogicNamespace.js +11 -11
- package/out/server/entity2LogicNamespace.js.map +1 -1
- package/out/server/extendBaseNode.js +18 -4
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/formatTsUtils.d.ts +2 -1
- package/out/server/formatTsUtils.js +64 -40
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getLogics.js +6 -13
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +7 -7
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.d.ts +1 -1
- package/out/server/getProcesses.js +1 -1
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/index.d.ts +1 -0
- package/out/server/index.js +27 -2
- package/out/server/index.js.map +1 -1
- package/out/server/naslServer.d.ts +7 -47
- package/out/server/naslServer.js +399 -604
- package/out/server/naslServer.js.map +1 -1
- package/out/server/naslStdlibMap.js +28 -30
- package/out/server/naslStdlibMap.js.map +1 -1
- package/out/server/translator.js +11 -59
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.js +3 -33
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +4 -6
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +4 -7
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +5 -7
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEnumSelectBlock.js +2 -5
- package/out/templator/genEnumSelectBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +2 -2
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +2 -2
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genQueryComponent.d.ts +2 -2
- package/out/templator/genQueryComponent.js +1 -4
- package/out/templator/genQueryComponent.js.map +1 -1
- package/out/templator/genTableBlock.js +2 -2
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +3 -4
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.js +1 -1
- package/out/templator/utils.js.map +1 -1
- package/out/test/integration/node-nasl-server.js +38 -10
- package/out/test/integration/node-nasl-server.js.map +1 -1
- package/out/translator/index.d.ts +0 -1
- package/out/translator/index.js +1 -1
- package/out/translator/index.js.map +1 -1
- package/out/utils/index.d.ts +0 -1
- package/out/utils/index.js +1 -38
- package/out/utils/index.js.map +1 -1
- package/out/utils/string.d.ts +2 -15
- package/out/utils/string.js +3 -18
- package/out/utils/string.js.map +1 -1
- package/package.json +2 -2
- package/sandbox/stdlib/nasl.auth.ts +1 -1
- package/sandbox/stdlib/nasl.core.ts +1 -0
- package/sandbox/stdlib/nasl.logging.ts +4 -4
- package/sandbox/stdlib/nasl.util.ts +8 -4
- 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/concepts/AnonymousFunction__.ts +48 -2
- package/src/concepts/App__.ts +288 -615
- package/src/concepts/BatchAssignment__.ts +45 -1
- 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 +61 -44
- 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 +8 -21
- package/src/concepts/Frontend__.ts +937 -0
- package/src/concepts/Identifier__.ts +18 -16
- package/src/concepts/LogicItem__.ts +8 -1
- package/src/concepts/Logic__.ts +128 -142
- 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 +51 -7
- package/src/concepts/View__.ts +21 -25
- package/src/concepts/basics/stdlib/nasl.auth.ts +1 -1
- package/src/concepts/basics/stdlib/nasl.logging.ts +5 -0
- package/src/concepts/basics/stdlib/nasl.ui.ts +2 -0
- package/src/concepts/basics/stdlib/nasl.util.ts +153 -19
- package/src/concepts/index__.ts +7 -0
- package/src/enums/KEYWORDS.ts +9 -0
- package/src/generator/genBundleFiles.ts +43 -29
- package/src/generator/genMetaData.ts +5 -10
- package/src/generator/genReleaseBody.ts +77 -41
- 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 +29 -3
- package/src/server/formatTsUtils.ts +6 -0
- package/src/server/getLogics.ts +13 -1
- package/src/server/getMemberIdentifier.ts +5 -5
- package/src/server/naslServer.ts +235 -58
- package/src/server/process2LogicNamespace.ts +8 -0
- package/src/server/translator.ts +33 -1
- package/src/service/creator/add.configs.js +4 -0
- package/src/service/datasource/api.js +11 -0
- package/src/service/datasource/index.js +6 -0
- package/src/service/storage/init.ts +12 -0
- package/src/service/video/VideoTranscribe.js +1 -0
- package/src/templator/genEditTableBlock.ts +8 -16
- package/src/templator/genGetBlock.ts +18 -19
- package/src/templator/genGridViewBlock.ts +18 -18
- package/src/templator/genListViewBlock.ts +8 -11
- package/src/templator/genTableBlock.ts +6 -10
- package/ts-worker/lib/tsserver.js +8 -1
- package/out/automate/engine/2.14-components.d.ts +0 -1115
- package/out/automate/engine/2.14-components.js +0 -1087
- package/out/automate/engine/2.14-components.js.map +0 -1
- package/out/concepts/ExternalDestination__.d.ts +0 -73
- package/out/concepts/ExternalDestination__.js +0 -264
- package/out/concepts/ExternalDestination__.js.map +0 -1
- package/out/concepts/MatchExpression__.d.ts +0 -97
- package/out/concepts/MatchExpression__.js +0 -281
- package/out/concepts/MatchExpression__.js.map +0 -1
- package/out/concepts/StringInterpolation__.d.ts +0 -113
- package/out/concepts/StringInterpolation__.js +0 -227
- package/out/concepts/StringInterpolation__.js.map +0 -1
- package/out/generator/genReleaseBody.d.ts +0 -41
- package/out/generator/genReleaseBody.js +0 -349
- package/out/generator/genReleaseBody.js.map +0 -1
- package/out/service/defaultErrorMessage.json +0 -97
- package/out/service/logic/api.d.ts +0 -9
- package/out/service/logic/api.js +0 -11
- package/out/service/logic/api.js.map +0 -1
- package/out/service/logic/index.d.ts +0 -2
- package/out/service/logic/index.js +0 -10
- package/out/service/logic/index.js.map +0 -1
- package/sandbox/stdlib/dist/nasl.logging.js +0 -0
- package/src/automate/engine/dist/index.dev.js +0 -517
- package/src/common/dist/BaseNode.js +0 -1101
- package/src/concepts/basics/stdlib/dist/nasl.util.js +0 -1503
- 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 -513
- package/src/concepts/dist/CallInterface__.js +0 -533
- package/src/concepts/dist/CallLogic__.js +0 -892
- package/src/concepts/dist/ForEachStatement__.js +0 -426
- package/src/concepts/dist/MatchCase__.js +0 -587
- package/src/concepts/dist/Match__.js +0 -631
- package/src/concepts/dist/MemberExpression__.js +0 -348
- package/src/concepts/dist/Param__.js +0 -538
- package/src/concepts/dist/Return__.js +0 -494
- package/src/concepts/dist/Variable__.js +0 -537
- package/src/concepts/dist/ViewElement__.js +0 -1680
- package/src/generator/dist/genBundleFiles.js +0 -261
- package/src/generator/dist/genMetaData.js +0 -249
- package/src/server/dist/formatTsUtils.js +0 -683
- package/src/server/dist/naslServer.js +0 -3474
- package/src/service/storage/dist/init.js +0 -572
- package/ts-worker/dist/webpack.config.dev.js +0 -108
package/src/server/naslServer.ts
CHANGED
|
@@ -61,6 +61,7 @@ import {
|
|
|
61
61
|
BooleanLiteral,
|
|
62
62
|
BatchAssignment,
|
|
63
63
|
ForEachStatement,
|
|
64
|
+
Frontend,
|
|
64
65
|
} from '../concepts';
|
|
65
66
|
import { lsp2tspNumber, SourceMap, SourceMapItem } from '../translator';
|
|
66
67
|
import axios from '../service/storage';
|
|
@@ -81,10 +82,6 @@ const EmbeddedTSFileLineMap: { [name: string]: number } = {
|
|
|
81
82
|
const EmbeddedTSFileOffsetMap: { [name: string]: number } = {
|
|
82
83
|
Variable: 12,
|
|
83
84
|
};
|
|
84
|
-
// 要Check的文件
|
|
85
|
-
const filesToCheck: Set<string> = new Set();
|
|
86
|
-
// 单个文件正在change,不允许同时两个文件一起change
|
|
87
|
-
let singleFileChangeIng = false;
|
|
88
85
|
|
|
89
86
|
export interface FileNode extends BaseNode {
|
|
90
87
|
getEmbeddedFilePath(name?: string): string;
|
|
@@ -168,6 +165,10 @@ export class NaslServer {
|
|
|
168
165
|
// 需要执行修改的文件
|
|
169
166
|
changeStackList: Array<EventPayload> = [];
|
|
170
167
|
|
|
168
|
+
filesToCheck: Set<string>;
|
|
169
|
+
|
|
170
|
+
singleFileChangeIng: Boolean;
|
|
171
|
+
|
|
171
172
|
constructor() {
|
|
172
173
|
/// #if process.env.BUILD_TARGET === 'node'
|
|
173
174
|
if (globalThis.process) // For TS build
|
|
@@ -179,6 +180,11 @@ export class NaslServer {
|
|
|
179
180
|
this.worker = new Worker('/ts-worker.js');
|
|
180
181
|
/// #endif
|
|
181
182
|
|
|
183
|
+
// 要Check的文件
|
|
184
|
+
this.filesToCheck = new Set();
|
|
185
|
+
// 单个文件正在change,不允许同时两个文件一起change
|
|
186
|
+
this.singleFileChangeIng = false;
|
|
187
|
+
|
|
182
188
|
this.diagnosticManager = new DiagnosticManager();
|
|
183
189
|
|
|
184
190
|
this.messager = new Messager({
|
|
@@ -202,7 +208,34 @@ export class NaslServer {
|
|
|
202
208
|
// 收集到一个行为集合
|
|
203
209
|
const eventValue = $event.value;
|
|
204
210
|
eventValue.forEach(async (item: EventPayload) => {
|
|
205
|
-
|
|
211
|
+
/**
|
|
212
|
+
* 多个行为进行合并
|
|
213
|
+
* 合并规则是
|
|
214
|
+
* 1.[a,b,c,c] 在cc的时候,在已有一个c,又来一个c的时候,如果他们不都是file级别的节点
|
|
215
|
+
* 就可以前面的内容去掉,只保留最后一个
|
|
216
|
+
* 2.[a,b,c,b,c] 在bc已存在,又来了bc 这就都要保留,因为可能顺序有相关性,不能去掉
|
|
217
|
+
* 理论上只处理同时几个操作 合并,
|
|
218
|
+
* 3.有field的也直接保留
|
|
219
|
+
*/
|
|
220
|
+
try {
|
|
221
|
+
const changeEvent = item.originEvent;
|
|
222
|
+
const changeNode = changeEvent.target;
|
|
223
|
+
const { fileNode } = this.getCurrentSource(changeNode);
|
|
224
|
+
if (changeNode !== fileNode || !changeEvent.field) {
|
|
225
|
+
const findIndex = this.changeStackList.findIndex((changeStackItem: EventPayload) => {
|
|
226
|
+
const target = changeStackItem.target;
|
|
227
|
+
const { fileNode: targetFileNode } = this.getCurrentSource(target);
|
|
228
|
+
return targetFileNode === fileNode;
|
|
229
|
+
});
|
|
230
|
+
if (findIndex === this.changeStackList.length - 1) {
|
|
231
|
+
this.changeStackList.pop();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
this.changeStackList.push(item.originEvent);
|
|
235
|
+
} catch (err) {
|
|
236
|
+
console.log(err);
|
|
237
|
+
this.changeStackList.push(item.originEvent);
|
|
238
|
+
}
|
|
206
239
|
});
|
|
207
240
|
|
|
208
241
|
// 如果有长度开始执行状态机
|
|
@@ -249,16 +282,32 @@ export class NaslServer {
|
|
|
249
282
|
} catch (err) {
|
|
250
283
|
}
|
|
251
284
|
});
|
|
252
|
-
module.
|
|
285
|
+
(module as App).frontends?.forEach((frontend) => {
|
|
253
286
|
try {
|
|
254
|
-
const result =
|
|
287
|
+
const result = frontend.toEmbeddedTSFile();
|
|
255
288
|
results.push(result);
|
|
256
289
|
// sourceMap都存在目录级别内容下,在页面层级下去找
|
|
257
|
-
|
|
258
|
-
this.file2NodeMap.set(result.filePath,
|
|
290
|
+
frontend.sourceMap = result.sourceMap;
|
|
291
|
+
this.file2NodeMap.set(result.filePath, frontend);
|
|
259
292
|
} catch (err) {
|
|
260
293
|
console.log(err);
|
|
261
294
|
}
|
|
295
|
+
frontend.variables?.forEach((frontendVariable) => {
|
|
296
|
+
try {
|
|
297
|
+
const result = frontendVariable.toEmbeddedTSFile();
|
|
298
|
+
results.push(result);
|
|
299
|
+
// sourceMap都存在目录级别内容下,在页面层级下去找
|
|
300
|
+
frontendVariable.sourceMap = result.sourceMap;
|
|
301
|
+
this.file2NodeMap.set(result.filePath, frontendVariable);
|
|
302
|
+
} catch (err) {
|
|
303
|
+
console.log(err);
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
// view的生成
|
|
307
|
+
if (!config.closeViews) {
|
|
308
|
+
this.view2TSFile(frontend.views, results);
|
|
309
|
+
}
|
|
310
|
+
frontend.componentDependencies?.forEach((item) => this.contentToFile(item, results));
|
|
262
311
|
});
|
|
263
312
|
|
|
264
313
|
(module as App).dataSources?.forEach((dataSource) => {
|
|
@@ -315,11 +364,6 @@ export class NaslServer {
|
|
|
315
364
|
}
|
|
316
365
|
});
|
|
317
366
|
|
|
318
|
-
// view的生成
|
|
319
|
-
if (!config.closeViews) {
|
|
320
|
-
this.view2TSFile(module.views, results);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
367
|
module.processes.forEach((process) => {
|
|
324
368
|
try {
|
|
325
369
|
const result = process.toEmbeddedTSFile();
|
|
@@ -370,7 +414,6 @@ export class NaslServer {
|
|
|
370
414
|
// 其他模块的创建内容
|
|
371
415
|
app.dependencies.forEach((item) => this.contentToFile(item, results));
|
|
372
416
|
app.interfaceDependencies.forEach((item) => this.contentToFile(item, results));
|
|
373
|
-
app.componentDependencies.forEach((item) => this.contentToFile(item, results));
|
|
374
417
|
} catch (err) {
|
|
375
418
|
console.log(err);
|
|
376
419
|
}
|
|
@@ -615,7 +658,8 @@ export class NaslServer {
|
|
|
615
658
|
return '';
|
|
616
659
|
}
|
|
617
660
|
async getDataSchemaStructureOrTypeAnnotation(node: ViewElement) {
|
|
618
|
-
if (!(node instanceof ViewElement))
|
|
661
|
+
if (!(node instanceof ViewElement))
|
|
662
|
+
return;
|
|
619
663
|
|
|
620
664
|
const { currentSource, fileNode } = this.getCurrentSource(node);
|
|
621
665
|
const quickInfo = await this._getTypeQuickinfo({
|
|
@@ -626,16 +670,18 @@ export class NaslServer {
|
|
|
626
670
|
if (quickInfo.responseRequired) {
|
|
627
671
|
const displayString = quickInfo?.response?.displayString || '';
|
|
628
672
|
const flag = displayString.includes('<') && displayString.includes('>');
|
|
629
|
-
if(!flag)
|
|
673
|
+
if (!flag)
|
|
674
|
+
return;
|
|
630
675
|
|
|
631
676
|
const types = /\<([^()]+)\>/g.exec(displayString);
|
|
632
|
-
|
|
677
|
+
const typeStr = types && types[1];
|
|
633
678
|
const app = node.app;
|
|
634
679
|
if (typeStr.includes('__name: "AStructure_')) {
|
|
635
680
|
const properties: StructureProperty[] = [];
|
|
636
681
|
typeStr
|
|
637
682
|
.replace(/([^:\s]+):\s+([^;]+);/g, ($1, name, typeKey) => {
|
|
638
|
-
if(name === '__name')
|
|
683
|
+
if (name === '__name')
|
|
684
|
+
return;
|
|
639
685
|
|
|
640
686
|
typeKey = `app.${typeKey}`;
|
|
641
687
|
const keys = typeKey.split('.');
|
|
@@ -647,12 +693,12 @@ export class NaslServer {
|
|
|
647
693
|
typeKind: 'reference',
|
|
648
694
|
typeName,
|
|
649
695
|
typeNamespace,
|
|
650
|
-
})
|
|
651
|
-
}))
|
|
696
|
+
}),
|
|
697
|
+
}));
|
|
652
698
|
return '';
|
|
653
699
|
});
|
|
654
700
|
return TypeAnnotation.createTypeAnonymousStructure(properties);
|
|
655
|
-
} else if(typeStr.startsWith('structures'))
|
|
701
|
+
} else if (typeStr.startsWith('structures'))
|
|
656
702
|
return app.findNodeByCompleteName(`app.${typeStr}`);
|
|
657
703
|
}
|
|
658
704
|
}
|
|
@@ -814,7 +860,8 @@ export class NaslServer {
|
|
|
814
860
|
// record.suggestionDiagnostics = record.suggestionDiagnostics.filter((item) => !item.text.includes(`implicitly has an 'any' type, but a better type may be inferred from usage.`));
|
|
815
861
|
// }
|
|
816
862
|
record.suggestionDiagnostics = record.suggestionDiagnostics
|
|
817
|
-
.filter((item) => [`'__LogicEmpty' is declared but its value is never read.`, `'__destinationEmpty__' is declared but its value is never read.`
|
|
863
|
+
.filter((item) => [`'__LogicEmpty' is declared but its value is never read.`, `'__destinationEmpty__' is declared but its value is never read.`
|
|
864
|
+
, `'__UpdateNoProperty__' is declared but its value is never read.`].includes(item.text))
|
|
818
865
|
.map((diag) => this._resolveDiagnostic(diag as unknown as tsProtocol.DiagnosticWithFileName, node as FileNode, record))
|
|
819
866
|
.filter((diag) => !!diag);
|
|
820
867
|
|
|
@@ -847,7 +894,7 @@ export class NaslServer {
|
|
|
847
894
|
}
|
|
848
895
|
if (removed)
|
|
849
896
|
return diagnostics;
|
|
850
|
-
fileNode?.sourceMap.forEach(
|
|
897
|
+
fileNode?.sourceMap.forEach((value, node) => {
|
|
851
898
|
if (node instanceof Match) {
|
|
852
899
|
const { cases, expression } = node || {};
|
|
853
900
|
const typeAnnotationMap: any = {};
|
|
@@ -857,7 +904,7 @@ export class NaslServer {
|
|
|
857
904
|
count: 0,
|
|
858
905
|
};
|
|
859
906
|
if (Array.isArray(cases)) {
|
|
860
|
-
cases.forEach(
|
|
907
|
+
cases.forEach((caseItem, index) => {
|
|
861
908
|
let isDisabled = false;
|
|
862
909
|
// 是最后一项
|
|
863
910
|
if (index === cases.length - 1) {
|
|
@@ -997,7 +1044,7 @@ export class NaslServer {
|
|
|
997
1044
|
if (removed)
|
|
998
1045
|
return diagnostics;
|
|
999
1046
|
|
|
1000
|
-
fileNode?.sourceMap.forEach(
|
|
1047
|
+
fileNode?.sourceMap.forEach((value, node) => {
|
|
1001
1048
|
if (node instanceof ViewElement && node.view === fileNode) {
|
|
1002
1049
|
if (node.tag) {
|
|
1003
1050
|
node.bindAttrs.forEach((bindAttr) => {
|
|
@@ -1111,6 +1158,40 @@ export class NaslServer {
|
|
|
1111
1158
|
},
|
|
1112
1159
|
};
|
|
1113
1160
|
diagnostics.push(diagnostic);
|
|
1161
|
+
} else if (propertyValue.value) {
|
|
1162
|
+
const dataSource: any = fileNode;
|
|
1163
|
+
// 数据源有连接错误
|
|
1164
|
+
let envText;
|
|
1165
|
+
if (propertyValue.env === 'dev') {
|
|
1166
|
+
if (dataSource.__devConnectError) {
|
|
1167
|
+
envText = '开发';
|
|
1168
|
+
} else if (dataSource.__devConnectError === false) {
|
|
1169
|
+
return;
|
|
1170
|
+
}
|
|
1171
|
+
} else if (propertyValue.env === 'online') {
|
|
1172
|
+
if (dataSource.__onlineConnectError) {
|
|
1173
|
+
envText = '生产';
|
|
1174
|
+
} else if (dataSource.__onlineConnectError === false) {
|
|
1175
|
+
return;
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
// 手动插入报错
|
|
1179
|
+
if (envText) {
|
|
1180
|
+
const diagnostic = {
|
|
1181
|
+
node: fileNode,
|
|
1182
|
+
severity: 'error',
|
|
1183
|
+
message: `数据源配置:数据源 ${property.name} ${envText}环境数据源连接不通,请先检查${envText}环境数据源配置`,
|
|
1184
|
+
// 保留原来的内容方便查询一些问题
|
|
1185
|
+
originalDiagnostic: {
|
|
1186
|
+
fileName: '',
|
|
1187
|
+
start: <any>null,
|
|
1188
|
+
end: <any>null,
|
|
1189
|
+
category: 'error',
|
|
1190
|
+
text: `DataSource connection error`,
|
|
1191
|
+
},
|
|
1192
|
+
};
|
|
1193
|
+
return diagnostics.push(diagnostic);
|
|
1194
|
+
}
|
|
1114
1195
|
}
|
|
1115
1196
|
});
|
|
1116
1197
|
}
|
|
@@ -1121,17 +1202,18 @@ export class NaslServer {
|
|
|
1121
1202
|
if (fileNode.parentNode instanceof App && !fileNode.parentNode.logics.includes(fileNode))
|
|
1122
1203
|
return diagnostics;
|
|
1123
1204
|
|
|
1124
|
-
fileNode?.sourceMap.forEach(
|
|
1205
|
+
fileNode?.sourceMap.forEach((value, node) => {
|
|
1206
|
+
//OQL支持返回复合类型数据了
|
|
1125
1207
|
// SqlQueryComponent内部返回值类型,如果是嵌套的就需要报错
|
|
1126
|
-
if ((node instanceof OqlQueryComponent || node instanceof SqlQueryComponent) && (node as SqlQueryComponent).getTypeBanError()) {
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
}
|
|
1208
|
+
// if ((node instanceof OqlQueryComponent || node instanceof SqlQueryComponent) && (node as SqlQueryComponent).getTypeBanError()) {
|
|
1209
|
+
// const diagnostic = {
|
|
1210
|
+
// node,
|
|
1211
|
+
// severity: 'error',
|
|
1212
|
+
// message: 'SQL查询:返回类型内部,不支持复杂类型。',
|
|
1213
|
+
// };
|
|
1214
|
+
// node.tsErrorDetail = diagnostic;
|
|
1215
|
+
// diagnostics.push(diagnostic);
|
|
1216
|
+
// }
|
|
1135
1217
|
if (node instanceof Return || node instanceof Variable) {
|
|
1136
1218
|
if (!node.typeAnnotation && !node.__TypeAnnotation) {
|
|
1137
1219
|
const nodeTypeName = node.concept === 'Return' ? '输出参数' : '局部变量';
|
|
@@ -1167,6 +1249,11 @@ export class NaslServer {
|
|
|
1167
1249
|
this.checkNodeError(node, diagnostics);
|
|
1168
1250
|
});
|
|
1169
1251
|
}
|
|
1252
|
+
if (fileNode instanceof Process) {
|
|
1253
|
+
fileNode?.sourceMap.forEach((value, node) => {
|
|
1254
|
+
this.checkNodeError(node, diagnostics);
|
|
1255
|
+
});
|
|
1256
|
+
}
|
|
1170
1257
|
return diagnostics;
|
|
1171
1258
|
}
|
|
1172
1259
|
|
|
@@ -1244,9 +1331,30 @@ export class NaslServer {
|
|
|
1244
1331
|
node.tsErrorDetail = diagnostic;
|
|
1245
1332
|
diagnostics.push(diagnostic);
|
|
1246
1333
|
}
|
|
1334
|
+
// 如果TypeAnnotation 还存在,但是本身已经不是union类型,就是已经从union换别的类型了就都要报错
|
|
1335
|
+
} else if (node instanceof TypeAnnotation && matchExpressionType?.typeKind !== 'union') {
|
|
1336
|
+
const diagnostic = {
|
|
1337
|
+
node,
|
|
1338
|
+
severity: 'error',
|
|
1339
|
+
message: '匹配:选择类型不存在',
|
|
1340
|
+
titleTip: '该类型已被删除',
|
|
1341
|
+
};
|
|
1342
|
+
node.tsErrorDetail = diagnostic;
|
|
1343
|
+
diagnostics.push(diagnostic);
|
|
1344
|
+
// 如果可枚举变量的 ,变量 还存在,但是本身已经是union类型,就是已经从别的类型 换了union就都要报错
|
|
1345
|
+
} else if (!(node instanceof TypeAnnotation) && matchExpressionType?.typeKind === 'union') {
|
|
1346
|
+
const diagnostic = {
|
|
1347
|
+
node,
|
|
1348
|
+
severity: 'error',
|
|
1349
|
+
message: '匹配:选择值不存在',
|
|
1350
|
+
titleTip: '该值无法匹配,请重新选择类型',
|
|
1351
|
+
};
|
|
1352
|
+
node.tsErrorDetail = diagnostic;
|
|
1353
|
+
diagnostics.push(diagnostic);
|
|
1247
1354
|
}
|
|
1248
1355
|
if (node.tsErrorDetail) {
|
|
1249
|
-
|
|
1356
|
+
// 如果父级是枚举,而且子集选的是变量,就提示枚举值已被删除
|
|
1357
|
+
if (matchExpressionType?.typeNamespace?.includes('enums') && (node instanceof MemberExpression)) {
|
|
1250
1358
|
node.tsErrorDetail.titleTip = '该枚举值已被删除';
|
|
1251
1359
|
} else if (!node.tsErrorDetail.titleTip) {
|
|
1252
1360
|
node.tsErrorDetail.titleTip = '该值已被删除';
|
|
@@ -1263,6 +1371,25 @@ export class NaslServer {
|
|
|
1263
1371
|
node.tsErrorDetail = diagnostic;
|
|
1264
1372
|
diagnostics.push(diagnostic);
|
|
1265
1373
|
}
|
|
1374
|
+
/**
|
|
1375
|
+
* 如果节点是内置函数
|
|
1376
|
+
* 穷举在线上的情况,不在线上就void报错, calllogic 和 callinterface 因为原来有报错,所以就忽略掉
|
|
1377
|
+
* && 他在父级中,不在body
|
|
1378
|
+
* && 也不再 if的线上
|
|
1379
|
+
* && 也不再 switch的线上consequent
|
|
1380
|
+
* && 也不再草稿区域
|
|
1381
|
+
* && 不在 parentNode.parentNode(只用处理两层的,超过两层上就需要报错,只用直接是参数位第一层的需要) 是 callfunction 和 callInfterfase中,因为这两本身有强制类型,内置函数或者一些带T的声明那种,
|
|
1382
|
+
* && 而且也没有类型,就说明在槽位里,就需要报错
|
|
1383
|
+
*/
|
|
1384
|
+
if (node instanceof 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) {
|
|
1385
|
+
const diagnostic = {
|
|
1386
|
+
node,
|
|
1387
|
+
severity: 'error',
|
|
1388
|
+
message: `类型不一致,当前内置函数${node.calleeName || ''}无返回值。`,
|
|
1389
|
+
};
|
|
1390
|
+
node.tsErrorDetail = diagnostic;
|
|
1391
|
+
diagnostics.push(diagnostic);
|
|
1392
|
+
}
|
|
1266
1393
|
}
|
|
1267
1394
|
|
|
1268
1395
|
/* 接口导入查找 */
|
|
@@ -1654,7 +1781,7 @@ export class NaslServer {
|
|
|
1654
1781
|
// 因为要用下面的点位信息
|
|
1655
1782
|
const name = minRange.node.name;
|
|
1656
1783
|
// 如果name不改,那就是要改命名空间
|
|
1657
|
-
if (newValue === name) {
|
|
1784
|
+
if (node instanceof Frontend || newValue === name) {
|
|
1658
1785
|
const namespace = minRange.node.namespace;
|
|
1659
1786
|
// 先看下标位置
|
|
1660
1787
|
const lineText = record.lineText;
|
|
@@ -1773,6 +1900,24 @@ export class NaslServer {
|
|
|
1773
1900
|
minRange.newValue = newTsNameSpace;
|
|
1774
1901
|
}
|
|
1775
1902
|
}
|
|
1903
|
+
if (node instanceof Frontend && minRange.node instanceof Destination) {
|
|
1904
|
+
const tsCalleeNamespace = minRange.node.tsCalleeNamespace;
|
|
1905
|
+
const tsName = minRange.node.tsName;
|
|
1906
|
+
const oldValue = tsCalleeNamespace + '.' + tsName;
|
|
1907
|
+
// 先看下标位置
|
|
1908
|
+
const lineText = record.lineText;
|
|
1909
|
+
const index = lineText.indexOf(oldValue);
|
|
1910
|
+
// 在把开始结束位置的-开始位置,来知道是哪里要替换
|
|
1911
|
+
const start = record.start.offset - index - 1;
|
|
1912
|
+
const end = record.end.offset - index - 1;
|
|
1913
|
+
if (start <= tsCalleeNamespace.length) {
|
|
1914
|
+
// 新的完整的value
|
|
1915
|
+
let newTsNameSpace = tsCalleeNamespace.substring(0, start) + newValue + tsCalleeNamespace.substring(end, tsCalleeNamespace.length);
|
|
1916
|
+
minRange.setTypeMethods = 'setViewNamespace';
|
|
1917
|
+
newTsNameSpace = newTsNameSpace.replace(/\.\$/g, '.');
|
|
1918
|
+
minRange.newValue = newTsNameSpace;
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1776
1921
|
// 如果是事件修改
|
|
1777
1922
|
// 如果是view也需要加前缀
|
|
1778
1923
|
// logic 和 views名称修改 可能会触发bindEvent修改
|
|
@@ -2306,7 +2451,7 @@ export class NaslServer {
|
|
|
2306
2451
|
return TypeAnnotation.createPrimitive('Boolean');
|
|
2307
2452
|
}
|
|
2308
2453
|
// Convert和new都是自身携带类型的,就不进行修改
|
|
2309
|
-
if (node instanceof CallFunction && node.calleeNamespace === 'nasl.util' && (
|
|
2454
|
+
if (node instanceof CallFunction && node.calleeNamespace === 'nasl.util' && (['Convert', 'New', 'FromString'].includes(node.calleeName))) {
|
|
2310
2455
|
if (node.typeArguments.length) {
|
|
2311
2456
|
return node.typeArguments[0];
|
|
2312
2457
|
}
|
|
@@ -2396,6 +2541,9 @@ export class NaslServer {
|
|
|
2396
2541
|
'Return',
|
|
2397
2542
|
'Variable',
|
|
2398
2543
|
'Match',
|
|
2544
|
+
'NewComposite',
|
|
2545
|
+
'NewList',
|
|
2546
|
+
'NewMap',
|
|
2399
2547
|
].includes(node.concept))
|
|
2400
2548
|
return;
|
|
2401
2549
|
// 要去ls那边获取的
|
|
@@ -2442,12 +2590,18 @@ export class NaslServer {
|
|
|
2442
2590
|
let newCode = item.code.substring(0, indexOf);
|
|
2443
2591
|
newCode = newCode.substring(newCode.lastIndexOf('\n'), indexOf);
|
|
2444
2592
|
fileDetail.offset = newCode.length + 'return '.length;
|
|
2593
|
+
} else if (['NewComposite', 'NewList', 'NewMap'].includes(node.concept)) {
|
|
2594
|
+
fileDetail.line = item.range.end.line;
|
|
2595
|
+
const indexOf = item.code.indexOf('return __newComposite');
|
|
2596
|
+
let newCode = item.code.substring(0, indexOf);
|
|
2597
|
+
newCode = newCode.substring(newCode.lastIndexOf('\n'), indexOf);
|
|
2598
|
+
fileDetail.offset = newCode.length + 'return '.length;
|
|
2445
2599
|
}
|
|
2446
2600
|
args.push(fileDetail);
|
|
2447
2601
|
});
|
|
2448
|
-
console.time('请求')
|
|
2602
|
+
console.time('请求');
|
|
2449
2603
|
const resultMap: any = (await this.getNaslNodeTypeFull(args)).response;
|
|
2450
|
-
console.timeEnd('请求')
|
|
2604
|
+
console.timeEnd('请求');
|
|
2451
2605
|
|
|
2452
2606
|
// console.log(resultMap);
|
|
2453
2607
|
|
|
@@ -2773,7 +2927,7 @@ export class NaslServer {
|
|
|
2773
2927
|
};
|
|
2774
2928
|
}
|
|
2775
2929
|
|
|
2776
|
-
async getCurrentTypeAnnotation(node: BaseNode) {
|
|
2930
|
+
async getCurrentTypeAnnotation(node: BaseNode, outTime: number = 600) {
|
|
2777
2931
|
if (node.__TypeAnnotation) {
|
|
2778
2932
|
return node.__TypeAnnotation;
|
|
2779
2933
|
}
|
|
@@ -2787,7 +2941,7 @@ export class NaslServer {
|
|
|
2787
2941
|
} else {
|
|
2788
2942
|
resolve(null);
|
|
2789
2943
|
}
|
|
2790
|
-
},
|
|
2944
|
+
}, outTime);
|
|
2791
2945
|
const mySetInterval = setInterval(() => {
|
|
2792
2946
|
if (node.__isCorrectTypeAnnotation) {
|
|
2793
2947
|
resolve(node.__TypeAnnotation);
|
|
@@ -2877,7 +3031,7 @@ export class NaslServer {
|
|
|
2877
3031
|
// 更新文件之后
|
|
2878
3032
|
await this.updateFiles({ outputFiles });
|
|
2879
3033
|
|
|
2880
|
-
newRefs.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
3034
|
+
newRefs.refs.forEach((ref) => this.filesToCheck.add(ref.file));
|
|
2881
3035
|
}
|
|
2882
3036
|
|
|
2883
3037
|
/**
|
|
@@ -2900,13 +3054,13 @@ export class NaslServer {
|
|
|
2900
3054
|
offset: EmbeddedTSFileOffsetMap[fileNode.concept] ?? 6,
|
|
2901
3055
|
});
|
|
2902
3056
|
|
|
2903
|
-
newRefs.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
3057
|
+
newRefs.refs.forEach((ref) => this.filesToCheck.add(ref.file));
|
|
2904
3058
|
// 唤起建立连接弹框
|
|
2905
3059
|
// 文件级别的建立连接采取提醒
|
|
2906
3060
|
if (action === 'create' && (targetNode as any).__init) {
|
|
2907
3061
|
// 清除临时状态, 完成本次创建
|
|
2908
3062
|
delete (targetNode as any).__init;
|
|
2909
|
-
if (fileNode === targetNode && filesToCheck.size > 1) {
|
|
3063
|
+
if (fileNode === targetNode && this.filesToCheck.size > 1) {
|
|
2910
3064
|
const confirmParms = {
|
|
2911
3065
|
actionType: 'createEstablishConnection',
|
|
2912
3066
|
node: fileNode,
|
|
@@ -2943,8 +3097,8 @@ export class NaslServer {
|
|
|
2943
3097
|
line: EmbeddedTSFileLineMap[fileNode.concept] ?? 2,
|
|
2944
3098
|
offset: EmbeddedTSFileOffsetMap[fileNode.concept] ?? 6,
|
|
2945
3099
|
});
|
|
2946
|
-
oldRefs.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
2947
|
-
filesToCheck.delete(oldFilePath);
|
|
3100
|
+
oldRefs.refs.forEach((ref) => this.filesToCheck.add(ref.file));
|
|
3101
|
+
this.filesToCheck.delete(oldFilePath);
|
|
2948
3102
|
// 更新文件之后
|
|
2949
3103
|
await this.updateFiles({ outputFiles });
|
|
2950
3104
|
|
|
@@ -2956,7 +3110,7 @@ export class NaslServer {
|
|
|
2956
3110
|
});
|
|
2957
3111
|
const newRefFileList: Set<string> = new Set();
|
|
2958
3112
|
newRefs.refs.forEach((ref) => {
|
|
2959
|
-
filesToCheck.add(ref.file);
|
|
3113
|
+
this.filesToCheck.add(ref.file);
|
|
2960
3114
|
newRefFileList.add(ref.file);
|
|
2961
3115
|
});
|
|
2962
3116
|
|
|
@@ -2985,7 +3139,7 @@ export class NaslServer {
|
|
|
2985
3139
|
line: EmbeddedTSFileLineMap[fileNode.concept] ?? 2,
|
|
2986
3140
|
offset: EmbeddedTSFileOffsetMap[fileNode.concept] ?? 6,
|
|
2987
3141
|
});
|
|
2988
|
-
newRefs2.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
3142
|
+
newRefs2.refs.forEach((ref) => this.filesToCheck.add(ref.file));
|
|
2989
3143
|
} else {
|
|
2990
3144
|
// 查一下当前属性依赖的文件
|
|
2991
3145
|
const { currentSource, fileNode } = this.getCurrentSource(targetNode);
|
|
@@ -2999,7 +3153,7 @@ export class NaslServer {
|
|
|
2999
3153
|
line: lsp2tspNumber(currentSource.range.start.line),
|
|
3000
3154
|
offset: lsp2tspNumber(currentSource.range.start.character),
|
|
3001
3155
|
});
|
|
3002
|
-
oldRefs.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
3156
|
+
oldRefs.refs.forEach((ref) => this.filesToCheck.add(ref.file));
|
|
3003
3157
|
// 更新文件之后
|
|
3004
3158
|
await this.updateFiles({ outputFiles });
|
|
3005
3159
|
|
|
@@ -3008,7 +3162,7 @@ export class NaslServer {
|
|
|
3008
3162
|
line: lsp2tspNumber(currentSource.range.start.line),
|
|
3009
3163
|
offset: lsp2tspNumber(currentSource.range.start.character),
|
|
3010
3164
|
});
|
|
3011
|
-
newRefs2.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
3165
|
+
newRefs2.refs.forEach((ref) => this.filesToCheck.add(ref.file));
|
|
3012
3166
|
}
|
|
3013
3167
|
}
|
|
3014
3168
|
}
|
|
@@ -3024,6 +3178,29 @@ export class NaslServer {
|
|
|
3024
3178
|
*/
|
|
3025
3179
|
async incidentalAction(action: string, fileNode: BaseNode, targetNode: BaseNode, oldpath?: string) {
|
|
3026
3180
|
if ((action === 'create' || action === 'delete' || (action === 'update' && oldpath)) && fileNode === targetNode) {
|
|
3181
|
+
//删除、更改、新增端
|
|
3182
|
+
if (fileNode instanceof Frontend && (fileNode.views?.length || fileNode.variables?.length)) {
|
|
3183
|
+
const fileNodeChildren = [...fileNode.views, ...fileNode.variables];
|
|
3184
|
+
for (let i = 0; i < fileNodeChildren.length; i++) {
|
|
3185
|
+
const fileNodeItem = fileNodeChildren[i];
|
|
3186
|
+
const result = (fileNodeItem as FileNode).toEmbeddedTSFile();
|
|
3187
|
+
fileNodeItem.sourceMap = result.sourceMap;
|
|
3188
|
+
if (action === 'create') {
|
|
3189
|
+
await this.handleChange(fileNodeItem, fileNodeItem, result, action);
|
|
3190
|
+
await this.incidentalAction(action, fileNodeItem, fileNodeItem);
|
|
3191
|
+
} else if (action === 'delete') {
|
|
3192
|
+
await this.handleDelete(fileNodeItem, fileNodeItem, result);
|
|
3193
|
+
await this.incidentalAction(action, fileNodeItem, fileNodeItem);
|
|
3194
|
+
} else if (action === 'update' && oldpath) {
|
|
3195
|
+
const parentPath = oldpath.replace('.ts', '/');
|
|
3196
|
+
const foldName = fileNodeItem.concept === 'View' ? 'views' : 'variables';
|
|
3197
|
+
const currentOldPath = parentPath + foldName + '/' + fileNodeItem.name + '.ts';
|
|
3198
|
+
// 因为重命名这里只有当前修改父级的 旧名称, 所以他的子集也要根据旧名称去查依赖 更新内容
|
|
3199
|
+
await this.handleRename(fileNodeItem, fileNodeItem, result, currentOldPath);
|
|
3200
|
+
await this.incidentalAction(action, fileNodeItem, fileNodeItem, currentOldPath);
|
|
3201
|
+
}
|
|
3202
|
+
}
|
|
3203
|
+
}
|
|
3027
3204
|
// 删除或者新增页面
|
|
3028
3205
|
if (fileNode instanceof View && fileNode.children?.length) {
|
|
3029
3206
|
const fileNodeChildren = fileNode.children;
|
|
@@ -3095,7 +3272,7 @@ export class NaslServer {
|
|
|
3095
3272
|
}
|
|
3096
3273
|
|
|
3097
3274
|
async receiveHandleChange($event: EventPayload) {
|
|
3098
|
-
singleFileChangeIng = true;
|
|
3275
|
+
this.singleFileChangeIng = true;
|
|
3099
3276
|
// 行为
|
|
3100
3277
|
const action = $event.action;
|
|
3101
3278
|
const targetNode = $event.target;
|
|
@@ -3144,19 +3321,19 @@ export class NaslServer {
|
|
|
3144
3321
|
}
|
|
3145
3322
|
|
|
3146
3323
|
changeFileNext() {
|
|
3147
|
-
if (!singleFileChangeIng) {
|
|
3324
|
+
if (!this.singleFileChangeIng) {
|
|
3148
3325
|
const item = this.changeStackList.shift();
|
|
3149
3326
|
this.receiveHandleChange(item).catch((err) => {
|
|
3150
3327
|
console.log(err, 'receiveHandleChangeErr');
|
|
3151
3328
|
}).finally(async () => {
|
|
3152
3329
|
// 每一个文件与change接触就把状态置为false,让下一个进入
|
|
3153
|
-
singleFileChangeIng = false;
|
|
3330
|
+
this.singleFileChangeIng = false;
|
|
3154
3331
|
if (this.changeStackList.length) {
|
|
3155
3332
|
this.changeFileNext();
|
|
3156
3333
|
} else {
|
|
3157
|
-
console.log(Array.from(filesToCheck));
|
|
3158
|
-
await this.getDiagnosticRecordsAndPushAll(Array.from(filesToCheck));
|
|
3159
|
-
filesToCheck.clear();
|
|
3334
|
+
console.log(Array.from(this.filesToCheck));
|
|
3335
|
+
await this.getDiagnosticRecordsAndPushAll(Array.from(this.filesToCheck));
|
|
3336
|
+
this.filesToCheck.clear();
|
|
3160
3337
|
}
|
|
3161
3338
|
});
|
|
3162
3339
|
}
|
|
@@ -89,6 +89,10 @@ export function processToTreeFragment(process: Process) {
|
|
|
89
89
|
k.getNamespace = function () {
|
|
90
90
|
return path;
|
|
91
91
|
};
|
|
92
|
+
const api = `/api/${process.name}/${e.name}/${k.name}`;
|
|
93
|
+
k.getPath = function () {
|
|
94
|
+
return api;
|
|
95
|
+
};
|
|
92
96
|
});
|
|
93
97
|
|
|
94
98
|
fragment.elements.push({
|
|
@@ -107,6 +111,10 @@ export function processToTreeFragment(process: Process) {
|
|
|
107
111
|
launchLogic.getNamespace = function () {
|
|
108
112
|
return path;
|
|
109
113
|
};
|
|
114
|
+
const api = `/api/${process.name}/${launchLogic.name}`;
|
|
115
|
+
launchLogic.getPath = function () {
|
|
116
|
+
return api;
|
|
117
|
+
};
|
|
110
118
|
|
|
111
119
|
fragment.logics.push(launchLogic);
|
|
112
120
|
launchLogic.parentKey = 'readonly';
|