@lcap/nasl 2.20.0-beta.2 → 2.20.0
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 +2 -3
- package/out/automate/engine/index.js.map +1 -1
- package/out/automate/engine/uniqueName.d.ts +1 -1
- package/out/automate/engine/uniqueName.js +2 -2
- package/out/automate/engine/uniqueName.js.map +1 -1
- package/out/automate/engine/utils.js +4 -1
- package/out/automate/engine/utils.js.map +1 -1
- package/out/automate/template/myProcess.d.ts +1 -1
- package/out/automate/template/myProcess.js +2 -2
- package/out/automate/template/myProcess.js.map +1 -1
- package/out/bak/translator.js +14 -22
- package/out/bak/translator.js.map +1 -1
- package/out/common/BaseNode.js +4 -1
- package/out/common/BaseNode.js.map +1 -1
- package/out/common/Command.d.ts +1 -0
- package/out/common/Command.js +5 -1
- package/out/common/Command.js.map +1 -1
- package/out/concepts/App__.d.ts +4 -0
- package/out/concepts/App__.js +30 -6
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Assignee__.js +4 -3
- package/out/concepts/Assignee__.js.map +1 -1
- package/out/concepts/BatchAssignment__.js +3 -3
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts +7 -0
- package/out/concepts/BindAttribute__.js +270 -39
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.d.ts +7 -0
- package/out/concepts/BindDirective__.js +215 -17
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindStyle__.d.ts +7 -0
- package/out/concepts/BindStyle__.js +194 -4
- package/out/concepts/BindStyle__.js.map +1 -1
- package/out/concepts/CallFunction__.js +22 -8
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.js +3 -2
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +3 -0
- package/out/concepts/CallLogic__.js +78 -89
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.js +20 -3
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/ConfigGroup__.d.ts +1 -0
- package/out/concepts/ConfigGroup__.js +13 -0
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/ConfigProperty__.d.ts +19 -0
- package/out/concepts/ConfigProperty__.js +61 -0
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Configuration__.d.ts +1 -0
- package/out/concepts/Configuration__.js +13 -0
- package/out/concepts/Configuration__.js.map +1 -1
- package/out/concepts/DataSource__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +1 -0
- package/out/concepts/Destination__.js +61 -7
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/EntityProperty__.js +9 -1
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/EnumItem__.d.ts +5 -5
- package/out/concepts/EnumItem__.js +6 -6
- package/out/concepts/Enum__.d.ts +20 -19
- package/out/concepts/Enum__.js +28 -1
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/ExternalDestination__.d.ts +1 -0
- package/out/concepts/ExternalDestination__.js +21 -3
- package/out/concepts/ExternalDestination__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +2 -0
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Frontend__.d.ts +2 -1
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/Identifier__.js +16 -5
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/InterfaceParam__.js +9 -1
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/JSBlock__.js +5 -1
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +79 -79
- package/out/concepts/Logic__.js +16 -3
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Match__.d.ts +0 -3
- package/out/concepts/Match__.js +11 -66
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/MemberExpression__.js +9 -0
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.d.ts +16 -0
- package/out/concepts/Module__.js +43 -0
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/NewComposite__.d.ts +2 -4
- package/out/concepts/NewComposite__.js +91 -126
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/NewList__.d.ts +1 -0
- package/out/concepts/NewList__.js +22 -2
- package/out/concepts/NewList__.js.map +1 -1
- package/out/concepts/NewMap__.d.ts +1 -0
- package/out/concepts/NewMap__.js +43 -11
- package/out/concepts/NewMap__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.js +40 -12
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/Param__.js +10 -2
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +2 -1
- 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/ProcessOutcomes__.js +1 -1
- package/out/concepts/ProcessOutcomes__.js.map +1 -1
- package/out/concepts/Process__.js +1 -0
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/Return__.js +10 -2
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/StringInterpolation__.js +14 -2
- package/out/concepts/StringInterpolation__.js.map +1 -1
- package/out/concepts/StringLiteral__.js +6 -6
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.js +9 -1
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +6 -3
- package/out/concepts/TypeAnnotation__.js +67 -13
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/ValidationRule__.d.ts +1 -0
- package/out/concepts/ValidationRule__.js +53 -0
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.js +9 -1
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.js +17 -1
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +1 -3
- package/out/concepts/View__.js +22 -11
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.collection.js +6 -1
- package/out/concepts/basics/stdlib/nasl.collection.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.configuration.js +3 -0
- package/out/concepts/basics/stdlib/nasl.configuration.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.core.d.ts +2 -0
- package/out/concepts/basics/stdlib/nasl.core.js +34 -0
- package/out/concepts/basics/stdlib/nasl.core.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +4 -2
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/basics/types/index.d.ts +1 -0
- package/out/concepts/basics/types/index.js +3 -1
- package/out/concepts/basics/types/index.js.map +1 -1
- package/out/concepts/index__.d.ts +0 -1
- package/out/concepts/index__.js +0 -1
- package/out/concepts/index__.js.map +1 -1
- package/out/enums/KEYWORDS.js +8 -0
- package/out/enums/KEYWORDS.js.map +1 -1
- package/out/generator/genBundleFiles.js +24 -5
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genReleaseBody.d.ts +2 -3
- package/out/generator/genReleaseBody.js +97 -23
- package/out/generator/genReleaseBody.js.map +1 -1
- package/out/generator/permission.d.ts +2 -10
- package/out/generator/permission.js +27 -14
- package/out/generator/permission.js.map +1 -1
- package/out/server/entity2LogicNamespace.js +2 -20
- package/out/server/entity2LogicNamespace.js.map +1 -1
- package/out/server/extendBaseNode.js +16 -5
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/formatTsUtils.d.ts +2 -1
- package/out/server/formatTsUtils.js +40 -10
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getLogics.d.ts +2 -2
- package/out/server/getLogics.js +3 -3
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.d.ts +1 -0
- package/out/server/getMemberIdentifier.js +27 -1
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/index.js +1 -0
- package/out/server/index.js.map +1 -1
- package/out/server/naslServer.d.ts +7 -1
- package/out/server/naslServer.js +519 -46
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +109 -33
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.js +21 -1
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +1 -3
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +1 -3
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +2 -4
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +1 -1
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +2 -2
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +7 -1
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genSelectBlock.js +1 -1
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +2 -2
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +2 -3
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/utils/traverse.js +8 -2
- package/out/utils/traverse.js.map +1 -1
- package/package.json +2 -2
- package/sandbox/stdlib/dist/nasl.logging.js +0 -0
- package/sandbox/stdlib/dist/nasl.util.js +0 -0
- package/sandbox/stdlib/nasl.collection.ts +1 -0
- package/sandbox/stdlib/nasl.core.ts +34 -0
- package/sandbox/stdlib/nasl.oql.ts +71 -15
- package/sandbox/stdlib/nasl.util.ts +9 -3
- package/src/automate/engine/dist/index.dev.js +517 -0
- package/src/automate/engine/index.js +2 -3
- package/src/automate/engine/uniqueName.js +2 -2
- package/src/automate/engine/utils.js +4 -2
- package/src/automate/template/myProcess.js +2 -2
- package/src/bak/translator.js +16 -25
- package/src/common/BaseNode.ts +3 -1
- package/src/common/Command.ts +4 -0
- package/src/common/dist/BaseNode.js +1101 -0
- package/src/concepts/App__.ts +36 -7
- package/src/concepts/Assignee__.ts +4 -3
- package/src/concepts/BatchAssignment__.ts +3 -3
- package/src/concepts/BindAttribute__.ts +299 -38
- package/src/concepts/BindDirective__.ts +204 -31
- package/src/concepts/BindStyle__.ts +187 -24
- package/src/concepts/CallFunction__.ts +55 -10
- package/src/concepts/CallInterface__.ts +3 -2
- package/src/concepts/CallLogic__.ts +110 -90
- package/src/concepts/CallQueryComponent__.ts +18 -3
- package/src/concepts/ConfigGroup__.ts +17 -4
- package/src/concepts/ConfigProperty__.ts +70 -4
- package/src/concepts/Configuration__.ts +14 -5
- package/src/concepts/DataSource__.ts +4 -1
- package/src/concepts/Destination__.ts +61 -7
- package/src/concepts/EntityProperty__.ts +7 -1
- package/src/concepts/EnumItem__.ts +6 -6
- package/src/concepts/Enum__.ts +22 -19
- package/src/concepts/ExternalDestination__.ts +28 -8
- package/src/concepts/ForEachStatement__.ts +2 -0
- package/src/concepts/Frontend__.ts +2 -1
- package/src/concepts/Identifier__.ts +16 -5
- package/src/concepts/InterfaceParam__.ts +7 -1
- package/src/concepts/JSBlock__.ts +3 -2
- package/src/concepts/Logic__.ts +95 -83
- package/src/concepts/Match__.ts +31 -67
- package/src/concepts/MemberExpression__.ts +6 -0
- package/src/concepts/Module__.ts +57 -0
- package/src/concepts/NewComposite__.ts +95 -140
- package/src/concepts/NewList__.ts +23 -2
- package/src/concepts/NewMap__.ts +48 -24
- package/src/concepts/OqlQueryComponent__.ts +40 -20
- package/src/concepts/Param__.ts +178 -176
- package/src/concepts/ProcessElement__.ts +2 -1
- package/src/concepts/ProcessOutcome__.ts +1 -1
- package/src/concepts/ProcessOutcomes__.ts +1 -1
- package/src/concepts/Process__.ts +1 -0
- package/src/concepts/Return__.ts +8 -2
- package/src/concepts/StringInterpolation__.ts +19 -7
- package/src/concepts/StringLiteral__.ts +7 -6
- package/src/concepts/StructureProperty__.ts +7 -1
- package/src/concepts/TypeAnnotation__.ts +101 -14
- package/src/concepts/ValidationRule__.ts +58 -9
- package/src/concepts/Variable__.ts +11 -1
- package/src/concepts/ViewElement__.ts +39 -2
- package/src/concepts/View__.ts +26 -14
- package/src/concepts/basics/stdlib/dist/nasl.util.js +1602 -0
- package/src/concepts/basics/stdlib/dist/reference2TypeAnnotationList.js +24 -0
- package/src/concepts/basics/stdlib/nasl.collection.ts +6 -1
- package/src/concepts/basics/stdlib/nasl.configuration.ts +3 -0
- package/src/concepts/basics/stdlib/nasl.core.ts +33 -2
- package/src/concepts/basics/stdlib/nasl.util.ts +4 -2
- package/src/concepts/basics/types/index.ts +1 -0
- package/src/concepts/dist/BindAttribute__.js +795 -0
- package/src/concepts/dist/BindEvent__.js +732 -0
- package/src/concepts/dist/CallFunction__.js +527 -0
- package/src/concepts/dist/CallLogic__.js +932 -0
- package/src/concepts/dist/Destination__.js +708 -0
- package/src/concepts/dist/ExternalDestination__.js +298 -0
- package/src/concepts/dist/Identifier__.js +311 -0
- package/src/concepts/dist/StringInterpolation__.js +231 -0
- package/src/concepts/dist/TypeAnnotation__.js +834 -0
- package/src/concepts/dist/ViewElement__.js +1692 -0
- package/src/concepts/dist/View__.js +1601 -0
- package/src/concepts/index__.ts +0 -1
- package/src/enums/KEYWORDS.ts +8 -0
- package/src/generator/dist/genBundleFiles.js +261 -0
- package/src/generator/dist/genMetaData.js +245 -0
- package/src/generator/dist/permission.js +405 -0
- package/src/generator/genBundleFiles.ts +24 -5
- package/src/generator/genReleaseBody.ts +75 -30
- package/src/generator/permission.ts +31 -15
- package/src/server/entity2LogicNamespace.ts +2 -20
- package/src/server/extendBaseNode.ts +15 -5
- package/src/server/formatTsUtils.ts +41 -10
- package/src/server/getLogics.ts +4 -4
- package/src/server/getMemberIdentifier.ts +27 -1
- package/src/server/index.ts +2 -0
- package/src/server/naslServer.ts +520 -48
- package/src/server/translator.ts +96 -34
- package/src/service/storage/dist/init.js +579 -0
- package/src/service/storage/init.ts +22 -2
- package/src/templator/dist/genEditTableBlock.js +204 -0
- package/src/templator/dist/genGridViewBlock.js +265 -0
- package/src/templator/dist/genListViewBlock.js +84 -0
- package/src/templator/dist/genTableBlock.js +209 -0
- package/src/templator/dist/utils.js +527 -0
- package/src/templator/genCreateBlock.ts +1 -3
- package/src/templator/genCurdEditMultipleKeyBlock.ts +1 -3
- package/src/templator/genCurdMultipleKeyBlock.ts +2 -4
- package/src/templator/genGetBlock.ts +1 -1
- package/src/templator/genGridViewBlock.ts +3 -4
- package/src/templator/genListViewBlock.ts +9 -3
- package/src/templator/genSelectBlock.ts +1 -1
- package/src/templator/genTableBlock.ts +3 -3
- package/src/templator/genUpdateBlock.ts +2 -3
- package/src/utils/traverse.ts +10 -2
- package/ts-worker/lib/tsserver.js +10 -2
- package/ts-worker/package.json +1 -0
- package/ts-worker/webpack.config.js +11 -2
- package/out/concepts/ConstructArgument__.d.ts +0 -40
- package/out/concepts/ConstructArgument__.js +0 -108
- package/out/concepts/ConstructArgument__.js.map +0 -1
- package/out/concepts/Construct__.d.ts +0 -189
- package/out/concepts/Construct__.js +0 -340
- package/out/concepts/Construct__.js.map +0 -1
- package/out/templator/sql-parser/index.d.ts +0 -1
- package/out/templator/sql-parser/index.js +0 -228
- package/out/templator/sql-parser/index.js.map +0 -1
- package/out/templator/sql-parser/parser.js +0 -26664
- package/out/templator/sql-parser/parser.js.map +0 -1
package/out/server/naslServer.js
CHANGED
|
@@ -44,14 +44,17 @@ const diagnostic_1 = require("../manager/diagnostic");
|
|
|
44
44
|
const createUiTs_1 = __importDefault(require("./createUiTs"));
|
|
45
45
|
const coreTypeList_1 = require("../concepts/basics/types/coreTypeList");
|
|
46
46
|
const formatTsUtils_1 = require("./formatTsUtils");
|
|
47
|
+
const utils = __importStar(require("../utils"));
|
|
47
48
|
const naslStdlibMap_1 = __importDefault(require("./naslStdlibMap"));
|
|
48
49
|
const jsoner = __importStar(require("../service/storage/jsoner"));
|
|
49
50
|
const EventEmitter_1 = require("../common/EventEmitter");
|
|
51
|
+
const utils_1 = require("../utils");
|
|
50
52
|
const EmbeddedTSFileLineMap = {
|
|
51
53
|
Entity: 3,
|
|
52
54
|
};
|
|
53
55
|
const EmbeddedTSFileOffsetMap = {
|
|
54
56
|
Variable: 12,
|
|
57
|
+
ConfigProperty: 12,
|
|
55
58
|
};
|
|
56
59
|
let isChangeInterface = false; //判断是否导入接口
|
|
57
60
|
let actionArr = []; //用于导入接口收集更改的节点
|
|
@@ -102,6 +105,8 @@ class NaslServer {
|
|
|
102
105
|
changeStackList = [];
|
|
103
106
|
filesToCheck;
|
|
104
107
|
singleFileChangeIng;
|
|
108
|
+
// 包含组件逻辑调用的逻辑map
|
|
109
|
+
logicSetWithComponentLogic = new Set();
|
|
105
110
|
constructor() {
|
|
106
111
|
/// #if process.env.BUILD_TARGET === 'node'
|
|
107
112
|
if (globalThis.process) // For TS build
|
|
@@ -110,6 +115,7 @@ class NaslServer {
|
|
|
110
115
|
/// #endif
|
|
111
116
|
/// #if process.env.BUILD_TARGET !== 'node'
|
|
112
117
|
if (globalThis.window) // For TS build
|
|
118
|
+
/* !!!如果改动这里需要看下关联的对应文件:webpack/ts-worker/loader.js */
|
|
113
119
|
this.worker = new worker_threads_1.Worker('/ts-worker.js');
|
|
114
120
|
/// #endif
|
|
115
121
|
// 要Check的文件
|
|
@@ -316,6 +322,21 @@ class NaslServer {
|
|
|
316
322
|
}
|
|
317
323
|
});
|
|
318
324
|
}
|
|
325
|
+
module.configuration?.groups?.forEach((_group) => {
|
|
326
|
+
if (_group.name === 'custom') {
|
|
327
|
+
_group.properties.forEach((_property) => {
|
|
328
|
+
try {
|
|
329
|
+
const result = _property.toEmbeddedTSFile();
|
|
330
|
+
results.push(result);
|
|
331
|
+
// sourceMap都存在目录级别内容下,在页面层级下去找
|
|
332
|
+
_property.sourceMap = result.sourceMap;
|
|
333
|
+
this.file2NodeMap.set(result.filePath, _property);
|
|
334
|
+
}
|
|
335
|
+
catch (err) {
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
});
|
|
319
340
|
}
|
|
320
341
|
view2TSFile(viewsChildren, results) {
|
|
321
342
|
// 如果有子页面
|
|
@@ -698,6 +719,14 @@ class NaslServer {
|
|
|
698
719
|
const records = await this.getDiagnosticRecords(fileNames);
|
|
699
720
|
// diagnosticManager.pushAll(records);
|
|
700
721
|
}
|
|
722
|
+
/**
|
|
723
|
+
* 节点异常是只能挂载单个,如果已经了就不赋值了
|
|
724
|
+
*/
|
|
725
|
+
baseNodeAssignmentTsError(node, tsErrorDetail) {
|
|
726
|
+
if (node.tsErrorDetail)
|
|
727
|
+
return;
|
|
728
|
+
node.tsErrorDetail = tsErrorDetail;
|
|
729
|
+
}
|
|
701
730
|
/**
|
|
702
731
|
* 处理诊断结果
|
|
703
732
|
* @param records 结果
|
|
@@ -751,6 +780,42 @@ class NaslServer {
|
|
|
751
780
|
.map((diag) => this._resolveDiagnostic(diag, node, record))
|
|
752
781
|
.filter((diag) => !!diag);
|
|
753
782
|
record.semanticDiagnostics.push(...this._attachDiagnostics(node));
|
|
783
|
+
// 报错降级逻辑
|
|
784
|
+
record.semanticDiagnostics = record.semanticDiagnostics
|
|
785
|
+
.map((diagnostic) => {
|
|
786
|
+
// 错误降级如果属于草稿态的就降级
|
|
787
|
+
if (diagnostic?.node) {
|
|
788
|
+
let currentNode = diagnostic.node;
|
|
789
|
+
while (currentNode?.parentNode?.concept !== 'App') {
|
|
790
|
+
if (currentNode.parentKey?.toLowerCase()?.includes('playground')) {
|
|
791
|
+
// 草稿区降级
|
|
792
|
+
// 重置 图标和错误等级
|
|
793
|
+
diagnostic.severity = 'warning';
|
|
794
|
+
if (diagnostic.node?.tsErrorDetail) {
|
|
795
|
+
// 重置组件节点上的错误信息
|
|
796
|
+
diagnostic.node.tsErrorDetail.severity = 'warning';
|
|
797
|
+
}
|
|
798
|
+
record.suggestionDiagnostics.push(diagnostic);
|
|
799
|
+
return null;
|
|
800
|
+
}
|
|
801
|
+
else if (currentNode.concept === 'OqlQueryComponent') {
|
|
802
|
+
// OQL别名错误降级为警告
|
|
803
|
+
if (diagnostic.originalDiagnostic && diagnostic.originalDiagnostic?.text.includes('__OQL_ALIAS_WARNING__')) {
|
|
804
|
+
// 重置 图标和错误等级
|
|
805
|
+
diagnostic.severity = 'warning';
|
|
806
|
+
if (diagnostic.node?.tsErrorDetail) {
|
|
807
|
+
// 重置组件节点上的错误信息
|
|
808
|
+
diagnostic.node.tsErrorDetail.severity = 'warning';
|
|
809
|
+
}
|
|
810
|
+
record.suggestionDiagnostics.push(diagnostic);
|
|
811
|
+
return null;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
currentNode = currentNode.parentNode;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
return diagnostic;
|
|
818
|
+
}).filter((diag) => !!diag);
|
|
754
819
|
// 建议诊断
|
|
755
820
|
// 实体下的建议不用展示,因为都是平台自己写的逻辑
|
|
756
821
|
// if (node instanceof Entity) {
|
|
@@ -764,11 +829,51 @@ class NaslServer {
|
|
|
764
829
|
// // logic在for循环中,不展示any提示
|
|
765
830
|
// record.suggestionDiagnostics = record.suggestionDiagnostics.filter((item) => !item.text.includes(`implicitly has an 'any' type, but a better type may be inferred from usage.`));
|
|
766
831
|
// }
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
832
|
+
// 处理后的警告异常提示信息
|
|
833
|
+
record.suggestionDiagnostics = record.suggestionDiagnostics.map((diag) => {
|
|
834
|
+
// 上面错误降级下来的
|
|
835
|
+
if (diag?.node) {
|
|
836
|
+
return diag;
|
|
837
|
+
// 一些已知警告的单独处理
|
|
838
|
+
}
|
|
839
|
+
else if ([`'__LogicEmpty' is declared but its value is never read.`,
|
|
840
|
+
`'__destinationEmpty__' is declared but its value is never read.`,
|
|
841
|
+
`'__devConfigValueEmpty' is declared but its value is never read.`,
|
|
842
|
+
`'__onlineConfigValueEmpty' is declared but its value is never read.`,
|
|
843
|
+
`'__UpdateNoProperty__' is declared but its value is never read.`].includes(diag.text)) {
|
|
844
|
+
return this._resolveDiagnostic(diag, node, record);
|
|
845
|
+
}
|
|
846
|
+
else if ((diag.text).includes(` is declared but its value is never read.`)) {
|
|
847
|
+
// 局部变量和输入变量未使用的警告
|
|
848
|
+
if ((node.concept === 'View' || node.concept === 'Logic') && node.parentNode.concept !== 'Module') {
|
|
849
|
+
const minRange = this._findMinRange(diag, node);
|
|
850
|
+
if (minRange) {
|
|
851
|
+
/**
|
|
852
|
+
* 如果节点是入参类型
|
|
853
|
+
* 而且不是foreach中
|
|
854
|
+
* 而且不是事件逻辑的入参
|
|
855
|
+
*/
|
|
856
|
+
if (minRange.node instanceof concepts_1.Param && minRange.node.parentNode.concept !== 'ForEachStatement' && !minRange.node.getAncestor('BindEvent')) {
|
|
857
|
+
const diagnostic = {
|
|
858
|
+
node: minRange.node,
|
|
859
|
+
severity: 'warning',
|
|
860
|
+
message: `未使用的输入参数${minRange.node.name}`,
|
|
861
|
+
};
|
|
862
|
+
return diagnostic;
|
|
863
|
+
}
|
|
864
|
+
else if (minRange.node instanceof concepts_1.Variable) {
|
|
865
|
+
const diagnostic = {
|
|
866
|
+
node: minRange.node,
|
|
867
|
+
severity: 'warning',
|
|
868
|
+
message: `未使用的变量${minRange.node.name}`,
|
|
869
|
+
};
|
|
870
|
+
return diagnostic;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
return null;
|
|
876
|
+
}).filter((diag) => !!diag);
|
|
772
877
|
record.suggestionDiagnostics.push(...this._attachSuggestionDiagnostics(node));
|
|
773
878
|
});
|
|
774
879
|
return records;
|
|
@@ -781,22 +886,6 @@ class NaslServer {
|
|
|
781
886
|
_attachSuggestionDiagnostics(fileNode) {
|
|
782
887
|
const diagnostics = [];
|
|
783
888
|
if (fileNode instanceof concepts_1.Logic || fileNode instanceof concepts_1.View) {
|
|
784
|
-
// 判断逻辑是否已经删除
|
|
785
|
-
if (fileNode instanceof concepts_1.Logic && fileNode.parentNode instanceof concepts_1.App && !fileNode.parentNode.logics.includes(fileNode))
|
|
786
|
-
return diagnostics;
|
|
787
|
-
// 判断页面是否已经删除
|
|
788
|
-
let removed = false;
|
|
789
|
-
let curNode = fileNode;
|
|
790
|
-
// 递归检查,防止从顶层页面开始删除影响子页面内容检查
|
|
791
|
-
while (curNode instanceof concepts_1.View && !removed) {
|
|
792
|
-
if (curNode.parentNode instanceof concepts_1.View && !curNode.parentNode.children.includes(curNode)
|
|
793
|
-
|| curNode.parentNode instanceof concepts_1.Frontend && !curNode.parentNode.views.includes(curNode)) {
|
|
794
|
-
removed = true;
|
|
795
|
-
}
|
|
796
|
-
curNode = curNode.parentNode;
|
|
797
|
-
}
|
|
798
|
-
if (removed)
|
|
799
|
-
return diagnostics;
|
|
800
889
|
fileNode?.sourceMap.forEach((value, node) => {
|
|
801
890
|
if (node instanceof concepts_1.Match) {
|
|
802
891
|
const { cases, expression } = node || {};
|
|
@@ -913,7 +1002,7 @@ class NaslServer {
|
|
|
913
1002
|
const lastExpression = body[body.length - 1];
|
|
914
1003
|
diagnostic.node = lastExpression;
|
|
915
1004
|
diagnostic.message = `${lastExpression?.toUI()}期望的类型是${maxTypeAnnotation?.headTitle}`;
|
|
916
|
-
lastExpression
|
|
1005
|
+
this.baseNodeAssignmentTsError(lastExpression, diagnostic);
|
|
917
1006
|
diagnostics.push(diagnostic);
|
|
918
1007
|
}
|
|
919
1008
|
});
|
|
@@ -921,31 +1010,232 @@ class NaslServer {
|
|
|
921
1010
|
}
|
|
922
1011
|
}
|
|
923
1012
|
}
|
|
1013
|
+
else if (node instanceof concepts_1.NewList && !node.typeAnnotation) {
|
|
1014
|
+
// 匿名函数返回值有可能是newList,需要过滤。代码来源:AnonymousFunction.__ts
|
|
1015
|
+
const grandParent = node.parentNode?.parentNode?.parentNode;
|
|
1016
|
+
if (grandParent instanceof concepts_1.CallLogic
|
|
1017
|
+
&& /dataSources\.[^.]+\.entities\.[^.]+\.logics/.test(grandParent.calleeNamespace)
|
|
1018
|
+
&& ['update', 'updateBy', 'createOrUpdate', 'batchUpdate'].includes(grandParent.calleeName)) {
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
1021
|
+
const { items } = node || {};
|
|
1022
|
+
const typeAnnotationMap = {};
|
|
1023
|
+
// 最多数的类型
|
|
1024
|
+
let maxTypeAnnotationInfo = {
|
|
1025
|
+
typeAnnotation: null,
|
|
1026
|
+
count: 0,
|
|
1027
|
+
};
|
|
1028
|
+
if (Array.isArray(items)) {
|
|
1029
|
+
items.forEach((item) => {
|
|
1030
|
+
const typeAnnotation = item.__TypeAnnotation;
|
|
1031
|
+
// 仅处理有类型的情况,返回类型为void的情况由其他地方处理成报错
|
|
1032
|
+
if (typeAnnotation) {
|
|
1033
|
+
const sortedTypeKey = typeAnnotation.sortedTypeKey;
|
|
1034
|
+
if (!typeAnnotationMap[sortedTypeKey]) {
|
|
1035
|
+
typeAnnotationMap[sortedTypeKey] = {
|
|
1036
|
+
typeAnnotation,
|
|
1037
|
+
items: [],
|
|
1038
|
+
count: 0,
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
const typeAnnotationInfo = typeAnnotationMap[sortedTypeKey];
|
|
1042
|
+
typeAnnotationInfo.items.push(item);
|
|
1043
|
+
typeAnnotationInfo.count++;
|
|
1044
|
+
const { count } = typeAnnotationInfo;
|
|
1045
|
+
if (maxTypeAnnotationInfo.count < count) {
|
|
1046
|
+
maxTypeAnnotationInfo = {
|
|
1047
|
+
typeAnnotation,
|
|
1048
|
+
count,
|
|
1049
|
+
};
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1054
|
+
const { typeAnnotation: maxTypeAnnotation, } = maxTypeAnnotationInfo;
|
|
1055
|
+
for (const sortedTypeKey in typeAnnotationMap) {
|
|
1056
|
+
const { typeAnnotation, items } = typeAnnotationMap[sortedTypeKey];
|
|
1057
|
+
if (maxTypeAnnotation?.sortedTypeKey !== typeAnnotation?.sortedTypeKey) {
|
|
1058
|
+
if (Array.isArray(items)) {
|
|
1059
|
+
items.forEach((item) => {
|
|
1060
|
+
const diagnostic = {
|
|
1061
|
+
node: item,
|
|
1062
|
+
severity: 'warning',
|
|
1063
|
+
message: `NewList期望的类型是${maxTypeAnnotation?.headTitle}`,
|
|
1064
|
+
};
|
|
1065
|
+
this.baseNodeAssignmentTsError(item, diagnostic);
|
|
1066
|
+
diagnostics.push(diagnostic);
|
|
1067
|
+
});
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
else if (node instanceof concepts_1.NewMap && !node.typeAnnotation) {
|
|
1073
|
+
const { values } = node || {};
|
|
1074
|
+
const typeAnnotationMap = {};
|
|
1075
|
+
// 最多数的类型
|
|
1076
|
+
let maxTypeAnnotationInfo = {
|
|
1077
|
+
typeAnnotation: null,
|
|
1078
|
+
count: 0,
|
|
1079
|
+
};
|
|
1080
|
+
if (Array.isArray(values)) {
|
|
1081
|
+
values.forEach((value) => {
|
|
1082
|
+
if (!value)
|
|
1083
|
+
return;
|
|
1084
|
+
const typeAnnotation = value.__TypeAnnotation;
|
|
1085
|
+
// 仅处理有类型的情况,返回类型为void的情况由其他地方处理成报错
|
|
1086
|
+
if (typeAnnotation) {
|
|
1087
|
+
const sortedTypeKey = typeAnnotation.sortedTypeKey;
|
|
1088
|
+
if (!typeAnnotationMap[sortedTypeKey]) {
|
|
1089
|
+
typeAnnotationMap[sortedTypeKey] = {
|
|
1090
|
+
typeAnnotation,
|
|
1091
|
+
values: [],
|
|
1092
|
+
count: 0,
|
|
1093
|
+
};
|
|
1094
|
+
}
|
|
1095
|
+
const typeAnnotationInfo = typeAnnotationMap[sortedTypeKey];
|
|
1096
|
+
typeAnnotationInfo.values.push(value);
|
|
1097
|
+
typeAnnotationInfo.count++;
|
|
1098
|
+
const { count } = typeAnnotationInfo;
|
|
1099
|
+
if (maxTypeAnnotationInfo.count < count) {
|
|
1100
|
+
maxTypeAnnotationInfo = {
|
|
1101
|
+
typeAnnotation,
|
|
1102
|
+
count,
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1108
|
+
const { typeAnnotation: maxTypeAnnotation, } = maxTypeAnnotationInfo;
|
|
1109
|
+
for (const sortedTypeKey in typeAnnotationMap) {
|
|
1110
|
+
const { typeAnnotation, values } = typeAnnotationMap[sortedTypeKey];
|
|
1111
|
+
if (maxTypeAnnotation?.sortedTypeKey !== typeAnnotation?.sortedTypeKey) {
|
|
1112
|
+
if (Array.isArray(values)) {
|
|
1113
|
+
values.forEach((value) => {
|
|
1114
|
+
const diagnostic = {
|
|
1115
|
+
node: value,
|
|
1116
|
+
severity: 'warning',
|
|
1117
|
+
message: `NewMap中values值所期望的类型是${maxTypeAnnotation?.headTitle}`,
|
|
1118
|
+
};
|
|
1119
|
+
this.baseNodeAssignmentTsError(value, diagnostic);
|
|
1120
|
+
diagnostics.push(diagnostic);
|
|
1121
|
+
});
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
else if (node.concept === 'JSBlock') {
|
|
1127
|
+
// 初始js代码块先屏蔽掉
|
|
1128
|
+
if (node.code === `location.href = '/';`) {
|
|
1129
|
+
return null;
|
|
1130
|
+
}
|
|
1131
|
+
const diagnostic = {
|
|
1132
|
+
node,
|
|
1133
|
+
severity: 'warning',
|
|
1134
|
+
message: '不建议使用js代码块',
|
|
1135
|
+
};
|
|
1136
|
+
diagnostics.push(diagnostic);
|
|
1137
|
+
}
|
|
1138
|
+
else if (node.concept === 'Unparsed') {
|
|
1139
|
+
const diagnostic = {
|
|
1140
|
+
node,
|
|
1141
|
+
severity: 'warning',
|
|
1142
|
+
message: '不建议使用自定义表达式',
|
|
1143
|
+
};
|
|
1144
|
+
diagnostics.push(diagnostic);
|
|
1145
|
+
}
|
|
1146
|
+
else if (node instanceof concepts_1.CallQueryComponent) {
|
|
1147
|
+
// 可视化查询中不允许有复杂的数据结构
|
|
1148
|
+
const contentVariables = [];
|
|
1149
|
+
utils.traverse(({ node }) => {
|
|
1150
|
+
if (node?.parentNode?.concept !== 'MemberExpression') {
|
|
1151
|
+
if (node?.concept === 'MemberExpression') {
|
|
1152
|
+
contentVariables.push(node);
|
|
1153
|
+
}
|
|
1154
|
+
else if (node?.concept === 'Identifier') {
|
|
1155
|
+
// 因为要是父级是MemberExpression, 就放入了父级,子级就不需要了
|
|
1156
|
+
contentVariables.push(node);
|
|
1157
|
+
// QueryFromExpression QueryJoinExpression
|
|
1158
|
+
}
|
|
1159
|
+
else if (node?.concept === 'QueryFieldExpression' || node?.concept === 'QueryGroupByExpression') {
|
|
1160
|
+
contentVariables.push(node);
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
}, { node }, {
|
|
1164
|
+
mode: 'anyObject',
|
|
1165
|
+
excludedKeySet: new Set(['parentNode', '_events', 'globalDataMap', 'havingPlayground', 'wherePlayground']),
|
|
1166
|
+
});
|
|
1167
|
+
contentVariables?.forEach((variable) => {
|
|
1168
|
+
// 如果是复杂数据结构
|
|
1169
|
+
if (variable.__TypeAnnotation?.isComplexType()) {
|
|
1170
|
+
const diagnostic = {
|
|
1171
|
+
node,
|
|
1172
|
+
severity: 'warning',
|
|
1173
|
+
message: `数据查询中不可以使用复杂类型!当前类型:${variable.__TypeAnnotation?.typeChineseTitle}。`,
|
|
1174
|
+
};
|
|
1175
|
+
this.baseNodeAssignmentTsError(variable, diagnostic);
|
|
1176
|
+
diagnostics.push(diagnostic);
|
|
1177
|
+
}
|
|
1178
|
+
});
|
|
1179
|
+
}
|
|
924
1180
|
});
|
|
925
1181
|
}
|
|
926
1182
|
return diagnostics;
|
|
927
1183
|
}
|
|
1184
|
+
// 是否包含组件逻辑
|
|
1185
|
+
hasComponentLogics(expression) {
|
|
1186
|
+
let flag = false;
|
|
1187
|
+
(0, utils_1.traverse)((current) => {
|
|
1188
|
+
const { node } = current || {};
|
|
1189
|
+
const { concept } = node || {};
|
|
1190
|
+
if (concept === 'CallLogic') {
|
|
1191
|
+
// 调用组件逻辑
|
|
1192
|
+
if (node.isComponentLogic) {
|
|
1193
|
+
flag = true;
|
|
1194
|
+
}
|
|
1195
|
+
else if (node.isViewLogic) { // 调用页面逻辑
|
|
1196
|
+
const logicNode = node.view?.logics?.find?.((viewLogic) => viewLogic.name === node.calleeName);
|
|
1197
|
+
if (logicNode) {
|
|
1198
|
+
if (this.logicSetWithComponentLogic.has(logicNode.nodePath)) {
|
|
1199
|
+
flag = true;
|
|
1200
|
+
}
|
|
1201
|
+
else {
|
|
1202
|
+
const logicItem = logicNode.body?.find?.((logicItem) => this.hasComponentLogics(logicItem));
|
|
1203
|
+
if (logicItem) {
|
|
1204
|
+
flag = true;
|
|
1205
|
+
this.logicSetWithComponentLogic.add(logicNode.nodePath);
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
}, {
|
|
1212
|
+
node: expression,
|
|
1213
|
+
}, {
|
|
1214
|
+
mode: 'anyObject',
|
|
1215
|
+
excludedKeySet: new Set([
|
|
1216
|
+
'parentNode',
|
|
1217
|
+
'sourceMap',
|
|
1218
|
+
'storageJSON',
|
|
1219
|
+
'tsErrorDetail',
|
|
1220
|
+
'NaslAnnotatedJSON',
|
|
1221
|
+
'calledFrom',
|
|
1222
|
+
'_events',
|
|
1223
|
+
'_collectingList',
|
|
1224
|
+
'_historyList',
|
|
1225
|
+
]),
|
|
1226
|
+
});
|
|
1227
|
+
return flag;
|
|
1228
|
+
}
|
|
928
1229
|
/**
|
|
929
1230
|
* 额外的诊断
|
|
930
1231
|
* @param fileNode 文件级别的节点
|
|
931
1232
|
* @returns 诊断结果
|
|
932
1233
|
*/
|
|
933
1234
|
_attachDiagnostics(fileNode) {
|
|
1235
|
+
// 每次诊断前先清空这个Set
|
|
1236
|
+
this.logicSetWithComponentLogic = new Set();
|
|
934
1237
|
const diagnostics = [];
|
|
935
1238
|
if (fileNode instanceof concepts_1.View) {
|
|
936
|
-
// 判断页面是否已经删除
|
|
937
|
-
let removed = false;
|
|
938
|
-
let curNode = fileNode;
|
|
939
|
-
// 递归检查,防止从顶层页面开始删除影响子页面内容检查
|
|
940
|
-
while (curNode instanceof concepts_1.View && !removed) {
|
|
941
|
-
if (curNode.parentNode instanceof concepts_1.View && !curNode.parentNode.children.includes(curNode)
|
|
942
|
-
|| curNode.parentNode instanceof concepts_1.Frontend && !curNode.parentNode.views.includes(curNode)) {
|
|
943
|
-
removed = true;
|
|
944
|
-
}
|
|
945
|
-
curNode = curNode.parentNode;
|
|
946
|
-
}
|
|
947
|
-
if (removed)
|
|
948
|
-
return diagnostics;
|
|
949
1239
|
fileNode?.sourceMap.forEach((value, node) => {
|
|
950
1240
|
if (node instanceof concepts_1.ViewElement && node.view === fileNode) {
|
|
951
1241
|
if (node.tag) {
|
|
@@ -1027,7 +1317,7 @@ class NaslServer {
|
|
|
1027
1317
|
}
|
|
1028
1318
|
});
|
|
1029
1319
|
if (!msg)
|
|
1030
|
-
msg = '
|
|
1320
|
+
msg = '未设置类型或未赋值。直接赋值系统可以自动推断类型。';
|
|
1031
1321
|
const diagnostic = {
|
|
1032
1322
|
node,
|
|
1033
1323
|
severity: 'error',
|
|
@@ -1037,6 +1327,31 @@ class NaslServer {
|
|
|
1037
1327
|
diagnostics.push(diagnostic);
|
|
1038
1328
|
}
|
|
1039
1329
|
}
|
|
1330
|
+
else if (node instanceof concepts_1.BindAttribute || node instanceof concepts_1.BindDirective || node instanceof concepts_1.BindStyle) {
|
|
1331
|
+
if (Array.isArray(node.bindExpressions)) {
|
|
1332
|
+
const exp = node.bindExpressions.find((bindExpression) => this.hasComponentLogics(bindExpression));
|
|
1333
|
+
if (exp) {
|
|
1334
|
+
//const element: any = node.getAncestor('ViewElement');
|
|
1335
|
+
//const api = config.allNodesAPI[element?.tag];
|
|
1336
|
+
//const attr = api?.attrs?.find?.((attr) => {
|
|
1337
|
+
// return attr.name === node.name;
|
|
1338
|
+
//});
|
|
1339
|
+
const map = {
|
|
1340
|
+
BindAttribute: '属性',
|
|
1341
|
+
BindDirective: '指令',
|
|
1342
|
+
BindStyle: '样式属性',
|
|
1343
|
+
};
|
|
1344
|
+
//“${attr?.title || node.title || node.name}”
|
|
1345
|
+
const diagnostic = {
|
|
1346
|
+
node,
|
|
1347
|
+
severity: 'error',
|
|
1348
|
+
message: `${map[node.concept]}表达式不能绑定组件逻辑`,
|
|
1349
|
+
};
|
|
1350
|
+
node.tsErrorDetail = diagnostic;
|
|
1351
|
+
diagnostics.push(diagnostic);
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1040
1355
|
else {
|
|
1041
1356
|
this.checkNodeError(node, diagnostics);
|
|
1042
1357
|
}
|
|
@@ -1107,9 +1422,6 @@ class NaslServer {
|
|
|
1107
1422
|
}
|
|
1108
1423
|
}
|
|
1109
1424
|
if (fileNode instanceof concepts_1.Logic) {
|
|
1110
|
-
// 判断逻辑是否已经删除
|
|
1111
|
-
if (fileNode.parentNode instanceof concepts_1.App && !fileNode.parentNode.logics.includes(fileNode))
|
|
1112
|
-
return diagnostics;
|
|
1113
1425
|
fileNode?.sourceMap.forEach((value, node) => {
|
|
1114
1426
|
//OQL支持返回复合类型数据了
|
|
1115
1427
|
// SqlQueryComponent内部返回值类型,如果是嵌套的就需要报错
|
|
@@ -1122,6 +1434,24 @@ class NaslServer {
|
|
|
1122
1434
|
// node.tsErrorDetail = diagnostic;
|
|
1123
1435
|
// diagnostics.push(diagnostic);
|
|
1124
1436
|
// }
|
|
1437
|
+
if (node instanceof concepts_1.OqlQueryComponent) {
|
|
1438
|
+
// 自动推导情况
|
|
1439
|
+
const typeAnnotation = (0, formatTsUtils_1.type2TypeAnnotation)(node.__nodeType);
|
|
1440
|
+
if (!node.typeAnnotation && typeAnnotation) {
|
|
1441
|
+
if (typeAnnotation.typeName === 'List' && typeAnnotation.typeKind === 'generic') {
|
|
1442
|
+
const typeArguments = typeAnnotation.typeArguments;
|
|
1443
|
+
if (typeArguments.length && typeArguments[0].isComplexType()) {
|
|
1444
|
+
const diagnostic = {
|
|
1445
|
+
node,
|
|
1446
|
+
severity: 'error',
|
|
1447
|
+
message: `SQL查询:返回类型不支持单个复杂类型 ${typeArguments[0].headTitle}。`,
|
|
1448
|
+
};
|
|
1449
|
+
node.tsErrorDetail = diagnostic;
|
|
1450
|
+
diagnostics.push(diagnostic);
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1125
1455
|
if (node instanceof concepts_1.Return || node instanceof concepts_1.Variable) {
|
|
1126
1456
|
if (!node.typeAnnotation && !node.__TypeAnnotation) {
|
|
1127
1457
|
const nodeTypeName = node.concept === 'Return' ? '输出参数' : '局部变量';
|
|
@@ -1225,6 +1555,19 @@ class NaslServer {
|
|
|
1225
1555
|
}
|
|
1226
1556
|
});
|
|
1227
1557
|
}
|
|
1558
|
+
if (node instanceof concepts_1.MatchCase && node.getAncestor('Match')?.isExpression && node.body.length === 0) {
|
|
1559
|
+
// 如果不是其他就标红
|
|
1560
|
+
if ((node?.getIndexOfParent() !== (node.getAncestor('Match')?.cases?.length || 0) - 1)) {
|
|
1561
|
+
const diagnostic = {
|
|
1562
|
+
node,
|
|
1563
|
+
severity: 'error',
|
|
1564
|
+
message: '匹配分支:表达式不能为空',
|
|
1565
|
+
titleTip: '表达式不能为空',
|
|
1566
|
+
};
|
|
1567
|
+
node.tsErrorDetail = diagnostic;
|
|
1568
|
+
diagnostics.push(diagnostic);
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1228
1571
|
// 如果节点是match的patterns 里的
|
|
1229
1572
|
if (node?.parentKey === 'patterns' && node.parentNode instanceof concepts_1.MatchCase) {
|
|
1230
1573
|
const matchNode = node.getAncestor('Match');
|
|
@@ -1300,11 +1643,55 @@ class NaslServer {
|
|
|
1300
1643
|
const diagnostic = {
|
|
1301
1644
|
node,
|
|
1302
1645
|
severity: 'error',
|
|
1303
|
-
message:
|
|
1646
|
+
message: `类型不匹配,传入类型:void`,
|
|
1304
1647
|
};
|
|
1305
1648
|
node.tsErrorDetail = diagnostic;
|
|
1306
1649
|
diagnostics.push(diagnostic);
|
|
1307
1650
|
}
|
|
1651
|
+
// newMap key或者value没填都要有报错
|
|
1652
|
+
if (node instanceof concepts_1.NewMap) {
|
|
1653
|
+
// 如果一项没有key 或者没有 value 就报错
|
|
1654
|
+
const findFlag = node.keys?.some((key, index) => !key || !node.values?.[index]);
|
|
1655
|
+
if (findFlag) {
|
|
1656
|
+
const diagnostic = {
|
|
1657
|
+
node,
|
|
1658
|
+
severity: 'error',
|
|
1659
|
+
message: `新建Map的key和value应该都必填`,
|
|
1660
|
+
};
|
|
1661
|
+
node.tsErrorDetail = diagnostic;
|
|
1662
|
+
diagnostics.push(diagnostic);
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
// 赋值语句左右list 和 map等可以 必须都一样
|
|
1666
|
+
if (node instanceof concepts_1.Assignment && !node.tsErrorDetail) {
|
|
1667
|
+
const leftType = node.left?.__TypeAnnotation || {};
|
|
1668
|
+
const rightType = node.right?.__TypeAnnotation || {};
|
|
1669
|
+
// 如果左边节点是 泛型,而且 左边泛型的名字 和 右边一样, 而且是list 或者map 就强制报错
|
|
1670
|
+
// 而且右边原来没有报错
|
|
1671
|
+
if (leftType.typeKind === 'generic' && leftType.typeKind === rightType.typeKind && leftType.typeName === rightType.typeName && ['Map', 'List'].includes(leftType.typeName)) {
|
|
1672
|
+
if (!(node.right.tsErrorDetail) && leftType.sortedTypeKey !== rightType.sortedTypeKey) {
|
|
1673
|
+
const excludeList = [
|
|
1674
|
+
'nasl.collection.List<nasl.core.String>',
|
|
1675
|
+
'nasl.collection.List<nasl.core.Text>',
|
|
1676
|
+
'nasl.collection.List<nasl.core.Email>',
|
|
1677
|
+
'nasl.collection.Map<nasl.core.String, nasl.core.String>',
|
|
1678
|
+
'nasl.collection.Map<nasl.core.String, nasl.core.Text>',
|
|
1679
|
+
'nasl.collection.Map<nasl.core.String, nasl.core.Email>',
|
|
1680
|
+
];
|
|
1681
|
+
// 先特殊处理等 类型合并后就可以去掉了
|
|
1682
|
+
if (excludeList.includes(leftType.sortedTypeKey) && excludeList.includes(rightType.sortedTypeKey)) {
|
|
1683
|
+
return null;
|
|
1684
|
+
}
|
|
1685
|
+
const diagnostic = {
|
|
1686
|
+
node: node.right,
|
|
1687
|
+
severity: 'error',
|
|
1688
|
+
message: `左右参数类型不一致!左边类型:${leftType.typeChineseTitle},右边类型:${rightType.typeChineseTitle}。`,
|
|
1689
|
+
};
|
|
1690
|
+
node.right.tsErrorDetail = diagnostic;
|
|
1691
|
+
diagnostics.push(diagnostic);
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1308
1695
|
}
|
|
1309
1696
|
/* 接口导入查找 */
|
|
1310
1697
|
existStructureFix(semanticDiagnostics, node, that) {
|
|
@@ -1371,7 +1758,7 @@ class NaslServer {
|
|
|
1371
1758
|
*/
|
|
1372
1759
|
_resolveDiagnostic(diagnostic, fileNode, record) {
|
|
1373
1760
|
// 拓展模块中的翻译先过滤掉,因为有错用户也不能修改
|
|
1374
|
-
if (fileNode.module)
|
|
1761
|
+
if (fileNode.module && !(fileNode instanceof concepts_1.ConfigProperty))
|
|
1375
1762
|
return;
|
|
1376
1763
|
const minRange = this._findMinRange(diagnostic, fileNode);
|
|
1377
1764
|
const tsErrorDetail = {
|
|
@@ -1592,6 +1979,53 @@ class NaslServer {
|
|
|
1592
1979
|
refsList = [...methodRefs];
|
|
1593
1980
|
}
|
|
1594
1981
|
}
|
|
1982
|
+
if (node instanceof concepts_1.Process) {
|
|
1983
|
+
if (currentSource) {
|
|
1984
|
+
const code = currentSource.code;
|
|
1985
|
+
const prefix = '__ProcessIdentification__';
|
|
1986
|
+
let positions = [];
|
|
1987
|
+
let pos = code.indexOf(prefix);
|
|
1988
|
+
while (pos !== -1) {
|
|
1989
|
+
positions.push(pos);
|
|
1990
|
+
pos = code.indexOf(prefix, pos + prefix.length);
|
|
1991
|
+
}
|
|
1992
|
+
positions.shift();
|
|
1993
|
+
// 拿到标识下定义的const process = {...}
|
|
1994
|
+
positions = positions.map((position) => code.indexOf('const', position + prefix.length));
|
|
1995
|
+
const promises = positions.map((item) => this.references({
|
|
1996
|
+
file: fileNode.getEmbeddedFilePath(),
|
|
1997
|
+
line: (0, translator_1.lsp2tspNumber)(currentSource.range.start.line),
|
|
1998
|
+
offset: (0, translator_1.lsp2tspNumber)(currentSource.range.start.character + item),
|
|
1999
|
+
}));
|
|
2000
|
+
const results = await Promise.all(promises);
|
|
2001
|
+
results.forEach((constRefs) => {
|
|
2002
|
+
refsList = [...refsList, ...constRefs.refs];
|
|
2003
|
+
});
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
if (node instanceof concepts_1.ProcessElement) {
|
|
2007
|
+
if (currentSource) {
|
|
2008
|
+
const code = currentSource.code;
|
|
2009
|
+
const prefix = '__ProcessIdentification__';
|
|
2010
|
+
let positions = [];
|
|
2011
|
+
let pos = code.indexOf(prefix);
|
|
2012
|
+
while (pos !== -1) {
|
|
2013
|
+
positions.push(pos);
|
|
2014
|
+
pos = code.indexOf(prefix, pos + prefix.length);
|
|
2015
|
+
}
|
|
2016
|
+
// 拿到标识下定义的const process = {...}
|
|
2017
|
+
positions = positions.map((position) => code.indexOf(`${node.name}:`, position + prefix.length));
|
|
2018
|
+
const promises = positions.map((item) => this.references({
|
|
2019
|
+
file: fileNode.getEmbeddedFilePath(),
|
|
2020
|
+
line: (0, translator_1.lsp2tspNumber)(currentSource.range.start.line),
|
|
2021
|
+
offset: (0, translator_1.lsp2tspNumber)(currentSource.range.start.character + item),
|
|
2022
|
+
}));
|
|
2023
|
+
const results = await Promise.all(promises);
|
|
2024
|
+
results.forEach((constRefs) => {
|
|
2025
|
+
refsList = [...refsList, ...constRefs.refs];
|
|
2026
|
+
});
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
1595
2029
|
// console.log(refsList, 'refsList');
|
|
1596
2030
|
return refsList;
|
|
1597
2031
|
}
|
|
@@ -2241,12 +2675,14 @@ class NaslServer {
|
|
|
2241
2675
|
// 如果没有sourceMap,就继续向上找 ,或者到module结束
|
|
2242
2676
|
// 如果 节点找到 app 或者module 停止 或者entity找到DataSource为止
|
|
2243
2677
|
// 如果当前节点是view就不要向上查找了
|
|
2678
|
+
// 配置参数的ConfigProperty也不需要向上找
|
|
2244
2679
|
while (!sourceMap
|
|
2245
2680
|
&& fileNode
|
|
2246
2681
|
&& !(fileNode.parentNode instanceof concepts_1.App)
|
|
2247
2682
|
&& !(fileNode.parentNode instanceof concepts_1.Module)
|
|
2248
2683
|
&& !(fileNode.parentNode instanceof concepts_1.DataSource)
|
|
2249
|
-
&& !(fileNode instanceof concepts_1.View)
|
|
2684
|
+
&& !(fileNode instanceof concepts_1.View)
|
|
2685
|
+
&& !(fileNode instanceof concepts_1.ConfigProperty)) {
|
|
2250
2686
|
fileNode = fileNode.parentNode;
|
|
2251
2687
|
sourceMap = fileNode?.sourceMap;
|
|
2252
2688
|
}
|
|
@@ -2334,7 +2770,7 @@ class NaslServer {
|
|
|
2334
2770
|
* @returns 不需要去查就可以返回类型的节点
|
|
2335
2771
|
*/
|
|
2336
2772
|
getCurrentNodeKnownTypeAnnotation(node) {
|
|
2337
|
-
if (node.concept === 'StringLiteral' || node.concept === 'BooleanLiteral' || node.concept === 'NullLiteral') {
|
|
2773
|
+
if (node.concept === 'StringLiteral' || node.concept === 'StringInterpolation' || node.concept === 'BooleanLiteral' || node.concept === 'NullLiteral') {
|
|
2338
2774
|
let type = 'String';
|
|
2339
2775
|
switch (node.concept) {
|
|
2340
2776
|
case 'NullLiteral':
|
|
@@ -2434,6 +2870,9 @@ class NaslServer {
|
|
|
2434
2870
|
'NewComposite',
|
|
2435
2871
|
'NewList',
|
|
2436
2872
|
'NewMap',
|
|
2873
|
+
'OqlQueryComponent',
|
|
2874
|
+
'QueryFieldExpression',
|
|
2875
|
+
'QueryGroupByExpression',
|
|
2437
2876
|
].includes(node.concept))
|
|
2438
2877
|
return;
|
|
2439
2878
|
// 要去ls那边获取的
|
|
@@ -2468,7 +2907,7 @@ class NaslServer {
|
|
|
2468
2907
|
}
|
|
2469
2908
|
fileDetail.offset = fileDetail.offset + indexOf;
|
|
2470
2909
|
}
|
|
2471
|
-
else if (node.concept === 'MemberExpression' || node.concept === 'Identifier') {
|
|
2910
|
+
else if (node.concept === 'MemberExpression' || node.concept === 'Identifier' || node.concept === 'QueryFieldExpression' || node.concept === 'QueryGroupByExpression') {
|
|
2472
2911
|
if (item.code.includes('.')) {
|
|
2473
2912
|
const codeArr = item.code?.split('.');
|
|
2474
2913
|
const lastLen = codeArr?.[codeArr.length - 1]?.length;
|
|
@@ -2492,6 +2931,9 @@ class NaslServer {
|
|
|
2492
2931
|
newCode = newCode.substring(newCode.lastIndexOf('\n'), indexOf);
|
|
2493
2932
|
fileDetail.offset = newCode.length + 'return '.length;
|
|
2494
2933
|
}
|
|
2934
|
+
else if (['OqlQueryComponent'].includes(node.concept)) {
|
|
2935
|
+
fileDetail.offset += 10;
|
|
2936
|
+
}
|
|
2495
2937
|
args.push(fileDetail);
|
|
2496
2938
|
});
|
|
2497
2939
|
console.time('请求');
|
|
@@ -2541,6 +2983,19 @@ class NaslServer {
|
|
|
2541
2983
|
// 因为node可能是经过处理的TypeAnnotation
|
|
2542
2984
|
node.__isCorrectTypeAnnotation = true;
|
|
2543
2985
|
if (value) {
|
|
2986
|
+
if (node instanceof concepts_1.OqlQueryComponent) {
|
|
2987
|
+
// 自动推导情况
|
|
2988
|
+
const typeAnnotation = value;
|
|
2989
|
+
if (!node.typeAnnotation && typeAnnotation) {
|
|
2990
|
+
if (typeAnnotation.typeName === 'List' && typeAnnotation.typeKind === 'generic') {
|
|
2991
|
+
const typeArguments = typeAnnotation.typeArguments;
|
|
2992
|
+
if (typeArguments.length && typeArguments[0].isComplexType()) {
|
|
2993
|
+
node.__TypeAnnotation = null;
|
|
2994
|
+
return;
|
|
2995
|
+
}
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2544
2999
|
if (value instanceof concepts_1.TypeAnnotation) {
|
|
2545
3000
|
node.__TypeAnnotation = Object.freeze(value);
|
|
2546
3001
|
}
|
|
@@ -2548,6 +3003,10 @@ class NaslServer {
|
|
|
2548
3003
|
node.__TypeAnnotation = Object.freeze(value.typeAnnotation);
|
|
2549
3004
|
}
|
|
2550
3005
|
}
|
|
3006
|
+
else {
|
|
3007
|
+
// 清空原来已经赋值上去的类型,可能原来有现在没有了
|
|
3008
|
+
node.__TypeAnnotation = null;
|
|
3009
|
+
}
|
|
2551
3010
|
}
|
|
2552
3011
|
catch (err) {
|
|
2553
3012
|
if (globalThis.window) {
|
|
@@ -2761,6 +3220,10 @@ class NaslServer {
|
|
|
2761
3220
|
jsonNode.typeAnnotation = value.toJSON();
|
|
2762
3221
|
}
|
|
2763
3222
|
}
|
|
3223
|
+
if (node instanceof concepts_1.NewComposite && node.typeAnnotation.typeKind === 'anonymousStructure') {
|
|
3224
|
+
const jsonNode = jsoner.queryNodeByPath(json, node.getNodePath(false));
|
|
3225
|
+
jsonNode.typeAnnotation = value.toJSON();
|
|
3226
|
+
}
|
|
2764
3227
|
});
|
|
2765
3228
|
}
|
|
2766
3229
|
/**
|
|
@@ -2901,6 +3364,12 @@ class NaslServer {
|
|
|
2901
3364
|
// 如果是要删除的内容,就是当前的file节点,要关闭当前文件,就把内容置为空
|
|
2902
3365
|
if (fileNode === targetNode) {
|
|
2903
3366
|
outputFiles = [{ file: filePath, fileContent: '' }];
|
|
3367
|
+
// 去掉原来存储的当前节点的nasl内存的存储,和错误的存储
|
|
3368
|
+
// 已经删除的就不用在去check错误了
|
|
3369
|
+
// check就会去取类型啥的,没有必要
|
|
3370
|
+
this.diagnosticManager.deleteOwn(fileNode.id);
|
|
3371
|
+
// 删除文件同时删除ls存储nasl 的引用
|
|
3372
|
+
this.file2NodeMap.delete(filePath);
|
|
2904
3373
|
}
|
|
2905
3374
|
else {
|
|
2906
3375
|
// 如果是要删除logic一个小内容,要覆盖全部内容
|
|
@@ -2928,13 +3397,17 @@ class NaslServer {
|
|
|
2928
3397
|
line: EmbeddedTSFileLineMap[fileNode.concept] ?? 2,
|
|
2929
3398
|
offset: EmbeddedTSFileOffsetMap[fileNode.concept] ?? 6,
|
|
2930
3399
|
});
|
|
2931
|
-
|
|
3400
|
+
const files = new Set();
|
|
3401
|
+
newRefs.refs.forEach((ref) => {
|
|
3402
|
+
this.filesToCheck.add(ref.file);
|
|
3403
|
+
files.add(ref.file);
|
|
3404
|
+
});
|
|
2932
3405
|
// 唤起建立连接弹框
|
|
2933
3406
|
// 文件级别的建立连接采取提醒
|
|
2934
3407
|
if (action === 'create' && targetNode.__init) {
|
|
2935
3408
|
// 清除临时状态, 完成本次创建
|
|
2936
3409
|
delete targetNode.__init;
|
|
2937
|
-
if (fileNode === targetNode &&
|
|
3410
|
+
if (fileNode === targetNode && files.size > 1) {
|
|
2938
3411
|
const confirmParms = {
|
|
2939
3412
|
actionType: 'createEstablishConnection',
|
|
2940
3413
|
node: fileNode,
|