@lcap/nasl 1.0.0-alpha.13 → 1.0.0-alpha.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/automate/engine/index.d.ts +1 -1
- package/out/automate/engine/index.js +73 -25
- package/out/automate/engine/index.js.map +1 -1
- package/out/automate/engine/utils.js +7 -6
- package/out/automate/engine/utils.js.map +1 -1
- package/out/common/BaseNode.d.ts +5 -4
- package/out/common/BaseNode.js +48 -41
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/App__.d.ts +18 -1
- package/out/concepts/App__.js +64 -24
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Argument__.js +2 -2
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/Assignee__.d.ts +190 -0
- package/out/concepts/Assignee__.js +264 -0
- package/out/concepts/Assignee__.js.map +1 -0
- package/out/concepts/BinaryExpression__.js +6 -6
- package/out/concepts/BinaryExpression__.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts +19 -0
- package/out/concepts/BindAttribute__.js +36 -2
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +21 -1
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.d.ts +1 -0
- package/out/concepts/BindEvent__.js +38 -14
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/CallFunction__.js +20 -7
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.d.ts +11 -8
- package/out/concepts/CallInterface__.js +160 -23
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +1 -0
- package/out/concepts/CallLogic__.js +17 -7
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.d.ts +5 -1
- package/out/concepts/CallQueryComponent__.js +15 -11
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Comment__.js +6 -2
- package/out/concepts/Comment__.js.map +1 -1
- package/out/concepts/ConfigGroup__.js +1 -1
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/ConfigProperty__.js +1 -1
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Configuration__.js +1 -1
- package/out/concepts/Configuration__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +11 -0
- package/out/concepts/Destination__.js +59 -19
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +10 -2
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +7 -0
- package/out/concepts/EntityProperty__.js +60 -3
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +4 -1
- package/out/concepts/Entity__.js +29 -12
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/Enum__.d.ts +4 -0
- package/out/concepts/Enum__.js +9 -6
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/Event__.js +1 -1
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +8 -12
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Function__.js +5 -5
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.js +26 -24
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.js +2 -2
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/InterfaceParam__.d.ts +2 -0
- package/out/concepts/InterfaceParam__.js +41 -21
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/Interface__.d.ts +3 -0
- package/out/concepts/Interface__.js +105 -9
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +2 -1
- package/out/concepts/LogicItem__.js +14 -0
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +3 -0
- package/out/concepts/Logic__.js +57 -16
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MemberExpression__.js +13 -6
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.d.ts +6 -0
- package/out/concepts/Module__.js +18 -8
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/Namespace__.d.ts +4 -0
- package/out/concepts/Namespace__.js +23 -12
- package/out/concepts/Namespace__.js.map +1 -1
- package/out/concepts/Param__.d.ts +2 -1
- package/out/concepts/Param__.js +35 -22
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessComponent__.js +2 -2
- package/out/concepts/ProcessComponent__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +20 -18
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/ProcessOutcome__.js +1 -1
- package/out/concepts/ProcessOutcome__.js.map +1 -1
- package/out/concepts/Process__.d.ts +6 -1
- package/out/concepts/Process__.js +18 -14
- 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/QueryFromExpression__.js +1 -1
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.js +2 -2
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/QuerySelectExpression__.js +1 -1
- package/out/concepts/QuerySelectExpression__.js.map +1 -1
- package/out/concepts/Return__.d.ts +1 -0
- package/out/concepts/Return__.js +38 -25
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.js +1 -1
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/StringLiteral__.d.ts +1 -1
- package/out/concepts/StringLiteral__.js +2 -2
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.d.ts +5 -4
- package/out/concepts/StructureProperty__.js +54 -31
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.d.ts +1 -0
- package/out/concepts/Structure__.js +18 -5
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SwitchCase__.js +3 -3
- package/out/concepts/SwitchCase__.js.map +1 -1
- package/out/concepts/SwitchStatement__.js +1 -1
- package/out/concepts/SwitchStatement__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +3 -5
- package/out/concepts/TypeAnnotation__.js +36 -14
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/UnaryExpression__.js +4 -2
- package/out/concepts/UnaryExpression__.js.map +1 -1
- package/out/concepts/ValidationRule__.d.ts +1 -0
- package/out/concepts/ValidationRule__.js +27 -1
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.d.ts +1 -0
- package/out/concepts/Variable__.js +38 -25
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewComponent__.js +5 -5
- package/out/concepts/ViewComponent__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +7 -1
- package/out/concepts/ViewElement__.js +154 -117
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +4 -0
- package/out/concepts/View__.js +38 -25
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.js +1 -1
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/concepts/basics/stdlib/index.js +3 -1
- package/out/concepts/basics/stdlib/index.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.auth.d.ts +3 -0
- package/out/concepts/basics/stdlib/nasl.auth.js +30 -0
- package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -0
- package/out/concepts/basics/stdlib/nasl.browser copy.d.ts +3 -0
- package/out/concepts/basics/stdlib/nasl.browser copy.js +70 -0
- package/out/concepts/basics/stdlib/nasl.browser copy.js.map +1 -0
- package/out/concepts/basics/stdlib/nasl.browser.js +6 -35
- package/out/concepts/basics/stdlib/nasl.browser.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.configuration.d.ts +3 -0
- package/out/concepts/basics/stdlib/nasl.configuration.js +25 -0
- package/out/concepts/basics/stdlib/nasl.configuration.js.map +1 -0
- package/out/concepts/basics/stdlib/nasl.util.js +49 -41
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.validation.js +26 -20
- package/out/concepts/basics/stdlib/nasl.validation.js.map +1 -1
- package/out/concepts/basics/types/coreTypeList.js +11 -11
- package/out/concepts/basics/types/coreTypeList.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 +1 -1
- package/out/enums/KEYWORDS.js.map +1 -1
- package/out/generator/genBundleFiles.d.ts +1 -0
- package/out/generator/genBundleFiles.js +122 -93
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/manager/diagnostic.d.ts +1 -1
- package/out/server/createUiTs.d.ts +1 -0
- package/out/server/createUiTs.js +19 -2
- package/out/server/createUiTs.js.map +1 -1
- package/out/server/entity2LogicNamespace.js +24 -9
- package/out/server/entity2LogicNamespace.js.map +1 -1
- package/out/server/getExtensionModules.js +2 -0
- package/out/server/getExtensionModules.js.map +1 -1
- package/out/server/getLogics.js +40 -56
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.d.ts +4 -0
- package/out/server/getMemberIdentifier.js +90 -48
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.d.ts +2 -2
- package/out/server/getProcesses.js +34 -11
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/index.js +4 -0
- package/out/server/index.js.map +1 -1
- package/out/server/naslServer.d.ts +11 -30
- package/out/server/naslServer.js +410 -199
- package/out/server/naslServer.js.map +1 -1
- package/out/server/process2LogicNamespace.d.ts +10 -0
- package/out/server/process2LogicNamespace.js +16 -0
- package/out/server/process2LogicNamespace.js.map +1 -1
- package/out/server/translator.d.ts +22 -3
- package/out/server/translator.js +336 -130
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.js +29 -15
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +5 -5
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +9 -13
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +7 -7
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.js +2 -2
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +4 -2
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.d.ts +1 -1
- package/out/templator/genGridViewBlock.js +3 -3
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genQueryComponent.d.ts +2 -0
- package/out/templator/genQueryComponent.js +1 -0
- package/out/templator/genQueryComponent.js.map +1 -1
- package/out/templator/genTableBlock.d.ts +1 -1
- package/out/templator/genTableBlock.js +3 -3
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +7 -7
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.d.ts +3 -1
- package/out/templator/utils.js +2 -1
- package/out/templator/utils.js.map +1 -1
- package/out/utils/index.d.ts +6 -0
- package/out/utils/index.js +20 -1
- package/out/utils/index.js.map +1 -1
- package/package.json +2 -1
- package/src/automate/engine/index.js +73 -25
- package/src/automate/engine/utils.js +7 -6
- package/src/common/BaseNode.ts +51 -42
- package/src/concepts/App__.ts +104 -26
- package/src/concepts/Argument__.ts +3 -2
- package/src/concepts/Assignee__.ts +437 -0
- package/src/concepts/BinaryExpression__.ts +7 -6
- package/src/concepts/BindAttribute__.ts +51 -2
- package/src/concepts/BindDirective__.ts +20 -1
- package/src/concepts/BindEvent__.ts +39 -16
- package/src/concepts/CallFunction__.ts +21 -8
- package/src/concepts/CallInterface__.ts +161 -42
- package/src/concepts/CallLogic__.ts +21 -9
- package/src/concepts/CallQueryComponent__.ts +15 -13
- package/src/concepts/Comment__.ts +6 -2
- package/src/concepts/ConfigGroup__.ts +1 -1
- package/src/concepts/ConfigProperty__.ts +1 -1
- package/src/concepts/Configuration__.ts +1 -1
- package/src/concepts/Destination__.ts +57 -19
- package/src/concepts/End__.ts +9 -11
- package/src/concepts/EntityProperty__.ts +56 -3
- package/src/concepts/Entity__.ts +33 -20
- package/src/concepts/Enum__.ts +8 -7
- package/src/concepts/Event__.ts +1 -1
- package/src/concepts/ForEachStatement__.ts +8 -13
- package/src/concepts/Function__.ts +5 -5
- package/src/concepts/Identifier__.ts +31 -26
- package/src/concepts/IfStatement__.ts +2 -2
- package/src/concepts/InterfaceParam__.ts +39 -20
- package/src/concepts/Interface__.ts +103 -9
- package/src/concepts/LogicItem__.ts +16 -1
- package/src/concepts/Logic__.ts +60 -18
- package/src/concepts/MemberExpression__.ts +18 -6
- package/src/concepts/Module__.ts +19 -8
- package/src/concepts/Namespace__.ts +24 -12
- package/src/concepts/Param__.ts +34 -23
- package/src/concepts/ProcessComponent__.ts +2 -2
- package/src/concepts/ProcessElement__.ts +51 -50
- package/src/concepts/ProcessOutcome__.ts +1 -1
- package/src/concepts/Process__.ts +32 -28
- package/src/concepts/QueryAggregateExpression__.ts +1 -1
- package/src/concepts/QueryFromExpression__.ts +1 -1
- package/src/concepts/QueryJoinExpression__.ts +2 -2
- package/src/concepts/QuerySelectExpression__.ts +1 -1
- package/src/concepts/Return__.ts +35 -25
- package/src/concepts/SqlQueryComponent__.ts +1 -1
- package/src/concepts/StringLiteral__.ts +2 -2
- package/src/concepts/StructureProperty__.ts +49 -29
- package/src/concepts/Structure__.ts +17 -5
- package/src/concepts/SwitchCase__.ts +3 -3
- package/src/concepts/SwitchStatement__.ts +1 -1
- package/src/concepts/TypeAnnotation__.ts +34 -12
- package/src/concepts/UnaryExpression__.ts +4 -2
- package/src/concepts/ValidationRule__.ts +24 -1
- package/src/concepts/Variable__.ts +35 -24
- package/src/concepts/ViewComponent__.ts +5 -5
- package/src/concepts/ViewElement__.ts +168 -113
- package/src/concepts/View__.ts +44 -25
- package/src/concepts/WhileStatement__.ts +1 -1
- package/src/concepts/basics/stdlib/index.ts +3 -1
- package/src/concepts/basics/stdlib/nasl.auth.ts +26 -0
- package/src/concepts/basics/stdlib/nasl.browser.ts +7 -41
- package/src/concepts/basics/stdlib/nasl.configuration.ts +21 -0
- package/src/concepts/basics/stdlib/nasl.util.ts +49 -41
- package/src/concepts/basics/stdlib/nasl.validation.ts +17 -11
- package/src/concepts/basics/types/coreTypeList.ts +11 -11
- package/src/concepts/index__.ts +1 -0
- package/src/enums/KEYWORDS.ts +1 -1
- package/src/generator/genBundleFiles.ts +131 -112
- package/src/manager/diagnostic.ts +1 -1
- package/src/server/createUiTs.ts +22 -4
- package/src/server/entity2LogicNamespace.ts +25 -9
- package/src/server/getExtensionModules.ts +2 -0
- package/src/server/getLogics.ts +42 -58
- package/src/server/getMemberIdentifier.ts +88 -46
- package/src/server/getProcesses.ts +32 -9
- package/src/server/index.ts +12 -1
- package/src/server/naslServer.ts +422 -215
- package/src/server/process2LogicNamespace.ts +17 -1
- package/src/server/translator.ts +392 -134
- package/src/service/storage/init.ts +27 -16
- package/src/templator/genCreateBlock.ts +5 -5
- package/src/templator/genCurdEditMultipleKeyBlock.ts +25 -26
- package/src/templator/genCurdMultipleKeyBlock.ts +7 -7
- package/src/templator/genEditTableBlock.ts +2 -2
- package/src/templator/genGetBlock.ts +5 -7
- package/src/templator/genGridViewBlock.ts +4 -7
- package/src/templator/genQueryComponent.ts +1 -0
- package/src/templator/genTableBlock.ts +4 -7
- package/src/templator/genUpdateBlock.ts +7 -8
- package/src/templator/utils.ts +2 -1
- package/src/utils/index.ts +19 -0
package/src/server/naslServer.ts
CHANGED
|
@@ -39,10 +39,13 @@ import {
|
|
|
39
39
|
CallInterface,
|
|
40
40
|
Return,
|
|
41
41
|
ProcessElement,
|
|
42
|
+
NullLiteral,
|
|
43
|
+
Namespace,
|
|
44
|
+
Theme,
|
|
42
45
|
} from '../concepts';
|
|
43
46
|
import { lsp2tspNumber, SourceMap, SourceMapItem, embeddedTSEmitter } from '../translator';
|
|
44
47
|
import axios from '../service/storage';
|
|
45
|
-
import {
|
|
48
|
+
import { translateDiagnosticMessage, naslNodeTranslateMessage, MinRange } from './translator';
|
|
46
49
|
import { EventPayload, invokeCommand, registerCommand } from '../common';
|
|
47
50
|
import { DiagnosticRecord, Diagnostic, default as diagnosticManager } from '../manager/diagnostic';
|
|
48
51
|
import formatUiTs from './createUiTs';
|
|
@@ -61,12 +64,11 @@ interface FileNode extends BaseNode {
|
|
|
61
64
|
};
|
|
62
65
|
}
|
|
63
66
|
|
|
64
|
-
interface
|
|
67
|
+
interface SetNameNode extends BaseNode {
|
|
65
68
|
setName(name: string): any;
|
|
66
69
|
[propname: string]: any;
|
|
67
70
|
}
|
|
68
71
|
|
|
69
|
-
export { transformType, translateDiagnosticMessage };
|
|
70
72
|
const worker = new Worker('/ts-worker.js');
|
|
71
73
|
const messager = new Messager({
|
|
72
74
|
protocol: 'ts-worker',
|
|
@@ -81,10 +83,6 @@ const messager = new Messager({
|
|
|
81
83
|
},
|
|
82
84
|
});
|
|
83
85
|
|
|
84
|
-
interface MinRange {
|
|
85
|
-
node: BaseNode;
|
|
86
|
-
item: SourceMapItem;
|
|
87
|
-
}
|
|
88
86
|
interface reNameMinRange extends MinRange {
|
|
89
87
|
newValue?: any;
|
|
90
88
|
setTypeMethods?: string;
|
|
@@ -110,12 +108,18 @@ const naslServer = {
|
|
|
110
108
|
return this.messager.requestCommand('start');
|
|
111
109
|
},
|
|
112
110
|
async createUiTs(allComponent: any) {
|
|
113
|
-
const { code, elementsLogic } = await formatUiTs(allComponent);
|
|
111
|
+
const { code, elementsLogic, naslStdlibMap } = await formatUiTs(allComponent);
|
|
114
112
|
// 放入生產的uits文件
|
|
115
113
|
await naslServer.addFile({
|
|
116
114
|
file: 'nasl.ui.definition.ts',
|
|
117
115
|
fileContent: code,
|
|
118
116
|
});
|
|
117
|
+
Object.keys(naslStdlibMap).forEach(async (libFileName: string) => {
|
|
118
|
+
await naslServer.addFile({
|
|
119
|
+
file: '/' + libFileName,
|
|
120
|
+
fileContent: naslStdlibMap[libFileName],
|
|
121
|
+
});
|
|
122
|
+
});
|
|
119
123
|
naslServer.elementsLogic = elementsLogic;
|
|
120
124
|
// 全部文件加载完毕开始初始化
|
|
121
125
|
await naslServer.getDiagnosticRecordsAndPushAll();
|
|
@@ -207,20 +211,22 @@ const naslServer = {
|
|
|
207
211
|
}
|
|
208
212
|
},
|
|
209
213
|
view2TSFile(viewsChildren: View[], results: Array<ReturnType<Structure['toEmbeddedTSFile']>>) {
|
|
210
|
-
//
|
|
211
|
-
viewsChildren.
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
214
|
+
// 如果有子页面
|
|
215
|
+
if (viewsChildren && viewsChildren.length) {
|
|
216
|
+
viewsChildren.forEach((view) => {
|
|
217
|
+
try {
|
|
218
|
+
const result = view.toEmbeddedTSFile();
|
|
219
|
+
results.push(result);
|
|
220
|
+
view.sourceMap = result.sourceMap;
|
|
221
|
+
this.file2NodeMap.set(result.filePath, view);
|
|
222
|
+
if (view.children.length) {
|
|
223
|
+
naslServer.view2TSFile(view.children, results);
|
|
224
|
+
}
|
|
225
|
+
} catch (err) {
|
|
226
|
+
console.log(err);
|
|
219
227
|
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
});
|
|
228
|
+
});
|
|
229
|
+
}
|
|
224
230
|
},
|
|
225
231
|
async openApp(app: App) {
|
|
226
232
|
const results: Array<ReturnType<Structure['toEmbeddedTSFile']>> = [];
|
|
@@ -250,19 +256,16 @@ const naslServer = {
|
|
|
250
256
|
callback();
|
|
251
257
|
});
|
|
252
258
|
},
|
|
253
|
-
async
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}));
|
|
264
|
-
await this.writeFiles(files);
|
|
265
|
-
this._debugInFileStorage(module.parentNode as App, files);
|
|
259
|
+
async refreshApp(app: App) {
|
|
260
|
+
// 清除所有问题
|
|
261
|
+
diagnosticManager.clear();
|
|
262
|
+
await naslServer.deleteDirectoryFiles({ directoryName: '/embedded' });
|
|
263
|
+
// 清楚check count的数量
|
|
264
|
+
await this.messager.requestCommand('_clearTimeout');
|
|
265
|
+
// 重新加载app下内容
|
|
266
|
+
await naslServer.openApp(app);
|
|
267
|
+
// 重新check一遍所有内容
|
|
268
|
+
await naslServer.getDiagnosticRecordsAndPushAll();
|
|
266
269
|
},
|
|
267
270
|
/**
|
|
268
271
|
* 初始化之前添加文件
|
|
@@ -277,14 +280,7 @@ const naslServer = {
|
|
|
277
280
|
writeFiles(files: Array<tsProtocol.OpenRequestArgs>) {
|
|
278
281
|
return this.messager.requestCommand('writeFiles', files);
|
|
279
282
|
},
|
|
280
|
-
|
|
281
|
-
* 新增或修改文件
|
|
282
|
-
* @param {*} files
|
|
283
|
-
* @returns
|
|
284
|
-
*/
|
|
285
|
-
outputFiles(files: Array<tsProtocol.OpenRequestArgs>) {
|
|
286
|
-
return this.messager.requestCommand('outputFiles', files);
|
|
287
|
-
},
|
|
283
|
+
|
|
288
284
|
/**
|
|
289
285
|
* 新增、修改
|
|
290
286
|
* 删除文件 文件用修改内容为空模拟,防止报错
|
|
@@ -293,21 +289,26 @@ const naslServer = {
|
|
|
293
289
|
updateFiles(args: { outputFiles: Array<tsProtocol.OpenRequestArgs> }) {
|
|
294
290
|
return this.messager.requestCommand('updateFiles', args);
|
|
295
291
|
},
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* 清除一个目录下的所有文件
|
|
295
|
+
*/
|
|
296
|
+
deleteDirectoryFiles(args: { directoryName: string }) {
|
|
297
|
+
return this.messager.requestCommand('deleteDirectoryFiles', args);
|
|
298
|
+
},
|
|
296
299
|
_debugInFileStorage(node: BaseNode, openFiles: Array<tsProtocol.OpenRequestArgs>) {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
app = (node as any).rootNode || (node as any).app;
|
|
302
|
-
}
|
|
303
|
-
return Promise.all(openFiles.map(async (file) => {
|
|
304
|
-
const res = await axios.post('/api/App/debugEmbedded?id=' + app.id, file);
|
|
305
|
-
return res.data;
|
|
306
|
-
}));
|
|
307
|
-
}
|
|
308
|
-
} catch (err) {
|
|
309
|
-
console.log(err);
|
|
300
|
+
/// #if process.env.NODE_ENV === 'development'
|
|
301
|
+
let app = node;
|
|
302
|
+
if (node.concept !== 'App') {
|
|
303
|
+
app = (node as any).rootNode || (node as any).app;
|
|
310
304
|
}
|
|
305
|
+
return Promise.all(openFiles.map(async (file) => {
|
|
306
|
+
const res = await axios.post('/api/App/debugEmbedded?id=' + app.id, file);
|
|
307
|
+
return res.data;
|
|
308
|
+
})).catch((e) => {
|
|
309
|
+
console.error(e);
|
|
310
|
+
});
|
|
311
|
+
/// #endif
|
|
311
312
|
},
|
|
312
313
|
open() {
|
|
313
314
|
return this.messager.requestCommand('open');
|
|
@@ -348,7 +349,9 @@ const naslServer = {
|
|
|
348
349
|
const types = reg.exec(displayString);
|
|
349
350
|
// 取出提示的类型,组成是数组
|
|
350
351
|
const typeList: string[] = types[1].split(' | ').map((item: string) => {
|
|
351
|
-
if (
|
|
352
|
+
if (/\<([^()]+)\>/g.exec(item)) {
|
|
353
|
+
return item;
|
|
354
|
+
} else if (item.includes(' ')) {
|
|
352
355
|
const strs = item.split(' ');
|
|
353
356
|
const type = strs[strs.length - 1];
|
|
354
357
|
return type;
|
|
@@ -363,7 +366,7 @@ const naslServer = {
|
|
|
363
366
|
return typeList;
|
|
364
367
|
},
|
|
365
368
|
async getTypeQuickinfo(node: BaseNode) {
|
|
366
|
-
if (node instanceof
|
|
369
|
+
if (node && node instanceof BaseNode) {
|
|
367
370
|
const callFunction = node.parentNode.parentNode;
|
|
368
371
|
/**
|
|
369
372
|
* currentSource callFunction 的节点,要去到当前节点的位置
|
|
@@ -384,22 +387,45 @@ const naslServer = {
|
|
|
384
387
|
const typeAnnotation = primitiveTypeList.find((typeAnnotation) => typeAnnotation.typeName === type);
|
|
385
388
|
if (typeAnnotation) {
|
|
386
389
|
res.push(typeAnnotation);
|
|
387
|
-
} else if (type === 'unknown') {
|
|
390
|
+
} else if (type === 'unknown' || type === 'never') {
|
|
388
391
|
return null;
|
|
389
392
|
}
|
|
390
393
|
});
|
|
391
394
|
if (!res.length) {
|
|
392
|
-
|
|
395
|
+
return [];
|
|
396
|
+
} else {
|
|
397
|
+
return [{ title: '基础类型', children: res }];
|
|
393
398
|
}
|
|
394
|
-
// 调整结构
|
|
395
|
-
const dataTypeList: Array<{
|
|
396
|
-
title: string;
|
|
397
|
-
children: Array<TypeAnnotation>;
|
|
398
|
-
}> = [{ title: '基础类型', children: res }];
|
|
399
|
-
return dataTypeList;
|
|
400
399
|
}
|
|
400
|
+
} else {
|
|
401
|
+
// 字符串 和 inter
|
|
402
|
+
return [{ title: '基础类型', children: [primitiveTypeList[4]] }];
|
|
401
403
|
}
|
|
402
404
|
},
|
|
405
|
+
async getDataSchemaType(node: BaseNode) {
|
|
406
|
+
if (!(node instanceof ViewElement))
|
|
407
|
+
return;
|
|
408
|
+
const { currentSource, fileNode } = naslServer.getCurrentSource(node);
|
|
409
|
+
const quickInfo = await naslServer._getTypeQuickinfo({
|
|
410
|
+
file: (fileNode as FileNode).getEmbeddedFilePath(),
|
|
411
|
+
line: lsp2tspNumber(currentSource.range.start.line),
|
|
412
|
+
offset: lsp2tspNumber(currentSource.range.start.character) + `__elements.`.length,
|
|
413
|
+
});
|
|
414
|
+
if (quickInfo.responseRequired) {
|
|
415
|
+
const displayString = quickInfo?.response?.displayString || '';
|
|
416
|
+
const flag = displayString.includes('<') && displayString.includes('>');
|
|
417
|
+
if (flag) {
|
|
418
|
+
let str = '';
|
|
419
|
+
const types = naslServer.getDisplayString2Type(displayString);
|
|
420
|
+
if (Array.isArray(types) && types.length) {
|
|
421
|
+
const type = types[0];
|
|
422
|
+
str = type === 'any' || type === 'unknown' || type === 'never' ? '' : type;
|
|
423
|
+
}
|
|
424
|
+
return str;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return '';
|
|
428
|
+
},
|
|
403
429
|
_getTypeQuickinfo(args: any) {
|
|
404
430
|
return this.messager.requestCommand('quickInfo', args) as unknown as { responseRequired: boolean; response: tsProtocol.QuickInfoResponseBody };
|
|
405
431
|
},
|
|
@@ -446,7 +472,7 @@ const naslServer = {
|
|
|
446
472
|
|
|
447
473
|
// 语义诊断
|
|
448
474
|
record.semanticDiagnostics = record.semanticDiagnostics
|
|
449
|
-
.map((diag) => this._resolveDiagnostic(diag as unknown as tsProtocol.DiagnosticWithFileName,
|
|
475
|
+
.map((diag) => this._resolveDiagnostic(diag as unknown as tsProtocol.DiagnosticWithFileName, node as FileNode))
|
|
450
476
|
.filter((diag) => !!diag);
|
|
451
477
|
|
|
452
478
|
// 建议诊断
|
|
@@ -480,9 +506,8 @@ const naslServer = {
|
|
|
480
506
|
};
|
|
481
507
|
|
|
482
508
|
if (minRange) {
|
|
483
|
-
// let message = this.translateDiagnosticMessage(diagnostic.text);
|
|
484
509
|
// 节点的error要置为true
|
|
485
|
-
return
|
|
510
|
+
return naslNodeTranslateMessage(minRange, tsErrorDetail);
|
|
486
511
|
} else {
|
|
487
512
|
// 没找到节点, 先把问题暴露出来
|
|
488
513
|
return {
|
|
@@ -491,60 +516,6 @@ const naslServer = {
|
|
|
491
516
|
};
|
|
492
517
|
}
|
|
493
518
|
},
|
|
494
|
-
/**
|
|
495
|
-
* 处理一些边界情况
|
|
496
|
-
* @param minRange
|
|
497
|
-
* @param tsErrorDetail 报错具体信息
|
|
498
|
-
* @returns
|
|
499
|
-
*/
|
|
500
|
-
_diagnosticSpecialTreatment(minRange: MinRange, tsErrorDetail: Diagnostic) {
|
|
501
|
-
const text = tsErrorDetail.originalDiagnostic.text;
|
|
502
|
-
// 有一些节点报错信息不向外暴露,缺失一些原生标签等等的展示
|
|
503
|
-
if (minRange.node instanceof View || minRange.node instanceof ViewElement) {
|
|
504
|
-
if (text.startsWith(`'nasl.ui' has no exported member named `)) {
|
|
505
|
-
return null;
|
|
506
|
-
} else if (text.startsWith(`Property '`) && text.includes(`does not exist on type 'typeof ui'.`)) {
|
|
507
|
-
return null;
|
|
508
|
-
} else if (text.startsWith(`Namespace 'nasl.ui' has no exported member `)) {
|
|
509
|
-
return null;
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
if (/Expected (.+?) arguments, but got (.+?)./.exec(text)) {
|
|
513
|
-
// bindevent本身现在就不传参数
|
|
514
|
-
if (minRange.node instanceof BindEvent) {
|
|
515
|
-
return null;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
// 因为缺少参数时候有可能有特殊情况,因为原本少的多了就会找到 callLogic上,
|
|
520
|
-
// 但是只少一个的时候就会找到准确的Argument上 需要特殊处理, ui层就可以统一处理
|
|
521
|
-
if (minRange.node instanceof Argument) {
|
|
522
|
-
if (/Expected (.+?) arguments, but got (.+?)./.exec(text)) {
|
|
523
|
-
minRange.node = minRange.node.parentNode;
|
|
524
|
-
} else {
|
|
525
|
-
// if (/Type '(.+?)' is not assignable to type '(.+?)'./.exec(text)) {
|
|
526
|
-
// }
|
|
527
|
-
// Argument在callInterface上的报错放到内部
|
|
528
|
-
if (minRange.node.expression) {
|
|
529
|
-
minRange.node = minRange.node.expression;
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
if (/'(.+?)' has no exported member(?: named)? '(.+?)'/.exec(text) || /Property '(.+?)' does not exist on type '(.+?)'./.exec(text)) {
|
|
535
|
-
if (minRange.node instanceof TypeAnnotation) {
|
|
536
|
-
// 变量type的报错放到内部
|
|
537
|
-
minRange.node = minRange.node.parentNode;
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
minRange.node.tsErrorDetail = tsErrorDetail;
|
|
542
|
-
return {
|
|
543
|
-
id: minRange.node.id,
|
|
544
|
-
node: minRange.node,
|
|
545
|
-
...tsErrorDetail,
|
|
546
|
-
};
|
|
547
|
-
},
|
|
548
519
|
_findMinRange(diagnostic: tsProtocol.DiagnosticWithFileName | tsProtocol.ReferencesResponseItem, fileNode: FileNode) {
|
|
549
520
|
let minRange: MinRange;
|
|
550
521
|
const sourceMap: SourceMap = fileNode.sourceMap;
|
|
@@ -599,6 +570,23 @@ const naslServer = {
|
|
|
599
570
|
offset: lsp2tspNumber(currentSource.range.start.character),
|
|
600
571
|
});
|
|
601
572
|
refsList = [...newRefs.refs];
|
|
573
|
+
} else {
|
|
574
|
+
if (node instanceof Module) {
|
|
575
|
+
const lists = node.logics || node.structures || node.enums;
|
|
576
|
+
const moduleName = (fileNode as FileNode).getEmbeddedFilePath();
|
|
577
|
+
if (lists.length) {
|
|
578
|
+
const item = lists[0];
|
|
579
|
+
const { fileNode } = naslServer.getCurrentSource(item);
|
|
580
|
+
const newRefs = await naslServer.references({
|
|
581
|
+
file: (fileNode as FileNode).getEmbeddedFilePath(),
|
|
582
|
+
line: 1,
|
|
583
|
+
offset: 22, //固定的位置,module的位置信息
|
|
584
|
+
});
|
|
585
|
+
refsList = newRefs.refs.filter((item) => !item.file.startsWith(moduleName));
|
|
586
|
+
// 多塞一个 ,删除的时候就有值了, 上面过滤了之后可能是空的
|
|
587
|
+
refsList.unshift(newRefs.refs[0]);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
602
590
|
}
|
|
603
591
|
|
|
604
592
|
// 如果是entity就需要在单独,查一边来修改名字
|
|
@@ -611,7 +599,7 @@ const naslServer = {
|
|
|
611
599
|
|
|
612
600
|
if (node instanceof Return) {
|
|
613
601
|
// 过滤一下最后出去的值
|
|
614
|
-
refsList = refsList.filter((item) => !
|
|
602
|
+
refsList = refsList.filter((item) => !item.lineText.includes('return '));
|
|
615
603
|
}
|
|
616
604
|
|
|
617
605
|
// 如果是参数, 就需要把logic的引用 都查找出来就需要把他的父级的引用全部查找出来
|
|
@@ -672,18 +660,24 @@ const naslServer = {
|
|
|
672
660
|
line: lsp2tspNumber(currentSource.range.start.line),
|
|
673
661
|
offset: lsp2tspNumber(currentSource.range.start.character + methodsNameIndex),
|
|
674
662
|
});
|
|
675
|
-
const methodRefs
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
663
|
+
const methodRefs: tsProtocol.ReferencesResponseItem[] = [];
|
|
664
|
+
methods.refs.forEach((item) => {
|
|
665
|
+
// 定义里的格式,在删除的时候留下来占位
|
|
666
|
+
// 重命名的时候会过滤
|
|
667
|
+
|
|
668
|
+
// 这里只过滤 __elements.button = new nasl.ui.Button<any>这种格式
|
|
669
|
+
// if (item.lineText.includes('__elements.') && item.lineText.includes('new nasl.ui.'))
|
|
670
|
+
// return false;
|
|
671
|
+
// 处理声明组件名可能重复的问题, 查找引用不提示
|
|
672
|
+
const find = methodRefs.find((findItem) => item.lineText === findItem.lineText && item.lineText.includes(': nasl.ui.'));
|
|
673
|
+
if (!find) {
|
|
674
|
+
methodRefs.push(item);
|
|
681
675
|
}
|
|
682
|
-
return true;
|
|
683
676
|
});
|
|
684
677
|
refsList = [...methodRefs];
|
|
685
678
|
}
|
|
686
679
|
}
|
|
680
|
+
console.log(refsList, 'refsList');
|
|
687
681
|
return refsList;
|
|
688
682
|
},
|
|
689
683
|
/**
|
|
@@ -701,7 +695,7 @@ const naslServer = {
|
|
|
701
695
|
const fileNode = this.file2NodeMap.get(record.file);
|
|
702
696
|
if (!fileNode)
|
|
703
697
|
return null;
|
|
704
|
-
const minRange: reNameMinRange = this._findMinRange(record,
|
|
698
|
+
const minRange: reNameMinRange = this._findMinRange(record, fileNode as FileNode);
|
|
705
699
|
if (minRange) {
|
|
706
700
|
// 如果节点是TypeAnnotation类型,
|
|
707
701
|
// 很复杂,可能是多级嵌套结构
|
|
@@ -715,7 +709,7 @@ const naslServer = {
|
|
|
715
709
|
minRange.setTypeMethods = 'setCalleeName';
|
|
716
710
|
}
|
|
717
711
|
if (minRange.node instanceof CallLogic && node instanceof ViewElement) {
|
|
718
|
-
minRange.setTypeMethods = '
|
|
712
|
+
minRange.setTypeMethods = 'setCalleeNamespace';
|
|
719
713
|
minRange.newValue = 'elements.' + newValue + '.logics';
|
|
720
714
|
}
|
|
721
715
|
// 如果节点是实体修改引发calllogic修改
|
|
@@ -862,7 +856,12 @@ const naslServer = {
|
|
|
862
856
|
// 如果是view也需要加前缀
|
|
863
857
|
// logic 和 views名称修改 可能会触发bindEvent修改
|
|
864
858
|
if (minRange.node instanceof BindEvent) {
|
|
865
|
-
|
|
859
|
+
// 页面逻辑直接赋值就可以, 因为是相对路径
|
|
860
|
+
if ((node instanceof ViewElement)) {
|
|
861
|
+
minRange.setTypeMethods = 'setCalleeNamespace';
|
|
862
|
+
minRange.newValue = 'elements.' + newValue + '.logics';
|
|
863
|
+
} else {
|
|
864
|
+
/**
|
|
866
865
|
* 如果namespce是 'app.views.Student.views.404.views.505.views.update'
|
|
867
866
|
* 在ts中会是'app.views.Student.views.$404.views.$505.views.update'
|
|
868
867
|
* 但是505 要改名为 666 ,要存的是666
|
|
@@ -871,26 +870,45 @@ const naslServer = {
|
|
|
871
870
|
* 2.在匹配到的内容中取转后的namespace的位置
|
|
872
871
|
* 3.然后把namespace中的 $替换成 ''
|
|
873
872
|
*/
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
// 先看下标位置
|
|
877
|
-
const lineText = record.lineText;
|
|
878
|
-
const index = lineText.indexOf(oldValue);
|
|
873
|
+
const tsCalleeNamespace = minRange.node.tsCalleeNamespace;
|
|
874
|
+
const oldValue = tsCalleeNamespace;
|
|
879
875
|
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
876
|
+
// 先看下标位置
|
|
877
|
+
const lineText = record.lineText;
|
|
878
|
+
const index = lineText.indexOf(oldValue);
|
|
879
|
+
|
|
880
|
+
// 在把开始结束位置的-开始位置,来知道是哪里要替换
|
|
881
|
+
const start = record.start.offset - index - 1;
|
|
882
|
+
const end = record.end.offset - index - 1;
|
|
883
883
|
|
|
884
|
-
// 新的完整的value
|
|
885
|
-
if (start > tsCalleeNamespace.length) {
|
|
886
|
-
minRange.setTypeMethods = 'setCalleeName';
|
|
887
|
-
minRange.newValue = newValue;
|
|
888
|
-
} else {
|
|
889
884
|
// 新的完整的value
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
885
|
+
if (start > tsCalleeNamespace.length) {
|
|
886
|
+
minRange.setTypeMethods = 'setCalleeName';
|
|
887
|
+
minRange.newValue = newValue;
|
|
888
|
+
} else {
|
|
889
|
+
// 新的完整的value
|
|
890
|
+
let newTsNameSpace = tsCalleeNamespace.substring(0, start) + newValue + tsCalleeNamespace.substring(end, tsCalleeNamespace.length);
|
|
891
|
+
minRange.setTypeMethods = 'setCalleeNamespace';
|
|
892
|
+
newTsNameSpace = newTsNameSpace.replace(/\.\$/g, '.');
|
|
893
|
+
minRange.newValue = newTsNameSpace;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
if (minRange.node instanceof Destination && node instanceof Param) {
|
|
898
|
+
// 因为view是key value 绑定所以需要重新赋值
|
|
899
|
+
if (node.parentNode instanceof View) {
|
|
900
|
+
const nodeArguments = minRange.node.arguments;
|
|
901
|
+
const findArgument = nodeArguments.find((item) => node.name === item.keyword);
|
|
902
|
+
if (findArgument) {
|
|
903
|
+
minRange.setTypeMethods = 'setArgumentsKeyWord';
|
|
904
|
+
minRange.newValue = {
|
|
905
|
+
findArgument,
|
|
906
|
+
newKeyword: newValue,
|
|
907
|
+
};
|
|
908
|
+
}
|
|
909
|
+
} else {
|
|
910
|
+
// 如果是修改param查找到Destination就不操作
|
|
911
|
+
return null;
|
|
894
912
|
}
|
|
895
913
|
}
|
|
896
914
|
if (minRange.node instanceof Interface && node instanceof Logic) {
|
|
@@ -906,17 +924,17 @@ const naslServer = {
|
|
|
906
924
|
const newBindRoles = str.split(',');
|
|
907
925
|
minRange.newValue = newBindRoles;
|
|
908
926
|
}
|
|
909
|
-
if (
|
|
927
|
+
if (minRange.node instanceof QueryFieldExpression && node instanceof Entity) {
|
|
910
928
|
minRange.setTypeMethods = 'setEntityAsName';
|
|
911
929
|
}
|
|
912
930
|
|
|
913
|
-
if ((minRange.node instanceof QueryFromExpression) &&
|
|
931
|
+
if ((minRange.node instanceof QueryFromExpression || minRange.node instanceof QueryJoinExpression) && node instanceof Entity) {
|
|
914
932
|
minRange.setTypeMethods = 'setEntityName';
|
|
915
933
|
}
|
|
916
|
-
if (
|
|
934
|
+
if (minRange.node instanceof QueryFieldExpression && node instanceof EntityProperty) {
|
|
917
935
|
minRange.setTypeMethods = 'setPropertyName';
|
|
918
936
|
}
|
|
919
|
-
if (minRange.node instanceof Destination && node instanceof Process) {
|
|
937
|
+
if (minRange.node instanceof Destination && (node instanceof Process || node instanceof ProcessElement)) {
|
|
920
938
|
return null;
|
|
921
939
|
}
|
|
922
940
|
// 枚举修改枚举名,比较特殊
|
|
@@ -928,8 +946,8 @@ const naslServer = {
|
|
|
928
946
|
if (minRange.node instanceof Logic && node instanceof Param) {
|
|
929
947
|
return null;
|
|
930
948
|
}
|
|
931
|
-
//
|
|
932
|
-
if (minRange.node instanceof
|
|
949
|
+
// params修改 查找bindevent不需要修改
|
|
950
|
+
if (minRange.node instanceof BindEvent && node instanceof Param) {
|
|
933
951
|
return null;
|
|
934
952
|
}
|
|
935
953
|
// 如果是子页面修改
|
|
@@ -937,8 +955,37 @@ const naslServer = {
|
|
|
937
955
|
if (minRange.node instanceof View && node instanceof View && minRange.node !== node) {
|
|
938
956
|
return null;
|
|
939
957
|
}
|
|
958
|
+
/**
|
|
959
|
+
* 屏蔽组件生成内容块中的变量或者逻辑,出现在表格选择中。在bindAttr中还会有,所以过滤一把
|
|
960
|
+
*/
|
|
961
|
+
if ((minRange.node instanceof Identifier || minRange.node instanceof MemberExpression) && node instanceof Param && minRange.node.parentNode instanceof BindAttribute) {
|
|
962
|
+
return null;
|
|
963
|
+
}
|
|
964
|
+
// 修改element引发view改名
|
|
965
|
+
if (node instanceof ViewElement && minRange.node instanceof View) {
|
|
966
|
+
return null;
|
|
967
|
+
}
|
|
968
|
+
// params修改 查找View不需要修改
|
|
940
969
|
// 逻辑改名,触发了在定义里面的,element定义,的值,直接掠过
|
|
941
|
-
if (minRange.node instanceof View && node instanceof Logic) {
|
|
970
|
+
if (minRange.node instanceof View && (node instanceof Logic || node instanceof Param)) {
|
|
971
|
+
/**
|
|
972
|
+
* 这里过滤一下,一些查找引用,重复的内容,直接屏蔽掉,防止操作重复
|
|
973
|
+
* 因为在生成的时候 ,可能弄了一些副作用的引用
|
|
974
|
+
*/
|
|
975
|
+
// 本来是想在上面过滤一把的先放到这里匹配这两个的时候 就会找到
|
|
976
|
+
// refsList = refsList.filter((item) => {
|
|
977
|
+
// 屏蔽组件查找查到定义这里,也过滤一下
|
|
978
|
+
// if (item.lineText.includes(': nasl.ui.'))
|
|
979
|
+
// return false;
|
|
980
|
+
// return true;
|
|
981
|
+
// });
|
|
982
|
+
return null;
|
|
983
|
+
}
|
|
984
|
+
// 流程改名不触发Logic改名
|
|
985
|
+
if (minRange.node instanceof Logic && node instanceof Process) {
|
|
986
|
+
return null;
|
|
987
|
+
}
|
|
988
|
+
if (minRange.node instanceof Logic && node instanceof ProcessElement && node.type === 'UserTask') {
|
|
942
989
|
return null;
|
|
943
990
|
}
|
|
944
991
|
} else {
|
|
@@ -955,25 +1002,29 @@ const naslServer = {
|
|
|
955
1002
|
},
|
|
956
1003
|
_addParamsPrepare(node: BaseNode, refsList: any[]) {
|
|
957
1004
|
const App = node.rootNode;
|
|
958
|
-
const
|
|
1005
|
+
const parantNode = node.parentNode as Logic | View;
|
|
959
1006
|
// 收集修改
|
|
960
1007
|
App.emit('collect:start', {
|
|
961
1008
|
actionMsg: '增加逻辑参数',
|
|
962
1009
|
});
|
|
963
1010
|
node.create({
|
|
964
1011
|
index: 0,
|
|
965
|
-
parentNode:
|
|
1012
|
+
parentNode: parantNode,
|
|
966
1013
|
parentKey: node.parentKey,
|
|
967
1014
|
});
|
|
968
1015
|
refsList.forEach((record) => {
|
|
969
1016
|
const fileNode = this.file2NodeMap.get(record.file);
|
|
970
1017
|
if (!fileNode)
|
|
971
1018
|
return null;
|
|
972
|
-
const minRange: MinRange = this._findMinRange(record,
|
|
1019
|
+
const minRange: MinRange = this._findMinRange(record, fileNode as FileNode);
|
|
973
1020
|
if (minRange) {
|
|
974
1021
|
// 如果找到节点是callLogic就去更新
|
|
975
1022
|
if (minRange.node instanceof CallLogic && node instanceof Param) {
|
|
976
|
-
minRange.node.setCalleeArgName(
|
|
1023
|
+
minRange.node.setCalleeArgName((parantNode) as Logic);
|
|
1024
|
+
}
|
|
1025
|
+
// 如果节点参数增加页面也要更新
|
|
1026
|
+
if (minRange.node instanceof Destination && node instanceof Param) {
|
|
1027
|
+
minRange.node.setViewArgument((parantNode) as View);
|
|
977
1028
|
}
|
|
978
1029
|
}
|
|
979
1030
|
});
|
|
@@ -983,10 +1034,13 @@ const naslServer = {
|
|
|
983
1034
|
// 查找引用
|
|
984
1035
|
async findReferences(node: BaseNode) {
|
|
985
1036
|
let refsList = await naslServer._isHaveRef(node);
|
|
986
|
-
console.log(refsList, 'refsList');
|
|
987
1037
|
// 如果查找引用查到自己里面的引用不展示
|
|
988
|
-
refsList = refsList.filter((item) =>
|
|
989
|
-
|
|
1038
|
+
refsList = refsList.filter((item) => {
|
|
1039
|
+
// 自己引用自己的过滤掉
|
|
1040
|
+
// 删除的时候过滤一把组件删除提示
|
|
1041
|
+
// 展示组件自己屏蔽掉
|
|
1042
|
+
return !item.isDefinition && !(item.lineText.includes(' = new nasl.ui.'));
|
|
1043
|
+
});
|
|
990
1044
|
// 最后返回的结果
|
|
991
1045
|
let result = new Map();
|
|
992
1046
|
// 树的构造,key: 一个file的node, 值是 [[logic, params],[logic, returns]]
|
|
@@ -998,7 +1052,7 @@ const naslServer = {
|
|
|
998
1052
|
const fileNode = this.file2NodeMap.get(record.file);
|
|
999
1053
|
if (!fileNode)
|
|
1000
1054
|
return;
|
|
1001
|
-
const minRange = this._findMinRange(record,
|
|
1055
|
+
const minRange = this._findMinRange(record, fileNode as FileNode);
|
|
1002
1056
|
// 过滤一把不需要改的信息
|
|
1003
1057
|
if (minRange) {
|
|
1004
1058
|
// 拼装树
|
|
@@ -1034,7 +1088,9 @@ const naslServer = {
|
|
|
1034
1088
|
// 排除一些不放入集合的节点
|
|
1035
1089
|
let isNeedPush = true;
|
|
1036
1090
|
// 如果不是ViewElement 或者 Assignment , 或者如果是的话, 排除l-root
|
|
1037
|
-
if (currentNode instanceof ViewElement && (currentNode as ViewElement).tag
|
|
1091
|
+
if (currentNode instanceof ViewElement && (currentNode as ViewElement).tag === 'l-root')
|
|
1092
|
+
isNeedPush = false;
|
|
1093
|
+
else if (currentNode instanceof Argument)
|
|
1038
1094
|
isNeedPush = false;
|
|
1039
1095
|
else if (currentNode instanceof Assignment)
|
|
1040
1096
|
isNeedPush = false;
|
|
@@ -1137,6 +1193,8 @@ const naslServer = {
|
|
|
1137
1193
|
* 当前this上下文 的Source 和 父级文件级别的节点
|
|
1138
1194
|
*/
|
|
1139
1195
|
getCurrentSource(node: BaseNode) {
|
|
1196
|
+
if (node instanceof App || node instanceof Theme)
|
|
1197
|
+
return { fileNode: null };
|
|
1140
1198
|
let sourceMap = node.sourceMap;
|
|
1141
1199
|
let fileNode = node;
|
|
1142
1200
|
// 如果没有sourceMap,就继续向上找 ,或者到module结束
|
|
@@ -1216,6 +1274,47 @@ async function handleDelete(fileNode: BaseNode, targetNode: BaseNode, result: Re
|
|
|
1216
1274
|
// console.log('filesToCheck', filesToCheck, filesToCheck.size);
|
|
1217
1275
|
await naslServer.getDiagnosticRecordsAndPushAll(Array.from(filesToCheck));
|
|
1218
1276
|
}
|
|
1277
|
+
BaseNode.prototype.findReadOnlyLogicUsage = function () {
|
|
1278
|
+
let targetNode;
|
|
1279
|
+
|
|
1280
|
+
if (this.parentNode.concept === 'Namespace' || this.parentNode.parentNode.concept === 'Namespace') {
|
|
1281
|
+
const sourceMap = this.parentNode.concept === 'Namespace' ? this.parentNode.parentNode.sourceMap : this.parentNode.parentNode.parentNode.sourceMap;
|
|
1282
|
+
for (const item of sourceMap) {
|
|
1283
|
+
const logic = item[0] as Logic;
|
|
1284
|
+
if (this.concept === 'Logic') {
|
|
1285
|
+
if (logic instanceof Logic)
|
|
1286
|
+
if (logic.calleewholeKey === (this as Logic).calleewholeKey) {
|
|
1287
|
+
targetNode = logic;
|
|
1288
|
+
break;
|
|
1289
|
+
}
|
|
1290
|
+
} else {
|
|
1291
|
+
if (logic instanceof Logic)
|
|
1292
|
+
if (logic.calleewholeKey === (this.parentNode as Logic).calleewholeKey) {
|
|
1293
|
+
targetNode = logic;
|
|
1294
|
+
break;
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
} else if (this.parentNode.concept === 'Module') {
|
|
1299
|
+
// 父级是模块的还是用它本身去查找引用
|
|
1300
|
+
targetNode = this;
|
|
1301
|
+
} else {
|
|
1302
|
+
const sourceMap = this.parentNode.sourceMap;
|
|
1303
|
+
for (const item of sourceMap) {
|
|
1304
|
+
const logic = item[0] as Logic;
|
|
1305
|
+
if (logic.getNamespace && logic.getNamespace() === (this as Logic).getNamespace()) {
|
|
1306
|
+
targetNode = logic;
|
|
1307
|
+
break;
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
try {
|
|
1313
|
+
return naslServer.findReferences(targetNode);
|
|
1314
|
+
} catch (err) {
|
|
1315
|
+
console.log(err);
|
|
1316
|
+
}
|
|
1317
|
+
};
|
|
1219
1318
|
// 查找引用
|
|
1220
1319
|
BaseNode.prototype.findUsage = function findUsage() {
|
|
1221
1320
|
try {
|
|
@@ -1241,7 +1340,7 @@ BaseNode.prototype.changeName = async function changeName(newValue: string, upda
|
|
|
1241
1340
|
*/
|
|
1242
1341
|
const res = naslServer._renamePrepare(this, refsList, newValue);
|
|
1243
1342
|
if (res.length <= 1) {
|
|
1244
|
-
(this as
|
|
1343
|
+
(this as SetNameNode).setName(newValue);
|
|
1245
1344
|
} else {
|
|
1246
1345
|
const callback = (value: boolean) => {
|
|
1247
1346
|
if (value) {
|
|
@@ -1251,7 +1350,7 @@ BaseNode.prototype.changeName = async function changeName(newValue: string, upda
|
|
|
1251
1350
|
actionMsg: '重命名并更新引用',
|
|
1252
1351
|
});
|
|
1253
1352
|
res.forEach((item) => {
|
|
1254
|
-
const itemNode = item.node as
|
|
1353
|
+
const itemNode = item.node as SetNameNode;
|
|
1255
1354
|
if (item.newValue) {
|
|
1256
1355
|
// 如果有指定的修改方法,就用那个,没有就修改名字
|
|
1257
1356
|
item.setTypeMethods ? itemNode[item.setTypeMethods](item.newValue) : itemNode.setName?.(item.newValue);
|
|
@@ -1262,7 +1361,7 @@ BaseNode.prototype.changeName = async function changeName(newValue: string, upda
|
|
|
1262
1361
|
// 结束修改 ,批量操作
|
|
1263
1362
|
App.emit('collect:end');
|
|
1264
1363
|
} else {
|
|
1265
|
-
(this as
|
|
1364
|
+
(this as SetNameNode).setName(newValue);
|
|
1266
1365
|
}
|
|
1267
1366
|
};
|
|
1268
1367
|
const confirmParms = {
|
|
@@ -1300,8 +1399,26 @@ BaseNode.prototype.prepareDelete = async function prepareDelete() {
|
|
|
1300
1399
|
* 查找这个节点是不是有依赖
|
|
1301
1400
|
*/
|
|
1302
1401
|
const node = this;
|
|
1303
|
-
|
|
1304
|
-
|
|
1402
|
+
let refsList = await naslServer._isHaveRef(node);
|
|
1403
|
+
// 删除的时候过滤一把组件删除提示
|
|
1404
|
+
refsList = refsList.filter((item) => {
|
|
1405
|
+
// 因为ui组件本身会多渲染一次,就先过滤一个
|
|
1406
|
+
return !(item.lineText.includes(': nasl.ui.'));
|
|
1407
|
+
});
|
|
1408
|
+
// 删除参数单独处理
|
|
1409
|
+
if (node instanceof Param) {
|
|
1410
|
+
const methodRefs: tsProtocol.ReferencesResponseItem[] = [];
|
|
1411
|
+
refsList.forEach((item) => {
|
|
1412
|
+
// 入参查找引用,查到logic 和自己,内容完全一样,就保留一个
|
|
1413
|
+
const find = methodRefs.find((findItem) => item.lineText === findItem.lineText);
|
|
1414
|
+
if (!find) {
|
|
1415
|
+
methodRefs.push(item);
|
|
1416
|
+
}
|
|
1417
|
+
});
|
|
1418
|
+
refsList = methodRefs;
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
// delete的弹框展示
|
|
1305
1422
|
const confirmParms = {
|
|
1306
1423
|
actionType: 'delete',
|
|
1307
1424
|
tipFlag: false,
|
|
@@ -1327,12 +1444,27 @@ BaseNode.prototype.prepareDelete = async function prepareDelete() {
|
|
|
1327
1444
|
// 如果有依赖就有一个查找引用提示
|
|
1328
1445
|
confirmParms.tipFlag = true;
|
|
1329
1446
|
const node = this;
|
|
1447
|
+
|
|
1448
|
+
// 删除页面或者流程
|
|
1449
|
+
if (node instanceof View || node instanceof Process) {
|
|
1450
|
+
/**
|
|
1451
|
+
* 查找这个页面是不是有依赖
|
|
1452
|
+
*/
|
|
1453
|
+
let viewPath = (this as FileNode).getEmbeddedFilePath();
|
|
1454
|
+
viewPath = viewPath.slice(0, viewPath.length - 3);
|
|
1455
|
+
const find = refsList.find((record) => !record.file.includes(viewPath));
|
|
1456
|
+
// 如果没有别的文件的依赖,就直接delete
|
|
1457
|
+
if (!find) {
|
|
1458
|
+
this.delete();
|
|
1459
|
+
return;
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1330
1462
|
callback = () => {
|
|
1331
1463
|
// removeParam
|
|
1332
1464
|
// 跟rename 还不太一样,部分修改依赖修改好的值,然后在下面的修改需要把自己传递进去
|
|
1333
1465
|
if (node instanceof Param) {
|
|
1334
1466
|
const App = this.rootNode;
|
|
1335
|
-
const
|
|
1467
|
+
const parentNode = this.parentNode;
|
|
1336
1468
|
// 收集修改
|
|
1337
1469
|
App.emit('collect:start', {
|
|
1338
1470
|
actionMsg: '删除参数',
|
|
@@ -1342,10 +1474,13 @@ BaseNode.prototype.prepareDelete = async function prepareDelete() {
|
|
|
1342
1474
|
const fileNode = naslServer.file2NodeMap.get(record.file);
|
|
1343
1475
|
if (!fileNode)
|
|
1344
1476
|
return null;
|
|
1345
|
-
const minRange: MinRange = naslServer._findMinRange(record,
|
|
1477
|
+
const minRange: MinRange = naslServer._findMinRange(record, fileNode as FileNode);
|
|
1346
1478
|
if (minRange) {
|
|
1347
1479
|
if (minRange.node instanceof CallLogic) {
|
|
1348
|
-
minRange.node.setCalleeArgName(
|
|
1480
|
+
minRange.node.setCalleeArgName(parentNode as Logic);
|
|
1481
|
+
}
|
|
1482
|
+
if (minRange.node instanceof Destination) {
|
|
1483
|
+
minRange.node.setViewArgument(parentNode as View);
|
|
1349
1484
|
}
|
|
1350
1485
|
}
|
|
1351
1486
|
});
|
|
@@ -1365,7 +1500,7 @@ BaseNode.prototype.prepareDelete = async function prepareDelete() {
|
|
|
1365
1500
|
const fileNode = naslServer.file2NodeMap.get(record.file);
|
|
1366
1501
|
if (!fileNode)
|
|
1367
1502
|
return null;
|
|
1368
|
-
const minRange: MinRange = naslServer._findMinRange(record,
|
|
1503
|
+
const minRange: MinRange = naslServer._findMinRange(record, fileNode as FileNode);
|
|
1369
1504
|
if (minRange) {
|
|
1370
1505
|
if (minRange.node instanceof Interface) {
|
|
1371
1506
|
minRange.node.delete();
|
|
@@ -1374,6 +1509,7 @@ BaseNode.prototype.prepareDelete = async function prepareDelete() {
|
|
|
1374
1509
|
});
|
|
1375
1510
|
// 结束修改 ,批量操作
|
|
1376
1511
|
App.emit('collect:end');
|
|
1512
|
+
return;
|
|
1377
1513
|
}
|
|
1378
1514
|
// 删除权限节点
|
|
1379
1515
|
if (node instanceof Role) {
|
|
@@ -1387,7 +1523,7 @@ BaseNode.prototype.prepareDelete = async function prepareDelete() {
|
|
|
1387
1523
|
const fileNode = naslServer.file2NodeMap.get(record.file);
|
|
1388
1524
|
if (!fileNode)
|
|
1389
1525
|
return null;
|
|
1390
|
-
const minRange: MinRange = naslServer._findMinRange(record,
|
|
1526
|
+
const minRange: MinRange = naslServer._findMinRange(record, fileNode as FileNode);
|
|
1391
1527
|
if (minRange) {
|
|
1392
1528
|
if (minRange.node instanceof View || minRange.node instanceof ViewElement) {
|
|
1393
1529
|
// oldName旧的节点存的值
|
|
@@ -1404,6 +1540,10 @@ BaseNode.prototype.prepareDelete = async function prepareDelete() {
|
|
|
1404
1540
|
return;
|
|
1405
1541
|
}
|
|
1406
1542
|
|
|
1543
|
+
// 删除页面或者流程,如果上一步没有return 就说明他是有别的引用的,会有引用弹框
|
|
1544
|
+
if (node instanceof View || node instanceof Process) {
|
|
1545
|
+
this.delete();
|
|
1546
|
+
}
|
|
1407
1547
|
// 其余的都直接调用删除
|
|
1408
1548
|
// Structure 和 Interface是内部有delete方法
|
|
1409
1549
|
if (node instanceof Structure || node instanceof Interface) {
|
|
@@ -1434,30 +1574,6 @@ BaseNode.prototype.addParamsPrepare = async function addParamsPrepare() {
|
|
|
1434
1574
|
}
|
|
1435
1575
|
};
|
|
1436
1576
|
|
|
1437
|
-
/**
|
|
1438
|
-
* 页面的删除同步他的子页面要一起删除
|
|
1439
|
-
*/
|
|
1440
|
-
BaseNode.prototype.viewPrepareDelete = async function viewPrepareDelete() {
|
|
1441
|
-
try {
|
|
1442
|
-
/**
|
|
1443
|
-
* 查找这个页面是不是有依赖
|
|
1444
|
-
*/
|
|
1445
|
-
const refsList = await naslServer._isHaveRef(this);
|
|
1446
|
-
let viewPath = (this as FileNode).getEmbeddedFilePath();
|
|
1447
|
-
viewPath = viewPath.slice(0, viewPath.length - 3);
|
|
1448
|
-
const find = refsList.find((record) => !record.file.includes(viewPath));
|
|
1449
|
-
// 如果有别的文件的依赖
|
|
1450
|
-
if (find) {
|
|
1451
|
-
// 就展示弹框
|
|
1452
|
-
this.prepareDelete();
|
|
1453
|
-
} else {
|
|
1454
|
-
this.delete();
|
|
1455
|
-
}
|
|
1456
|
-
} catch (err) {
|
|
1457
|
-
console.log(err);
|
|
1458
|
-
}
|
|
1459
|
-
};
|
|
1460
|
-
|
|
1461
1577
|
/**
|
|
1462
1578
|
* 除去rename场景下的更新
|
|
1463
1579
|
* @param fileNode 文件级别的节点
|
|
@@ -1482,14 +1598,19 @@ async function handleChange(fileNode: BaseNode, targetNode: BaseNode, result: Re
|
|
|
1482
1598
|
newRefs.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
1483
1599
|
// 唤起建立连接弹框
|
|
1484
1600
|
// 文件级别的建立连接采取提醒
|
|
1485
|
-
if (
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1601
|
+
if (action === 'create' && (targetNode as any).__init) {
|
|
1602
|
+
// 清除临时状态, 完成本次创建
|
|
1603
|
+
delete (targetNode as any).__init;
|
|
1604
|
+
if (fileNode === targetNode && filesToCheck.size > 1) {
|
|
1605
|
+
const confirmParms = {
|
|
1606
|
+
actionType: 'createEstablishConnection',
|
|
1607
|
+
node: fileNode,
|
|
1608
|
+
icon: 'success',
|
|
1609
|
+
};
|
|
1610
|
+
invokeCommand('tsConfirm.open', confirmParms, () => {});
|
|
1611
|
+
}
|
|
1492
1612
|
}
|
|
1613
|
+
|
|
1493
1614
|
// console.log('filesToCheck', filesToCheck, filesToCheck.size);
|
|
1494
1615
|
await naslServer.getDiagnosticRecordsAndPushAll(Array.from(filesToCheck));
|
|
1495
1616
|
}
|
|
@@ -1546,8 +1667,9 @@ async function handleRename(fileNode: BaseNode, targetNode: BaseNode, result: Re
|
|
|
1546
1667
|
node: fileNode,
|
|
1547
1668
|
icon: 'success',
|
|
1548
1669
|
};
|
|
1549
|
-
invokeCommand('tsConfirm.open', confirmParms, () => {
|
|
1670
|
+
invokeCommand('tsConfirm.open', confirmParms, () => {});
|
|
1550
1671
|
}
|
|
1672
|
+
// console.log('filesToCheck', filesToCheck, filesToCheck.size);
|
|
1551
1673
|
} else {
|
|
1552
1674
|
// 查一下当前属性依赖的文件
|
|
1553
1675
|
const { currentSource, fileNode } = naslServer.getCurrentSource(targetNode);
|
|
@@ -1572,7 +1694,67 @@ async function handleRename(fileNode: BaseNode, targetNode: BaseNode, result: Re
|
|
|
1572
1694
|
|
|
1573
1695
|
// console.log('filesToCheck', filesToCheck, filesToCheck.size);
|
|
1574
1696
|
await naslServer.getDiagnosticRecordsAndPushAll(Array.from(filesToCheck));
|
|
1575
|
-
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
/**
|
|
1700
|
+
* 处理一些节点操作,子节点需要更新并且check的场景
|
|
1701
|
+
* 因为删除,新增父页面,或者重命名会一起
|
|
1702
|
+
* 删除或者新增view而且他有子集 就要执行同样的操作
|
|
1703
|
+
* @param action 当前操作类型
|
|
1704
|
+
* @param fileNode 文件节点
|
|
1705
|
+
* @param targetNode 操作节点 这里要两个相等才会走家去面对哦逻辑
|
|
1706
|
+
* @param oldpath 触发内容的oldpath
|
|
1707
|
+
*/
|
|
1708
|
+
async function incidentalAction(action: string, fileNode: BaseNode, targetNode: BaseNode, oldpath?: string) {
|
|
1709
|
+
if ((action === 'create' || action === 'delete' || (action === 'update' && oldpath)) && fileNode === targetNode) {
|
|
1710
|
+
// 删除或者新增页面
|
|
1711
|
+
if (fileNode instanceof View && fileNode.children?.length) {
|
|
1712
|
+
const fileNodeChildren = fileNode.children;
|
|
1713
|
+
for (let i = 0; i < fileNodeChildren.length; i++) {
|
|
1714
|
+
const fileNodeItem = fileNodeChildren[i];
|
|
1715
|
+
const result = (fileNodeItem as FileNode).toEmbeddedTSFile();
|
|
1716
|
+
if (action === 'create') {
|
|
1717
|
+
await handleChange(fileNodeItem, fileNodeItem, result, action);
|
|
1718
|
+
await incidentalAction(action, fileNodeItem, fileNodeItem);
|
|
1719
|
+
} else if (action === 'delete') {
|
|
1720
|
+
await handleDelete(fileNodeItem, fileNodeItem, result);
|
|
1721
|
+
await incidentalAction(action, fileNodeItem, fileNodeItem);
|
|
1722
|
+
} else if (action === 'update' && oldpath) {
|
|
1723
|
+
const parentPath = oldpath.replace('.ts', '/');
|
|
1724
|
+
const currentOldPath = parentPath + fileNodeItem.name + '.ts';
|
|
1725
|
+
// 因为重命名这里只有当前修改父级的 旧名称, 所以他的子集也要根据旧名称去查依赖 更新内容
|
|
1726
|
+
await handleRename(fileNodeItem, fileNodeItem, result, currentOldPath);
|
|
1727
|
+
await incidentalAction(action, fileNodeItem, fileNodeItem, currentOldPath);
|
|
1728
|
+
}
|
|
1729
|
+
};
|
|
1730
|
+
}
|
|
1731
|
+
// 删除或新增模块
|
|
1732
|
+
// 需要把下面的哦内容全部都更新一遍
|
|
1733
|
+
if (fileNode instanceof Module) {
|
|
1734
|
+
const module: Module = (targetNode) as Module;
|
|
1735
|
+
const results: Array<ReturnType<Structure['toEmbeddedTSFile']>> = [];
|
|
1736
|
+
naslServer.contentToFile(module, results);
|
|
1737
|
+
for (let i = 0; i < results.length; i++) {
|
|
1738
|
+
const result = results[i];
|
|
1739
|
+
const node = naslServer.file2NodeMap.get(result.filePath);
|
|
1740
|
+
if (action === 'create') {
|
|
1741
|
+
await handleChange(node, node, result, action);
|
|
1742
|
+
} else {
|
|
1743
|
+
await handleDelete(node, node, result);
|
|
1744
|
+
}
|
|
1745
|
+
};
|
|
1746
|
+
|
|
1747
|
+
// 删除模块通知更新列表
|
|
1748
|
+
if (action === 'delete') {
|
|
1749
|
+
try {
|
|
1750
|
+
// 如果已经
|
|
1751
|
+
invokeCommand('module.delete', true);
|
|
1752
|
+
} catch (err) {
|
|
1753
|
+
console.log('module.delete', '组件销毁了,不用唤起了');
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1576
1758
|
}
|
|
1577
1759
|
|
|
1578
1760
|
async function receiveHandleChange($event: EventPayload) {
|
|
@@ -1582,7 +1764,11 @@ async function receiveHandleChange($event: EventPayload) {
|
|
|
1582
1764
|
// 当前操作的文件节点
|
|
1583
1765
|
const { fileNode } = naslServer.getCurrentSource(targetNode);
|
|
1584
1766
|
// 如果是导入模块就,就引入对应模块,先不处理module和Configuration,下面的内容会自动创建
|
|
1585
|
-
if (fileNode instanceof Module || fileNode instanceof Configuration) {
|
|
1767
|
+
if (!fileNode || fileNode instanceof Module || fileNode instanceof Configuration) {
|
|
1768
|
+
// module单独处理
|
|
1769
|
+
if (fileNode instanceof Module) {
|
|
1770
|
+
await incidentalAction(action, fileNode, targetNode);
|
|
1771
|
+
}
|
|
1586
1772
|
return;
|
|
1587
1773
|
}
|
|
1588
1774
|
|
|
@@ -1602,25 +1788,46 @@ async function receiveHandleChange($event: EventPayload) {
|
|
|
1602
1788
|
|
|
1603
1789
|
fileNode.sourceMap = result.sourceMap;
|
|
1604
1790
|
if (action === 'update' || action === 'create') {
|
|
1605
|
-
if ($event?.field !== 'name')
|
|
1791
|
+
if ($event?.field !== 'name') {
|
|
1606
1792
|
await handleChange(fileNode, targetNode, result, action);
|
|
1607
|
-
|
|
1608
|
-
|
|
1793
|
+
await incidentalAction(action, fileNode, targetNode);
|
|
1794
|
+
} else {
|
|
1795
|
+
const oldpath = (fileNode as FileNode).getEmbeddedFilePath($event.oldObject.name);
|
|
1796
|
+
await handleRename(fileNode, targetNode, result, oldpath);
|
|
1797
|
+
await incidentalAction(action, fileNode, targetNode, oldpath);
|
|
1609
1798
|
}
|
|
1610
1799
|
}
|
|
1611
1800
|
// 删除
|
|
1612
1801
|
if (action === 'delete') {
|
|
1802
|
+
await incidentalAction(action, fileNode, targetNode);
|
|
1613
1803
|
await handleDelete(fileNode, targetNode, result);
|
|
1614
1804
|
}
|
|
1805
|
+
return true;
|
|
1615
1806
|
}
|
|
1616
1807
|
|
|
1617
1808
|
// 监听所有改变操作
|
|
1618
1809
|
embeddedTSEmitter.on('change', ($event: EventPayload) => {
|
|
1619
1810
|
// 收集到一个行为集合
|
|
1620
1811
|
const eventValue = $event.value;
|
|
1621
|
-
|
|
1622
|
-
|
|
1812
|
+
const stackList: Array<EventPayload> = [];
|
|
1813
|
+
eventValue.forEach(async (item: EventPayload) => {
|
|
1814
|
+
stackList.push(item.originEvent);
|
|
1623
1815
|
});
|
|
1816
|
+
|
|
1817
|
+
// 异步状态机,一个完成了在执行下一个
|
|
1818
|
+
function next() {
|
|
1819
|
+
const item = stackList.shift();
|
|
1820
|
+
receiveHandleChange(item).then(() => {
|
|
1821
|
+
if (stackList.length) {
|
|
1822
|
+
next();
|
|
1823
|
+
}
|
|
1824
|
+
});
|
|
1825
|
+
}
|
|
1826
|
+
|
|
1827
|
+
// 如果有长度开始执行状态机
|
|
1828
|
+
if (stackList.length) {
|
|
1829
|
+
next();
|
|
1830
|
+
}
|
|
1624
1831
|
});
|
|
1625
1832
|
|
|
1626
1833
|
naslServer.messager.options.context = naslServer;
|