@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/out/server/naslServer.js
CHANGED
|
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.translateDiagnosticMessage = exports.transformType = void 0;
|
|
7
6
|
/// #if process.env.NODE_ENV
|
|
8
7
|
// import Worker from '../../../ts-worker/dist/bundle.js';
|
|
9
8
|
/// #else
|
|
@@ -14,8 +13,6 @@ const concepts_1 = require("../concepts");
|
|
|
14
13
|
const translator_1 = require("../translator");
|
|
15
14
|
const storage_1 = __importDefault(require("../service/storage"));
|
|
16
15
|
const translator_2 = require("./translator");
|
|
17
|
-
Object.defineProperty(exports, "transformType", { enumerable: true, get: function () { return translator_2.transformType; } });
|
|
18
|
-
Object.defineProperty(exports, "translateDiagnosticMessage", { enumerable: true, get: function () { return translator_2.translateDiagnosticMessage; } });
|
|
19
16
|
const common_1 = require("../common");
|
|
20
17
|
const diagnostic_1 = __importDefault(require("../manager/diagnostic"));
|
|
21
18
|
const createUiTs_1 = __importDefault(require("./createUiTs"));
|
|
@@ -50,12 +47,18 @@ const naslServer = {
|
|
|
50
47
|
return this.messager.requestCommand('start');
|
|
51
48
|
},
|
|
52
49
|
async createUiTs(allComponent) {
|
|
53
|
-
const { code, elementsLogic } = await (0, createUiTs_1.default)(allComponent);
|
|
50
|
+
const { code, elementsLogic, naslStdlibMap } = await (0, createUiTs_1.default)(allComponent);
|
|
54
51
|
// 放入生產的uits文件
|
|
55
52
|
await naslServer.addFile({
|
|
56
53
|
file: 'nasl.ui.definition.ts',
|
|
57
54
|
fileContent: code,
|
|
58
55
|
});
|
|
56
|
+
Object.keys(naslStdlibMap).forEach(async (libFileName) => {
|
|
57
|
+
await naslServer.addFile({
|
|
58
|
+
file: '/' + libFileName,
|
|
59
|
+
fileContent: naslStdlibMap[libFileName],
|
|
60
|
+
});
|
|
61
|
+
});
|
|
59
62
|
naslServer.elementsLogic = elementsLogic;
|
|
60
63
|
// 全部文件加载完毕开始初始化
|
|
61
64
|
await naslServer.getDiagnosticRecordsAndPushAll();
|
|
@@ -151,21 +154,23 @@ const naslServer = {
|
|
|
151
154
|
}
|
|
152
155
|
},
|
|
153
156
|
view2TSFile(viewsChildren, results) {
|
|
154
|
-
//
|
|
155
|
-
viewsChildren.
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
157
|
+
// 如果有子页面
|
|
158
|
+
if (viewsChildren && viewsChildren.length) {
|
|
159
|
+
viewsChildren.forEach((view) => {
|
|
160
|
+
try {
|
|
161
|
+
const result = view.toEmbeddedTSFile();
|
|
162
|
+
results.push(result);
|
|
163
|
+
view.sourceMap = result.sourceMap;
|
|
164
|
+
this.file2NodeMap.set(result.filePath, view);
|
|
165
|
+
if (view.children.length) {
|
|
166
|
+
naslServer.view2TSFile(view.children, results);
|
|
167
|
+
}
|
|
163
168
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
+
catch (err) {
|
|
170
|
+
console.log(err);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
169
174
|
},
|
|
170
175
|
async openApp(app) {
|
|
171
176
|
const results = [];
|
|
@@ -195,20 +200,16 @@ const naslServer = {
|
|
|
195
200
|
callback();
|
|
196
201
|
});
|
|
197
202
|
},
|
|
198
|
-
async
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
fileContent: result.code,
|
|
209
|
-
}));
|
|
210
|
-
await this.writeFiles(files);
|
|
211
|
-
this._debugInFileStorage(module.parentNode, files);
|
|
203
|
+
async refreshApp(app) {
|
|
204
|
+
// 清除所有问题
|
|
205
|
+
diagnostic_1.default.clear();
|
|
206
|
+
await naslServer.deleteDirectoryFiles({ directoryName: '/embedded' });
|
|
207
|
+
// 清楚check count的数量
|
|
208
|
+
await this.messager.requestCommand('_clearTimeout');
|
|
209
|
+
// 重新加载app下内容
|
|
210
|
+
await naslServer.openApp(app);
|
|
211
|
+
// 重新check一遍所有内容
|
|
212
|
+
await naslServer.getDiagnosticRecordsAndPushAll();
|
|
212
213
|
},
|
|
213
214
|
/**
|
|
214
215
|
* 初始化之前添加文件
|
|
@@ -223,14 +224,6 @@ const naslServer = {
|
|
|
223
224
|
writeFiles(files) {
|
|
224
225
|
return this.messager.requestCommand('writeFiles', files);
|
|
225
226
|
},
|
|
226
|
-
/**
|
|
227
|
-
* 新增或修改文件
|
|
228
|
-
* @param {*} files
|
|
229
|
-
* @returns
|
|
230
|
-
*/
|
|
231
|
-
outputFiles(files) {
|
|
232
|
-
return this.messager.requestCommand('outputFiles', files);
|
|
233
|
-
},
|
|
234
227
|
/**
|
|
235
228
|
* 新增、修改
|
|
236
229
|
* 删除文件 文件用修改内容为空模拟,防止报错
|
|
@@ -239,22 +232,25 @@ const naslServer = {
|
|
|
239
232
|
updateFiles(args) {
|
|
240
233
|
return this.messager.requestCommand('updateFiles', args);
|
|
241
234
|
},
|
|
235
|
+
/**
|
|
236
|
+
* 清除一个目录下的所有文件
|
|
237
|
+
*/
|
|
238
|
+
deleteDirectoryFiles(args) {
|
|
239
|
+
return this.messager.requestCommand('deleteDirectoryFiles', args);
|
|
240
|
+
},
|
|
242
241
|
_debugInFileStorage(node, openFiles) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
app = node.rootNode || node.app;
|
|
248
|
-
}
|
|
249
|
-
return Promise.all(openFiles.map(async (file) => {
|
|
250
|
-
const res = await storage_1.default.post('/api/App/debugEmbedded?id=' + app.id, file);
|
|
251
|
-
return res.data;
|
|
252
|
-
}));
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
catch (err) {
|
|
256
|
-
console.log(err);
|
|
242
|
+
/// #if process.env.NODE_ENV === 'development'
|
|
243
|
+
let app = node;
|
|
244
|
+
if (node.concept !== 'App') {
|
|
245
|
+
app = node.rootNode || node.app;
|
|
257
246
|
}
|
|
247
|
+
return Promise.all(openFiles.map(async (file) => {
|
|
248
|
+
const res = await storage_1.default.post('/api/App/debugEmbedded?id=' + app.id, file);
|
|
249
|
+
return res.data;
|
|
250
|
+
})).catch((e) => {
|
|
251
|
+
console.error(e);
|
|
252
|
+
});
|
|
253
|
+
/// #endif
|
|
258
254
|
},
|
|
259
255
|
open() {
|
|
260
256
|
return this.messager.requestCommand('open');
|
|
@@ -296,7 +292,10 @@ const naslServer = {
|
|
|
296
292
|
const types = reg.exec(displayString);
|
|
297
293
|
// 取出提示的类型,组成是数组
|
|
298
294
|
const typeList = types[1].split(' | ').map((item) => {
|
|
299
|
-
if (
|
|
295
|
+
if (/\<([^()]+)\>/g.exec(item)) {
|
|
296
|
+
return item;
|
|
297
|
+
}
|
|
298
|
+
else if (item.includes(' ')) {
|
|
300
299
|
const strs = item.split(' ');
|
|
301
300
|
const type = strs[strs.length - 1];
|
|
302
301
|
return type;
|
|
@@ -313,7 +312,7 @@ const naslServer = {
|
|
|
313
312
|
return typeList;
|
|
314
313
|
},
|
|
315
314
|
async getTypeQuickinfo(node) {
|
|
316
|
-
if (node instanceof concepts_1.
|
|
315
|
+
if (node && node instanceof concepts_1.BaseNode) {
|
|
317
316
|
const callFunction = node.parentNode.parentNode;
|
|
318
317
|
/**
|
|
319
318
|
* currentSource callFunction 的节点,要去到当前节点的位置
|
|
@@ -335,18 +334,46 @@ const naslServer = {
|
|
|
335
334
|
if (typeAnnotation) {
|
|
336
335
|
res.push(typeAnnotation);
|
|
337
336
|
}
|
|
338
|
-
else if (type === 'unknown') {
|
|
337
|
+
else if (type === 'unknown' || type === 'never') {
|
|
339
338
|
return null;
|
|
340
339
|
}
|
|
341
340
|
});
|
|
342
341
|
if (!res.length) {
|
|
343
|
-
|
|
342
|
+
return [];
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
return [{ title: '基础类型', children: res }];
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
// 字符串 和 inter
|
|
351
|
+
return [{ title: '基础类型', children: [coreTypeList_1.primitiveTypeList[4]] }];
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
async getDataSchemaType(node) {
|
|
355
|
+
if (!(node instanceof concepts_1.ViewElement))
|
|
356
|
+
return;
|
|
357
|
+
const { currentSource, fileNode } = naslServer.getCurrentSource(node);
|
|
358
|
+
const quickInfo = await naslServer._getTypeQuickinfo({
|
|
359
|
+
file: fileNode.getEmbeddedFilePath(),
|
|
360
|
+
line: (0, translator_1.lsp2tspNumber)(currentSource.range.start.line),
|
|
361
|
+
offset: (0, translator_1.lsp2tspNumber)(currentSource.range.start.character) + `__elements.`.length,
|
|
362
|
+
});
|
|
363
|
+
if (quickInfo.responseRequired) {
|
|
364
|
+
const displayString = quickInfo?.response?.displayString || '';
|
|
365
|
+
const flag = displayString.includes('<') && displayString.includes('>');
|
|
366
|
+
if (flag) {
|
|
367
|
+
let str = '';
|
|
368
|
+
const types = naslServer.getDisplayString2Type(displayString);
|
|
369
|
+
if (Array.isArray(types) && types.length) {
|
|
370
|
+
const type = types[0];
|
|
371
|
+
str = type === 'any' || type === 'unknown' || type === 'never' ? '' : type;
|
|
344
372
|
}
|
|
345
|
-
|
|
346
|
-
const dataTypeList = [{ title: '基础类型', children: res }];
|
|
347
|
-
return dataTypeList;
|
|
373
|
+
return str;
|
|
348
374
|
}
|
|
349
375
|
}
|
|
376
|
+
return '';
|
|
350
377
|
},
|
|
351
378
|
_getTypeQuickinfo(args) {
|
|
352
379
|
return this.messager.requestCommand('quickInfo', args);
|
|
@@ -425,9 +452,8 @@ const naslServer = {
|
|
|
425
452
|
originalDiagnostic: diagnostic,
|
|
426
453
|
};
|
|
427
454
|
if (minRange) {
|
|
428
|
-
// let message = this.translateDiagnosticMessage(diagnostic.text);
|
|
429
455
|
// 节点的error要置为true
|
|
430
|
-
return
|
|
456
|
+
return (0, translator_2.naslNodeTranslateMessage)(minRange, tsErrorDetail);
|
|
431
457
|
}
|
|
432
458
|
else {
|
|
433
459
|
// 没找到节点, 先把问题暴露出来
|
|
@@ -437,60 +463,6 @@ const naslServer = {
|
|
|
437
463
|
};
|
|
438
464
|
}
|
|
439
465
|
},
|
|
440
|
-
/**
|
|
441
|
-
* 处理一些边界情况
|
|
442
|
-
* @param minRange
|
|
443
|
-
* @param tsErrorDetail 报错具体信息
|
|
444
|
-
* @returns
|
|
445
|
-
*/
|
|
446
|
-
_diagnosticSpecialTreatment(minRange, tsErrorDetail) {
|
|
447
|
-
const text = tsErrorDetail.originalDiagnostic.text;
|
|
448
|
-
// 有一些节点报错信息不向外暴露,缺失一些原生标签等等的展示
|
|
449
|
-
if (minRange.node instanceof concepts_1.View || minRange.node instanceof concepts_1.ViewElement) {
|
|
450
|
-
if (text.startsWith(`'nasl.ui' has no exported member named `)) {
|
|
451
|
-
return null;
|
|
452
|
-
}
|
|
453
|
-
else if (text.startsWith(`Property '`) && text.includes(`does not exist on type 'typeof ui'.`)) {
|
|
454
|
-
return null;
|
|
455
|
-
}
|
|
456
|
-
else if (text.startsWith(`Namespace 'nasl.ui' has no exported member `)) {
|
|
457
|
-
return null;
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
if (/Expected (.+?) arguments, but got (.+?)./.exec(text)) {
|
|
461
|
-
// bindevent本身现在就不传参数
|
|
462
|
-
if (minRange.node instanceof concepts_1.BindEvent) {
|
|
463
|
-
return null;
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
// 因为缺少参数时候有可能有特殊情况,因为原本少的多了就会找到 callLogic上,
|
|
467
|
-
// 但是只少一个的时候就会找到准确的Argument上 需要特殊处理, ui层就可以统一处理
|
|
468
|
-
if (minRange.node instanceof concepts_1.Argument) {
|
|
469
|
-
if (/Expected (.+?) arguments, but got (.+?)./.exec(text)) {
|
|
470
|
-
minRange.node = minRange.node.parentNode;
|
|
471
|
-
}
|
|
472
|
-
else {
|
|
473
|
-
// if (/Type '(.+?)' is not assignable to type '(.+?)'./.exec(text)) {
|
|
474
|
-
// }
|
|
475
|
-
// Argument在callInterface上的报错放到内部
|
|
476
|
-
if (minRange.node.expression) {
|
|
477
|
-
minRange.node = minRange.node.expression;
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
if (/'(.+?)' has no exported member(?: named)? '(.+?)'/.exec(text) || /Property '(.+?)' does not exist on type '(.+?)'./.exec(text)) {
|
|
482
|
-
if (minRange.node instanceof concepts_1.TypeAnnotation) {
|
|
483
|
-
// 变量type的报错放到内部
|
|
484
|
-
minRange.node = minRange.node.parentNode;
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
minRange.node.tsErrorDetail = tsErrorDetail;
|
|
488
|
-
return {
|
|
489
|
-
id: minRange.node.id,
|
|
490
|
-
node: minRange.node,
|
|
491
|
-
...tsErrorDetail,
|
|
492
|
-
};
|
|
493
|
-
},
|
|
494
466
|
_findMinRange(diagnostic, fileNode) {
|
|
495
467
|
let minRange;
|
|
496
468
|
const sourceMap = fileNode.sourceMap;
|
|
@@ -546,6 +518,24 @@ const naslServer = {
|
|
|
546
518
|
});
|
|
547
519
|
refsList = [...newRefs.refs];
|
|
548
520
|
}
|
|
521
|
+
else {
|
|
522
|
+
if (node instanceof concepts_1.Module) {
|
|
523
|
+
const lists = node.logics || node.structures || node.enums;
|
|
524
|
+
const moduleName = fileNode.getEmbeddedFilePath();
|
|
525
|
+
if (lists.length) {
|
|
526
|
+
const item = lists[0];
|
|
527
|
+
const { fileNode } = naslServer.getCurrentSource(item);
|
|
528
|
+
const newRefs = await naslServer.references({
|
|
529
|
+
file: fileNode.getEmbeddedFilePath(),
|
|
530
|
+
line: 1,
|
|
531
|
+
offset: 22, //固定的位置,module的位置信息
|
|
532
|
+
});
|
|
533
|
+
refsList = newRefs.refs.filter((item) => !item.file.startsWith(moduleName));
|
|
534
|
+
// 多塞一个 ,删除的时候就有值了, 上面过滤了之后可能是空的
|
|
535
|
+
refsList.unshift(newRefs.refs[0]);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
549
539
|
// 如果是entity就需要在单独,查一边来修改名字
|
|
550
540
|
if (node instanceof concepts_1.Entity) {
|
|
551
541
|
// 过滤一把不需要改的信息
|
|
@@ -555,7 +545,7 @@ const naslServer = {
|
|
|
555
545
|
}
|
|
556
546
|
if (node instanceof concepts_1.Return) {
|
|
557
547
|
// 过滤一下最后出去的值
|
|
558
|
-
refsList = refsList.filter((item) => !
|
|
548
|
+
refsList = refsList.filter((item) => !item.lineText.includes('return '));
|
|
559
549
|
}
|
|
560
550
|
// 如果是参数, 就需要把logic的引用 都查找出来就需要把他的父级的引用全部查找出来
|
|
561
551
|
if (node instanceof concepts_1.Param && node.parentNode instanceof concepts_1.Logic) {
|
|
@@ -613,18 +603,23 @@ const naslServer = {
|
|
|
613
603
|
line: (0, translator_1.lsp2tspNumber)(currentSource.range.start.line),
|
|
614
604
|
offset: (0, translator_1.lsp2tspNumber)(currentSource.range.start.character + methodsNameIndex),
|
|
615
605
|
});
|
|
616
|
-
const methodRefs =
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
606
|
+
const methodRefs = [];
|
|
607
|
+
methods.refs.forEach((item) => {
|
|
608
|
+
// 定义里的格式,在删除的时候留下来占位
|
|
609
|
+
// 重命名的时候会过滤
|
|
610
|
+
// 这里只过滤 __elements.button = new nasl.ui.Button<any>这种格式
|
|
611
|
+
// if (item.lineText.includes('__elements.') && item.lineText.includes('new nasl.ui.'))
|
|
612
|
+
// return false;
|
|
613
|
+
// 处理声明组件名可能重复的问题, 查找引用不提示
|
|
614
|
+
const find = methodRefs.find((findItem) => item.lineText === findItem.lineText && item.lineText.includes(': nasl.ui.'));
|
|
615
|
+
if (!find) {
|
|
616
|
+
methodRefs.push(item);
|
|
622
617
|
}
|
|
623
|
-
return true;
|
|
624
618
|
});
|
|
625
619
|
refsList = [...methodRefs];
|
|
626
620
|
}
|
|
627
621
|
}
|
|
622
|
+
console.log(refsList, 'refsList');
|
|
628
623
|
return refsList;
|
|
629
624
|
},
|
|
630
625
|
/**
|
|
@@ -656,7 +651,7 @@ const naslServer = {
|
|
|
656
651
|
minRange.setTypeMethods = 'setCalleeName';
|
|
657
652
|
}
|
|
658
653
|
if (minRange.node instanceof concepts_1.CallLogic && node instanceof concepts_1.ViewElement) {
|
|
659
|
-
minRange.setTypeMethods = '
|
|
654
|
+
minRange.setTypeMethods = 'setCalleeNamespace';
|
|
660
655
|
minRange.newValue = 'elements.' + newValue + '.logics';
|
|
661
656
|
}
|
|
662
657
|
// 如果节点是实体修改引发calllogic修改
|
|
@@ -804,7 +799,13 @@ const naslServer = {
|
|
|
804
799
|
// 如果是view也需要加前缀
|
|
805
800
|
// logic 和 views名称修改 可能会触发bindEvent修改
|
|
806
801
|
if (minRange.node instanceof concepts_1.BindEvent) {
|
|
807
|
-
|
|
802
|
+
// 页面逻辑直接赋值就可以, 因为是相对路径
|
|
803
|
+
if ((node instanceof concepts_1.ViewElement)) {
|
|
804
|
+
minRange.setTypeMethods = 'setCalleeNamespace';
|
|
805
|
+
minRange.newValue = 'elements.' + newValue + '.logics';
|
|
806
|
+
}
|
|
807
|
+
else {
|
|
808
|
+
/**
|
|
808
809
|
* 如果namespce是 'app.views.Student.views.404.views.505.views.update'
|
|
809
810
|
* 在ts中会是'app.views.Student.views.$404.views.$505.views.update'
|
|
810
811
|
* 但是505 要改名为 666 ,要存的是666
|
|
@@ -813,25 +814,44 @@ const naslServer = {
|
|
|
813
814
|
* 2.在匹配到的内容中取转后的namespace的位置
|
|
814
815
|
* 3.然后把namespace中的 $替换成 ''
|
|
815
816
|
*/
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
817
|
+
const tsCalleeNamespace = minRange.node.tsCalleeNamespace;
|
|
818
|
+
const oldValue = tsCalleeNamespace;
|
|
819
|
+
// 先看下标位置
|
|
820
|
+
const lineText = record.lineText;
|
|
821
|
+
const index = lineText.indexOf(oldValue);
|
|
822
|
+
// 在把开始结束位置的-开始位置,来知道是哪里要替换
|
|
823
|
+
const start = record.start.offset - index - 1;
|
|
824
|
+
const end = record.end.offset - index - 1;
|
|
825
|
+
// 新的完整的value
|
|
826
|
+
if (start > tsCalleeNamespace.length) {
|
|
827
|
+
minRange.setTypeMethods = 'setCalleeName';
|
|
828
|
+
minRange.newValue = newValue;
|
|
829
|
+
}
|
|
830
|
+
else {
|
|
831
|
+
// 新的完整的value
|
|
832
|
+
let newTsNameSpace = tsCalleeNamespace.substring(0, start) + newValue + tsCalleeNamespace.substring(end, tsCalleeNamespace.length);
|
|
833
|
+
minRange.setTypeMethods = 'setCalleeNamespace';
|
|
834
|
+
newTsNameSpace = newTsNameSpace.replace(/\.\$/g, '.');
|
|
835
|
+
minRange.newValue = newTsNameSpace;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
if (minRange.node instanceof concepts_1.Destination && node instanceof concepts_1.Param) {
|
|
840
|
+
// 因为view是key value 绑定所以需要重新赋值
|
|
841
|
+
if (node.parentNode instanceof concepts_1.View) {
|
|
842
|
+
const nodeArguments = minRange.node.arguments;
|
|
843
|
+
const findArgument = nodeArguments.find((item) => node.name === item.keyword);
|
|
844
|
+
if (findArgument) {
|
|
845
|
+
minRange.setTypeMethods = 'setArgumentsKeyWord';
|
|
846
|
+
minRange.newValue = {
|
|
847
|
+
findArgument,
|
|
848
|
+
newKeyword: newValue,
|
|
849
|
+
};
|
|
850
|
+
}
|
|
828
851
|
}
|
|
829
852
|
else {
|
|
830
|
-
//
|
|
831
|
-
|
|
832
|
-
minRange.setTypeMethods = 'setCalleeNamespace';
|
|
833
|
-
newTsNameSpace = newTsNameSpace.replace(/\.\$/g, '.');
|
|
834
|
-
minRange.newValue = newTsNameSpace;
|
|
853
|
+
// 如果是修改param查找到Destination就不操作
|
|
854
|
+
return null;
|
|
835
855
|
}
|
|
836
856
|
}
|
|
837
857
|
if (minRange.node instanceof concepts_1.Interface && node instanceof concepts_1.Logic) {
|
|
@@ -847,16 +867,16 @@ const naslServer = {
|
|
|
847
867
|
const newBindRoles = str.split(',');
|
|
848
868
|
minRange.newValue = newBindRoles;
|
|
849
869
|
}
|
|
850
|
-
if (
|
|
870
|
+
if (minRange.node instanceof concepts_1.QueryFieldExpression && node instanceof concepts_1.Entity) {
|
|
851
871
|
minRange.setTypeMethods = 'setEntityAsName';
|
|
852
872
|
}
|
|
853
|
-
if ((minRange.node instanceof concepts_1.QueryFromExpression) &&
|
|
873
|
+
if ((minRange.node instanceof concepts_1.QueryFromExpression || minRange.node instanceof concepts_1.QueryJoinExpression) && node instanceof concepts_1.Entity) {
|
|
854
874
|
minRange.setTypeMethods = 'setEntityName';
|
|
855
875
|
}
|
|
856
|
-
if (
|
|
876
|
+
if (minRange.node instanceof concepts_1.QueryFieldExpression && node instanceof concepts_1.EntityProperty) {
|
|
857
877
|
minRange.setTypeMethods = 'setPropertyName';
|
|
858
878
|
}
|
|
859
|
-
if (minRange.node instanceof concepts_1.Destination && node instanceof concepts_1.Process) {
|
|
879
|
+
if (minRange.node instanceof concepts_1.Destination && (node instanceof concepts_1.Process || node instanceof concepts_1.ProcessElement)) {
|
|
860
880
|
return null;
|
|
861
881
|
}
|
|
862
882
|
// 枚举修改枚举名,比较特殊
|
|
@@ -868,8 +888,8 @@ const naslServer = {
|
|
|
868
888
|
if (minRange.node instanceof concepts_1.Logic && node instanceof concepts_1.Param) {
|
|
869
889
|
return null;
|
|
870
890
|
}
|
|
871
|
-
//
|
|
872
|
-
if (minRange.node instanceof concepts_1.
|
|
891
|
+
// params修改 查找bindevent不需要修改
|
|
892
|
+
if (minRange.node instanceof concepts_1.BindEvent && node instanceof concepts_1.Param) {
|
|
873
893
|
return null;
|
|
874
894
|
}
|
|
875
895
|
// 如果是子页面修改
|
|
@@ -877,8 +897,37 @@ const naslServer = {
|
|
|
877
897
|
if (minRange.node instanceof concepts_1.View && node instanceof concepts_1.View && minRange.node !== node) {
|
|
878
898
|
return null;
|
|
879
899
|
}
|
|
900
|
+
/**
|
|
901
|
+
* 屏蔽组件生成内容块中的变量或者逻辑,出现在表格选择中。在bindAttr中还会有,所以过滤一把
|
|
902
|
+
*/
|
|
903
|
+
if ((minRange.node instanceof concepts_1.Identifier || minRange.node instanceof concepts_1.MemberExpression) && node instanceof concepts_1.Param && minRange.node.parentNode instanceof concepts_1.BindAttribute) {
|
|
904
|
+
return null;
|
|
905
|
+
}
|
|
906
|
+
// 修改element引发view改名
|
|
907
|
+
if (node instanceof concepts_1.ViewElement && minRange.node instanceof concepts_1.View) {
|
|
908
|
+
return null;
|
|
909
|
+
}
|
|
910
|
+
// params修改 查找View不需要修改
|
|
880
911
|
// 逻辑改名,触发了在定义里面的,element定义,的值,直接掠过
|
|
881
|
-
if (minRange.node instanceof concepts_1.View && node instanceof concepts_1.Logic) {
|
|
912
|
+
if (minRange.node instanceof concepts_1.View && (node instanceof concepts_1.Logic || node instanceof concepts_1.Param)) {
|
|
913
|
+
/**
|
|
914
|
+
* 这里过滤一下,一些查找引用,重复的内容,直接屏蔽掉,防止操作重复
|
|
915
|
+
* 因为在生成的时候 ,可能弄了一些副作用的引用
|
|
916
|
+
*/
|
|
917
|
+
// 本来是想在上面过滤一把的先放到这里匹配这两个的时候 就会找到
|
|
918
|
+
// refsList = refsList.filter((item) => {
|
|
919
|
+
// 屏蔽组件查找查到定义这里,也过滤一下
|
|
920
|
+
// if (item.lineText.includes(': nasl.ui.'))
|
|
921
|
+
// return false;
|
|
922
|
+
// return true;
|
|
923
|
+
// });
|
|
924
|
+
return null;
|
|
925
|
+
}
|
|
926
|
+
// 流程改名不触发Logic改名
|
|
927
|
+
if (minRange.node instanceof concepts_1.Logic && node instanceof concepts_1.Process) {
|
|
928
|
+
return null;
|
|
929
|
+
}
|
|
930
|
+
if (minRange.node instanceof concepts_1.Logic && node instanceof concepts_1.ProcessElement && node.type === 'UserTask') {
|
|
882
931
|
return null;
|
|
883
932
|
}
|
|
884
933
|
}
|
|
@@ -895,14 +944,14 @@ const naslServer = {
|
|
|
895
944
|
},
|
|
896
945
|
_addParamsPrepare(node, refsList) {
|
|
897
946
|
const App = node.rootNode;
|
|
898
|
-
const
|
|
947
|
+
const parantNode = node.parentNode;
|
|
899
948
|
// 收集修改
|
|
900
949
|
App.emit('collect:start', {
|
|
901
950
|
actionMsg: '增加逻辑参数',
|
|
902
951
|
});
|
|
903
952
|
node.create({
|
|
904
953
|
index: 0,
|
|
905
|
-
parentNode:
|
|
954
|
+
parentNode: parantNode,
|
|
906
955
|
parentKey: node.parentKey,
|
|
907
956
|
});
|
|
908
957
|
refsList.forEach((record) => {
|
|
@@ -913,7 +962,11 @@ const naslServer = {
|
|
|
913
962
|
if (minRange) {
|
|
914
963
|
// 如果找到节点是callLogic就去更新
|
|
915
964
|
if (minRange.node instanceof concepts_1.CallLogic && node instanceof concepts_1.Param) {
|
|
916
|
-
minRange.node.setCalleeArgName(
|
|
965
|
+
minRange.node.setCalleeArgName((parantNode));
|
|
966
|
+
}
|
|
967
|
+
// 如果节点参数增加页面也要更新
|
|
968
|
+
if (minRange.node instanceof concepts_1.Destination && node instanceof concepts_1.Param) {
|
|
969
|
+
minRange.node.setViewArgument((parantNode));
|
|
917
970
|
}
|
|
918
971
|
}
|
|
919
972
|
});
|
|
@@ -923,9 +976,13 @@ const naslServer = {
|
|
|
923
976
|
// 查找引用
|
|
924
977
|
async findReferences(node) {
|
|
925
978
|
let refsList = await naslServer._isHaveRef(node);
|
|
926
|
-
console.log(refsList, 'refsList');
|
|
927
979
|
// 如果查找引用查到自己里面的引用不展示
|
|
928
|
-
refsList = refsList.filter((item) =>
|
|
980
|
+
refsList = refsList.filter((item) => {
|
|
981
|
+
// 自己引用自己的过滤掉
|
|
982
|
+
// 删除的时候过滤一把组件删除提示
|
|
983
|
+
// 展示组件自己屏蔽掉
|
|
984
|
+
return !item.isDefinition && !(item.lineText.includes(' = new nasl.ui.'));
|
|
985
|
+
});
|
|
929
986
|
// 最后返回的结果
|
|
930
987
|
let result = new Map();
|
|
931
988
|
// 树的构造,key: 一个file的node, 值是 [[logic, params],[logic, returns]]
|
|
@@ -974,7 +1031,9 @@ const naslServer = {
|
|
|
974
1031
|
// 排除一些不放入集合的节点
|
|
975
1032
|
let isNeedPush = true;
|
|
976
1033
|
// 如果不是ViewElement 或者 Assignment , 或者如果是的话, 排除l-root
|
|
977
|
-
if (currentNode instanceof concepts_1.ViewElement && currentNode.tag
|
|
1034
|
+
if (currentNode instanceof concepts_1.ViewElement && currentNode.tag === 'l-root')
|
|
1035
|
+
isNeedPush = false;
|
|
1036
|
+
else if (currentNode instanceof concepts_1.Argument)
|
|
978
1037
|
isNeedPush = false;
|
|
979
1038
|
else if (currentNode instanceof concepts_1.Assignment)
|
|
980
1039
|
isNeedPush = false;
|
|
@@ -1077,6 +1136,8 @@ const naslServer = {
|
|
|
1077
1136
|
* 当前this上下文 的Source 和 父级文件级别的节点
|
|
1078
1137
|
*/
|
|
1079
1138
|
getCurrentSource(node) {
|
|
1139
|
+
if (node instanceof concepts_1.App || node instanceof concepts_1.Theme)
|
|
1140
|
+
return { fileNode: null };
|
|
1080
1141
|
let sourceMap = node.sourceMap;
|
|
1081
1142
|
let fileNode = node;
|
|
1082
1143
|
// 如果没有sourceMap,就继续向上找 ,或者到module结束
|
|
@@ -1157,6 +1218,49 @@ async function handleDelete(fileNode, targetNode, result) {
|
|
|
1157
1218
|
// console.log('filesToCheck', filesToCheck, filesToCheck.size);
|
|
1158
1219
|
await naslServer.getDiagnosticRecordsAndPushAll(Array.from(filesToCheck));
|
|
1159
1220
|
}
|
|
1221
|
+
concepts_1.BaseNode.prototype.findReadOnlyLogicUsage = function () {
|
|
1222
|
+
let targetNode;
|
|
1223
|
+
if (this.parentNode.concept === 'Namespace' || this.parentNode.parentNode.concept === 'Namespace') {
|
|
1224
|
+
const sourceMap = this.parentNode.concept === 'Namespace' ? this.parentNode.parentNode.sourceMap : this.parentNode.parentNode.parentNode.sourceMap;
|
|
1225
|
+
for (const item of sourceMap) {
|
|
1226
|
+
const logic = item[0];
|
|
1227
|
+
if (this.concept === 'Logic') {
|
|
1228
|
+
if (logic instanceof concepts_1.Logic)
|
|
1229
|
+
if (logic.calleewholeKey === this.calleewholeKey) {
|
|
1230
|
+
targetNode = logic;
|
|
1231
|
+
break;
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
else {
|
|
1235
|
+
if (logic instanceof concepts_1.Logic)
|
|
1236
|
+
if (logic.calleewholeKey === this.parentNode.calleewholeKey) {
|
|
1237
|
+
targetNode = logic;
|
|
1238
|
+
break;
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
else if (this.parentNode.concept === 'Module') {
|
|
1244
|
+
// 父级是模块的还是用它本身去查找引用
|
|
1245
|
+
targetNode = this;
|
|
1246
|
+
}
|
|
1247
|
+
else {
|
|
1248
|
+
const sourceMap = this.parentNode.sourceMap;
|
|
1249
|
+
for (const item of sourceMap) {
|
|
1250
|
+
const logic = item[0];
|
|
1251
|
+
if (logic.getNamespace && logic.getNamespace() === this.getNamespace()) {
|
|
1252
|
+
targetNode = logic;
|
|
1253
|
+
break;
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
try {
|
|
1258
|
+
return naslServer.findReferences(targetNode);
|
|
1259
|
+
}
|
|
1260
|
+
catch (err) {
|
|
1261
|
+
console.log(err);
|
|
1262
|
+
}
|
|
1263
|
+
};
|
|
1160
1264
|
// 查找引用
|
|
1161
1265
|
concepts_1.BaseNode.prototype.findUsage = function findUsage() {
|
|
1162
1266
|
try {
|
|
@@ -1244,8 +1348,25 @@ concepts_1.BaseNode.prototype.prepareDelete = async function prepareDelete() {
|
|
|
1244
1348
|
* 查找这个节点是不是有依赖
|
|
1245
1349
|
*/
|
|
1246
1350
|
const node = this;
|
|
1247
|
-
|
|
1248
|
-
|
|
1351
|
+
let refsList = await naslServer._isHaveRef(node);
|
|
1352
|
+
// 删除的时候过滤一把组件删除提示
|
|
1353
|
+
refsList = refsList.filter((item) => {
|
|
1354
|
+
// 因为ui组件本身会多渲染一次,就先过滤一个
|
|
1355
|
+
return !(item.lineText.includes(': nasl.ui.'));
|
|
1356
|
+
});
|
|
1357
|
+
// 删除参数单独处理
|
|
1358
|
+
if (node instanceof concepts_1.Param) {
|
|
1359
|
+
const methodRefs = [];
|
|
1360
|
+
refsList.forEach((item) => {
|
|
1361
|
+
// 入参查找引用,查到logic 和自己,内容完全一样,就保留一个
|
|
1362
|
+
const find = methodRefs.find((findItem) => item.lineText === findItem.lineText);
|
|
1363
|
+
if (!find) {
|
|
1364
|
+
methodRefs.push(item);
|
|
1365
|
+
}
|
|
1366
|
+
});
|
|
1367
|
+
refsList = methodRefs;
|
|
1368
|
+
}
|
|
1369
|
+
// delete的弹框展示
|
|
1249
1370
|
const confirmParms = {
|
|
1250
1371
|
actionType: 'delete',
|
|
1251
1372
|
tipFlag: false,
|
|
@@ -1273,12 +1394,26 @@ concepts_1.BaseNode.prototype.prepareDelete = async function prepareDelete() {
|
|
|
1273
1394
|
// 如果有依赖就有一个查找引用提示
|
|
1274
1395
|
confirmParms.tipFlag = true;
|
|
1275
1396
|
const node = this;
|
|
1397
|
+
// 删除页面或者流程
|
|
1398
|
+
if (node instanceof concepts_1.View || node instanceof concepts_1.Process) {
|
|
1399
|
+
/**
|
|
1400
|
+
* 查找这个页面是不是有依赖
|
|
1401
|
+
*/
|
|
1402
|
+
let viewPath = this.getEmbeddedFilePath();
|
|
1403
|
+
viewPath = viewPath.slice(0, viewPath.length - 3);
|
|
1404
|
+
const find = refsList.find((record) => !record.file.includes(viewPath));
|
|
1405
|
+
// 如果没有别的文件的依赖,就直接delete
|
|
1406
|
+
if (!find) {
|
|
1407
|
+
this.delete();
|
|
1408
|
+
return;
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1276
1411
|
callback = () => {
|
|
1277
1412
|
// removeParam
|
|
1278
1413
|
// 跟rename 还不太一样,部分修改依赖修改好的值,然后在下面的修改需要把自己传递进去
|
|
1279
1414
|
if (node instanceof concepts_1.Param) {
|
|
1280
1415
|
const App = this.rootNode;
|
|
1281
|
-
const
|
|
1416
|
+
const parentNode = this.parentNode;
|
|
1282
1417
|
// 收集修改
|
|
1283
1418
|
App.emit('collect:start', {
|
|
1284
1419
|
actionMsg: '删除参数',
|
|
@@ -1291,7 +1426,10 @@ concepts_1.BaseNode.prototype.prepareDelete = async function prepareDelete() {
|
|
|
1291
1426
|
const minRange = naslServer._findMinRange(record, fileNode);
|
|
1292
1427
|
if (minRange) {
|
|
1293
1428
|
if (minRange.node instanceof concepts_1.CallLogic) {
|
|
1294
|
-
minRange.node.setCalleeArgName(
|
|
1429
|
+
minRange.node.setCalleeArgName(parentNode);
|
|
1430
|
+
}
|
|
1431
|
+
if (minRange.node instanceof concepts_1.Destination) {
|
|
1432
|
+
minRange.node.setViewArgument(parentNode);
|
|
1295
1433
|
}
|
|
1296
1434
|
}
|
|
1297
1435
|
});
|
|
@@ -1320,6 +1458,7 @@ concepts_1.BaseNode.prototype.prepareDelete = async function prepareDelete() {
|
|
|
1320
1458
|
});
|
|
1321
1459
|
// 结束修改 ,批量操作
|
|
1322
1460
|
App.emit('collect:end');
|
|
1461
|
+
return;
|
|
1323
1462
|
}
|
|
1324
1463
|
// 删除权限节点
|
|
1325
1464
|
if (node instanceof concepts_1.Role) {
|
|
@@ -1349,6 +1488,10 @@ concepts_1.BaseNode.prototype.prepareDelete = async function prepareDelete() {
|
|
|
1349
1488
|
App.emit('collect:end');
|
|
1350
1489
|
return;
|
|
1351
1490
|
}
|
|
1491
|
+
// 删除页面或者流程,如果上一步没有return 就说明他是有别的引用的,会有引用弹框
|
|
1492
|
+
if (node instanceof concepts_1.View || node instanceof concepts_1.Process) {
|
|
1493
|
+
this.delete();
|
|
1494
|
+
}
|
|
1352
1495
|
// 其余的都直接调用删除
|
|
1353
1496
|
// Structure 和 Interface是内部有delete方法
|
|
1354
1497
|
if (node instanceof concepts_1.Structure || node instanceof concepts_1.Interface) {
|
|
@@ -1380,31 +1523,6 @@ concepts_1.BaseNode.prototype.addParamsPrepare = async function addParamsPrepare
|
|
|
1380
1523
|
console.log(err);
|
|
1381
1524
|
}
|
|
1382
1525
|
};
|
|
1383
|
-
/**
|
|
1384
|
-
* 页面的删除同步他的子页面要一起删除
|
|
1385
|
-
*/
|
|
1386
|
-
concepts_1.BaseNode.prototype.viewPrepareDelete = async function viewPrepareDelete() {
|
|
1387
|
-
try {
|
|
1388
|
-
/**
|
|
1389
|
-
* 查找这个页面是不是有依赖
|
|
1390
|
-
*/
|
|
1391
|
-
const refsList = await naslServer._isHaveRef(this);
|
|
1392
|
-
let viewPath = this.getEmbeddedFilePath();
|
|
1393
|
-
viewPath = viewPath.slice(0, viewPath.length - 3);
|
|
1394
|
-
const find = refsList.find((record) => !record.file.includes(viewPath));
|
|
1395
|
-
// 如果有别的文件的依赖
|
|
1396
|
-
if (find) {
|
|
1397
|
-
// 就展示弹框
|
|
1398
|
-
this.prepareDelete();
|
|
1399
|
-
}
|
|
1400
|
-
else {
|
|
1401
|
-
this.delete();
|
|
1402
|
-
}
|
|
1403
|
-
}
|
|
1404
|
-
catch (err) {
|
|
1405
|
-
console.log(err);
|
|
1406
|
-
}
|
|
1407
|
-
};
|
|
1408
1526
|
/**
|
|
1409
1527
|
* 除去rename场景下的更新
|
|
1410
1528
|
* @param fileNode 文件级别的节点
|
|
@@ -1426,13 +1544,17 @@ async function handleChange(fileNode, targetNode, result, action) {
|
|
|
1426
1544
|
newRefs.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
1427
1545
|
// 唤起建立连接弹框
|
|
1428
1546
|
// 文件级别的建立连接采取提醒
|
|
1429
|
-
if (
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1547
|
+
if (action === 'create' && targetNode.__init) {
|
|
1548
|
+
// 清除临时状态, 完成本次创建
|
|
1549
|
+
delete targetNode.__init;
|
|
1550
|
+
if (fileNode === targetNode && filesToCheck.size > 1) {
|
|
1551
|
+
const confirmParms = {
|
|
1552
|
+
actionType: 'createEstablishConnection',
|
|
1553
|
+
node: fileNode,
|
|
1554
|
+
icon: 'success',
|
|
1555
|
+
};
|
|
1556
|
+
(0, common_1.invokeCommand)('tsConfirm.open', confirmParms, () => { });
|
|
1557
|
+
}
|
|
1436
1558
|
}
|
|
1437
1559
|
// console.log('filesToCheck', filesToCheck, filesToCheck.size);
|
|
1438
1560
|
await naslServer.getDiagnosticRecordsAndPushAll(Array.from(filesToCheck));
|
|
@@ -1487,6 +1609,7 @@ async function handleRename(fileNode, targetNode, result, oldFilePath) {
|
|
|
1487
1609
|
};
|
|
1488
1610
|
(0, common_1.invokeCommand)('tsConfirm.open', confirmParms, () => { });
|
|
1489
1611
|
}
|
|
1612
|
+
// console.log('filesToCheck', filesToCheck, filesToCheck.size);
|
|
1490
1613
|
}
|
|
1491
1614
|
else {
|
|
1492
1615
|
// 查一下当前属性依赖的文件
|
|
@@ -1510,7 +1633,71 @@ async function handleRename(fileNode, targetNode, result, oldFilePath) {
|
|
|
1510
1633
|
}
|
|
1511
1634
|
// console.log('filesToCheck', filesToCheck, filesToCheck.size);
|
|
1512
1635
|
await naslServer.getDiagnosticRecordsAndPushAll(Array.from(filesToCheck));
|
|
1513
|
-
|
|
1636
|
+
}
|
|
1637
|
+
/**
|
|
1638
|
+
* 处理一些节点操作,子节点需要更新并且check的场景
|
|
1639
|
+
* 因为删除,新增父页面,或者重命名会一起
|
|
1640
|
+
* 删除或者新增view而且他有子集 就要执行同样的操作
|
|
1641
|
+
* @param action 当前操作类型
|
|
1642
|
+
* @param fileNode 文件节点
|
|
1643
|
+
* @param targetNode 操作节点 这里要两个相等才会走家去面对哦逻辑
|
|
1644
|
+
* @param oldpath 触发内容的oldpath
|
|
1645
|
+
*/
|
|
1646
|
+
async function incidentalAction(action, fileNode, targetNode, oldpath) {
|
|
1647
|
+
if ((action === 'create' || action === 'delete' || (action === 'update' && oldpath)) && fileNode === targetNode) {
|
|
1648
|
+
// 删除或者新增页面
|
|
1649
|
+
if (fileNode instanceof concepts_1.View && fileNode.children?.length) {
|
|
1650
|
+
const fileNodeChildren = fileNode.children;
|
|
1651
|
+
for (let i = 0; i < fileNodeChildren.length; i++) {
|
|
1652
|
+
const fileNodeItem = fileNodeChildren[i];
|
|
1653
|
+
const result = fileNodeItem.toEmbeddedTSFile();
|
|
1654
|
+
if (action === 'create') {
|
|
1655
|
+
await handleChange(fileNodeItem, fileNodeItem, result, action);
|
|
1656
|
+
await incidentalAction(action, fileNodeItem, fileNodeItem);
|
|
1657
|
+
}
|
|
1658
|
+
else if (action === 'delete') {
|
|
1659
|
+
await handleDelete(fileNodeItem, fileNodeItem, result);
|
|
1660
|
+
await incidentalAction(action, fileNodeItem, fileNodeItem);
|
|
1661
|
+
}
|
|
1662
|
+
else if (action === 'update' && oldpath) {
|
|
1663
|
+
const parentPath = oldpath.replace('.ts', '/');
|
|
1664
|
+
const currentOldPath = parentPath + fileNodeItem.name + '.ts';
|
|
1665
|
+
// 因为重命名这里只有当前修改父级的 旧名称, 所以他的子集也要根据旧名称去查依赖 更新内容
|
|
1666
|
+
await handleRename(fileNodeItem, fileNodeItem, result, currentOldPath);
|
|
1667
|
+
await incidentalAction(action, fileNodeItem, fileNodeItem, currentOldPath);
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
;
|
|
1671
|
+
}
|
|
1672
|
+
// 删除或新增模块
|
|
1673
|
+
// 需要把下面的哦内容全部都更新一遍
|
|
1674
|
+
if (fileNode instanceof concepts_1.Module) {
|
|
1675
|
+
const module = (targetNode);
|
|
1676
|
+
const results = [];
|
|
1677
|
+
naslServer.contentToFile(module, results);
|
|
1678
|
+
for (let i = 0; i < results.length; i++) {
|
|
1679
|
+
const result = results[i];
|
|
1680
|
+
const node = naslServer.file2NodeMap.get(result.filePath);
|
|
1681
|
+
if (action === 'create') {
|
|
1682
|
+
await handleChange(node, node, result, action);
|
|
1683
|
+
}
|
|
1684
|
+
else {
|
|
1685
|
+
await handleDelete(node, node, result);
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
;
|
|
1689
|
+
// 删除模块通知更新列表
|
|
1690
|
+
if (action === 'delete') {
|
|
1691
|
+
try {
|
|
1692
|
+
// 如果已经
|
|
1693
|
+
(0, common_1.invokeCommand)('module.delete', true);
|
|
1694
|
+
}
|
|
1695
|
+
catch (err) {
|
|
1696
|
+
console.log('module.delete', '组件销毁了,不用唤起了');
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1514
1701
|
}
|
|
1515
1702
|
async function receiveHandleChange($event) {
|
|
1516
1703
|
// 行为
|
|
@@ -1519,7 +1706,11 @@ async function receiveHandleChange($event) {
|
|
|
1519
1706
|
// 当前操作的文件节点
|
|
1520
1707
|
const { fileNode } = naslServer.getCurrentSource(targetNode);
|
|
1521
1708
|
// 如果是导入模块就,就引入对应模块,先不处理module和Configuration,下面的内容会自动创建
|
|
1522
|
-
if (fileNode instanceof concepts_1.Module || fileNode instanceof concepts_1.Configuration) {
|
|
1709
|
+
if (!fileNode || fileNode instanceof concepts_1.Module || fileNode instanceof concepts_1.Configuration) {
|
|
1710
|
+
// module单独处理
|
|
1711
|
+
if (fileNode instanceof concepts_1.Module) {
|
|
1712
|
+
await incidentalAction(action, fileNode, targetNode);
|
|
1713
|
+
}
|
|
1523
1714
|
return;
|
|
1524
1715
|
}
|
|
1525
1716
|
const result = fileNode.toEmbeddedTSFile();
|
|
@@ -1537,24 +1728,44 @@ async function receiveHandleChange($event) {
|
|
|
1537
1728
|
]);
|
|
1538
1729
|
fileNode.sourceMap = result.sourceMap;
|
|
1539
1730
|
if (action === 'update' || action === 'create') {
|
|
1540
|
-
if ($event?.field !== 'name')
|
|
1731
|
+
if ($event?.field !== 'name') {
|
|
1541
1732
|
await handleChange(fileNode, targetNode, result, action);
|
|
1733
|
+
await incidentalAction(action, fileNode, targetNode);
|
|
1734
|
+
}
|
|
1542
1735
|
else {
|
|
1543
|
-
|
|
1736
|
+
const oldpath = fileNode.getEmbeddedFilePath($event.oldObject.name);
|
|
1737
|
+
await handleRename(fileNode, targetNode, result, oldpath);
|
|
1738
|
+
await incidentalAction(action, fileNode, targetNode, oldpath);
|
|
1544
1739
|
}
|
|
1545
1740
|
}
|
|
1546
1741
|
// 删除
|
|
1547
1742
|
if (action === 'delete') {
|
|
1743
|
+
await incidentalAction(action, fileNode, targetNode);
|
|
1548
1744
|
await handleDelete(fileNode, targetNode, result);
|
|
1549
1745
|
}
|
|
1746
|
+
return true;
|
|
1550
1747
|
}
|
|
1551
1748
|
// 监听所有改变操作
|
|
1552
1749
|
translator_1.embeddedTSEmitter.on('change', ($event) => {
|
|
1553
1750
|
// 收集到一个行为集合
|
|
1554
1751
|
const eventValue = $event.value;
|
|
1555
|
-
|
|
1556
|
-
|
|
1752
|
+
const stackList = [];
|
|
1753
|
+
eventValue.forEach(async (item) => {
|
|
1754
|
+
stackList.push(item.originEvent);
|
|
1557
1755
|
});
|
|
1756
|
+
// 异步状态机,一个完成了在执行下一个
|
|
1757
|
+
function next() {
|
|
1758
|
+
const item = stackList.shift();
|
|
1759
|
+
receiveHandleChange(item).then(() => {
|
|
1760
|
+
if (stackList.length) {
|
|
1761
|
+
next();
|
|
1762
|
+
}
|
|
1763
|
+
});
|
|
1764
|
+
}
|
|
1765
|
+
// 如果有长度开始执行状态机
|
|
1766
|
+
if (stackList.length) {
|
|
1767
|
+
next();
|
|
1768
|
+
}
|
|
1558
1769
|
});
|
|
1559
1770
|
naslServer.messager.options.context = naslServer;
|
|
1560
1771
|
exports.default = naslServer;
|