@lcap/nasl-language-server-core 3.14.0-beta.7 → 3.14.0-beta.9
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/checker.d.ts +2 -2
- package/out/checker.d.ts.map +1 -1
- package/out/checker.js +47 -196
- package/out/checker.js.map +1 -1
- package/out/index.js +7 -17
- package/out/index.js.map +1 -1
- package/out/module/graph.d.ts.map +1 -1
- package/out/reference-manager/builtin-q-name.d.ts.map +1 -1
- package/out/reference-manager/builtin-q-name.js +8 -7
- package/out/reference-manager/builtin-q-name.js.map +1 -1
- package/out/reference-manager/collect-q-name.d.ts +3 -3
- package/out/reference-manager/collect-q-name.d.ts.map +1 -1
- package/out/reference-manager/collect-q-name.js +11 -12
- package/out/reference-manager/collect-q-name.js.map +1 -1
- package/out/reference-manager/reference-manager.d.ts +9 -24
- package/out/reference-manager/reference-manager.d.ts.map +1 -1
- package/out/reference-manager/reference-manager.js +110 -269
- package/out/reference-manager/reference-manager.js.map +1 -1
- package/out/reference-manager/remove-q-name.d.ts +3 -3
- package/out/reference-manager/remove-q-name.d.ts.map +1 -1
- package/out/reference-manager/remove-q-name.js +9 -12
- package/out/reference-manager/remove-q-name.js.map +1 -1
- package/out/reference-manager/rename-q-name.d.ts +3 -3
- package/out/reference-manager/rename-q-name.d.ts.map +1 -1
- package/out/reference-manager/rename-q-name.js +9 -9
- package/out/reference-manager/rename-q-name.js.map +1 -1
- package/out/symbol/graph.d.ts +1 -1
- package/out/symbol/namespace.d.ts.map +1 -1
- package/out/symbol/symbol.d.ts.map +1 -1
- package/out/symbol/traverse/concepts/frontend/frontend.d.ts.map +1 -1
- package/out/symbol/traverse/concepts/frontend/frontend.js +1 -0
- package/out/symbol/traverse/concepts/frontend/frontend.js.map +1 -1
- package/out/symbol/traverse/concepts/frontend/view.js +2 -2
- package/out/symbol/traverse/concepts/frontend/view.js.map +1 -1
- package/out/symbol/traverse/concepts/index.d.ts +1 -2
- package/out/symbol/traverse/concepts/index.d.ts.map +1 -1
- package/out/symbol/traverse/concepts/utils.js +6 -6
- package/out/symbol/traverse/concepts/utils.js.map +1 -1
- package/out/symbol/traverse/traverse.js +2 -1
- package/out/symbol/traverse/traverse.js.map +1 -1
- package/out/symbol/utils.js +2 -1
- package/out/symbol/utils.js.map +1 -1
- package/out/typer/collectGlobalDefs.js +15 -25
- package/out/typer/collectGlobalDefs.js.map +1 -1
- package/out/typer/component-def-manager/component-def-manager.d.ts +7 -27
- package/out/typer/component-def-manager/component-def-manager.d.ts.map +1 -1
- package/out/typer/component-def-manager/component-def-manager.js +16 -63
- package/out/typer/component-def-manager/component-def-manager.js.map +1 -1
- package/out/typer/component-def-manager/utils.d.ts.map +1 -1
- package/out/typer/component-def-manager/utils.js +9 -8
- package/out/typer/component-def-manager/utils.js.map +1 -1
- package/out/typer/dispatch-all.d.ts +3 -10
- package/out/typer/dispatch-all.d.ts.map +1 -1
- package/out/typer/dispatch-all.js +43 -46
- package/out/typer/dispatch-all.js.map +1 -1
- package/out/typer/dispatch-def.d.ts +3 -5
- package/out/typer/dispatch-def.d.ts.map +1 -1
- package/out/typer/dispatch-def.js +51 -116
- package/out/typer/dispatch-def.js.map +1 -1
- package/out/typer/dispatch-expr.d.ts +8 -3
- package/out/typer/dispatch-expr.d.ts.map +1 -1
- package/out/typer/dispatch-expr.js +370 -464
- package/out/typer/dispatch-expr.js.map +1 -1
- package/out/typer/dispatch-process.d.ts +2 -0
- package/out/typer/dispatch-process.d.ts.map +1 -1
- package/out/typer/dispatch-process.js +39 -56
- package/out/typer/dispatch-process.js.map +1 -1
- package/out/typer/dispatch-stmt.d.ts.map +1 -1
- package/out/typer/dispatch-stmt.js +37 -31
- package/out/typer/dispatch-stmt.js.map +1 -1
- package/out/typer/dispatch-view.d.ts +6 -18
- package/out/typer/dispatch-view.d.ts.map +1 -1
- package/out/typer/dispatch-view.js +163 -361
- package/out/typer/dispatch-view.js.map +1 -1
- package/out/typer/fix-use-before-assign.d.ts.map +1 -1
- package/out/typer/helper.d.ts +0 -1
- package/out/typer/helper.d.ts.map +1 -1
- package/out/typer/helper.js +27 -27
- package/out/typer/helper.js.map +1 -1
- package/out/typer/incremental-update.d.ts +3 -4
- package/out/typer/incremental-update.d.ts.map +1 -1
- package/out/typer/incremental-update.js +74 -55
- package/out/typer/incremental-update.js.map +1 -1
- package/out/typer/index.d.ts +3 -5
- package/out/typer/index.d.ts.map +1 -1
- package/out/typer/index.js +28 -28
- package/out/typer/index.js.map +1 -1
- package/out/typer/sem-diag.d.ts.map +1 -1
- package/out/typer/sem-diag.js +3 -3
- package/out/typer/sem-diag.js.map +1 -1
- package/out/typer/solver.d.ts.map +1 -1
- package/out/typer/solver.js +50 -67
- package/out/typer/solver.js.map +1 -1
- package/out/typer/subster.d.ts +5 -2
- package/out/typer/subster.d.ts.map +1 -1
- package/out/typer/subster.js +84 -112
- package/out/typer/subster.js.map +1 -1
- package/out/typer/topo-sort.d.ts +3 -3
- package/out/typer/topo-sort.d.ts.map +1 -1
- package/out/typer/topo-sort.js +14 -7
- package/out/typer/topo-sort.js.map +1 -1
- package/out/typer/typeManager.d.ts +49 -21
- package/out/typer/typeManager.d.ts.map +1 -1
- package/out/typer/typeManager.js +399 -130
- package/out/typer/typeManager.js.map +1 -1
- package/out/typer/typer.d.ts +17 -61
- package/out/typer/typer.d.ts.map +1 -1
- package/out/typer/typer.js +40 -162
- package/out/typer/typer.js.map +1 -1
- package/out/typer/unifier.d.ts +7 -16
- package/out/typer/unifier.d.ts.map +1 -1
- package/out/typer/unifier.js +48 -86
- package/out/typer/unifier.js.map +1 -1
- package/out/utils/array.js +2 -1
- package/out/utils/array.js.map +1 -1
- package/out/utils/assertion.js +2 -1
- package/out/utils/assertion.js.map +1 -1
- package/out/utils/bind-expression-hack.d.ts +1 -2
- package/out/utils/bind-expression-hack.d.ts.map +1 -1
- package/out/utils/bind-expression-hack.js +10 -19
- package/out/utils/bind-expression-hack.js.map +1 -1
- package/out/utils/error-boundary.d.ts.map +1 -1
- package/out/utils/error-boundary.js +5 -8
- package/out/utils/error-boundary.js.map +1 -1
- package/out/utils/parseTsClassType.d.ts +11 -10
- package/out/utils/parseTsClassType.d.ts.map +1 -1
- package/out/utils/parseTsClassType.js +30 -34
- package/out/utils/parseTsClassType.js.map +1 -1
- package/out/utils/types.js +2 -1
- package/out/utils/types.js.map +1 -1
- package/out/utils/vue-hack.js +2 -1
- package/out/utils/vue-hack.js.map +1 -1
- package/out/utils/vue.js +2 -1
- package/out/utils/vue.js.map +1 -1
- package/package.json +10 -7
- package/out/typer/query-manager/query-manager.d.ts +0 -28
- package/out/typer/query-manager/query-manager.d.ts.map +0 -1
- package/out/typer/query-manager/query-manager.js +0 -63
- package/out/typer/query-manager/query-manager.js.map +0 -1
- package/out/typer/query-manager/query-tokens.d.ts +0 -4
- package/out/typer/query-manager/query-tokens.d.ts.map +0 -1
- package/out/typer/query-manager/query-tokens.js +0 -8
- package/out/typer/query-manager/query-tokens.js.map +0 -1
- package/out/typer/query-manager/type-level-evaluation-of.d.ts +0 -13
- package/out/typer/query-manager/type-level-evaluation-of.d.ts.map +0 -1
- package/out/typer/query-manager/type-level-evaluation-of.js +0 -4
- package/out/typer/query-manager/type-level-evaluation-of.js.map +0 -1
- package/out/typer/type-hint-manager/type-hint-manager.d.ts +0 -39
- package/out/typer/type-hint-manager/type-hint-manager.d.ts.map +0 -1
- package/out/typer/type-hint-manager/type-hint-manager.js +0 -58
- package/out/typer/type-hint-manager/type-hint-manager.js.map +0 -1
- package/out/typer/type-predicate.d.ts +0 -39
- package/out/typer/type-predicate.d.ts.map +0 -1
- package/out/typer/type-predicate.js +0 -331
- package/out/typer/type-predicate.js.map +0 -1
- package/out/utils/nasl-type-manipulation.d.ts +0 -7
- package/out/utils/nasl-type-manipulation.d.ts.map +0 -1
- package/out/utils/nasl-type-manipulation.js +0 -26
- package/out/utils/nasl-type-manipulation.js.map +0 -1
package/out/checker.d.ts
CHANGED
|
@@ -37,10 +37,10 @@ export declare function createErrorDiagnoser(context: DiagnoseContext): {
|
|
|
37
37
|
setLatestVersionsOfSharedApp: (sharedAppVersions: SharedAppVersion[]) => void;
|
|
38
38
|
diagnosticApp: () => Generator<TypeAnnotation | {
|
|
39
39
|
typeKind: string;
|
|
40
|
-
} | undefined, void,
|
|
40
|
+
} | undefined, void, unknown>;
|
|
41
41
|
checkNode: (node: SyntaxNode | undefined) => Generator<TypeAnnotation | {
|
|
42
42
|
typeKind: string;
|
|
43
|
-
} | undefined, any,
|
|
43
|
+
} | undefined, any, unknown>;
|
|
44
44
|
clearDiagnostics: (node: SyntaxNode) => void;
|
|
45
45
|
getDiagnostics: (node: SyntaxNode) => NodeDiagnosticsMap | FileDiagnosticsMap | undefined;
|
|
46
46
|
error: (node: SyntaxNode, message: string, context?: ErrorContext) => void;
|
package/out/checker.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checker.d.ts","sourceRoot":"","sources":["../src/checker.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EAU0F,GAAG,EAMvG,QAAQ,EACT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACgE,cAAc,EAEpF,MAAM,qBAAqB,CAAC;AAM7B,OAAO,
|
|
1
|
+
{"version":3,"file":"checker.d.ts","sourceRoot":"","sources":["../src/checker.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EAU0F,GAAG,EAMvG,QAAQ,EACT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACgE,cAAc,EAEpF,MAAM,qBAAqB,CAAC;AAM7B,OAAO,EAAgB,MAAM,EAAE,MAAM,SAAS,CAAC;AAE/C,oBAAY,QAAQ;IAClB,IAAI,YAAY;IAChB,KAAK,UAAU;CAChB;AAED,MAAM,WAAW,UAAU;IAEzB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAEpB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,KAAK,YAAY,GAAG;IAClB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAMF,MAAM,MAAM,kBAAkB,GAAG,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAEpE,MAAM,MAAM,kBAAkB,GAAG,GAAG,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC;AAMrE,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAqBF,KAAK,eAAe,GAAG;IACrB,GAAG,EAAE,GAAG,CAAC;IACT,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,OAAO,CAAC;IACf,yBAAyB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC/C,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AA8OF;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,eAAe;oCA4yHpB,OAAO;sDAPW,gBAAgB,EAAE;;;;sBAdjD,UAAU,GAAG,SAAS;;;6BAoChB,UAAU;2BAsBZ,UAAU;kBAlzHnB,UAAU,WAAW,MAAM,YAAY,YAAY;EAk0HzE;AAGD,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IAEX,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IACrC,mBAAmB,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IACvC,qBAAqB,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;CAC1C;AAED,eAAO,MAAM,6BAA6B,aAAc,UAAU,sCAAoC,MAAM,gBAAgB,CAmC3H,CAAA"}
|
package/out/checker.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transformDiagnosticsToRecords = exports.Severity = void 0;
|
|
4
|
-
exports.createErrorDiagnoser = createErrorDiagnoser;
|
|
3
|
+
exports.transformDiagnosticsToRecords = exports.createErrorDiagnoser = exports.Severity = void 0;
|
|
5
4
|
const decimal_js_1 = require("decimal.js");
|
|
6
5
|
const nasl_concepts_1 = require("@lcap/nasl-concepts");
|
|
7
6
|
const service_1 = require("@lcap/nasl-concepts/service");
|
|
@@ -39,21 +38,6 @@ function isControlFlowNode(node) {
|
|
|
39
38
|
function isCallExpression(node) {
|
|
40
39
|
return nasl_concepts_1.asserts.isCallFunction(node) || nasl_concepts_1.asserts.isCallInterface(node) || nasl_concepts_1.asserts.isCallLogic(node) || nasl_concepts_1.asserts.isCallConnector(node) || nasl_concepts_1.asserts.isCallEvent(node);
|
|
41
40
|
}
|
|
42
|
-
// fast cheap unsafe checks
|
|
43
|
-
// 不判断空指针让它更快
|
|
44
|
-
const isCallFunction = (node) => node.concept === 'CallFunction';
|
|
45
|
-
const isCallLogic = (node) => node.concept === 'CallLogic' || node.concept === 'CallConnector';
|
|
46
|
-
const isCallInterface = (node) => node.concept === 'CallInterface' || node.concept === 'CallMicroserviceInterface' || node.concept === 'CallAuthInterface';
|
|
47
|
-
const isCallAuthInterface = (node) => node.concept === 'CallAuthInterface';
|
|
48
|
-
const isCallConnector = (node) => node.concept === 'CallConnector';
|
|
49
|
-
const isCallEvent = (node) => node.concept === 'CallEvent';
|
|
50
|
-
// order matters as for speed
|
|
51
|
-
const fastIsCallExpression = (node) => isCallLogic(node) || isCallFunction(node) || isCallEvent(node) || isCallInterface(node) || isCallAuthInterface(node) || isCallConnector(node);
|
|
52
|
-
const isEnd = (node) => node.concept === 'End';
|
|
53
|
-
const isAbort = (node) => node.concept === 'Abort';
|
|
54
|
-
const isBreak = (node) => node.concept === 'Break';
|
|
55
|
-
const isContinue = (node) => node.concept === 'Continue';
|
|
56
|
-
const fastIsControlFlowNode = (node) => isEnd(node) || isAbort(node) || isBreak(node) || isContinue(node);
|
|
57
41
|
function getExpressionNodeName(concept) {
|
|
58
42
|
const expressionNodeName = {
|
|
59
43
|
CallFunction: '内置函数',
|
|
@@ -266,9 +250,8 @@ function createErrorDiagnoser(context) {
|
|
|
266
250
|
const diagnosticMap = new Map();
|
|
267
251
|
// 文件级别节点
|
|
268
252
|
const fileNodes = [];
|
|
269
|
-
let inPlayground =
|
|
253
|
+
let inPlayground = false;
|
|
270
254
|
let inAuthLogic = false;
|
|
271
|
-
let dbType = '';
|
|
272
255
|
let curVarCounter = 0;
|
|
273
256
|
/**
|
|
274
257
|
* 获取当前文件节点
|
|
@@ -293,7 +276,7 @@ function createErrorDiagnoser(context) {
|
|
|
293
276
|
if (diagnostics) {
|
|
294
277
|
const diagnostic = {
|
|
295
278
|
message,
|
|
296
|
-
severity: inPlayground
|
|
279
|
+
severity: inPlayground ? Severity.WARN : severity ?? Severity.ERROR,
|
|
297
280
|
...others,
|
|
298
281
|
};
|
|
299
282
|
if (isDebug) {
|
|
@@ -719,18 +702,18 @@ function createErrorDiagnoser(context) {
|
|
|
719
702
|
error(node, `预期 ${minArgsCount} 个参数,但传入了 ${argsLen} 个。`);
|
|
720
703
|
}
|
|
721
704
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(args, function* (arg, index) {
|
|
705
|
+
arg.paramRequired = true;
|
|
722
706
|
const param = params?.[index];
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
return;
|
|
707
|
+
if ((hasSpreadParam && index > spreadParamIndex) || isNonRequiredParam(param)) {
|
|
708
|
+
arg.paramRequired = false;
|
|
709
|
+
}
|
|
727
710
|
const paramType = (nasl_concepts_1.asserts.isTypeAnnotation(param) ? param : env.getType(param));
|
|
728
711
|
const argType = yield* checkNode(arg);
|
|
729
712
|
if (paramType?.typeKind === 'function' && argType?.typeKind === 'function') {
|
|
730
713
|
const argTypeArgs = argType?.typeArguments || [];
|
|
731
714
|
const paramTypeArgs = paramType?.typeArguments || [];
|
|
732
|
-
if (argTypeArgs
|
|
733
|
-
error(node, `高阶函数: 参数个数不匹配,期望 ${paramTypeArgs.length} 个, 实际传入 ${argTypeArgs
|
|
715
|
+
if (argTypeArgs?.length !== paramTypeArgs?.length) {
|
|
716
|
+
error(node, `高阶函数: 参数个数不匹配,期望 ${paramTypeArgs.length} 个, 实际传入 ${argTypeArgs?.length || 0} 个!`);
|
|
734
717
|
}
|
|
735
718
|
}
|
|
736
719
|
});
|
|
@@ -741,7 +724,7 @@ function createErrorDiagnoser(context) {
|
|
|
741
724
|
*/
|
|
742
725
|
function* checkVariableType(node) {
|
|
743
726
|
const type = env.getType(node);
|
|
744
|
-
if (
|
|
727
|
+
if (isUninstantiatedType(type)) {
|
|
745
728
|
const logic = node.getAncestor('SubLogic') || node.getAncestor('Logic');
|
|
746
729
|
let used = false;
|
|
747
730
|
logic.traverseStrictChildren((item) => {
|
|
@@ -798,20 +781,19 @@ function createErrorDiagnoser(context) {
|
|
|
798
781
|
*/
|
|
799
782
|
function* checkPlayground(playground) {
|
|
800
783
|
if (playground?.length) {
|
|
801
|
-
inPlayground
|
|
784
|
+
inPlayground = true;
|
|
802
785
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(playground, function* (node) {
|
|
803
786
|
yield* checkNode(node);
|
|
804
787
|
});
|
|
805
|
-
inPlayground
|
|
788
|
+
inPlayground = false;
|
|
806
789
|
}
|
|
807
790
|
}
|
|
808
791
|
/**
|
|
809
792
|
* 未推导出的类型
|
|
810
|
-
* 这个可能有问题,因为可能是 type 的嵌套结构没有推导出类型,看使用场景了
|
|
811
793
|
* @param type
|
|
812
794
|
* @returns
|
|
813
795
|
*/
|
|
814
|
-
function
|
|
796
|
+
function isUninstantiatedType(type) {
|
|
815
797
|
return !type || type?.typeKind === 'typeParam' || type?.typeName === 'Null' || type?.typeName === 'void';
|
|
816
798
|
}
|
|
817
799
|
/**
|
|
@@ -821,14 +803,9 @@ function createErrorDiagnoser(context) {
|
|
|
821
803
|
*/
|
|
822
804
|
function* checkNonNullExpression(node) {
|
|
823
805
|
const type = yield* checkNode(node);
|
|
824
|
-
if (
|
|
806
|
+
if (isUninstantiatedType(type)) {
|
|
825
807
|
const scope = node?.constructor?.nodeTitle;
|
|
826
|
-
|
|
827
|
-
error(node, `${scope}:${node.name} 未定义。`);
|
|
828
|
-
}
|
|
829
|
-
else {
|
|
830
|
-
error(node, `${scope}:所选择的内容未定义。`);
|
|
831
|
-
}
|
|
808
|
+
error(node, `${scope}:所选择的内容未定义。`);
|
|
832
809
|
return errorType;
|
|
833
810
|
}
|
|
834
811
|
return type;
|
|
@@ -1159,8 +1136,7 @@ function createErrorDiagnoser(context) {
|
|
|
1159
1136
|
*/
|
|
1160
1137
|
function* checkVariable(node) {
|
|
1161
1138
|
yield* checkNode(node.defaultValue);
|
|
1162
|
-
|
|
1163
|
-
// yield* checkVariableType(node);
|
|
1139
|
+
yield* checkVariableType(node);
|
|
1164
1140
|
}
|
|
1165
1141
|
/**
|
|
1166
1142
|
* 检查 前端全局变量
|
|
@@ -1202,7 +1178,6 @@ function createErrorDiagnoser(context) {
|
|
|
1202
1178
|
* @param node
|
|
1203
1179
|
*/
|
|
1204
1180
|
function* checkDataSource(node) {
|
|
1205
|
-
dbType = node.dataSourceSqlType;
|
|
1206
1181
|
if (node.entities?.length) {
|
|
1207
1182
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.entities, function* (node) {
|
|
1208
1183
|
yield* checkNode(node);
|
|
@@ -1255,7 +1230,6 @@ function createErrorDiagnoser(context) {
|
|
|
1255
1230
|
if (duplidateEntities.length) {
|
|
1256
1231
|
error(node, `数据源${node.name}存在重名实体:${duplidateEntities.join(', ')}`);
|
|
1257
1232
|
}
|
|
1258
|
-
dbType = '';
|
|
1259
1233
|
}
|
|
1260
1234
|
/**
|
|
1261
1235
|
* 检查 实体
|
|
@@ -1280,69 +1254,6 @@ function createErrorDiagnoser(context) {
|
|
|
1280
1254
|
error(node, '共享范围为指定应用时,必须指定共享应用');
|
|
1281
1255
|
}
|
|
1282
1256
|
}
|
|
1283
|
-
function getCurrentDataBaseType(node) {
|
|
1284
|
-
if (node.databaseTypeAnnotation) {
|
|
1285
|
-
const databaseTypeMap = node.dataBaseTypeMap || {};
|
|
1286
|
-
const { typeName } = node.databaseTypeAnnotation;
|
|
1287
|
-
return databaseTypeMap[typeName];
|
|
1288
|
-
}
|
|
1289
|
-
const { typeName } = node.typeAnnotation;
|
|
1290
|
-
if (typeName === 'String') {
|
|
1291
|
-
const defaultDataBaseName = getInferredDefaultDataBaseName(node);
|
|
1292
|
-
if (defaultDataBaseName && defaultDataBaseName !== node.defaultDataBaseType?.type) {
|
|
1293
|
-
return {
|
|
1294
|
-
...(node.dataBaseTypeMap?.[defaultDataBaseName] ?? {}),
|
|
1295
|
-
};
|
|
1296
|
-
}
|
|
1297
|
-
}
|
|
1298
|
-
return node.defaultDataBaseType;
|
|
1299
|
-
}
|
|
1300
|
-
function getInferredDefaultDataBaseName(ndoe) {
|
|
1301
|
-
let defaultDataBaseName;
|
|
1302
|
-
const { typeName } = ndoe.typeAnnotation;
|
|
1303
|
-
if (typeName === 'String') {
|
|
1304
|
-
const dataSourceSqlType = dbType;
|
|
1305
|
-
let maxLength;
|
|
1306
|
-
const { rules } = ndoe;
|
|
1307
|
-
if (Array.isArray(rules)) {
|
|
1308
|
-
// 是否需要更新规则
|
|
1309
|
-
rules.forEach((rule) => {
|
|
1310
|
-
const match = rule.match(/^([^()]+)\(([\d\-.]+)\)$/);
|
|
1311
|
-
if (match) {
|
|
1312
|
-
const [, key, value] = match;
|
|
1313
|
-
if (key === 'maxLength') {
|
|
1314
|
-
maxLength = value;
|
|
1315
|
-
}
|
|
1316
|
-
}
|
|
1317
|
-
});
|
|
1318
|
-
}
|
|
1319
|
-
// 不同数据库 最大长度 短、中、长 对应的默认储存类型
|
|
1320
|
-
const sqlMap = {
|
|
1321
|
-
mysql: {
|
|
1322
|
-
255: 'varchar',
|
|
1323
|
-
4000: 'text',
|
|
1324
|
-
16777215: 'mediumtext',
|
|
1325
|
-
},
|
|
1326
|
-
oracle: {
|
|
1327
|
-
255: 'varchar2',
|
|
1328
|
-
4000: 'clob',
|
|
1329
|
-
16777215: 'clob',
|
|
1330
|
-
},
|
|
1331
|
-
dameng: {
|
|
1332
|
-
255: 'varchar2',
|
|
1333
|
-
4000: 'text',
|
|
1334
|
-
16777215: 'text',
|
|
1335
|
-
},
|
|
1336
|
-
db2: {
|
|
1337
|
-
255: 'varchar',
|
|
1338
|
-
4000: 'clob',
|
|
1339
|
-
16777215: 'clob',
|
|
1340
|
-
},
|
|
1341
|
-
};
|
|
1342
|
-
defaultDataBaseName = sqlMap?.[dataSourceSqlType]?.[maxLength];
|
|
1343
|
-
}
|
|
1344
|
-
return defaultDataBaseName;
|
|
1345
|
-
}
|
|
1346
1257
|
/**
|
|
1347
1258
|
* 检查 实体属性
|
|
1348
1259
|
* @param node
|
|
@@ -1351,6 +1262,7 @@ function createErrorDiagnoser(context) {
|
|
|
1351
1262
|
yield* checkNode(node.defaultValue);
|
|
1352
1263
|
yield* checkNode(node.typeAnnotation);
|
|
1353
1264
|
const entity = node.getAncestor('Entity');
|
|
1265
|
+
const dbType = entity.dataSource.dataSourceSqlType;
|
|
1354
1266
|
const { origin } = entity || {};
|
|
1355
1267
|
if (dbType && !['excel', 'table'].includes(origin)) {
|
|
1356
1268
|
const { typeAnnotation, databaseTypeAnnotation, rules } = node;
|
|
@@ -1365,7 +1277,7 @@ function createErrorDiagnoser(context) {
|
|
|
1365
1277
|
});
|
|
1366
1278
|
}
|
|
1367
1279
|
let message = '';
|
|
1368
|
-
const dataBaseTyp =
|
|
1280
|
+
const dataBaseTyp = node.currentDataBaseType;
|
|
1369
1281
|
if (!dataBaseTyp && databaseTypeAnnotation) {
|
|
1370
1282
|
const { typeName: databaseTypeName } = databaseTypeAnnotation;
|
|
1371
1283
|
const errorMsg = `平台目前暂不支持${dbType}数据库的${databaseTypeName}存储类型`;
|
|
@@ -1502,9 +1414,7 @@ function createErrorDiagnoser(context) {
|
|
|
1502
1414
|
const value = numeric.value;
|
|
1503
1415
|
const decimalPlaces = value?.split('.')[1]?.length || 0;
|
|
1504
1416
|
if (decimalPlaces > +scale) {
|
|
1505
|
-
error(node, `实体字段${node.name}默认值的小数位数不能大于设置的小数位数${scale}
|
|
1506
|
-
severity: Severity.WARN,
|
|
1507
|
-
});
|
|
1417
|
+
error(node, `实体字段${node.name}默认值的小数位数不能大于设置的小数位数${scale},否则将会按照小数位数自动截断`);
|
|
1508
1418
|
}
|
|
1509
1419
|
}
|
|
1510
1420
|
break;
|
|
@@ -1681,8 +1591,7 @@ function createErrorDiagnoser(context) {
|
|
|
1681
1591
|
*/
|
|
1682
1592
|
function* checkReturn(node) {
|
|
1683
1593
|
yield* checkNode(node.defaultValue);
|
|
1684
|
-
|
|
1685
|
-
// yield* checkVariableType(node);
|
|
1594
|
+
yield* checkVariableType(node);
|
|
1686
1595
|
}
|
|
1687
1596
|
/**
|
|
1688
1597
|
* 检查 接口
|
|
@@ -1913,10 +1822,6 @@ function createErrorDiagnoser(context) {
|
|
|
1913
1822
|
* @param node
|
|
1914
1823
|
*/
|
|
1915
1824
|
function* checkViewElement(node) {
|
|
1916
|
-
// lcap-login 组件需要完全不做任何检查,不报任何错误。里面一大堆脏数据。
|
|
1917
|
-
if (node.tag === 'lcap-login') {
|
|
1918
|
-
return;
|
|
1919
|
-
}
|
|
1920
1825
|
const shouldProvideCurrentCtx = !!(node.slotScope);
|
|
1921
1826
|
let unbindVariables;
|
|
1922
1827
|
if (shouldProvideCurrentCtx) {
|
|
@@ -1970,9 +1875,10 @@ function createErrorDiagnoser(context) {
|
|
|
1970
1875
|
const isTempWarningMode = node.parentNode?.concept === 'ViewElement' &&
|
|
1971
1876
|
node.parentNode?.tag === 'u-table-view-expander';
|
|
1972
1877
|
if (isTempWarningMode) {
|
|
1973
|
-
inPlayground
|
|
1878
|
+
const oldInPlayground = inPlayground;
|
|
1879
|
+
inPlayground = true;
|
|
1974
1880
|
yield* checkNode(node.expression);
|
|
1975
|
-
inPlayground
|
|
1881
|
+
inPlayground = oldInPlayground;
|
|
1976
1882
|
}
|
|
1977
1883
|
else {
|
|
1978
1884
|
yield* checkNode(node.expression);
|
|
@@ -2023,9 +1929,7 @@ function createErrorDiagnoser(context) {
|
|
|
2023
1929
|
if (processElement || node.type === 'dynamic') {
|
|
2024
1930
|
yield* checkNode(node.destination);
|
|
2025
1931
|
}
|
|
2026
|
-
|
|
2027
|
-
yield* checkNode(node.externalDestination);
|
|
2028
|
-
}
|
|
1932
|
+
yield* checkNode(node.externalDestination);
|
|
2029
1933
|
if (node.rules?.length) {
|
|
2030
1934
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.rules, function* (node) {
|
|
2031
1935
|
yield* checkNode(node);
|
|
@@ -2317,8 +2221,6 @@ function createErrorDiagnoser(context) {
|
|
|
2317
2221
|
yield* checkNode(node);
|
|
2318
2222
|
});
|
|
2319
2223
|
}
|
|
2320
|
-
// 无人审批策略
|
|
2321
|
-
yield* checkNode(node.unmannedApprovalStrategy);
|
|
2322
2224
|
if (node.fieldPermissions?.length) {
|
|
2323
2225
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.fieldPermissions, function* (node) {
|
|
2324
2226
|
yield* checkNode(node);
|
|
@@ -2337,40 +2239,6 @@ function createErrorDiagnoser(context) {
|
|
|
2337
2239
|
}
|
|
2338
2240
|
unbindVariables();
|
|
2339
2241
|
}
|
|
2340
|
-
/**
|
|
2341
|
-
* 检查 无人时,自动转派审批策略
|
|
2342
|
-
* @param node
|
|
2343
|
-
*/
|
|
2344
|
-
function* checkReassignUnmannedV2(node) {
|
|
2345
|
-
return yield* checkNode(node.assignees);
|
|
2346
|
-
}
|
|
2347
|
-
/**
|
|
2348
|
-
* 检查 用户经办人
|
|
2349
|
-
* @param node
|
|
2350
|
-
*/
|
|
2351
|
-
function* checkUserAssignees(node) {
|
|
2352
|
-
if (!node.users?.length) {
|
|
2353
|
-
error(node, '转派人员为空');
|
|
2354
|
-
}
|
|
2355
|
-
}
|
|
2356
|
-
/**
|
|
2357
|
-
* 检查 角色经办人
|
|
2358
|
-
* @param node
|
|
2359
|
-
*/
|
|
2360
|
-
function* checkRoleAssignees(node) {
|
|
2361
|
-
if (!node.roles?.length) {
|
|
2362
|
-
error(node, '转派角色为空');
|
|
2363
|
-
}
|
|
2364
|
-
}
|
|
2365
|
-
/**
|
|
2366
|
-
* 检查 部门经办人
|
|
2367
|
-
* @param node
|
|
2368
|
-
*/
|
|
2369
|
-
function* checkDepartmentAssignees(node) {
|
|
2370
|
-
if (!node.departments?.length) {
|
|
2371
|
-
error(node, '转派部门为空');
|
|
2372
|
-
}
|
|
2373
|
-
}
|
|
2374
2242
|
/**
|
|
2375
2243
|
* 检查 字段权限控制详情
|
|
2376
2244
|
* @param node
|
|
@@ -2707,7 +2575,7 @@ function createErrorDiagnoser(context) {
|
|
|
2707
2575
|
return;
|
|
2708
2576
|
}
|
|
2709
2577
|
const ref = env.resolvedCallTypeBindings.get(node) ?? env.resolveRef(node);
|
|
2710
|
-
if (ref
|
|
2578
|
+
if (ref) {
|
|
2711
2579
|
// 检查使用范围
|
|
2712
2580
|
yield* checkScopeOfUse(node, ref);
|
|
2713
2581
|
yield* checkCallExpressionParameters(node, ref);
|
|
@@ -2763,7 +2631,7 @@ function createErrorDiagnoser(context) {
|
|
|
2763
2631
|
node.parentKey !== 'consequent' &&
|
|
2764
2632
|
node.parentNode?.parentNode?.concept !== 'CallInterface' &&
|
|
2765
2633
|
node.parentNode.concept !== 'Block' &&
|
|
2766
|
-
|
|
2634
|
+
isUninstantiatedType(type)) {
|
|
2767
2635
|
let showErr = false;
|
|
2768
2636
|
if (node.parentNode?.parentNode?.concept === 'CallLogic') {
|
|
2769
2637
|
// calllogic 中别的类型会强校验,但是内置函数,不会强制校验,下面这几个其实是走的内置函数的实现,所以需要手动增加一下校验
|
|
@@ -3042,7 +2910,7 @@ function createErrorDiagnoser(context) {
|
|
|
3042
2910
|
* @param node
|
|
3043
2911
|
*/
|
|
3044
2912
|
function* checkMatchCase(node) {
|
|
3045
|
-
const match =
|
|
2913
|
+
const match = node.getAncestor('Match');
|
|
3046
2914
|
if (node.patterns?.length) {
|
|
3047
2915
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.patterns, function* (node) {
|
|
3048
2916
|
yield* checkNode(node);
|
|
@@ -3055,7 +2923,7 @@ function createErrorDiagnoser(context) {
|
|
|
3055
2923
|
// 先使用ts原始的报错,这个先注释掉
|
|
3056
2924
|
if (nasl_concepts_1.asserts.isTypeAnnotation(node) && matchExpressionType?.typeKind === 'union') {
|
|
3057
2925
|
(0, service_1.transformUnionTypeAnnotation)(matchExpressionType, match?.app);
|
|
3058
|
-
const haveType =
|
|
2926
|
+
const haveType = matchExpressionType?.typeArguments.find((item) => item.sortedTypeKey === node.sortedTypeKey);
|
|
3059
2927
|
if (!haveType) {
|
|
3060
2928
|
message = '匹配:选择类型不存在';
|
|
3061
2929
|
titleTip = '该类型已被删除';
|
|
@@ -3182,25 +3050,19 @@ function createErrorDiagnoser(context) {
|
|
|
3182
3050
|
? getPropertyOfType(node.parentNode.typeAnnotation, node.name)
|
|
3183
3051
|
: env.resolveRef(node);
|
|
3184
3052
|
if (!ref) {
|
|
3185
|
-
if (node.
|
|
3186
|
-
/**
|
|
3187
|
-
* 参考类型检查器的 {@link tpIdentifier}方法
|
|
3188
|
-
*/
|
|
3189
|
-
return typer_1.naslLongTy;
|
|
3190
|
-
}
|
|
3191
|
-
else if (node.name === 'it') {
|
|
3053
|
+
if (node.name === 'it') {
|
|
3192
3054
|
return env.getType(node);
|
|
3193
3055
|
}
|
|
3194
3056
|
else {
|
|
3195
3057
|
const { name } = node;
|
|
3196
3058
|
// 之前有一些脏数据,先兼容
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3059
|
+
if (['true', 'false'].includes(name)) {
|
|
3060
|
+
return new nasl_concepts_1.TypeAnnotation({
|
|
3061
|
+
typeKind: 'primitive',
|
|
3062
|
+
typeName: 'Boolean',
|
|
3063
|
+
typeNamespace: 'nasl.core',
|
|
3064
|
+
});
|
|
3065
|
+
}
|
|
3204
3066
|
if (
|
|
3205
3067
|
// name 是 A.B.C
|
|
3206
3068
|
name?.split('.')?.length > 1
|
|
@@ -3370,7 +3232,7 @@ function createErrorDiagnoser(context) {
|
|
|
3370
3232
|
const prop = getPropertyOfType(type, propertyName);
|
|
3371
3233
|
if (prop) {
|
|
3372
3234
|
const propertyType = yield* checkNode(property);
|
|
3373
|
-
if (
|
|
3235
|
+
if (isUninstantiatedType(propertyType)) {
|
|
3374
3236
|
error(node, `${property.name}推导不出类型!请连线或手动设置`);
|
|
3375
3237
|
}
|
|
3376
3238
|
else if (type.typeKind === 'anonymousStructure') {
|
|
@@ -3831,7 +3693,7 @@ function createErrorDiagnoser(context) {
|
|
|
3831
3693
|
if (ensureNodeKeyExists(node, 'typeName') && node.typeKind === 'reference') {
|
|
3832
3694
|
const ref = env.resolveRef(node);
|
|
3833
3695
|
if (!ref) {
|
|
3834
|
-
error(node,
|
|
3696
|
+
error(node, `找不到类型${node.typeName}`);
|
|
3835
3697
|
}
|
|
3836
3698
|
}
|
|
3837
3699
|
}
|
|
@@ -3867,8 +3729,12 @@ function createErrorDiagnoser(context) {
|
|
|
3867
3729
|
}
|
|
3868
3730
|
function* dispatchNode(node) {
|
|
3869
3731
|
try {
|
|
3732
|
+
// 控制流节点
|
|
3733
|
+
if (isControlFlowNode(node)) {
|
|
3734
|
+
return yield* checkControlFlowNode(node);
|
|
3735
|
+
}
|
|
3870
3736
|
// 调用表达式
|
|
3871
|
-
if (
|
|
3737
|
+
if (isCallExpression(node)) {
|
|
3872
3738
|
return yield* checkCallExpression(node);
|
|
3873
3739
|
}
|
|
3874
3740
|
const { concept } = node;
|
|
@@ -3975,14 +3841,6 @@ function createErrorDiagnoser(context) {
|
|
|
3975
3841
|
return yield* checkProcessDefinitionV2(node);
|
|
3976
3842
|
case 'ProcessElementV2':
|
|
3977
3843
|
return yield* checkProcessElementV2(node);
|
|
3978
|
-
case 'ReassignUnmannedV2':
|
|
3979
|
-
return yield* checkReassignUnmannedV2(node);
|
|
3980
|
-
case 'UserAssignees':
|
|
3981
|
-
return yield* checkUserAssignees(node);
|
|
3982
|
-
case 'RoleAssignees':
|
|
3983
|
-
return yield* checkRoleAssignees(node);
|
|
3984
|
-
case 'DepartmentAssignees':
|
|
3985
|
-
return yield* checkDepartmentAssignees(node);
|
|
3986
3844
|
case 'FieldPermissionV2':
|
|
3987
3845
|
return yield* checkFieldPermissionV2(node);
|
|
3988
3846
|
case 'MsgTriggerLauncher':
|
|
@@ -4096,13 +3954,9 @@ function createErrorDiagnoser(context) {
|
|
|
4096
3954
|
case 'Start':
|
|
4097
3955
|
return;
|
|
4098
3956
|
case 'SqlQueryComponent':
|
|
4099
|
-
return
|
|
3957
|
+
return;
|
|
4100
3958
|
default:
|
|
4101
|
-
|
|
4102
|
-
}
|
|
4103
|
-
// 控制流节点,低频或没啥人用的东西放后面判断
|
|
4104
|
-
if (fastIsControlFlowNode(node)) {
|
|
4105
|
-
return yield* checkControlFlowNode(node);
|
|
3959
|
+
console.log(node);
|
|
4106
3960
|
}
|
|
4107
3961
|
}
|
|
4108
3962
|
catch (err) {
|
|
@@ -4115,7 +3969,6 @@ function createErrorDiagnoser(context) {
|
|
|
4115
3969
|
* @returns 清理函数
|
|
4116
3970
|
*/
|
|
4117
3971
|
function handleFileNode(node) {
|
|
4118
|
-
// TODO: checkNodeIsFileModuleInIde 也慢,后续可以优化
|
|
4119
3972
|
const isFileModule = fileNodes.length ? (0, service_1.checkNodeIsFileModuleInIde)(node) : true;
|
|
4120
3973
|
if (isFileModule) {
|
|
4121
3974
|
fileNodes.push(node);
|
|
@@ -4135,8 +3988,7 @@ function createErrorDiagnoser(context) {
|
|
|
4135
3988
|
* @returns
|
|
4136
3989
|
*/
|
|
4137
3990
|
function* checkNode(node) {
|
|
4138
|
-
|
|
4139
|
-
if (!node || !node.concept) {
|
|
3991
|
+
if (!nasl_concepts_1.asserts.isBaseNode(node)) {
|
|
4140
3992
|
return;
|
|
4141
3993
|
}
|
|
4142
3994
|
const cleanup = handleFileNode(node);
|
|
@@ -4205,6 +4057,7 @@ function createErrorDiagnoser(context) {
|
|
|
4205
4057
|
error,
|
|
4206
4058
|
};
|
|
4207
4059
|
}
|
|
4060
|
+
exports.createErrorDiagnoser = createErrorDiagnoser;
|
|
4208
4061
|
const transformDiagnosticsToRecords = (fileNode, diagnostics) => {
|
|
4209
4062
|
const records = [];
|
|
4210
4063
|
let filePath;
|
|
@@ -4243,6 +4096,4 @@ const transformDiagnosticsToRecords = (fileNode, diagnostics) => {
|
|
|
4243
4096
|
return records;
|
|
4244
4097
|
};
|
|
4245
4098
|
exports.transformDiagnosticsToRecords = transformDiagnosticsToRecords;
|
|
4246
|
-
// @ts-expect-error
|
|
4247
|
-
const toRaw = (nd) => nd.__v_raw ?? nd;
|
|
4248
4099
|
//# sourceMappingURL=checker.js.map
|