@lcap/nasl 1.0.1 → 2.12.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.d.ts +1 -0
- package/out/automate/engine/index.js +34 -12
- package/out/automate/engine/index.js.map +1 -1
- package/out/automate/engine/operators.d.ts +10 -2
- package/out/automate/engine/operators.js +105 -7
- package/out/automate/engine/operators.js.map +1 -1
- package/out/automate/engine/uniqueName.d.ts +8 -2
- package/out/automate/engine/uniqueName.js +72 -4
- package/out/automate/engine/uniqueName.js.map +1 -1
- package/out/automate/engine/utils.d.ts +1 -0
- package/out/automate/engine/utils.js +108 -67
- package/out/automate/engine/utils.js.map +1 -1
- package/out/automate/template/process.d.ts +9 -0
- package/out/automate/template/process.js +10976 -0
- package/out/automate/template/process.js.map +1 -0
- package/out/bak/translator.js +1 -0
- package/out/bak/translator.js.map +1 -1
- package/out/common/BaseNode.d.ts +6 -1
- package/out/common/BaseNode.js +37 -6
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/App__.d.ts +52 -49
- package/out/concepts/App__.js +89 -53
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Assignee__.d.ts +11 -0
- package/out/concepts/Assignee__.js +34 -0
- package/out/concepts/Assignee__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +2 -2
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +10 -3
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.js +15 -6
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.d.ts +4 -0
- package/out/concepts/BooleanLiteral__.js +11 -0
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/CallFunction__.js +9 -4
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallLogic__.js +48 -30
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.d.ts +34 -4
- package/out/concepts/CallQueryComponent__.js +340 -95
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Comment__.js +1 -1
- package/out/concepts/Comment__.js.map +1 -1
- package/out/concepts/ConfigGroup__.d.ts +1 -0
- package/out/concepts/ConfigGroup__.js +7 -0
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/ConfigProperty__.d.ts +1 -0
- package/out/concepts/ConfigProperty__.js +3 -0
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Configuration__.d.ts +1 -0
- package/out/concepts/Configuration__.js +3 -0
- package/out/concepts/Configuration__.js.map +1 -1
- package/out/concepts/Constant__.js +6 -6
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/DataSource__.d.ts +143 -0
- package/out/concepts/DataSource__.js +318 -0
- package/out/concepts/DataSource__.js.map +1 -0
- package/out/concepts/Destination__.js +22 -8
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +2 -2
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityIndex__.d.ts +5 -0
- package/out/concepts/EntityIndex__.js +10 -2
- package/out/concepts/EntityIndex__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +9 -0
- package/out/concepts/EntityProperty__.js +22 -7
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +6 -0
- package/out/concepts/Entity__.js +27 -11
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/Enum__.d.ts +1 -0
- package/out/concepts/Enum__.js +14 -4
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +2 -2
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Function__.d.ts +18 -0
- package/out/concepts/Function__.js +96 -1
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.js +5 -14
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.js +8 -8
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/InterfaceParam__.js +9 -4
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/Interface__.js +19 -12
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/JSBlock__.js +3 -5
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/Logic__.js +44 -44
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Module__.d.ts +116 -194
- package/out/concepts/Module__.js +31 -114
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/Namespace__.d.ts +0 -86
- package/out/concepts/Namespace__.js +1 -108
- package/out/concepts/Namespace__.js.map +1 -1
- package/out/concepts/Param__.d.ts +3 -2
- package/out/concepts/Param__.js +15 -8
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +38 -12
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/Process__.d.ts +1 -1
- package/out/concepts/Process__.js +17 -10
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/QueryAggregateExpression__.js +1 -1
- package/out/concepts/QueryAggregateExpression__.js.map +1 -1
- package/out/concepts/QueryFieldExpression__.d.ts +1 -0
- package/out/concepts/QueryFieldExpression__.js +11 -1
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.d.ts +4 -0
- package/out/concepts/QueryFromExpression__.js +13 -2
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryGroupByExpression__.d.ts +3 -0
- package/out/concepts/QueryGroupByExpression__.js +20 -0
- package/out/concepts/QueryGroupByExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.d.ts +4 -0
- package/out/concepts/QueryJoinExpression__.js +14 -3
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/Return__.d.ts +1 -1
- package/out/concepts/Return__.js +16 -11
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/Role__.js +10 -3
- package/out/concepts/Role__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.d.ts +14 -0
- package/out/concepts/SqlQueryComponent__.js +48 -5
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/StringLiteral__.d.ts +1 -1
- package/out/concepts/StringLiteral__.js +2 -9
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.js +11 -10
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.js +19 -12
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SwitchCase__.d.ts +1 -1
- package/out/concepts/SwitchCase__.js +23 -25
- package/out/concepts/SwitchCase__.js.map +1 -1
- package/out/concepts/SwitchStatement__.js +1 -6
- package/out/concepts/SwitchStatement__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +8 -0
- package/out/concepts/TypeAnnotation__.js +53 -3
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/Variable__.d.ts +1 -1
- package/out/concepts/Variable__.js +16 -11
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.js +25 -20
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +1 -3
- package/out/concepts/View__.js +42 -36
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.js +4 -4
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.auth.js +20 -0
- package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.configuration.js +1 -1
- package/out/concepts/basics/stdlib/nasl.configuration.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.interface.d.ts +2 -0
- package/out/concepts/basics/stdlib/nasl.interface.js +4 -4
- package/out/concepts/basics/stdlib/nasl.interface.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.process.d.ts +4 -0
- package/out/concepts/basics/stdlib/nasl.process.js +410 -0
- package/out/concepts/basics/stdlib/nasl.process.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +1 -11
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +270 -8
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/basics/stdlib/reference2TypeAnnotationList.js +1 -1
- package/out/concepts/basics/stdlib/reference2TypeAnnotationList.js.map +1 -1
- package/out/concepts/basics/types/index.d.ts +2 -0
- package/out/concepts/basics/types/index.js +6 -1
- package/out/concepts/basics/types/index.js.map +1 -1
- package/out/concepts/index__.d.ts +1 -0
- package/out/concepts/index__.js +1 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/enums/KEYWORDS.js +0 -7
- package/out/enums/KEYWORDS.js.map +1 -1
- package/out/generator/genBundleFiles.d.ts +3 -1
- package/out/generator/genBundleFiles.js +23 -5
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.d.ts +1 -0
- package/out/generator/genMetaData.js +20 -12
- package/out/generator/genMetaData.js.map +1 -1
- package/out/index.d.ts +1 -1
- package/out/index.js +2 -1
- package/out/index.js.map +1 -1
- package/out/manager/diagnostic.d.ts +1 -1
- package/out/server/createUiTs.js +1 -0
- package/out/server/createUiTs.js.map +1 -1
- package/out/{test/integration/connect-file copy.d.ts → server/extendBaseNode.d.ts} +0 -0
- package/out/server/extendBaseNode.js +323 -0
- package/out/server/extendBaseNode.js.map +1 -0
- package/out/server/getLogics.js +49 -2
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +52 -2
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.d.ts +8 -2
- package/out/server/getProcesses.js +228 -20
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/getScope.d.ts +1 -0
- package/out/server/getScope.js +4 -0
- package/out/server/getScope.js.map +1 -1
- package/out/server/index.d.ts +1 -0
- package/out/server/index.js +1 -0
- package/out/server/index.js.map +1 -1
- package/out/server/naslServer.d.ts +8 -5
- package/out/server/naslServer.js +314 -383
- package/out/server/naslServer.js.map +1 -1
- package/out/server/process2LogicNamespace.js +10 -1
- package/out/server/process2LogicNamespace.js.map +1 -1
- package/out/server/translator.d.ts +1 -1
- package/out/server/translator.js +40 -2
- package/out/server/translator.js.map +1 -1
- package/out/service/creator/errHandles.js +5 -0
- package/out/service/creator/errHandles.js.map +1 -1
- package/out/service/storage/init.d.ts +1 -0
- package/out/service/storage/init.js +113 -94
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +34 -24
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +28 -18
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +45 -29
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.js +15 -13
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genEnumSelectBlock.js +1 -1
- package/out/templator/genEnumSelectBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +1 -1
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +29 -24
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +7 -5
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genQueryComponent.js +31 -29
- package/out/templator/genQueryComponent.js.map +1 -1
- package/out/templator/genSelectBlock.js +13 -22
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +31 -21
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +35 -25
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.d.ts +5 -3
- package/out/templator/utils.js +2 -1
- package/out/templator/utils.js.map +1 -1
- package/out/test/integration/connect-file.js +6 -6
- package/out/test/integration/connect-file.js.map +1 -1
- package/out/translator/index.js +1 -1
- package/out/translator/index.js.map +1 -1
- package/out/utils/index.d.ts +5 -0
- package/out/utils/index.js +50 -1
- package/out/utils/index.js.map +1 -1
- package/package.json +1 -2
- package/src/automate/engine/index.js +33 -8
- package/src/automate/engine/operators.js +114 -17
- package/src/automate/engine/uniqueName.js +77 -9
- package/src/automate/engine/utils.js +110 -69
- package/src/automate/template/process.js +10999 -0
- package/src/bak/translator.js +1 -0
- package/src/common/BaseNode.ts +35 -7
- package/src/concepts/App__.ts +132 -131
- package/src/concepts/Assignee__.ts +30 -0
- package/src/concepts/BindAttribute__.ts +2 -2
- package/src/concepts/BindDirective__.ts +9 -7
- package/src/concepts/BindEvent__.ts +14 -6
- package/src/concepts/BooleanLiteral__.ts +12 -0
- package/src/concepts/CallFunction__.ts +7 -4
- package/src/concepts/CallLogic__.ts +47 -32
- package/src/concepts/CallQueryComponent__.ts +352 -101
- package/src/concepts/Comment__.ts +1 -1
- package/src/concepts/ConfigGroup__.ts +3 -1
- package/src/concepts/ConfigProperty__.ts +4 -0
- package/src/concepts/Configuration__.ts +3 -0
- package/src/concepts/Constant__.ts +6 -6
- package/src/concepts/DataSource__.ts +391 -0
- package/src/concepts/Destination__.ts +22 -8
- package/src/concepts/End__.ts +2 -2
- package/src/concepts/EntityIndex__.ts +11 -2
- package/src/concepts/EntityProperty__.ts +23 -7
- package/src/concepts/Entity__.ts +38 -14
- package/src/concepts/Enum__.ts +15 -4
- package/src/concepts/ForEachStatement__.ts +2 -2
- package/src/concepts/Function__.ts +95 -1
- package/src/concepts/Identifier__.ts +5 -14
- package/src/concepts/IfStatement__.ts +9 -9
- package/src/concepts/InterfaceParam__.ts +9 -4
- package/src/concepts/Interface__.ts +20 -12
- package/src/concepts/JSBlock__.ts +3 -12
- package/src/concepts/Logic__.ts +45 -79
- package/src/concepts/Module__.ts +141 -342
- package/src/concepts/Namespace__.ts +1 -204
- package/src/concepts/Param__.ts +17 -9
- package/src/concepts/ProcessElement__.ts +42 -15
- package/src/concepts/Process__.ts +18 -12
- package/src/concepts/QueryAggregateExpression__.ts +1 -1
- package/src/concepts/QueryFieldExpression__.ts +13 -1
- package/src/concepts/QueryFromExpression__.ts +13 -2
- package/src/concepts/QueryGroupByExpression__.ts +23 -0
- package/src/concepts/QueryJoinExpression__.ts +14 -3
- package/src/concepts/Return__.ts +16 -11
- package/src/concepts/Role__.ts +10 -4
- package/src/concepts/SqlQueryComponent__.ts +47 -11
- package/src/concepts/StringLiteral__.ts +2 -9
- package/src/concepts/StructureProperty__.ts +11 -14
- package/src/concepts/Structure__.ts +19 -11
- package/src/concepts/SwitchCase__.ts +23 -27
- package/src/concepts/SwitchStatement__.ts +1 -5
- package/src/concepts/TypeAnnotation__.ts +52 -3
- package/src/concepts/Variable__.ts +16 -11
- package/src/concepts/ViewElement__.ts +26 -39
- package/src/concepts/View__.ts +45 -38
- package/src/concepts/WhileStatement__.ts +4 -4
- package/src/concepts/basics/stdlib/nasl.auth.ts +20 -0
- package/src/concepts/basics/stdlib/nasl.configuration.ts +1 -1
- package/src/concepts/basics/stdlib/nasl.interface.ts +1 -1
- package/src/concepts/basics/stdlib/nasl.process.ts +406 -0
- package/src/concepts/basics/stdlib/nasl.ui.ts +1 -11
- package/src/concepts/basics/stdlib/nasl.util.ts +271 -8
- package/src/concepts/basics/stdlib/reference2TypeAnnotationList.ts +1 -1
- package/src/concepts/basics/types/index.ts +2 -0
- package/src/concepts/index__.ts +1 -0
- package/src/enums/KEYWORDS.ts +0 -7
- package/src/generator/genBundleFiles.ts +28 -7
- package/src/generator/genMetaData.ts +22 -13
- package/src/index.ts +1 -1
- package/src/manager/diagnostic.ts +1 -1
- package/src/server/createUiTs.ts +1 -0
- package/src/server/extendBaseNode.ts +318 -0
- package/src/server/getLogics.ts +51 -5
- package/src/server/getMemberIdentifier.ts +53 -2
- package/src/server/getProcesses.ts +238 -21
- package/src/server/getScope.ts +5 -0
- package/src/server/index.ts +1 -0
- package/src/server/naslServer.ts +322 -380
- package/src/server/process2LogicNamespace.ts +29 -19
- package/src/server/translator.ts +42 -2
- package/src/service/creator/errHandles.js +6 -0
- package/src/service/storage/init.ts +115 -97
- package/src/templator/genCreateBlock.ts +35 -26
- package/src/templator/genCurdEditMultipleKeyBlock.ts +29 -21
- package/src/templator/genCurdMultipleKeyBlock.ts +46 -31
- package/src/templator/genEditTableBlock.ts +17 -14
- package/src/templator/genEnumSelectBlock.ts +1 -1
- package/src/templator/genGetBlock.ts +1 -1
- package/src/templator/genGridViewBlock.ts +30 -25
- package/src/templator/genListViewBlock.ts +10 -7
- package/src/templator/genQueryComponent.ts +34 -30
- package/src/templator/genSelectBlock.ts +14 -23
- package/src/templator/genTableBlock.ts +32 -23
- package/src/templator/genUpdateBlock.ts +36 -26
- package/src/templator/utils.ts +5 -2
- package/src/test/integration/connect-file.ts +6 -6
- package/src/translator/index.ts +1 -1
- package/src/utils/index.ts +51 -0
- package/out/concepts/basics/stdlib/nasl.browser copy.d.ts +0 -3
- package/out/concepts/basics/stdlib/nasl.browser copy.js +0 -70
- package/out/concepts/basics/stdlib/nasl.browser copy.js.map +0 -1
- package/out/terms/LEVEL_NAME_MAP.d.ts +0 -26
- package/out/terms/LEVEL_NAME_MAP.js +0 -30
- package/out/terms/LEVEL_NAME_MAP.js.map +0 -1
- package/out/test/integration/connect-file copy.js +0 -50
- package/out/test/integration/connect-file copy.js.map +0 -1
- package/out/test/integration/node-nasl-server.d.ts +0 -1
- package/out/test/integration/node-nasl-server.js +0 -41
- package/out/test/integration/node-nasl-server.js.map +0 -1
package/out/server/naslServer.js
CHANGED
|
@@ -17,6 +17,7 @@ const common_1 = require("../common");
|
|
|
17
17
|
const diagnostic_1 = __importDefault(require("../manager/diagnostic"));
|
|
18
18
|
const createUiTs_1 = __importDefault(require("./createUiTs"));
|
|
19
19
|
const coreTypeList_1 = require("../concepts/basics/types/coreTypeList");
|
|
20
|
+
const utils_1 = require("../utils");
|
|
20
21
|
const EmbeddedTSFileLineMap = {
|
|
21
22
|
Entity: 3,
|
|
22
23
|
};
|
|
@@ -35,6 +36,9 @@ const messager = new Messager_1.default({
|
|
|
35
36
|
}
|
|
36
37
|
},
|
|
37
38
|
});
|
|
39
|
+
let isChangeInterface = false; //判断是否导入接口
|
|
40
|
+
let actionArr = []; //用于导入接口收集更改的节点
|
|
41
|
+
let timer = null; //超时器用于收集导入接口相关
|
|
38
42
|
const naslServer = {
|
|
39
43
|
messager,
|
|
40
44
|
worker,
|
|
@@ -78,17 +82,30 @@ const naslServer = {
|
|
|
78
82
|
console.log(err);
|
|
79
83
|
}
|
|
80
84
|
});
|
|
81
|
-
module.
|
|
85
|
+
module.dataSources?.forEach((dataSource) => {
|
|
86
|
+
// 本身dataSource也要生成一个文件用于改名
|
|
82
87
|
try {
|
|
83
|
-
const result =
|
|
88
|
+
const result = dataSource.toEmbeddedTSFile();
|
|
84
89
|
results.push(result);
|
|
85
90
|
// sourceMap都存在目录级别内容下,在页面层级下去找
|
|
86
|
-
|
|
87
|
-
this.file2NodeMap.set(result.filePath,
|
|
91
|
+
dataSource.sourceMap = result.sourceMap;
|
|
92
|
+
this.file2NodeMap.set(result.filePath, dataSource);
|
|
88
93
|
}
|
|
89
94
|
catch (err) {
|
|
90
95
|
console.log(err);
|
|
91
96
|
}
|
|
97
|
+
dataSource.entities.forEach((entity) => {
|
|
98
|
+
try {
|
|
99
|
+
const result = entity.toEmbeddedTSFile();
|
|
100
|
+
results.push(result);
|
|
101
|
+
// sourceMap都存在目录级别内容下,在页面层级下去找
|
|
102
|
+
entity.sourceMap = result.sourceMap;
|
|
103
|
+
this.file2NodeMap.set(result.filePath, entity);
|
|
104
|
+
}
|
|
105
|
+
catch (err) {
|
|
106
|
+
console.log(err);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
92
109
|
});
|
|
93
110
|
module.interfaces.forEach((_interface) => {
|
|
94
111
|
try {
|
|
@@ -322,31 +339,38 @@ const naslServer = {
|
|
|
322
339
|
* fileNode
|
|
323
340
|
*/
|
|
324
341
|
const { currentSource, fileNode } = naslServer.getCurrentSource(callFunction);
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
342
|
+
try {
|
|
343
|
+
const quickInfo = await naslServer._getTypeQuickinfo({
|
|
344
|
+
file: fileNode.getEmbeddedFilePath(),
|
|
345
|
+
line: (0, translator_1.lsp2tspNumber)(currentSource.range.start.line),
|
|
346
|
+
offset: (0, translator_1.lsp2tspNumber)(currentSource.range.start.character) + `nasl.util.C`.length,
|
|
347
|
+
});
|
|
348
|
+
if (quickInfo.responseRequired) {
|
|
349
|
+
const displayString = quickInfo?.response?.displayString || '';
|
|
350
|
+
const typeList = naslServer.getDisplayString2Type(displayString);
|
|
351
|
+
const res = [];
|
|
352
|
+
typeList.forEach((type) => {
|
|
353
|
+
const typeAnnotation = coreTypeList_1.primitiveTypeList.find((typeAnnotation) => typeAnnotation.typeName === type);
|
|
354
|
+
if (typeAnnotation) {
|
|
355
|
+
res.push(typeAnnotation);
|
|
356
|
+
}
|
|
357
|
+
else if (type === 'unknown' || type === 'never') {
|
|
358
|
+
return null;
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
if (!res.length) {
|
|
362
|
+
return [];
|
|
338
363
|
}
|
|
339
|
-
else
|
|
340
|
-
return
|
|
364
|
+
else {
|
|
365
|
+
return [{ title: '基础类型', children: res }];
|
|
341
366
|
}
|
|
342
|
-
});
|
|
343
|
-
if (!res.length) {
|
|
344
|
-
return [];
|
|
345
|
-
}
|
|
346
|
-
else {
|
|
347
|
-
return [{ title: '基础类型', children: res }];
|
|
348
367
|
}
|
|
349
368
|
}
|
|
369
|
+
catch (err) {
|
|
370
|
+
console.log(err);
|
|
371
|
+
// 如果有异常就先放开全部可选,兜底逻辑
|
|
372
|
+
return [];
|
|
373
|
+
}
|
|
350
374
|
}
|
|
351
375
|
else {
|
|
352
376
|
// 字符串 和 inter
|
|
@@ -421,9 +445,13 @@ const naslServer = {
|
|
|
421
445
|
item.node ? (item.node.tsErrorDetail = undefined) : '';
|
|
422
446
|
});
|
|
423
447
|
// 语义诊断
|
|
448
|
+
if (isChangeInterface) {
|
|
449
|
+
this.existStructureFix(record.semanticDiagnostics, node, this);
|
|
450
|
+
}
|
|
424
451
|
record.semanticDiagnostics = record.semanticDiagnostics
|
|
425
452
|
.map((diag) => this._resolveDiagnostic(diag, node))
|
|
426
453
|
.filter((diag) => !!diag);
|
|
454
|
+
record.semanticDiagnostics.push(...this._attachDiagnostics(node));
|
|
427
455
|
// 建议诊断
|
|
428
456
|
// 实体下的建议不用展示,因为都是平台自己写的逻辑
|
|
429
457
|
// if (node instanceof Entity) {
|
|
@@ -445,6 +473,110 @@ const naslServer = {
|
|
|
445
473
|
});
|
|
446
474
|
return records;
|
|
447
475
|
},
|
|
476
|
+
_attachDiagnostics(fileNode) {
|
|
477
|
+
const diagnostics = [];
|
|
478
|
+
if (fileNode instanceof concepts_1.View) {
|
|
479
|
+
(0, utils_1.traverse)((current) => {
|
|
480
|
+
if (current.node.tag) {
|
|
481
|
+
current.node.bindAttrs.forEach((bindAttr) => {
|
|
482
|
+
if ((bindAttr.model || bindAttr.sync) && bindAttr.expression && bindAttr.expression.concept !== 'Identifier' && bindAttr.expression.concept !== 'MemberExpression') {
|
|
483
|
+
const diagnostic = {
|
|
484
|
+
node: bindAttr,
|
|
485
|
+
severity: 'error',
|
|
486
|
+
message: '页面元素双向绑定:只允许绑定可赋值的变量和字段。',
|
|
487
|
+
};
|
|
488
|
+
bindAttr.tsErrorDetail = diagnostic;
|
|
489
|
+
diagnostics.push(diagnostic);
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
}, { node: { children: fileNode.elements } });
|
|
494
|
+
}
|
|
495
|
+
if (fileNode instanceof concepts_1.DataSource) {
|
|
496
|
+
const dataSourceGroup = fileNode.rootNode.configuration?.getGroup('dataSource');
|
|
497
|
+
if (dataSourceGroup) {
|
|
498
|
+
const property = dataSourceGroup.getProperty(fileNode.name);
|
|
499
|
+
if (property && property.values) {
|
|
500
|
+
property.values.forEach((propertyValue) => {
|
|
501
|
+
if (!propertyValue.value && fileNode.name !== 'defaultDS') {
|
|
502
|
+
const diagnostic = {
|
|
503
|
+
node: fileNode,
|
|
504
|
+
severity: 'error',
|
|
505
|
+
message: `数据源配置:数据源${property.name}${propertyValue.env === 'dev' ? '开发环境' : '生产环境'}未配置数据信息`,
|
|
506
|
+
// 保留原来的内容方便查询一些问题
|
|
507
|
+
originalDiagnostic: {
|
|
508
|
+
fileName: '',
|
|
509
|
+
start: null,
|
|
510
|
+
end: null,
|
|
511
|
+
category: 'error',
|
|
512
|
+
text: `Data Source is not config`,
|
|
513
|
+
},
|
|
514
|
+
};
|
|
515
|
+
diagnostics.push(diagnostic);
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
return diagnostics;
|
|
522
|
+
},
|
|
523
|
+
/* 接口导入查找 */
|
|
524
|
+
existStructureFix(semanticDiagnostics, node, that) {
|
|
525
|
+
let module;
|
|
526
|
+
semanticDiagnostics.map((diag) => {
|
|
527
|
+
const minRange = this._findMinRange(diag, node);
|
|
528
|
+
if (diag.text?.includes('has no exported member named')) {
|
|
529
|
+
if (minRange.node instanceof concepts_1.Logic) {
|
|
530
|
+
return null;
|
|
531
|
+
}
|
|
532
|
+
const typeAnnotation = minRange.node instanceof concepts_1.TypeAnnotation ? minRange.node.upperNode.typeAnnotation : minRange.node.typeAnnotation;
|
|
533
|
+
const regNamespace = /<(\S*)>/;
|
|
534
|
+
const typeKey = (typeAnnotation.typeKey.match(regNamespace) && typeAnnotation.typeKey.match(regNamespace)[1]) || typeAnnotation.typeKey;
|
|
535
|
+
const typeKeyArr = typeKey.split('.');
|
|
536
|
+
if (typeKeyArr[0] === 'apis') {
|
|
537
|
+
const structureName = typeKeyArr[3];
|
|
538
|
+
const moduleName = typeKeyArr[1];
|
|
539
|
+
const app = typeAnnotation.upperNode.app;
|
|
540
|
+
if (!app) {
|
|
541
|
+
return null;
|
|
542
|
+
}
|
|
543
|
+
module = app.interfaceDependencies?.find((item) => item.name === moduleName);
|
|
544
|
+
let existStructure = module?.structures?.find((item) => item.name.toUpperCase() === structureName.toUpperCase());
|
|
545
|
+
if (!existStructure) {
|
|
546
|
+
const realName = structureName.replace(/\d*$/, (m) => String(''));
|
|
547
|
+
existStructure = module?.structures?.find((item) => item.name.toUpperCase() === realName.toUpperCase());
|
|
548
|
+
}
|
|
549
|
+
if (existStructure) {
|
|
550
|
+
const editTypeAnnotation = JSON.parse(JSON.stringify(typeAnnotation).replace(new RegExp(structureName, 'g'), existStructure.name));
|
|
551
|
+
actionArr.push({ target: typeAnnotation.parentNode, typeannotation: editTypeAnnotation });
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
return null;
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
557
|
+
return diag;
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
if (actionArr.length) {
|
|
561
|
+
if (timer)
|
|
562
|
+
return;
|
|
563
|
+
timer = window.setTimeout(() => {
|
|
564
|
+
const app = actionArr[0].target.app;
|
|
565
|
+
app.emit('collect:start', {
|
|
566
|
+
actionMsg: '设置导入接口数据类型错误',
|
|
567
|
+
});
|
|
568
|
+
module.isAdd && module.setIsAdd(false);
|
|
569
|
+
actionArr.forEach((item) => {
|
|
570
|
+
item.target.setDataType(concepts_1.TypeAnnotation.from(item.typeannotation));
|
|
571
|
+
});
|
|
572
|
+
app.emit('collect:end');
|
|
573
|
+
actionArr = [];
|
|
574
|
+
isChangeInterface = false;
|
|
575
|
+
clearTimeout(timer);
|
|
576
|
+
timer = null;
|
|
577
|
+
}, 2000);
|
|
578
|
+
}
|
|
579
|
+
},
|
|
448
580
|
_resolveDiagnostic(diagnostic, fileNode) {
|
|
449
581
|
const minRange = this._findMinRange(diagnostic, fileNode);
|
|
450
582
|
const tsErrorDetail = {
|
|
@@ -538,6 +670,33 @@ const naslServer = {
|
|
|
538
670
|
}
|
|
539
671
|
}
|
|
540
672
|
}
|
|
673
|
+
// 如果是DataSource就需要在单独,查一边来修改名字
|
|
674
|
+
if (node instanceof concepts_1.DataSource) {
|
|
675
|
+
// 过滤一把不需要改的信息
|
|
676
|
+
refsList = refsList.filter((item) => {
|
|
677
|
+
const dataSourceFile = fileNode.getEmbeddedFilePath();
|
|
678
|
+
const entityFilePrefix = dataSourceFile.replace('.ts', '');
|
|
679
|
+
/**
|
|
680
|
+
* 特殊处理,因为关联属性或者关联实体等等都是在实体里,在实体中因为自己不可以是自己的类型
|
|
681
|
+
* 所以全部过滤掉了,
|
|
682
|
+
* 但是在datasource里面在实体里会有大量的引用,不需要全部修改.只需要处理除了8个函数之外的引用
|
|
683
|
+
* 所以底部内容是8个函数,所以这里就 用entity的行数 减去8个函数的行数,然后其余的在进行处理
|
|
684
|
+
* 进行过滤
|
|
685
|
+
*/
|
|
686
|
+
// 不要数据源下面的实体里的引用 ,保留原始的节点内容
|
|
687
|
+
let flag = false;
|
|
688
|
+
if (item.file.includes(entityFilePrefix)) {
|
|
689
|
+
const entity = this.file2NodeMap.get(item.file);
|
|
690
|
+
const { currentSource } = naslServer.getCurrentSource(entity);
|
|
691
|
+
// 32 8个函数的总行数
|
|
692
|
+
if (item.end.line < currentSource.range.end.line - 32 && item.start.line > 1) {
|
|
693
|
+
flag = true;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
// 属于实体而且需要修改和查到 || 不是实体前缀的 || 他本身
|
|
697
|
+
return flag || !item.file.includes(entityFilePrefix) || dataSourceFile === item.file;
|
|
698
|
+
});
|
|
699
|
+
}
|
|
541
700
|
// 如果是entity就需要在单独,查一边来修改名字
|
|
542
701
|
if (node instanceof concepts_1.Entity) {
|
|
543
702
|
// 过滤一把不需要改的信息
|
|
@@ -819,20 +978,20 @@ const naslServer = {
|
|
|
819
978
|
// logic 和 views名称修改 可能会触发bindEvent修改
|
|
820
979
|
if (minRange.node instanceof concepts_1.BindEvent) {
|
|
821
980
|
// 页面逻辑直接赋值就可以, 因为是相对路径
|
|
822
|
-
if (
|
|
981
|
+
if (node instanceof concepts_1.ViewElement) {
|
|
823
982
|
minRange.setTypeMethods = 'setCalleeNamespace';
|
|
824
983
|
minRange.newValue = 'elements.' + newValue + '.logics';
|
|
825
984
|
}
|
|
826
985
|
else {
|
|
827
986
|
/**
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
987
|
+
* 如果namespce是 'app.views.Student.views.404.views.505.views.update'
|
|
988
|
+
* 在ts中会是'app.views.Student.views.$404.views.$505.views.update'
|
|
989
|
+
* 但是505 要改名为 666 ,要存的是666
|
|
990
|
+
* 'app.views.Student.views.404.views.666.views.update'
|
|
991
|
+
* 1.取到转后的
|
|
992
|
+
* 2.在匹配到的内容中取转后的namespace的位置
|
|
993
|
+
* 3.然后把namespace中的 $替换成 ''
|
|
994
|
+
*/
|
|
836
995
|
const tsCalleeNamespace = minRange.node.tsCalleeNamespace;
|
|
837
996
|
const oldValue = tsCalleeNamespace;
|
|
838
997
|
// 先看下标位置
|
|
@@ -893,19 +1052,70 @@ const naslServer = {
|
|
|
893
1052
|
if (minRange.node instanceof concepts_1.QueryFieldExpression && node instanceof concepts_1.Entity) {
|
|
894
1053
|
minRange.setTypeMethods = 'setEntityAsName';
|
|
895
1054
|
}
|
|
1055
|
+
// 如果修改的是dataSource字段
|
|
1056
|
+
if (node instanceof concepts_1.DataSource) {
|
|
1057
|
+
const setTypeNamespace = (typeNamespace, record) => {
|
|
1058
|
+
// 先看下标位置
|
|
1059
|
+
const lineText = record.lineText;
|
|
1060
|
+
const index = lineText.indexOf(typeNamespace);
|
|
1061
|
+
// 在把开始结束位置的-开始位置,来知道是哪里要替换
|
|
1062
|
+
const start = record.start.offset - index - 1;
|
|
1063
|
+
const end = record.end.offset - index - 1;
|
|
1064
|
+
// 新的完整的value
|
|
1065
|
+
const newTextValue = typeNamespace.substring(0, start) + newValue + typeNamespace.substring(end, typeNamespace.length);
|
|
1066
|
+
minRange.newValue = newTextValue;
|
|
1067
|
+
return newTextValue;
|
|
1068
|
+
};
|
|
1069
|
+
if (minRange.node instanceof concepts_1.TypeAnnotation) {
|
|
1070
|
+
minRange.setTypeMethods = 'setTypeNamespace';
|
|
1071
|
+
const newValue = setTypeNamespace(minRange.node.typeNamespace, record);
|
|
1072
|
+
minRange.newValue = newValue;
|
|
1073
|
+
}
|
|
1074
|
+
else if (minRange.node instanceof concepts_1.QueryFromExpression || minRange.node instanceof concepts_1.QueryJoinExpression) {
|
|
1075
|
+
minRange.setTypeMethods = 'setEntityNamespace';
|
|
1076
|
+
const newValue = setTypeNamespace(minRange.node.entityNamespace, record);
|
|
1077
|
+
minRange.newValue = newValue;
|
|
1078
|
+
}
|
|
1079
|
+
else if (minRange.node instanceof concepts_1.QueryFieldExpression) {
|
|
1080
|
+
return null;
|
|
1081
|
+
}
|
|
1082
|
+
else if (minRange.node instanceof concepts_1.CallLogic) {
|
|
1083
|
+
minRange.setTypeMethods = 'setCalleeNamespace';
|
|
1084
|
+
const newValue = setTypeNamespace(minRange.node.calleeNamespace, record);
|
|
1085
|
+
minRange.newValue = newValue;
|
|
1086
|
+
}
|
|
1087
|
+
else if (minRange.node instanceof concepts_1.EntityProperty) {
|
|
1088
|
+
minRange.setTypeMethods = 'setRelationNamespace';
|
|
1089
|
+
const newValue = setTypeNamespace(minRange.node.relationNamespace, record);
|
|
1090
|
+
minRange.newValue = newValue;
|
|
1091
|
+
}
|
|
1092
|
+
else if (minRange.node instanceof concepts_1.SqlQueryComponent) {
|
|
1093
|
+
minRange.setTypeMethods = 'setDataSource';
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
if (minRange.node instanceof concepts_1.QueryGroupByExpression && node instanceof concepts_1.Entity) {
|
|
1097
|
+
minRange.setTypeMethods = 'setEntityAsName';
|
|
1098
|
+
}
|
|
896
1099
|
if ((minRange.node instanceof concepts_1.QueryFromExpression || minRange.node instanceof concepts_1.QueryJoinExpression) && node instanceof concepts_1.Entity) {
|
|
897
1100
|
minRange.setTypeMethods = 'setEntityName';
|
|
898
1101
|
}
|
|
899
1102
|
if (minRange.node instanceof concepts_1.QueryFieldExpression && node instanceof concepts_1.EntityProperty) {
|
|
900
1103
|
minRange.setTypeMethods = 'setPropertyName';
|
|
901
1104
|
}
|
|
1105
|
+
if (minRange.node instanceof concepts_1.QueryGroupByExpression && node instanceof concepts_1.EntityProperty) {
|
|
1106
|
+
minRange.setTypeMethods = 'setPropertyName';
|
|
1107
|
+
}
|
|
902
1108
|
// 如果跳转链接或者页面变量同一个param和TypeAnnotation 有两个过滤掉一个
|
|
903
|
-
if ((minRange.node instanceof concepts_1.Param || minRange.node instanceof concepts_1.Variable || minRange.node instanceof concepts_1.Return)
|
|
1109
|
+
if ((minRange.node instanceof concepts_1.Param || minRange.node instanceof concepts_1.Variable || minRange.node instanceof concepts_1.Return)
|
|
1110
|
+
&& (node instanceof concepts_1.Entity || node instanceof concepts_1.Enum || node instanceof concepts_1.Structure)) {
|
|
904
1111
|
return null;
|
|
905
1112
|
}
|
|
906
1113
|
if (minRange.node instanceof concepts_1.Destination && (node instanceof concepts_1.Process || node instanceof concepts_1.ProcessElement)) {
|
|
907
1114
|
return null;
|
|
908
1115
|
}
|
|
1116
|
+
if (minRange.node instanceof concepts_1.Assignee && (node instanceof concepts_1.Process || node instanceof concepts_1.ProcessElement)) {
|
|
1117
|
+
return null;
|
|
1118
|
+
}
|
|
909
1119
|
// 枚举修改枚举名,比较特殊
|
|
910
1120
|
if (minRange.node instanceof concepts_1.EnumItem && node instanceof concepts_1.Enum) {
|
|
911
1121
|
// 什么都不做,用来跳过修改
|
|
@@ -936,7 +1146,7 @@ const naslServer = {
|
|
|
936
1146
|
/**
|
|
937
1147
|
* 这里过滤一下,一些查找引用,重复的内容,直接屏蔽掉,防止操作重复
|
|
938
1148
|
* 因为在生成的时候 ,可能弄了一些副作用的引用
|
|
939
|
-
|
|
1149
|
+
*/
|
|
940
1150
|
// 本来是想在上面过滤一把的先放到这里匹配这两个的时候 就会找到
|
|
941
1151
|
// refsList = refsList.filter((item) => {
|
|
942
1152
|
// 屏蔽组件查找查到定义这里,也过滤一下
|
|
@@ -951,7 +1161,7 @@ const naslServer = {
|
|
|
951
1161
|
* 流程改名不触发Logic改名
|
|
952
1162
|
* 如果是修改param查找到logic就不操作
|
|
953
1163
|
* 除非想在内部修改别的内容所以暂时屏蔽掉
|
|
954
|
-
|
|
1164
|
+
*/
|
|
955
1165
|
if (minRange.node instanceof concepts_1.Logic && node !== minRange.node) {
|
|
956
1166
|
return null;
|
|
957
1167
|
}
|
|
@@ -967,18 +1177,9 @@ const naslServer = {
|
|
|
967
1177
|
console.log(result);
|
|
968
1178
|
return result;
|
|
969
1179
|
},
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
const parantNode = node
|
|
973
|
-
// 收集修改
|
|
974
|
-
App.emit('collect:start', {
|
|
975
|
-
actionMsg: '增加逻辑参数',
|
|
976
|
-
});
|
|
977
|
-
node.create({
|
|
978
|
-
index: 0,
|
|
979
|
-
parentNode: parantNode,
|
|
980
|
-
parentKey: node.parentKey,
|
|
981
|
-
});
|
|
1180
|
+
// 增加参数的副作用,用于更新logic和view
|
|
1181
|
+
_addParamsEffect(refsList, node) {
|
|
1182
|
+
const parantNode = node?.parentNode;
|
|
982
1183
|
refsList.forEach((record) => {
|
|
983
1184
|
const fileNode = this.file2NodeMap.get(record.file);
|
|
984
1185
|
if (!fileNode)
|
|
@@ -987,27 +1188,45 @@ const naslServer = {
|
|
|
987
1188
|
if (minRange) {
|
|
988
1189
|
// 如果找到节点是callLogic就去更新
|
|
989
1190
|
if (minRange.node instanceof concepts_1.CallLogic && node instanceof concepts_1.Param) {
|
|
990
|
-
minRange.node.setCalleeArgName(
|
|
1191
|
+
minRange.node.setCalleeArgName(parantNode);
|
|
991
1192
|
}
|
|
992
1193
|
// 如果节点参数增加页面也要更新
|
|
993
1194
|
if (minRange.node instanceof concepts_1.Destination && node instanceof concepts_1.Param) {
|
|
994
|
-
minRange.node.setViewArgument(
|
|
1195
|
+
minRange.node.setViewArgument(parantNode);
|
|
995
1196
|
}
|
|
996
1197
|
}
|
|
997
1198
|
});
|
|
998
|
-
|
|
999
|
-
|
|
1199
|
+
},
|
|
1200
|
+
_addParamsPrepare(node, refsList, needAdd) {
|
|
1201
|
+
if (needAdd) {
|
|
1202
|
+
const App = node?.rootNode;
|
|
1203
|
+
const parantNode = node?.parentNode;
|
|
1204
|
+
// 收集修改
|
|
1205
|
+
App.emit('collect:start', {
|
|
1206
|
+
actionMsg: '增加逻辑参数',
|
|
1207
|
+
});
|
|
1208
|
+
node.create({
|
|
1209
|
+
index: 0,
|
|
1210
|
+
parentNode: parantNode,
|
|
1211
|
+
parentKey: node.parentKey,
|
|
1212
|
+
});
|
|
1213
|
+
naslServer._addParamsEffect(refsList, node);
|
|
1214
|
+
// 结束修改 ,批量操作
|
|
1215
|
+
App.emit('collect:end');
|
|
1216
|
+
return node;
|
|
1217
|
+
}
|
|
1218
|
+
naslServer._addParamsEffect(refsList, node);
|
|
1219
|
+
return node;
|
|
1000
1220
|
},
|
|
1001
1221
|
// 查找引用
|
|
1002
1222
|
async findReferences(node) {
|
|
1003
1223
|
let refsList = await naslServer._isHaveRef(node);
|
|
1004
1224
|
// 如果查找引用查到自己里面的引用不展示
|
|
1005
|
-
refsList = refsList.filter((item) =>
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
});
|
|
1225
|
+
refsList = refsList.filter((item) =>
|
|
1226
|
+
// 自己引用自己的过滤掉
|
|
1227
|
+
// 删除的时候过滤一把组件删除提示
|
|
1228
|
+
// 展示组件自己屏蔽掉
|
|
1229
|
+
!item.isDefinition && !item.lineText.includes(' = new nasl.ui.'));
|
|
1011
1230
|
// 最后返回的结果
|
|
1012
1231
|
let result = new Map();
|
|
1013
1232
|
// 树的构造,key: 一个file的node, 值是 [[logic, params],[logic, returns]]
|
|
@@ -1040,14 +1259,15 @@ const naslServer = {
|
|
|
1040
1259
|
// 获取节点的上层渲染
|
|
1041
1260
|
_getTreeMap(minRange, fileNode, resMap, nodeMap) {
|
|
1042
1261
|
const minRangeNode = minRange.node;
|
|
1043
|
-
let
|
|
1262
|
+
let currentNode = minRangeNode;
|
|
1263
|
+
let parantNode = currentNode.parentNode;
|
|
1044
1264
|
// 顺序队列
|
|
1045
1265
|
const queue = [];
|
|
1046
1266
|
// 先插入自己,如果没有在往上找,
|
|
1047
1267
|
// 一直到file节点的父级
|
|
1048
1268
|
while (!(parantNode instanceof concepts_1.App)) {
|
|
1049
1269
|
// 找到上一级 在map对象中构造出他的子集
|
|
1050
|
-
|
|
1270
|
+
currentNode = parantNode;
|
|
1051
1271
|
parantNode = parantNode.parentNode;
|
|
1052
1272
|
// 如果第一次就塞入子集和父节点,以后就只用父节点了
|
|
1053
1273
|
// 因为部分节点没有name,先过滤掉
|
|
@@ -1094,12 +1314,12 @@ const naslServer = {
|
|
|
1094
1314
|
}
|
|
1095
1315
|
}
|
|
1096
1316
|
// 一个logic 或者 view可能会有多个顺序队列
|
|
1097
|
-
if (resMap.get(
|
|
1317
|
+
if (resMap.get(currentNode)) {
|
|
1098
1318
|
// 是否展示两个内容全等,但是两个queue的node可能不一样,但是只需要展示一个
|
|
1099
|
-
resMap.get(
|
|
1319
|
+
resMap.get(currentNode).push(queue);
|
|
1100
1320
|
}
|
|
1101
1321
|
else {
|
|
1102
|
-
resMap.set(
|
|
1322
|
+
resMap.set(currentNode, [queue]);
|
|
1103
1323
|
}
|
|
1104
1324
|
},
|
|
1105
1325
|
handleTreeMap(resMap) {
|
|
@@ -1166,8 +1386,14 @@ const naslServer = {
|
|
|
1166
1386
|
let sourceMap = node.sourceMap;
|
|
1167
1387
|
let fileNode = node;
|
|
1168
1388
|
// 如果没有sourceMap,就继续向上找 ,或者到module结束
|
|
1169
|
-
// 如果 节点找到 app 或者module 停止
|
|
1170
|
-
|
|
1389
|
+
// 如果 节点找到 app 或者module 停止 或者entity找到DataSource为止
|
|
1390
|
+
// 如果当前节点是view就不要向上查找了
|
|
1391
|
+
while (!sourceMap
|
|
1392
|
+
&& fileNode
|
|
1393
|
+
&& !(fileNode.parentNode instanceof concepts_1.App)
|
|
1394
|
+
&& !(fileNode.parentNode instanceof concepts_1.Module)
|
|
1395
|
+
&& !(fileNode.parentNode instanceof concepts_1.DataSource)
|
|
1396
|
+
&& !(fileNode instanceof concepts_1.View)) {
|
|
1171
1397
|
fileNode = fileNode.parentNode;
|
|
1172
1398
|
sourceMap = fileNode?.sourceMap;
|
|
1173
1399
|
}
|
|
@@ -1240,320 +1466,6 @@ async function handleDelete(fileNode, targetNode, result) {
|
|
|
1240
1466
|
await naslServer.updateFiles({ outputFiles });
|
|
1241
1467
|
newRefs.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
1242
1468
|
}
|
|
1243
|
-
concepts_1.BaseNode.prototype.findReadOnlyLogicUsage = function () {
|
|
1244
|
-
let targetNode;
|
|
1245
|
-
if (this.parentNode.concept === 'Namespace' || this.parentNode.parentNode.concept === 'Namespace') {
|
|
1246
|
-
const sourceMap = this.parentNode.concept === 'Namespace' ? this.parentNode.parentNode.sourceMap : this.parentNode.parentNode.parentNode.sourceMap;
|
|
1247
|
-
for (const item of sourceMap) {
|
|
1248
|
-
const logic = item[0];
|
|
1249
|
-
if (this.concept === 'Logic') {
|
|
1250
|
-
if (logic instanceof concepts_1.Logic)
|
|
1251
|
-
if (logic.calleewholeKey === this.calleewholeKey) {
|
|
1252
|
-
targetNode = logic;
|
|
1253
|
-
break;
|
|
1254
|
-
}
|
|
1255
|
-
}
|
|
1256
|
-
else {
|
|
1257
|
-
if (logic instanceof concepts_1.Logic)
|
|
1258
|
-
if (logic.calleewholeKey === this.parentNode.calleewholeKey) {
|
|
1259
|
-
targetNode = logic;
|
|
1260
|
-
break;
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
|
-
}
|
|
1264
|
-
}
|
|
1265
|
-
else if (this.parentNode.concept === 'Module') {
|
|
1266
|
-
// 父级是模块的还是用它本身去查找引用
|
|
1267
|
-
targetNode = this;
|
|
1268
|
-
}
|
|
1269
|
-
else {
|
|
1270
|
-
const sourceMap = this.parentNode.sourceMap;
|
|
1271
|
-
for (const item of sourceMap) {
|
|
1272
|
-
const logic = item[0];
|
|
1273
|
-
if (logic.getNamespace && logic.getNamespace() === this.getNamespace()) {
|
|
1274
|
-
targetNode = logic;
|
|
1275
|
-
break;
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
try {
|
|
1280
|
-
return naslServer.findReferences(targetNode);
|
|
1281
|
-
}
|
|
1282
|
-
catch (err) {
|
|
1283
|
-
console.log(err);
|
|
1284
|
-
}
|
|
1285
|
-
};
|
|
1286
|
-
// 查找引用
|
|
1287
|
-
concepts_1.BaseNode.prototype.findUsage = function findUsage() {
|
|
1288
|
-
try {
|
|
1289
|
-
return naslServer.findReferences(this);
|
|
1290
|
-
}
|
|
1291
|
-
catch (err) {
|
|
1292
|
-
console.log(err);
|
|
1293
|
-
}
|
|
1294
|
-
};
|
|
1295
|
-
concepts_1.BaseNode.prototype.changeName = async function changeName(newValue, updateAll = false) {
|
|
1296
|
-
console.log(newValue);
|
|
1297
|
-
console.log(this);
|
|
1298
|
-
try {
|
|
1299
|
-
/**
|
|
1300
|
-
* 查找这个节点是不是有依赖
|
|
1301
|
-
*/
|
|
1302
|
-
const refsList = await naslServer._isHaveRef(this);
|
|
1303
|
-
// 是不是有引用有的话,就返回
|
|
1304
|
-
/**
|
|
1305
|
-
* @param this 当前重命名的节点
|
|
1306
|
-
* @param newValue 传递过来的新值,给MemberExpression用的比较特殊
|
|
1307
|
-
* 而且,这个新值不一定会用到,MemberExpression在批量更新的时候,可以取到新的value, 这里需要位置信息防止 a.a.a.a 中的一个a发生修改
|
|
1308
|
-
* @returns 找到的引用
|
|
1309
|
-
*/
|
|
1310
|
-
const res = naslServer._renamePrepare(this, refsList, newValue);
|
|
1311
|
-
if (res.length <= 1) {
|
|
1312
|
-
this.setName(newValue);
|
|
1313
|
-
}
|
|
1314
|
-
else {
|
|
1315
|
-
const callback = (value) => {
|
|
1316
|
-
if (value) {
|
|
1317
|
-
const App = this.rootNode;
|
|
1318
|
-
// 收集修改
|
|
1319
|
-
App.emit('collect:start', {
|
|
1320
|
-
actionMsg: '重命名并更新引用',
|
|
1321
|
-
});
|
|
1322
|
-
res.forEach((item) => {
|
|
1323
|
-
const itemNode = item.node;
|
|
1324
|
-
if (item.newValue) {
|
|
1325
|
-
// 如果有指定的修改方法,就用那个,没有就修改名字
|
|
1326
|
-
item.setTypeMethods ? itemNode[item.setTypeMethods](item.newValue) : itemNode.setName?.(item.newValue);
|
|
1327
|
-
}
|
|
1328
|
-
else {
|
|
1329
|
-
item.setTypeMethods ? itemNode[item.setTypeMethods](newValue) : itemNode.setName?.(newValue);
|
|
1330
|
-
}
|
|
1331
|
-
});
|
|
1332
|
-
// 结束修改 ,批量操作
|
|
1333
|
-
App.emit('collect:end');
|
|
1334
|
-
}
|
|
1335
|
-
else {
|
|
1336
|
-
this.setName(newValue);
|
|
1337
|
-
}
|
|
1338
|
-
};
|
|
1339
|
-
const confirmParms = {
|
|
1340
|
-
actionType: 'rename',
|
|
1341
|
-
node: this,
|
|
1342
|
-
newValue,
|
|
1343
|
-
};
|
|
1344
|
-
/**
|
|
1345
|
-
* nasl和vue的通信,回退,要触发vue的watch。
|
|
1346
|
-
* 因为如果没修改的话nasl不会修改view,就不会通知到页面改成旧值
|
|
1347
|
-
* 先修改之
|
|
1348
|
-
*/
|
|
1349
|
-
const closeCallBack = () => {
|
|
1350
|
-
if (this.concept === 'EnumItem') {
|
|
1351
|
-
const oldValue = this.value;
|
|
1352
|
-
this.value = oldValue + ' ';
|
|
1353
|
-
setTimeout(() => {
|
|
1354
|
-
this.value = oldValue;
|
|
1355
|
-
}, 0);
|
|
1356
|
-
}
|
|
1357
|
-
else {
|
|
1358
|
-
const oldValue = this.name;
|
|
1359
|
-
this.name = oldValue + ' ';
|
|
1360
|
-
setTimeout(() => {
|
|
1361
|
-
this.name = oldValue;
|
|
1362
|
-
}, 0);
|
|
1363
|
-
}
|
|
1364
|
-
};
|
|
1365
|
-
updateAll ? callback(true) : (0, common_1.invokeCommand)('tsConfirm.open', confirmParms, callback, closeCallBack);
|
|
1366
|
-
return;
|
|
1367
|
-
}
|
|
1368
|
-
}
|
|
1369
|
-
catch (err) {
|
|
1370
|
-
console.log(err);
|
|
1371
|
-
}
|
|
1372
|
-
};
|
|
1373
|
-
/**
|
|
1374
|
-
* 准备删除
|
|
1375
|
-
*/
|
|
1376
|
-
concepts_1.BaseNode.prototype.prepareDelete = async function prepareDelete() {
|
|
1377
|
-
try {
|
|
1378
|
-
/**
|
|
1379
|
-
* 查找这个节点是不是有依赖
|
|
1380
|
-
*/
|
|
1381
|
-
const node = this;
|
|
1382
|
-
let refsList = await naslServer._isHaveRef(node);
|
|
1383
|
-
// 删除的时候过滤一把组件删除提示
|
|
1384
|
-
refsList = refsList.filter((item) => {
|
|
1385
|
-
// 因为ui组件本身会多渲染一次,就先过滤一个
|
|
1386
|
-
return !(item.lineText.includes(': nasl.ui.'));
|
|
1387
|
-
});
|
|
1388
|
-
// 删除参数单独处理
|
|
1389
|
-
if (node instanceof concepts_1.Param) {
|
|
1390
|
-
const methodRefs = [];
|
|
1391
|
-
refsList.forEach((item) => {
|
|
1392
|
-
// 入参查找引用,查到logic 和自己,内容完全一样,就保留一个
|
|
1393
|
-
const find = methodRefs.find((findItem) => item.lineText === findItem.lineText);
|
|
1394
|
-
if (!find) {
|
|
1395
|
-
methodRefs.push(item);
|
|
1396
|
-
}
|
|
1397
|
-
});
|
|
1398
|
-
refsList = methodRefs;
|
|
1399
|
-
}
|
|
1400
|
-
// delete的弹框展示
|
|
1401
|
-
const confirmParms = {
|
|
1402
|
-
actionType: 'delete',
|
|
1403
|
-
tipFlag: false,
|
|
1404
|
-
node,
|
|
1405
|
-
icon: 'warning',
|
|
1406
|
-
};
|
|
1407
|
-
let callback = null;
|
|
1408
|
-
if (refsList.length <= 1) {
|
|
1409
|
-
// 页面组件直接删除然后return
|
|
1410
|
-
if (node instanceof concepts_1.ViewElement) {
|
|
1411
|
-
this.delete();
|
|
1412
|
-
return;
|
|
1413
|
-
}
|
|
1414
|
-
callback = () => {
|
|
1415
|
-
// Structure 和 Interface是内部有delete方法
|
|
1416
|
-
if (node instanceof concepts_1.Structure || node instanceof concepts_1.Interface) {
|
|
1417
|
-
this.deleteLogincAndModule();
|
|
1418
|
-
}
|
|
1419
|
-
else {
|
|
1420
|
-
this.delete();
|
|
1421
|
-
}
|
|
1422
|
-
};
|
|
1423
|
-
}
|
|
1424
|
-
else {
|
|
1425
|
-
// 如果有依赖就有一个查找引用提示
|
|
1426
|
-
confirmParms.tipFlag = true;
|
|
1427
|
-
const node = this;
|
|
1428
|
-
// 删除页面或者流程
|
|
1429
|
-
if (node instanceof concepts_1.View || node instanceof concepts_1.Process) {
|
|
1430
|
-
/**
|
|
1431
|
-
* 查找这个页面是不是有依赖
|
|
1432
|
-
*/
|
|
1433
|
-
let viewPath = this.getEmbeddedFilePath();
|
|
1434
|
-
viewPath = viewPath.slice(0, viewPath.length - 3);
|
|
1435
|
-
const find = refsList.find((record) => !record.file.includes(viewPath));
|
|
1436
|
-
// 如果没有别的文件的依赖,就直接delete
|
|
1437
|
-
if (!find) {
|
|
1438
|
-
this.delete();
|
|
1439
|
-
return;
|
|
1440
|
-
}
|
|
1441
|
-
}
|
|
1442
|
-
callback = () => {
|
|
1443
|
-
// removeParam
|
|
1444
|
-
// 跟rename 还不太一样,部分修改依赖修改好的值,然后在下面的修改需要把自己传递进去
|
|
1445
|
-
if (node instanceof concepts_1.Param) {
|
|
1446
|
-
const App = this.rootNode;
|
|
1447
|
-
const parentNode = this.parentNode;
|
|
1448
|
-
// 收集修改
|
|
1449
|
-
App.emit('collect:start', {
|
|
1450
|
-
actionMsg: '删除参数',
|
|
1451
|
-
});
|
|
1452
|
-
this.delete();
|
|
1453
|
-
refsList.forEach((record) => {
|
|
1454
|
-
const fileNode = naslServer.file2NodeMap.get(record.file);
|
|
1455
|
-
if (!fileNode)
|
|
1456
|
-
return null;
|
|
1457
|
-
const minRange = naslServer._findMinRange(record, fileNode);
|
|
1458
|
-
if (minRange) {
|
|
1459
|
-
if (minRange.node instanceof concepts_1.CallLogic) {
|
|
1460
|
-
minRange.node.setCalleeArgName(parentNode);
|
|
1461
|
-
}
|
|
1462
|
-
if (minRange.node instanceof concepts_1.Destination) {
|
|
1463
|
-
minRange.node.setViewArgument(parentNode);
|
|
1464
|
-
}
|
|
1465
|
-
}
|
|
1466
|
-
});
|
|
1467
|
-
// 结束修改 ,批量操作
|
|
1468
|
-
App.emit('collect:end');
|
|
1469
|
-
return;
|
|
1470
|
-
}
|
|
1471
|
-
// 删除logic节点,如果有对应的interface要一起删除
|
|
1472
|
-
if (node instanceof concepts_1.Logic) {
|
|
1473
|
-
const App = this.rootNode;
|
|
1474
|
-
// 收集修改
|
|
1475
|
-
App.emit('collect:start', {
|
|
1476
|
-
actionMsg: '删除逻辑并删除导出的接口',
|
|
1477
|
-
});
|
|
1478
|
-
this.delete();
|
|
1479
|
-
refsList.forEach((record) => {
|
|
1480
|
-
const fileNode = naslServer.file2NodeMap.get(record.file);
|
|
1481
|
-
if (!fileNode)
|
|
1482
|
-
return null;
|
|
1483
|
-
const minRange = naslServer._findMinRange(record, fileNode);
|
|
1484
|
-
if (minRange) {
|
|
1485
|
-
if (minRange.node instanceof concepts_1.Interface) {
|
|
1486
|
-
minRange.node.delete();
|
|
1487
|
-
}
|
|
1488
|
-
}
|
|
1489
|
-
});
|
|
1490
|
-
// 结束修改 ,批量操作
|
|
1491
|
-
App.emit('collect:end');
|
|
1492
|
-
return;
|
|
1493
|
-
}
|
|
1494
|
-
// 删除权限节点
|
|
1495
|
-
if (node instanceof concepts_1.Role) {
|
|
1496
|
-
const App = this.rootNode;
|
|
1497
|
-
// 收集修改
|
|
1498
|
-
App.emit('collect:start', {
|
|
1499
|
-
actionMsg: '删除权限',
|
|
1500
|
-
});
|
|
1501
|
-
this.delete();
|
|
1502
|
-
refsList.forEach((record) => {
|
|
1503
|
-
const fileNode = naslServer.file2NodeMap.get(record.file);
|
|
1504
|
-
if (!fileNode)
|
|
1505
|
-
return null;
|
|
1506
|
-
const minRange = naslServer._findMinRange(record, fileNode);
|
|
1507
|
-
if (minRange) {
|
|
1508
|
-
if (minRange.node instanceof concepts_1.View || minRange.node instanceof concepts_1.ViewElement) {
|
|
1509
|
-
// oldName旧的节点存的值
|
|
1510
|
-
// newValue用户输入值
|
|
1511
|
-
// node.bindRoles 存的
|
|
1512
|
-
const str = minRange.node.bindRoles.toString().replace(this.name, '');
|
|
1513
|
-
const newBindRoles = str.split(',').filter((item) => !!item);
|
|
1514
|
-
minRange.node.setBindRoles(newBindRoles);
|
|
1515
|
-
}
|
|
1516
|
-
}
|
|
1517
|
-
});
|
|
1518
|
-
// 结束修改 ,批量操作
|
|
1519
|
-
App.emit('collect:end');
|
|
1520
|
-
return;
|
|
1521
|
-
}
|
|
1522
|
-
// 删除页面或者流程,如果上一步没有return 就说明他是有别的引用的,会有引用弹框
|
|
1523
|
-
if (node instanceof concepts_1.View || node instanceof concepts_1.Process) {
|
|
1524
|
-
this.delete();
|
|
1525
|
-
}
|
|
1526
|
-
// 其余的都直接调用删除
|
|
1527
|
-
// Structure 和 Interface是内部有delete方法
|
|
1528
|
-
if (node instanceof concepts_1.Structure || node instanceof concepts_1.Interface) {
|
|
1529
|
-
this.deleteLogincAndModule();
|
|
1530
|
-
}
|
|
1531
|
-
else {
|
|
1532
|
-
this.delete();
|
|
1533
|
-
}
|
|
1534
|
-
};
|
|
1535
|
-
}
|
|
1536
|
-
(0, common_1.invokeCommand)('tsConfirm.open', confirmParms, callback);
|
|
1537
|
-
}
|
|
1538
|
-
catch (err) {
|
|
1539
|
-
console.log(err);
|
|
1540
|
-
}
|
|
1541
|
-
};
|
|
1542
|
-
/**
|
|
1543
|
-
* 如果添加需要触发查找引用并且在之后,对内容产生影响
|
|
1544
|
-
*/
|
|
1545
|
-
concepts_1.BaseNode.prototype.addParamsPrepare = async function addParamsPrepare() {
|
|
1546
|
-
try {
|
|
1547
|
-
/**
|
|
1548
|
-
* 查找这个节点是不是有依赖
|
|
1549
|
-
*/
|
|
1550
|
-
const refsList = await naslServer._isHaveRef(this);
|
|
1551
|
-
return naslServer._addParamsPrepare(this, refsList);
|
|
1552
|
-
}
|
|
1553
|
-
catch (err) {
|
|
1554
|
-
console.log(err);
|
|
1555
|
-
}
|
|
1556
|
-
};
|
|
1557
1469
|
/**
|
|
1558
1470
|
* 除去rename场景下的更新
|
|
1559
1471
|
* @param fileNode 文件级别的节点
|
|
@@ -1676,6 +1588,7 @@ async function incidentalAction(action, fileNode, targetNode, oldpath) {
|
|
|
1676
1588
|
for (let i = 0; i < fileNodeChildren.length; i++) {
|
|
1677
1589
|
const fileNodeItem = fileNodeChildren[i];
|
|
1678
1590
|
const result = fileNodeItem.toEmbeddedTSFile();
|
|
1591
|
+
fileNodeItem.sourceMap = result.sourceMap;
|
|
1679
1592
|
if (action === 'create') {
|
|
1680
1593
|
await handleChange(fileNodeItem, fileNodeItem, result, action);
|
|
1681
1594
|
await incidentalAction(action, fileNodeItem, fileNodeItem);
|
|
@@ -1692,12 +1605,14 @@ async function incidentalAction(action, fileNode, targetNode, oldpath) {
|
|
|
1692
1605
|
await incidentalAction(action, fileNodeItem, fileNodeItem, currentOldPath);
|
|
1693
1606
|
}
|
|
1694
1607
|
}
|
|
1695
|
-
;
|
|
1696
1608
|
}
|
|
1697
1609
|
// 删除或新增模块
|
|
1698
1610
|
// 需要把下面的哦内容全部都更新一遍
|
|
1699
1611
|
if (fileNode instanceof concepts_1.Module) {
|
|
1700
|
-
|
|
1612
|
+
if (fileNode.type === 'interface' && fileNode.isAdd && action === 'create') {
|
|
1613
|
+
isChangeInterface = true;
|
|
1614
|
+
}
|
|
1615
|
+
const module = targetNode;
|
|
1701
1616
|
const results = [];
|
|
1702
1617
|
naslServer.contentToFile(module, results);
|
|
1703
1618
|
for (let i = 0; i < results.length; i++) {
|
|
@@ -1710,7 +1625,6 @@ async function incidentalAction(action, fileNode, targetNode, oldpath) {
|
|
|
1710
1625
|
await handleDelete(node, node, result);
|
|
1711
1626
|
}
|
|
1712
1627
|
}
|
|
1713
|
-
;
|
|
1714
1628
|
// 删除模块通知更新列表
|
|
1715
1629
|
if (action === 'delete') {
|
|
1716
1630
|
try {
|
|
@@ -1722,6 +1636,23 @@ async function incidentalAction(action, fileNode, targetNode, oldpath) {
|
|
|
1722
1636
|
}
|
|
1723
1637
|
}
|
|
1724
1638
|
}
|
|
1639
|
+
/**
|
|
1640
|
+
* DataSource只会重命名时候,需要把子集全部重新生成一下
|
|
1641
|
+
*/
|
|
1642
|
+
if (fileNode instanceof concepts_1.DataSource) {
|
|
1643
|
+
fileNode.entities.forEach(async (entity) => {
|
|
1644
|
+
try {
|
|
1645
|
+
const result = entity.toEmbeddedTSFile();
|
|
1646
|
+
const parentPath = oldpath.replace('.ts', '/');
|
|
1647
|
+
const currentOldPath = parentPath + '/entities/' + entity.name + '.ts';
|
|
1648
|
+
// 因为重命名这里只有当前修改父级的 旧名称, 所以他的子集也要根据旧名称去查依赖 更新内容
|
|
1649
|
+
await handleRename(entity, entity, result, currentOldPath);
|
|
1650
|
+
}
|
|
1651
|
+
catch (err) {
|
|
1652
|
+
console.log(err);
|
|
1653
|
+
}
|
|
1654
|
+
});
|
|
1655
|
+
}
|
|
1725
1656
|
}
|
|
1726
1657
|
}
|
|
1727
1658
|
async function receiveHandleChange($event) {
|