@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/src/server/naslServer.ts
CHANGED
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
QueryFromExpression,
|
|
24
24
|
QueryJoinExpression,
|
|
25
25
|
QueryFieldExpression,
|
|
26
|
+
QueryGroupByExpression,
|
|
26
27
|
Identifier,
|
|
27
28
|
CallLogic,
|
|
28
29
|
EnumItem,
|
|
@@ -43,6 +44,9 @@ import {
|
|
|
43
44
|
Namespace,
|
|
44
45
|
Theme,
|
|
45
46
|
Variable,
|
|
47
|
+
DataSource,
|
|
48
|
+
Assignee,
|
|
49
|
+
SqlQueryComponent,
|
|
46
50
|
} from '../concepts';
|
|
47
51
|
import { lsp2tspNumber, SourceMap, SourceMapItem, embeddedTSEmitter } from '../translator';
|
|
48
52
|
import axios from '../service/storage';
|
|
@@ -51,6 +55,7 @@ import { EventPayload, invokeCommand, registerCommand } from '../common';
|
|
|
51
55
|
import { DiagnosticRecord, Diagnostic, default as diagnosticManager } from '../manager/diagnostic';
|
|
52
56
|
import formatUiTs from './createUiTs';
|
|
53
57
|
import { primitiveTypeList } from '../concepts/basics/types/coreTypeList';
|
|
58
|
+
import { traverse } from '../utils';
|
|
54
59
|
|
|
55
60
|
const EmbeddedTSFileLineMap: { [name: string]: number } = {
|
|
56
61
|
Entity: 3,
|
|
@@ -58,7 +63,7 @@ const EmbeddedTSFileLineMap: { [name: string]: number } = {
|
|
|
58
63
|
// 要Check的文件
|
|
59
64
|
const filesToCheck: Set<string> = new Set();
|
|
60
65
|
|
|
61
|
-
interface FileNode extends BaseNode {
|
|
66
|
+
export interface FileNode extends BaseNode {
|
|
62
67
|
getEmbeddedFilePath(name?: string): string;
|
|
63
68
|
toEmbeddedTSFile(): {
|
|
64
69
|
code: string;
|
|
@@ -86,7 +91,7 @@ const messager = new Messager({
|
|
|
86
91
|
},
|
|
87
92
|
});
|
|
88
93
|
|
|
89
|
-
interface
|
|
94
|
+
interface RenameMinRange extends MinRange {
|
|
90
95
|
newValue?: any;
|
|
91
96
|
setTypeMethods?: string;
|
|
92
97
|
}
|
|
@@ -97,6 +102,10 @@ interface QuoteNode {
|
|
|
97
102
|
expanded: boolean;
|
|
98
103
|
children?: QuoteNode[];
|
|
99
104
|
}
|
|
105
|
+
let isChangeInterface = false; //判断是否导入接口
|
|
106
|
+
type ActionNode = { target: Variable; typeannotation: TypeAnnotation };
|
|
107
|
+
let actionArr: Array<ActionNode> = []; //用于导入接口收集更改的节点
|
|
108
|
+
let timer: number = null; //超时器用于收集导入接口相关
|
|
100
109
|
const naslServer = {
|
|
101
110
|
messager,
|
|
102
111
|
worker,
|
|
@@ -139,17 +148,30 @@ const naslServer = {
|
|
|
139
148
|
console.log(err);
|
|
140
149
|
}
|
|
141
150
|
});
|
|
142
|
-
module.
|
|
151
|
+
(module as App).dataSources?.forEach((dataSource) => {
|
|
152
|
+
// 本身dataSource也要生成一个文件用于改名
|
|
143
153
|
try {
|
|
144
|
-
const result =
|
|
154
|
+
const result = dataSource.toEmbeddedTSFile();
|
|
145
155
|
results.push(result);
|
|
146
156
|
// sourceMap都存在目录级别内容下,在页面层级下去找
|
|
147
|
-
|
|
148
|
-
this.file2NodeMap.set(result.filePath,
|
|
157
|
+
dataSource.sourceMap = result.sourceMap;
|
|
158
|
+
this.file2NodeMap.set(result.filePath, dataSource);
|
|
149
159
|
} catch (err) {
|
|
150
160
|
console.log(err);
|
|
151
161
|
}
|
|
162
|
+
dataSource.entities.forEach((entity) => {
|
|
163
|
+
try {
|
|
164
|
+
const result = entity.toEmbeddedTSFile();
|
|
165
|
+
results.push(result);
|
|
166
|
+
// sourceMap都存在目录级别内容下,在页面层级下去找
|
|
167
|
+
entity.sourceMap = result.sourceMap;
|
|
168
|
+
this.file2NodeMap.set(result.filePath, entity);
|
|
169
|
+
} catch (err) {
|
|
170
|
+
console.log(err);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
152
173
|
});
|
|
174
|
+
|
|
153
175
|
module.interfaces.forEach((_interface) => {
|
|
154
176
|
try {
|
|
155
177
|
const result = _interface.toEmbeddedTSFile();
|
|
@@ -377,28 +399,34 @@ const naslServer = {
|
|
|
377
399
|
* fileNode
|
|
378
400
|
*/
|
|
379
401
|
const { currentSource, fileNode } = naslServer.getCurrentSource(callFunction);
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
if (quickInfo.responseRequired) {
|
|
386
|
-
const displayString = quickInfo?.response?.displayString || '';
|
|
387
|
-
const typeList = naslServer.getDisplayString2Type(displayString);
|
|
388
|
-
let res: Array<TypeAnnotation> = [];
|
|
389
|
-
typeList.forEach((type) => {
|
|
390
|
-
const typeAnnotation = primitiveTypeList.find((typeAnnotation) => typeAnnotation.typeName === type);
|
|
391
|
-
if (typeAnnotation) {
|
|
392
|
-
res.push(typeAnnotation);
|
|
393
|
-
} else if (type === 'unknown' || type === 'never') {
|
|
394
|
-
return null;
|
|
395
|
-
}
|
|
402
|
+
try {
|
|
403
|
+
const quickInfo = await naslServer._getTypeQuickinfo({
|
|
404
|
+
file: (fileNode as FileNode).getEmbeddedFilePath(),
|
|
405
|
+
line: lsp2tspNumber(currentSource.range.start.line),
|
|
406
|
+
offset: lsp2tspNumber(currentSource.range.start.character) + `nasl.util.C`.length,
|
|
396
407
|
});
|
|
397
|
-
if (
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
408
|
+
if (quickInfo.responseRequired) {
|
|
409
|
+
const displayString = quickInfo?.response?.displayString || '';
|
|
410
|
+
const typeList = naslServer.getDisplayString2Type(displayString);
|
|
411
|
+
const res: Array<TypeAnnotation> = [];
|
|
412
|
+
typeList.forEach((type) => {
|
|
413
|
+
const typeAnnotation = primitiveTypeList.find((typeAnnotation) => typeAnnotation.typeName === type);
|
|
414
|
+
if (typeAnnotation) {
|
|
415
|
+
res.push(typeAnnotation);
|
|
416
|
+
} else if (type === 'unknown' || type === 'never') {
|
|
417
|
+
return null;
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
if (!res.length) {
|
|
421
|
+
return [];
|
|
422
|
+
} else {
|
|
423
|
+
return [{ title: '基础类型', children: res }];
|
|
424
|
+
}
|
|
401
425
|
}
|
|
426
|
+
} catch (err) {
|
|
427
|
+
console.log(err);
|
|
428
|
+
// 如果有异常就先放开全部可选,兜底逻辑
|
|
429
|
+
return [];
|
|
402
430
|
}
|
|
403
431
|
} else {
|
|
404
432
|
// 字符串 和 inter
|
|
@@ -472,11 +500,14 @@ const naslServer = {
|
|
|
472
500
|
oldRecord?.semanticDiagnostics.forEach((item) => {
|
|
473
501
|
item.node ? (item.node.tsErrorDetail = undefined) : '';
|
|
474
502
|
});
|
|
475
|
-
|
|
476
503
|
// 语义诊断
|
|
504
|
+
if (isChangeInterface) {
|
|
505
|
+
this.existStructureFix(record.semanticDiagnostics, node as FileNode, this);
|
|
506
|
+
}
|
|
477
507
|
record.semanticDiagnostics = record.semanticDiagnostics
|
|
478
508
|
.map((diag) => this._resolveDiagnostic(diag as unknown as tsProtocol.DiagnosticWithFileName, node as FileNode))
|
|
479
509
|
.filter((diag) => !!diag);
|
|
510
|
+
record.semanticDiagnostics.push(...this._attachDiagnostics(node));
|
|
480
511
|
|
|
481
512
|
// 建议诊断
|
|
482
513
|
// 实体下的建议不用展示,因为都是平台自己写的逻辑
|
|
@@ -497,8 +528,113 @@ const naslServer = {
|
|
|
497
528
|
record.suggestionDiagnostics = [];
|
|
498
529
|
// 语法诊断暂时不需要
|
|
499
530
|
});
|
|
531
|
+
|
|
500
532
|
return records;
|
|
501
533
|
},
|
|
534
|
+
_attachDiagnostics(fileNode: BaseNode): Diagnostic[] {
|
|
535
|
+
const diagnostics: Diagnostic[] = [];
|
|
536
|
+
if (fileNode instanceof View) {
|
|
537
|
+
traverse((current) => {
|
|
538
|
+
if (current.node.tag) {
|
|
539
|
+
current.node.bindAttrs.forEach((bindAttr) => {
|
|
540
|
+
if ((bindAttr.model || bindAttr.sync) && bindAttr.expression && bindAttr.expression.concept !== 'Identifier' && bindAttr.expression.concept !== 'MemberExpression') {
|
|
541
|
+
const diagnostic = {
|
|
542
|
+
node: bindAttr,
|
|
543
|
+
severity: 'error',
|
|
544
|
+
message: '页面元素双向绑定:只允许绑定可赋值的变量和字段。',
|
|
545
|
+
};
|
|
546
|
+
bindAttr.tsErrorDetail = diagnostic;
|
|
547
|
+
diagnostics.push(diagnostic);
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
}, { node: { children: fileNode.elements } as ViewElement });
|
|
552
|
+
}
|
|
553
|
+
if (fileNode instanceof DataSource) {
|
|
554
|
+
const dataSourceGroup = (fileNode.rootNode as App).configuration?.getGroup('dataSource');
|
|
555
|
+
if (dataSourceGroup) {
|
|
556
|
+
const property = dataSourceGroup.getProperty(fileNode.name);
|
|
557
|
+
if (property && property.values) {
|
|
558
|
+
property.values.forEach((propertyValue) => {
|
|
559
|
+
if (!propertyValue.value && fileNode.name !== 'defaultDS') {
|
|
560
|
+
const diagnostic = {
|
|
561
|
+
node: fileNode,
|
|
562
|
+
severity: 'error',
|
|
563
|
+
message: `数据源配置:数据源${property.name}${propertyValue.env === 'dev' ? '开发环境' : '生产环境'}未配置数据信息`,
|
|
564
|
+
// 保留原来的内容方便查询一些问题
|
|
565
|
+
originalDiagnostic: {
|
|
566
|
+
fileName: '',
|
|
567
|
+
start: <any>null,
|
|
568
|
+
end: <any>null,
|
|
569
|
+
category: 'error',
|
|
570
|
+
text: `Data Source is not config`,
|
|
571
|
+
},
|
|
572
|
+
};
|
|
573
|
+
diagnostics.push(diagnostic);
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
return diagnostics;
|
|
581
|
+
},
|
|
582
|
+
/* 接口导入查找 */
|
|
583
|
+
existStructureFix(semanticDiagnostics: Diagnostic[], node: FileNode, that: any) {
|
|
584
|
+
let module: Module;
|
|
585
|
+
semanticDiagnostics.map((diag) => {
|
|
586
|
+
const minRange = this._findMinRange(diag as unknown as tsProtocol.DiagnosticWithFileName, node);
|
|
587
|
+
if (diag.text?.includes('has no exported member named')) {
|
|
588
|
+
if (minRange.node instanceof Logic) {
|
|
589
|
+
return null;
|
|
590
|
+
}
|
|
591
|
+
const typeAnnotation = minRange.node instanceof TypeAnnotation ? (minRange.node.upperNode as Variable).typeAnnotation : (minRange.node as Variable).typeAnnotation;
|
|
592
|
+
const regNamespace = /<(\S*)>/;
|
|
593
|
+
const typeKey = (typeAnnotation.typeKey.match(regNamespace) && typeAnnotation.typeKey.match(regNamespace)[1]) || typeAnnotation.typeKey;
|
|
594
|
+
const typeKeyArr = typeKey.split('.');
|
|
595
|
+
if (typeKeyArr[0] === 'apis') {
|
|
596
|
+
const structureName = typeKeyArr[3];
|
|
597
|
+
const moduleName = typeKeyArr[1];
|
|
598
|
+
const app = (typeAnnotation.upperNode as Variable).app;
|
|
599
|
+
if (!app) {
|
|
600
|
+
return null;
|
|
601
|
+
}
|
|
602
|
+
module = app.interfaceDependencies?.find((item) => item.name === moduleName);
|
|
603
|
+
let existStructure = module?.structures?.find((item) => item.name.toUpperCase() === structureName.toUpperCase());
|
|
604
|
+
if (!existStructure) {
|
|
605
|
+
const realName = structureName.replace(/\d*$/, (m) => String(''));
|
|
606
|
+
existStructure = module?.structures?.find((item) => item.name.toUpperCase() === realName.toUpperCase());
|
|
607
|
+
}
|
|
608
|
+
if (existStructure) {
|
|
609
|
+
const editTypeAnnotation = JSON.parse(JSON.stringify(typeAnnotation).replace(new RegExp(structureName, 'g'), existStructure.name));
|
|
610
|
+
actionArr.push({ target: typeAnnotation.parentNode as Variable, typeannotation: editTypeAnnotation });
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
return null;
|
|
614
|
+
} else {
|
|
615
|
+
return diag;
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
if (actionArr.length) {
|
|
619
|
+
if (timer)
|
|
620
|
+
return;
|
|
621
|
+
timer = window.setTimeout(() => {
|
|
622
|
+
const app = actionArr[0].target.app;
|
|
623
|
+
app.emit('collect:start', {
|
|
624
|
+
actionMsg: '设置导入接口数据类型错误',
|
|
625
|
+
});
|
|
626
|
+
module.isAdd && module.setIsAdd(false);
|
|
627
|
+
actionArr.forEach((item) => {
|
|
628
|
+
item.target.setDataType(TypeAnnotation.from(item.typeannotation));
|
|
629
|
+
});
|
|
630
|
+
app.emit('collect:end');
|
|
631
|
+
actionArr = [];
|
|
632
|
+
isChangeInterface = false;
|
|
633
|
+
clearTimeout(timer);
|
|
634
|
+
timer = null;
|
|
635
|
+
}, 2000);
|
|
636
|
+
}
|
|
637
|
+
},
|
|
502
638
|
_resolveDiagnostic(diagnostic: tsProtocol.DiagnosticWithFileName, fileNode: FileNode): Diagnostic {
|
|
503
639
|
const minRange = this._findMinRange(diagnostic, fileNode);
|
|
504
640
|
const tsErrorDetail = {
|
|
@@ -592,6 +728,33 @@ const naslServer = {
|
|
|
592
728
|
}
|
|
593
729
|
}
|
|
594
730
|
|
|
731
|
+
// 如果是DataSource就需要在单独,查一边来修改名字
|
|
732
|
+
if (node instanceof DataSource) {
|
|
733
|
+
// 过滤一把不需要改的信息
|
|
734
|
+
refsList = refsList.filter((item) => {
|
|
735
|
+
const dataSourceFile = (fileNode as FileNode).getEmbeddedFilePath();
|
|
736
|
+
const entityFilePrefix = dataSourceFile.replace('.ts', '');
|
|
737
|
+
/**
|
|
738
|
+
* 特殊处理,因为关联属性或者关联实体等等都是在实体里,在实体中因为自己不可以是自己的类型
|
|
739
|
+
* 所以全部过滤掉了,
|
|
740
|
+
* 但是在datasource里面在实体里会有大量的引用,不需要全部修改.只需要处理除了8个函数之外的引用
|
|
741
|
+
* 所以底部内容是8个函数,所以这里就 用entity的行数 减去8个函数的行数,然后其余的在进行处理
|
|
742
|
+
* 进行过滤
|
|
743
|
+
*/
|
|
744
|
+
// 不要数据源下面的实体里的引用 ,保留原始的节点内容
|
|
745
|
+
let flag = false;
|
|
746
|
+
if (item.file.includes(entityFilePrefix)) {
|
|
747
|
+
const entity = this.file2NodeMap.get(item.file);
|
|
748
|
+
const { currentSource } = naslServer.getCurrentSource(entity);
|
|
749
|
+
// 32 8个函数的总行数
|
|
750
|
+
if (item.end.line < currentSource.range.end.line - 32 && item.start.line > 1) {
|
|
751
|
+
flag = true;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
// 属于实体而且需要修改和查到 || 不是实体前缀的 || 他本身
|
|
755
|
+
return flag || !item.file.includes(entityFilePrefix) || dataSourceFile === item.file;
|
|
756
|
+
});
|
|
757
|
+
}
|
|
595
758
|
// 如果是entity就需要在单独,查一边来修改名字
|
|
596
759
|
if (node instanceof Entity) {
|
|
597
760
|
// 过滤一把不需要改的信息
|
|
@@ -698,7 +861,7 @@ const naslServer = {
|
|
|
698
861
|
const fileNode = this.file2NodeMap.get(record.file);
|
|
699
862
|
if (!fileNode)
|
|
700
863
|
return null;
|
|
701
|
-
const minRange:
|
|
864
|
+
const minRange: RenameMinRange = this._findMinRange(record, fileNode as FileNode);
|
|
702
865
|
if (minRange) {
|
|
703
866
|
// 如果节点是TypeAnnotation类型,
|
|
704
867
|
// 很复杂,可能是多级嵌套结构
|
|
@@ -876,19 +1039,19 @@ const naslServer = {
|
|
|
876
1039
|
// logic 和 views名称修改 可能会触发bindEvent修改
|
|
877
1040
|
if (minRange.node instanceof BindEvent) {
|
|
878
1041
|
// 页面逻辑直接赋值就可以, 因为是相对路径
|
|
879
|
-
if (
|
|
1042
|
+
if (node instanceof ViewElement) {
|
|
880
1043
|
minRange.setTypeMethods = 'setCalleeNamespace';
|
|
881
1044
|
minRange.newValue = 'elements.' + newValue + '.logics';
|
|
882
1045
|
} else {
|
|
883
1046
|
/**
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
1047
|
+
* 如果namespce是 'app.views.Student.views.404.views.505.views.update'
|
|
1048
|
+
* 在ts中会是'app.views.Student.views.$404.views.$505.views.update'
|
|
1049
|
+
* 但是505 要改名为 666 ,要存的是666
|
|
1050
|
+
* 'app.views.Student.views.404.views.666.views.update'
|
|
1051
|
+
* 1.取到转后的
|
|
1052
|
+
* 2.在匹配到的内容中取转后的namespace的位置
|
|
1053
|
+
* 3.然后把namespace中的 $替换成 ''
|
|
1054
|
+
*/
|
|
892
1055
|
const tsCalleeNamespace = minRange.node.tsCalleeNamespace;
|
|
893
1056
|
const oldValue = tsCalleeNamespace;
|
|
894
1057
|
|
|
@@ -950,6 +1113,45 @@ const naslServer = {
|
|
|
950
1113
|
if (minRange.node instanceof QueryFieldExpression && node instanceof Entity) {
|
|
951
1114
|
minRange.setTypeMethods = 'setEntityAsName';
|
|
952
1115
|
}
|
|
1116
|
+
// 如果修改的是dataSource字段
|
|
1117
|
+
if (node instanceof DataSource) {
|
|
1118
|
+
const setTypeNamespace = (typeNamespace: string, record: any) => {
|
|
1119
|
+
// 先看下标位置
|
|
1120
|
+
const lineText = record.lineText;
|
|
1121
|
+
const index = lineText.indexOf(typeNamespace);
|
|
1122
|
+
// 在把开始结束位置的-开始位置,来知道是哪里要替换
|
|
1123
|
+
const start = record.start.offset - index - 1;
|
|
1124
|
+
const end = record.end.offset - index - 1;
|
|
1125
|
+
// 新的完整的value
|
|
1126
|
+
const newTextValue = typeNamespace.substring(0, start) + newValue + typeNamespace.substring(end, typeNamespace.length);
|
|
1127
|
+
minRange.newValue = newTextValue;
|
|
1128
|
+
return newTextValue;
|
|
1129
|
+
};
|
|
1130
|
+
if (minRange.node instanceof TypeAnnotation) {
|
|
1131
|
+
minRange.setTypeMethods = 'setTypeNamespace';
|
|
1132
|
+
const newValue = setTypeNamespace(minRange.node.typeNamespace, record);
|
|
1133
|
+
minRange.newValue = newValue;
|
|
1134
|
+
} else if (minRange.node instanceof QueryFromExpression || minRange.node instanceof QueryJoinExpression) {
|
|
1135
|
+
minRange.setTypeMethods = 'setEntityNamespace';
|
|
1136
|
+
const newValue = setTypeNamespace(minRange.node.entityNamespace, record);
|
|
1137
|
+
minRange.newValue = newValue;
|
|
1138
|
+
} else if (minRange.node instanceof QueryFieldExpression) {
|
|
1139
|
+
return null;
|
|
1140
|
+
} else if (minRange.node instanceof CallLogic) {
|
|
1141
|
+
minRange.setTypeMethods = 'setCalleeNamespace';
|
|
1142
|
+
const newValue = setTypeNamespace(minRange.node.calleeNamespace, record);
|
|
1143
|
+
minRange.newValue = newValue;
|
|
1144
|
+
} else if (minRange.node instanceof EntityProperty) {
|
|
1145
|
+
minRange.setTypeMethods = 'setRelationNamespace';
|
|
1146
|
+
const newValue = setTypeNamespace(minRange.node.relationNamespace, record);
|
|
1147
|
+
minRange.newValue = newValue;
|
|
1148
|
+
} else if (minRange.node instanceof SqlQueryComponent) {
|
|
1149
|
+
minRange.setTypeMethods = 'setDataSource';
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
if (minRange.node instanceof QueryGroupByExpression && node instanceof Entity) {
|
|
1153
|
+
minRange.setTypeMethods = 'setEntityAsName';
|
|
1154
|
+
}
|
|
953
1155
|
|
|
954
1156
|
if ((minRange.node instanceof QueryFromExpression || minRange.node instanceof QueryJoinExpression) && node instanceof Entity) {
|
|
955
1157
|
minRange.setTypeMethods = 'setEntityName';
|
|
@@ -957,14 +1159,23 @@ const naslServer = {
|
|
|
957
1159
|
if (minRange.node instanceof QueryFieldExpression && node instanceof EntityProperty) {
|
|
958
1160
|
minRange.setTypeMethods = 'setPropertyName';
|
|
959
1161
|
}
|
|
1162
|
+
if (minRange.node instanceof QueryGroupByExpression && node instanceof EntityProperty) {
|
|
1163
|
+
minRange.setTypeMethods = 'setPropertyName';
|
|
1164
|
+
}
|
|
960
1165
|
|
|
961
1166
|
// 如果跳转链接或者页面变量同一个param和TypeAnnotation 有两个过滤掉一个
|
|
962
|
-
if (
|
|
1167
|
+
if (
|
|
1168
|
+
(minRange.node instanceof Param || minRange.node instanceof Variable || minRange.node instanceof Return)
|
|
1169
|
+
&& (node instanceof Entity || node instanceof Enum || node instanceof Structure)
|
|
1170
|
+
) {
|
|
963
1171
|
return null;
|
|
964
1172
|
}
|
|
965
1173
|
if (minRange.node instanceof Destination && (node instanceof Process || node instanceof ProcessElement)) {
|
|
966
1174
|
return null;
|
|
967
1175
|
}
|
|
1176
|
+
if (minRange.node instanceof Assignee && (node instanceof Process || node instanceof ProcessElement)) {
|
|
1177
|
+
return null;
|
|
1178
|
+
}
|
|
968
1179
|
// 枚举修改枚举名,比较特殊
|
|
969
1180
|
if (minRange.node instanceof EnumItem && node instanceof Enum) {
|
|
970
1181
|
// 什么都不做,用来跳过修改
|
|
@@ -995,7 +1206,7 @@ const naslServer = {
|
|
|
995
1206
|
/**
|
|
996
1207
|
* 这里过滤一下,一些查找引用,重复的内容,直接屏蔽掉,防止操作重复
|
|
997
1208
|
* 因为在生成的时候 ,可能弄了一些副作用的引用
|
|
998
|
-
|
|
1209
|
+
*/
|
|
999
1210
|
// 本来是想在上面过滤一把的先放到这里匹配这两个的时候 就会找到
|
|
1000
1211
|
// refsList = refsList.filter((item) => {
|
|
1001
1212
|
// 屏蔽组件查找查到定义这里,也过滤一下
|
|
@@ -1010,7 +1221,7 @@ const naslServer = {
|
|
|
1010
1221
|
* 流程改名不触发Logic改名
|
|
1011
1222
|
* 如果是修改param查找到logic就不操作
|
|
1012
1223
|
* 除非想在内部修改别的内容所以暂时屏蔽掉
|
|
1013
|
-
|
|
1224
|
+
*/
|
|
1014
1225
|
if (minRange.node instanceof Logic && node !== minRange.node) {
|
|
1015
1226
|
return null;
|
|
1016
1227
|
}
|
|
@@ -1026,18 +1237,9 @@ const naslServer = {
|
|
|
1026
1237
|
console.log(result);
|
|
1027
1238
|
return result;
|
|
1028
1239
|
},
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
const parantNode = node
|
|
1032
|
-
// 收集修改
|
|
1033
|
-
App.emit('collect:start', {
|
|
1034
|
-
actionMsg: '增加逻辑参数',
|
|
1035
|
-
});
|
|
1036
|
-
node.create({
|
|
1037
|
-
index: 0,
|
|
1038
|
-
parentNode: parantNode,
|
|
1039
|
-
parentKey: node.parentKey,
|
|
1040
|
-
});
|
|
1240
|
+
// 增加参数的副作用,用于更新logic和view
|
|
1241
|
+
_addParamsEffect(refsList: any[], node: Param) {
|
|
1242
|
+
const parantNode = node?.parentNode as Logic | View;
|
|
1041
1243
|
refsList.forEach((record) => {
|
|
1042
1244
|
const fileNode = this.file2NodeMap.get(record.file);
|
|
1043
1245
|
if (!fileNode)
|
|
@@ -1046,27 +1248,45 @@ const naslServer = {
|
|
|
1046
1248
|
if (minRange) {
|
|
1047
1249
|
// 如果找到节点是callLogic就去更新
|
|
1048
1250
|
if (minRange.node instanceof CallLogic && node instanceof Param) {
|
|
1049
|
-
minRange.node.setCalleeArgName(
|
|
1251
|
+
minRange.node.setCalleeArgName(parantNode as Logic);
|
|
1050
1252
|
}
|
|
1051
1253
|
// 如果节点参数增加页面也要更新
|
|
1052
1254
|
if (minRange.node instanceof Destination && node instanceof Param) {
|
|
1053
|
-
minRange.node.setViewArgument(
|
|
1255
|
+
minRange.node.setViewArgument(parantNode as View);
|
|
1054
1256
|
}
|
|
1055
1257
|
}
|
|
1056
1258
|
});
|
|
1057
|
-
|
|
1058
|
-
|
|
1259
|
+
},
|
|
1260
|
+
_addParamsPrepare(node: BaseNode, refsList: any[], needAdd: boolean) {
|
|
1261
|
+
if (needAdd) {
|
|
1262
|
+
const App = node?.rootNode;
|
|
1263
|
+
const parantNode = node?.parentNode as Logic | View;
|
|
1264
|
+
// 收集修改
|
|
1265
|
+
App.emit('collect:start', {
|
|
1266
|
+
actionMsg: '增加逻辑参数',
|
|
1267
|
+
});
|
|
1268
|
+
node.create({
|
|
1269
|
+
index: 0,
|
|
1270
|
+
parentNode: parantNode,
|
|
1271
|
+
parentKey: node.parentKey,
|
|
1272
|
+
});
|
|
1273
|
+
naslServer._addParamsEffect(refsList, node as Param);
|
|
1274
|
+
// 结束修改 ,批量操作
|
|
1275
|
+
App.emit('collect:end');
|
|
1276
|
+
return node;
|
|
1277
|
+
}
|
|
1278
|
+
naslServer._addParamsEffect(refsList, node as Param);
|
|
1279
|
+
return node;
|
|
1059
1280
|
},
|
|
1060
1281
|
// 查找引用
|
|
1061
1282
|
async findReferences(node: BaseNode) {
|
|
1062
1283
|
let refsList = await naslServer._isHaveRef(node);
|
|
1063
1284
|
// 如果查找引用查到自己里面的引用不展示
|
|
1064
|
-
refsList = refsList.filter((item) =>
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
});
|
|
1285
|
+
refsList = refsList.filter((item) =>
|
|
1286
|
+
// 自己引用自己的过滤掉
|
|
1287
|
+
// 删除的时候过滤一把组件删除提示
|
|
1288
|
+
// 展示组件自己屏蔽掉
|
|
1289
|
+
!item.isDefinition && !item.lineText.includes(' = new nasl.ui.'));
|
|
1070
1290
|
// 最后返回的结果
|
|
1071
1291
|
let result = new Map();
|
|
1072
1292
|
// 树的构造,key: 一个file的node, 值是 [[logic, params],[logic, returns]]
|
|
@@ -1098,14 +1318,15 @@ const naslServer = {
|
|
|
1098
1318
|
// 获取节点的上层渲染
|
|
1099
1319
|
_getTreeMap(minRange: MinRange, fileNode: BaseNode, resMap: Map<BaseNode, Array<Array<QuoteNode>>>, nodeMap: Map<BaseNode, QuoteNode>) {
|
|
1100
1320
|
const minRangeNode = minRange.node;
|
|
1101
|
-
let
|
|
1321
|
+
let currentNode = minRangeNode;
|
|
1322
|
+
let parantNode = currentNode.parentNode;
|
|
1102
1323
|
// 顺序队列
|
|
1103
1324
|
const queue: any[] = [];
|
|
1104
1325
|
// 先插入自己,如果没有在往上找,
|
|
1105
1326
|
// 一直到file节点的父级
|
|
1106
1327
|
while (!(parantNode instanceof App)) {
|
|
1107
1328
|
// 找到上一级 在map对象中构造出他的子集
|
|
1108
|
-
|
|
1329
|
+
currentNode = parantNode;
|
|
1109
1330
|
parantNode = parantNode.parentNode;
|
|
1110
1331
|
// 如果第一次就塞入子集和父节点,以后就只用父节点了
|
|
1111
1332
|
// 因为部分节点没有name,先过滤掉
|
|
@@ -1153,11 +1374,11 @@ const naslServer = {
|
|
|
1153
1374
|
}
|
|
1154
1375
|
|
|
1155
1376
|
// 一个logic 或者 view可能会有多个顺序队列
|
|
1156
|
-
if (resMap.get(
|
|
1377
|
+
if (resMap.get(currentNode)) {
|
|
1157
1378
|
// 是否展示两个内容全等,但是两个queue的node可能不一样,但是只需要展示一个
|
|
1158
|
-
resMap.get(
|
|
1379
|
+
resMap.get(currentNode).push(queue);
|
|
1159
1380
|
} else {
|
|
1160
|
-
resMap.set(
|
|
1381
|
+
resMap.set(currentNode, [queue]);
|
|
1161
1382
|
}
|
|
1162
1383
|
},
|
|
1163
1384
|
handleTreeMap(resMap: Map<BaseNode, Array<Array<QuoteNode>>>) {
|
|
@@ -1224,8 +1445,16 @@ const naslServer = {
|
|
|
1224
1445
|
let sourceMap = node.sourceMap;
|
|
1225
1446
|
let fileNode = node;
|
|
1226
1447
|
// 如果没有sourceMap,就继续向上找 ,或者到module结束
|
|
1227
|
-
// 如果 节点找到 app 或者module 停止
|
|
1228
|
-
|
|
1448
|
+
// 如果 节点找到 app 或者module 停止 或者entity找到DataSource为止
|
|
1449
|
+
// 如果当前节点是view就不要向上查找了
|
|
1450
|
+
while (
|
|
1451
|
+
!sourceMap
|
|
1452
|
+
&& fileNode
|
|
1453
|
+
&& !(fileNode.parentNode instanceof App)
|
|
1454
|
+
&& !(fileNode.parentNode instanceof Module)
|
|
1455
|
+
&& !(fileNode.parentNode instanceof DataSource)
|
|
1456
|
+
&& !(fileNode instanceof View)
|
|
1457
|
+
) {
|
|
1229
1458
|
fileNode = fileNode.parentNode;
|
|
1230
1459
|
sourceMap = fileNode?.sourceMap;
|
|
1231
1460
|
}
|
|
@@ -1297,313 +1526,6 @@ async function handleDelete(fileNode: BaseNode, targetNode: BaseNode, result: Re
|
|
|
1297
1526
|
|
|
1298
1527
|
newRefs.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
1299
1528
|
}
|
|
1300
|
-
BaseNode.prototype.findReadOnlyLogicUsage = function () {
|
|
1301
|
-
let targetNode;
|
|
1302
|
-
|
|
1303
|
-
if (this.parentNode.concept === 'Namespace' || this.parentNode.parentNode.concept === 'Namespace') {
|
|
1304
|
-
const sourceMap = this.parentNode.concept === 'Namespace' ? this.parentNode.parentNode.sourceMap : this.parentNode.parentNode.parentNode.sourceMap;
|
|
1305
|
-
for (const item of sourceMap) {
|
|
1306
|
-
const logic = item[0] as Logic;
|
|
1307
|
-
if (this.concept === 'Logic') {
|
|
1308
|
-
if (logic instanceof Logic)
|
|
1309
|
-
if (logic.calleewholeKey === (this as Logic).calleewholeKey) {
|
|
1310
|
-
targetNode = logic;
|
|
1311
|
-
break;
|
|
1312
|
-
}
|
|
1313
|
-
} else {
|
|
1314
|
-
if (logic instanceof Logic)
|
|
1315
|
-
if (logic.calleewholeKey === (this.parentNode as Logic).calleewholeKey) {
|
|
1316
|
-
targetNode = logic;
|
|
1317
|
-
break;
|
|
1318
|
-
}
|
|
1319
|
-
}
|
|
1320
|
-
}
|
|
1321
|
-
} else if (this.parentNode.concept === 'Module') {
|
|
1322
|
-
// 父级是模块的还是用它本身去查找引用
|
|
1323
|
-
targetNode = this;
|
|
1324
|
-
} else {
|
|
1325
|
-
const sourceMap = this.parentNode.sourceMap;
|
|
1326
|
-
for (const item of sourceMap) {
|
|
1327
|
-
const logic = item[0] as Logic;
|
|
1328
|
-
if (logic.getNamespace && logic.getNamespace() === (this as Logic).getNamespace()) {
|
|
1329
|
-
targetNode = logic;
|
|
1330
|
-
break;
|
|
1331
|
-
}
|
|
1332
|
-
}
|
|
1333
|
-
}
|
|
1334
|
-
|
|
1335
|
-
try {
|
|
1336
|
-
return naslServer.findReferences(targetNode);
|
|
1337
|
-
} catch (err) {
|
|
1338
|
-
console.log(err);
|
|
1339
|
-
}
|
|
1340
|
-
};
|
|
1341
|
-
// 查找引用
|
|
1342
|
-
BaseNode.prototype.findUsage = function findUsage() {
|
|
1343
|
-
try {
|
|
1344
|
-
return naslServer.findReferences(this);
|
|
1345
|
-
} catch (err) {
|
|
1346
|
-
console.log(err);
|
|
1347
|
-
}
|
|
1348
|
-
};
|
|
1349
|
-
BaseNode.prototype.changeName = async function changeName(newValue: string, updateAll: boolean = false) {
|
|
1350
|
-
console.log(newValue);
|
|
1351
|
-
console.log(this);
|
|
1352
|
-
try {
|
|
1353
|
-
/**
|
|
1354
|
-
* 查找这个节点是不是有依赖
|
|
1355
|
-
*/
|
|
1356
|
-
const refsList = await naslServer._isHaveRef(this);
|
|
1357
|
-
// 是不是有引用有的话,就返回
|
|
1358
|
-
/**
|
|
1359
|
-
* @param this 当前重命名的节点
|
|
1360
|
-
* @param newValue 传递过来的新值,给MemberExpression用的比较特殊
|
|
1361
|
-
* 而且,这个新值不一定会用到,MemberExpression在批量更新的时候,可以取到新的value, 这里需要位置信息防止 a.a.a.a 中的一个a发生修改
|
|
1362
|
-
* @returns 找到的引用
|
|
1363
|
-
*/
|
|
1364
|
-
const res = naslServer._renamePrepare(this, refsList, newValue);
|
|
1365
|
-
if (res.length <= 1) {
|
|
1366
|
-
(this as SetNameNode).setName(newValue);
|
|
1367
|
-
} else {
|
|
1368
|
-
const callback = (value: boolean) => {
|
|
1369
|
-
if (value) {
|
|
1370
|
-
const App = this.rootNode;
|
|
1371
|
-
// 收集修改
|
|
1372
|
-
App.emit('collect:start', {
|
|
1373
|
-
actionMsg: '重命名并更新引用',
|
|
1374
|
-
});
|
|
1375
|
-
res.forEach((item) => {
|
|
1376
|
-
const itemNode = item.node as SetNameNode;
|
|
1377
|
-
if (item.newValue) {
|
|
1378
|
-
// 如果有指定的修改方法,就用那个,没有就修改名字
|
|
1379
|
-
item.setTypeMethods ? itemNode[item.setTypeMethods](item.newValue) : itemNode.setName?.(item.newValue);
|
|
1380
|
-
} else {
|
|
1381
|
-
item.setTypeMethods ? itemNode[item.setTypeMethods](newValue) : itemNode.setName?.(newValue);
|
|
1382
|
-
}
|
|
1383
|
-
});
|
|
1384
|
-
// 结束修改 ,批量操作
|
|
1385
|
-
App.emit('collect:end');
|
|
1386
|
-
} else {
|
|
1387
|
-
(this as SetNameNode).setName(newValue);
|
|
1388
|
-
}
|
|
1389
|
-
};
|
|
1390
|
-
const confirmParms = {
|
|
1391
|
-
actionType: 'rename',
|
|
1392
|
-
node: this,
|
|
1393
|
-
newValue,
|
|
1394
|
-
};
|
|
1395
|
-
/**
|
|
1396
|
-
* nasl和vue的通信,回退,要触发vue的watch。
|
|
1397
|
-
* 因为如果没修改的话nasl不会修改view,就不会通知到页面改成旧值
|
|
1398
|
-
* 先修改之
|
|
1399
|
-
*/
|
|
1400
|
-
const closeCallBack = () => {
|
|
1401
|
-
if (this.concept === 'EnumItem') {
|
|
1402
|
-
const oldValue = (this as EnumItem).value;
|
|
1403
|
-
(this as EnumItem).value = oldValue + ' ';
|
|
1404
|
-
setTimeout(() => {
|
|
1405
|
-
(this as EnumItem).value = oldValue;
|
|
1406
|
-
}, 0);
|
|
1407
|
-
} else {
|
|
1408
|
-
const oldValue = this.name;
|
|
1409
|
-
this.name = oldValue + ' ';
|
|
1410
|
-
setTimeout(() => {
|
|
1411
|
-
this.name = oldValue;
|
|
1412
|
-
}, 0);
|
|
1413
|
-
}
|
|
1414
|
-
};
|
|
1415
|
-
updateAll ? callback(true) : invokeCommand('tsConfirm.open', confirmParms, callback, closeCallBack);
|
|
1416
|
-
|
|
1417
|
-
return;
|
|
1418
|
-
}
|
|
1419
|
-
} catch (err) {
|
|
1420
|
-
console.log(err);
|
|
1421
|
-
}
|
|
1422
|
-
};
|
|
1423
|
-
|
|
1424
|
-
/**
|
|
1425
|
-
* 准备删除
|
|
1426
|
-
*/
|
|
1427
|
-
BaseNode.prototype.prepareDelete = async function prepareDelete() {
|
|
1428
|
-
try {
|
|
1429
|
-
/**
|
|
1430
|
-
* 查找这个节点是不是有依赖
|
|
1431
|
-
*/
|
|
1432
|
-
const node = this;
|
|
1433
|
-
let refsList = await naslServer._isHaveRef(node);
|
|
1434
|
-
// 删除的时候过滤一把组件删除提示
|
|
1435
|
-
refsList = refsList.filter((item) => {
|
|
1436
|
-
// 因为ui组件本身会多渲染一次,就先过滤一个
|
|
1437
|
-
return !(item.lineText.includes(': nasl.ui.'));
|
|
1438
|
-
});
|
|
1439
|
-
// 删除参数单独处理
|
|
1440
|
-
if (node instanceof Param) {
|
|
1441
|
-
const methodRefs: tsProtocol.ReferencesResponseItem[] = [];
|
|
1442
|
-
refsList.forEach((item) => {
|
|
1443
|
-
// 入参查找引用,查到logic 和自己,内容完全一样,就保留一个
|
|
1444
|
-
const find = methodRefs.find((findItem) => item.lineText === findItem.lineText);
|
|
1445
|
-
if (!find) {
|
|
1446
|
-
methodRefs.push(item);
|
|
1447
|
-
}
|
|
1448
|
-
});
|
|
1449
|
-
refsList = methodRefs;
|
|
1450
|
-
}
|
|
1451
|
-
|
|
1452
|
-
// delete的弹框展示
|
|
1453
|
-
const confirmParms = {
|
|
1454
|
-
actionType: 'delete',
|
|
1455
|
-
tipFlag: false,
|
|
1456
|
-
node,
|
|
1457
|
-
icon: 'warning',
|
|
1458
|
-
};
|
|
1459
|
-
let callback = null;
|
|
1460
|
-
if (refsList.length <= 1) {
|
|
1461
|
-
// 页面组件直接删除然后return
|
|
1462
|
-
if (node instanceof ViewElement) {
|
|
1463
|
-
this.delete();
|
|
1464
|
-
return;
|
|
1465
|
-
}
|
|
1466
|
-
callback = () => {
|
|
1467
|
-
// Structure 和 Interface是内部有delete方法
|
|
1468
|
-
if (node instanceof Structure || node instanceof Interface) {
|
|
1469
|
-
(this as any).deleteLogincAndModule();
|
|
1470
|
-
} else {
|
|
1471
|
-
this.delete();
|
|
1472
|
-
}
|
|
1473
|
-
};
|
|
1474
|
-
} else {
|
|
1475
|
-
// 如果有依赖就有一个查找引用提示
|
|
1476
|
-
confirmParms.tipFlag = true;
|
|
1477
|
-
const node = this;
|
|
1478
|
-
|
|
1479
|
-
// 删除页面或者流程
|
|
1480
|
-
if (node instanceof View || node instanceof Process) {
|
|
1481
|
-
/**
|
|
1482
|
-
* 查找这个页面是不是有依赖
|
|
1483
|
-
*/
|
|
1484
|
-
let viewPath = (this as FileNode).getEmbeddedFilePath();
|
|
1485
|
-
viewPath = viewPath.slice(0, viewPath.length - 3);
|
|
1486
|
-
const find = refsList.find((record) => !record.file.includes(viewPath));
|
|
1487
|
-
// 如果没有别的文件的依赖,就直接delete
|
|
1488
|
-
if (!find) {
|
|
1489
|
-
this.delete();
|
|
1490
|
-
return;
|
|
1491
|
-
}
|
|
1492
|
-
}
|
|
1493
|
-
callback = () => {
|
|
1494
|
-
// removeParam
|
|
1495
|
-
// 跟rename 还不太一样,部分修改依赖修改好的值,然后在下面的修改需要把自己传递进去
|
|
1496
|
-
if (node instanceof Param) {
|
|
1497
|
-
const App = this.rootNode;
|
|
1498
|
-
const parentNode = this.parentNode;
|
|
1499
|
-
// 收集修改
|
|
1500
|
-
App.emit('collect:start', {
|
|
1501
|
-
actionMsg: '删除参数',
|
|
1502
|
-
});
|
|
1503
|
-
this.delete();
|
|
1504
|
-
refsList.forEach((record) => {
|
|
1505
|
-
const fileNode = naslServer.file2NodeMap.get(record.file);
|
|
1506
|
-
if (!fileNode)
|
|
1507
|
-
return null;
|
|
1508
|
-
const minRange: MinRange = naslServer._findMinRange(record, fileNode as FileNode);
|
|
1509
|
-
if (minRange) {
|
|
1510
|
-
if (minRange.node instanceof CallLogic) {
|
|
1511
|
-
minRange.node.setCalleeArgName(parentNode as Logic);
|
|
1512
|
-
}
|
|
1513
|
-
if (minRange.node instanceof Destination) {
|
|
1514
|
-
minRange.node.setViewArgument(parentNode as View);
|
|
1515
|
-
}
|
|
1516
|
-
}
|
|
1517
|
-
});
|
|
1518
|
-
// 结束修改 ,批量操作
|
|
1519
|
-
App.emit('collect:end');
|
|
1520
|
-
return;
|
|
1521
|
-
}
|
|
1522
|
-
// 删除logic节点,如果有对应的interface要一起删除
|
|
1523
|
-
if (node instanceof Logic) {
|
|
1524
|
-
const App = this.rootNode;
|
|
1525
|
-
// 收集修改
|
|
1526
|
-
App.emit('collect:start', {
|
|
1527
|
-
actionMsg: '删除逻辑并删除导出的接口',
|
|
1528
|
-
});
|
|
1529
|
-
this.delete();
|
|
1530
|
-
refsList.forEach((record) => {
|
|
1531
|
-
const fileNode = naslServer.file2NodeMap.get(record.file);
|
|
1532
|
-
if (!fileNode)
|
|
1533
|
-
return null;
|
|
1534
|
-
const minRange: MinRange = naslServer._findMinRange(record, fileNode as FileNode);
|
|
1535
|
-
if (minRange) {
|
|
1536
|
-
if (minRange.node instanceof Interface) {
|
|
1537
|
-
minRange.node.delete();
|
|
1538
|
-
}
|
|
1539
|
-
}
|
|
1540
|
-
});
|
|
1541
|
-
// 结束修改 ,批量操作
|
|
1542
|
-
App.emit('collect:end');
|
|
1543
|
-
return;
|
|
1544
|
-
}
|
|
1545
|
-
// 删除权限节点
|
|
1546
|
-
if (node instanceof Role) {
|
|
1547
|
-
const App = this.rootNode;
|
|
1548
|
-
// 收集修改
|
|
1549
|
-
App.emit('collect:start', {
|
|
1550
|
-
actionMsg: '删除权限',
|
|
1551
|
-
});
|
|
1552
|
-
this.delete();
|
|
1553
|
-
refsList.forEach((record) => {
|
|
1554
|
-
const fileNode = naslServer.file2NodeMap.get(record.file);
|
|
1555
|
-
if (!fileNode)
|
|
1556
|
-
return null;
|
|
1557
|
-
const minRange: MinRange = naslServer._findMinRange(record, fileNode as FileNode);
|
|
1558
|
-
if (minRange) {
|
|
1559
|
-
if (minRange.node instanceof View || minRange.node instanceof ViewElement) {
|
|
1560
|
-
// oldName旧的节点存的值
|
|
1561
|
-
// newValue用户输入值
|
|
1562
|
-
// node.bindRoles 存的
|
|
1563
|
-
const str = minRange.node.bindRoles.toString().replace(this.name, '');
|
|
1564
|
-
const newBindRoles = str.split(',').filter((item) => !!item);
|
|
1565
|
-
minRange.node.setBindRoles(newBindRoles);
|
|
1566
|
-
}
|
|
1567
|
-
}
|
|
1568
|
-
});
|
|
1569
|
-
// 结束修改 ,批量操作
|
|
1570
|
-
App.emit('collect:end');
|
|
1571
|
-
return;
|
|
1572
|
-
}
|
|
1573
|
-
|
|
1574
|
-
// 删除页面或者流程,如果上一步没有return 就说明他是有别的引用的,会有引用弹框
|
|
1575
|
-
if (node instanceof View || node instanceof Process) {
|
|
1576
|
-
this.delete();
|
|
1577
|
-
}
|
|
1578
|
-
// 其余的都直接调用删除
|
|
1579
|
-
// Structure 和 Interface是内部有delete方法
|
|
1580
|
-
if (node instanceof Structure || node instanceof Interface) {
|
|
1581
|
-
(this as any).deleteLogincAndModule();
|
|
1582
|
-
} else {
|
|
1583
|
-
this.delete();
|
|
1584
|
-
}
|
|
1585
|
-
};
|
|
1586
|
-
}
|
|
1587
|
-
invokeCommand('tsConfirm.open', confirmParms, callback);
|
|
1588
|
-
} catch (err) {
|
|
1589
|
-
console.log(err);
|
|
1590
|
-
}
|
|
1591
|
-
};
|
|
1592
|
-
|
|
1593
|
-
/**
|
|
1594
|
-
* 如果添加需要触发查找引用并且在之后,对内容产生影响
|
|
1595
|
-
*/
|
|
1596
|
-
BaseNode.prototype.addParamsPrepare = async function addParamsPrepare() {
|
|
1597
|
-
try {
|
|
1598
|
-
/**
|
|
1599
|
-
* 查找这个节点是不是有依赖
|
|
1600
|
-
*/
|
|
1601
|
-
const refsList = await naslServer._isHaveRef(this);
|
|
1602
|
-
return naslServer._addParamsPrepare(this, refsList);
|
|
1603
|
-
} catch (err) {
|
|
1604
|
-
console.log(err);
|
|
1605
|
-
}
|
|
1606
|
-
};
|
|
1607
1529
|
|
|
1608
1530
|
/**
|
|
1609
1531
|
* 除去rename场景下的更新
|
|
@@ -1737,6 +1659,7 @@ async function incidentalAction(action: string, fileNode: BaseNode, targetNode:
|
|
|
1737
1659
|
for (let i = 0; i < fileNodeChildren.length; i++) {
|
|
1738
1660
|
const fileNodeItem = fileNodeChildren[i];
|
|
1739
1661
|
const result = (fileNodeItem as FileNode).toEmbeddedTSFile();
|
|
1662
|
+
fileNodeItem.sourceMap = result.sourceMap;
|
|
1740
1663
|
if (action === 'create') {
|
|
1741
1664
|
await handleChange(fileNodeItem, fileNodeItem, result, action);
|
|
1742
1665
|
await incidentalAction(action, fileNodeItem, fileNodeItem);
|
|
@@ -1750,12 +1673,15 @@ async function incidentalAction(action: string, fileNode: BaseNode, targetNode:
|
|
|
1750
1673
|
await handleRename(fileNodeItem, fileNodeItem, result, currentOldPath);
|
|
1751
1674
|
await incidentalAction(action, fileNodeItem, fileNodeItem, currentOldPath);
|
|
1752
1675
|
}
|
|
1753
|
-
}
|
|
1676
|
+
}
|
|
1754
1677
|
}
|
|
1755
1678
|
// 删除或新增模块
|
|
1756
1679
|
// 需要把下面的哦内容全部都更新一遍
|
|
1757
1680
|
if (fileNode instanceof Module) {
|
|
1758
|
-
|
|
1681
|
+
if (fileNode.type === 'interface' && fileNode.isAdd && action === 'create') {
|
|
1682
|
+
isChangeInterface = true;
|
|
1683
|
+
}
|
|
1684
|
+
const module: Module = targetNode as Module;
|
|
1759
1685
|
const results: Array<ReturnType<Structure['toEmbeddedTSFile']>> = [];
|
|
1760
1686
|
naslServer.contentToFile(module, results);
|
|
1761
1687
|
for (let i = 0; i < results.length; i++) {
|
|
@@ -1766,7 +1692,7 @@ async function incidentalAction(action: string, fileNode: BaseNode, targetNode:
|
|
|
1766
1692
|
} else {
|
|
1767
1693
|
await handleDelete(node, node, result);
|
|
1768
1694
|
}
|
|
1769
|
-
}
|
|
1695
|
+
}
|
|
1770
1696
|
|
|
1771
1697
|
// 删除模块通知更新列表
|
|
1772
1698
|
if (action === 'delete') {
|
|
@@ -1778,6 +1704,22 @@ async function incidentalAction(action: string, fileNode: BaseNode, targetNode:
|
|
|
1778
1704
|
}
|
|
1779
1705
|
}
|
|
1780
1706
|
}
|
|
1707
|
+
/**
|
|
1708
|
+
* DataSource只会重命名时候,需要把子集全部重新生成一下
|
|
1709
|
+
*/
|
|
1710
|
+
if (fileNode instanceof DataSource) {
|
|
1711
|
+
(fileNode as DataSource).entities.forEach(async (entity) => {
|
|
1712
|
+
try {
|
|
1713
|
+
const result = entity.toEmbeddedTSFile();
|
|
1714
|
+
const parentPath = oldpath.replace('.ts', '/');
|
|
1715
|
+
const currentOldPath = parentPath + '/entities/' + entity.name + '.ts';
|
|
1716
|
+
// 因为重命名这里只有当前修改父级的 旧名称, 所以他的子集也要根据旧名称去查依赖 更新内容
|
|
1717
|
+
await handleRename(entity, entity, result, currentOldPath);
|
|
1718
|
+
} catch (err) {
|
|
1719
|
+
console.log(err);
|
|
1720
|
+
}
|
|
1721
|
+
});
|
|
1722
|
+
}
|
|
1781
1723
|
}
|
|
1782
1724
|
}
|
|
1783
1725
|
|
|
@@ -1841,7 +1783,7 @@ embeddedTSEmitter.on('change', ($event: EventPayload) => {
|
|
|
1841
1783
|
// 异步状态机,一个完成了在执行下一个
|
|
1842
1784
|
function next() {
|
|
1843
1785
|
const item = stackList.shift();
|
|
1844
|
-
receiveHandleChange(item).then(async() => {
|
|
1786
|
+
receiveHandleChange(item).then(async () => {
|
|
1845
1787
|
if (stackList.length) {
|
|
1846
1788
|
next();
|
|
1847
1789
|
} else {
|