@lcap/nasl-language-server-core 4.0.0-alpha.1 → 4.0.0-beta.2
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 +121 -116
- package/out/checker.js.map +1 -1
- package/out/index.js +17 -7
- package/out/index.js.map +1 -1
- package/out/module/graph.d.ts.map +1 -1
- package/out/reference-manager/builtin-q-name.js +3 -4
- 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 +14 -13
- package/out/reference-manager/collect-q-name.js.map +1 -1
- package/out/reference-manager/reference-manager.d.ts +13 -7
- package/out/reference-manager/reference-manager.d.ts.map +1 -1
- package/out/reference-manager/reference-manager.js +131 -22
- 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 +11 -10
- 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 +0 -1
- 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 +2 -1
- package/out/symbol/traverse/concepts/index.d.ts.map +1 -1
- package/out/symbol/traverse/concepts/utils.js +4 -4
- package/out/symbol/traverse/concepts/utils.js.map +1 -1
- package/out/symbol/traverse/traverse.js +1 -2
- package/out/symbol/traverse/traverse.js.map +1 -1
- package/out/symbol/utils.js +1 -2
- package/out/symbol/utils.js.map +1 -1
- package/out/typer/collectGlobalDefs.d.ts.map +1 -1
- package/out/typer/collectGlobalDefs.js +44 -31
- package/out/typer/collectGlobalDefs.js.map +1 -1
- package/out/typer/component-def-manager/component-def-manager.d.ts +36 -7
- package/out/typer/component-def-manager/component-def-manager.d.ts.map +1 -1
- package/out/typer/component-def-manager/component-def-manager.js +75 -22
- 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 +59 -19
- package/out/typer/component-def-manager/utils.js.map +1 -1
- package/out/typer/dispatch-all.d.ts +1 -1
- package/out/typer/dispatch-all.d.ts.map +1 -1
- package/out/typer/dispatch-all.js +31 -28
- package/out/typer/dispatch-all.js.map +1 -1
- package/out/typer/dispatch-def.d.ts +6 -2
- package/out/typer/dispatch-def.d.ts.map +1 -1
- package/out/typer/dispatch-def.js +123 -42
- package/out/typer/dispatch-def.js.map +1 -1
- package/out/typer/dispatch-expr.d.ts +3 -1
- package/out/typer/dispatch-expr.d.ts.map +1 -1
- package/out/typer/dispatch-expr.js +541 -406
- package/out/typer/dispatch-expr.js.map +1 -1
- package/out/typer/dispatch-process.d.ts +1 -1
- package/out/typer/dispatch-process.d.ts.map +1 -1
- package/out/typer/dispatch-process.js +41 -29
- 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 +38 -56
- package/out/typer/dispatch-stmt.js.map +1 -1
- package/out/typer/dispatch-view.d.ts +6 -6
- package/out/typer/dispatch-view.d.ts.map +1 -1
- package/out/typer/dispatch-view.js +351 -193
- package/out/typer/dispatch-view.js.map +1 -1
- package/out/typer/fix-use-before-assign.d.ts.map +1 -1
- package/out/typer/fix-use-before-assign.js +8 -8
- package/out/typer/fix-use-before-assign.js.map +1 -1
- package/out/typer/helper.d.ts +3 -2
- package/out/typer/helper.d.ts.map +1 -1
- package/out/typer/helper.js +32 -32
- package/out/typer/helper.js.map +1 -1
- package/out/typer/incremental-update.d.ts +1 -1
- package/out/typer/incremental-update.d.ts.map +1 -1
- package/out/typer/incremental-update.js +25 -35
- package/out/typer/incremental-update.js.map +1 -1
- package/out/typer/index.d.ts +5 -3
- package/out/typer/index.d.ts.map +1 -1
- package/out/typer/index.js +51 -49
- package/out/typer/index.js.map +1 -1
- package/out/typer/query-manager/query-manager.d.ts +28 -0
- package/out/typer/query-manager/query-manager.d.ts.map +1 -0
- package/out/typer/query-manager/query-manager.js +63 -0
- package/out/typer/query-manager/query-manager.js.map +1 -0
- package/out/typer/query-manager/query-tokens.d.ts +4 -0
- package/out/typer/query-manager/query-tokens.d.ts.map +1 -0
- package/out/typer/query-manager/query-tokens.js +8 -0
- package/out/typer/query-manager/query-tokens.js.map +1 -0
- package/out/typer/query-manager/type-level-evaluation-of.d.ts +13 -0
- package/out/typer/query-manager/type-level-evaluation-of.d.ts.map +1 -0
- package/out/typer/query-manager/type-level-evaluation-of.js +4 -0
- package/out/typer/query-manager/type-level-evaluation-of.js.map +1 -0
- package/out/typer/sem-diag.d.ts +5 -3
- package/out/typer/sem-diag.d.ts.map +1 -1
- package/out/typer/sem-diag.js +57 -15
- package/out/typer/sem-diag.js.map +1 -1
- package/out/typer/solver.d.ts +10 -9
- package/out/typer/solver.d.ts.map +1 -1
- package/out/typer/solver.js +42 -42
- package/out/typer/solver.js.map +1 -1
- package/out/typer/subster.d.ts +20 -7
- package/out/typer/subster.d.ts.map +1 -1
- package/out/typer/subster.js +131 -76
- package/out/typer/subster.js.map +1 -1
- package/out/typer/topo-sort.d.ts.map +1 -1
- package/out/typer/topo-sort.js +18 -12
- package/out/typer/topo-sort.js.map +1 -1
- package/out/typer/type-hint-manager/type-hint-manager.d.ts +3 -0
- package/out/typer/type-hint-manager/type-hint-manager.d.ts.map +1 -1
- package/out/typer/type-hint-manager/type-hint-manager.js +8 -0
- package/out/typer/type-hint-manager/type-hint-manager.js.map +1 -1
- package/out/typer/type-manager.d.ts +154 -0
- package/out/typer/type-manager.d.ts.map +1 -0
- package/out/typer/type-manager.js +767 -0
- package/out/typer/type-manager.js.map +1 -0
- package/out/typer/type-predicate.d.ts +72 -0
- package/out/typer/type-predicate.d.ts.map +1 -0
- package/out/typer/type-predicate.js +435 -0
- package/out/typer/type-predicate.js.map +1 -0
- package/out/typer/typer.d.ts +40 -14
- package/out/typer/typer.d.ts.map +1 -1
- package/out/typer/typer.js +163 -59
- package/out/typer/typer.js.map +1 -1
- package/out/typer/unifier.d.ts +18 -10
- package/out/typer/unifier.d.ts.map +1 -1
- package/out/typer/unifier.js +145 -99
- package/out/typer/unifier.js.map +1 -1
- package/out/utils/array.js +1 -2
- package/out/utils/array.js.map +1 -1
- package/out/utils/assertion.js +1 -2
- package/out/utils/assertion.js.map +1 -1
- package/out/utils/bind-expression-hack.js +18 -9
- 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 +8 -5
- package/out/utils/error-boundary.js.map +1 -1
- package/out/utils/nasl-type-manipulation.d.ts +29 -0
- package/out/utils/nasl-type-manipulation.d.ts.map +1 -0
- package/out/utils/nasl-type-manipulation.js +77 -0
- package/out/utils/nasl-type-manipulation.js.map +1 -0
- package/out/utils/parseTsClassType.d.ts +10 -11
- package/out/utils/parseTsClassType.d.ts.map +1 -1
- package/out/utils/parseTsClassType.js +63 -52
- package/out/utils/parseTsClassType.js.map +1 -1
- package/out/utils/type-operator.d.ts +12 -0
- package/out/utils/type-operator.d.ts.map +1 -0
- package/out/utils/type-operator.js +38 -0
- package/out/utils/type-operator.js.map +1 -0
- package/out/utils/types.js +1 -2
- package/out/utils/types.js.map +1 -1
- package/out/utils/vue-hack.js +1 -2
- package/out/utils/vue-hack.js.map +1 -1
- package/out/utils/vue.js +1 -2
- package/out/utils/vue.js.map +1 -1
- package/package.json +6 -6
- package/out/typer/typeManager.d.ts +0 -96
- package/out/typer/typeManager.d.ts.map +0 -1
- package/out/typer/typeManager.js +0 -879
- package/out/typer/typeManager.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, any>;
|
|
41
41
|
checkNode: (node: SyntaxNode | undefined) => Generator<TypeAnnotation | {
|
|
42
42
|
typeKind: string;
|
|
43
|
-
} | undefined, any,
|
|
43
|
+
} | undefined, any, any>;
|
|
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,EAGpF,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,EAGpF,MAAM,qBAAqB,CAAC;AAM7B,OAAO,EAA4B,MAAM,EAAE,MAAM,SAAS,CAAC;AAI3D,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;AAgQF;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,eAAe;oCAwhIpB,OAAO;sDAPW,gBAAgB,EAAE;;;;sBAhBjD,UAAU,GAAG,SAAS;;;6BAsChB,UAAU;2BAuBZ,UAAU;kBAtgInB,UAAU,WAAW,MAAM,YAAY,YAAY;EAshIzE;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,GAAI,UAAU,UAAU,EAAE,aAAa,kBAAkB,KAAG,KAAK,CAAC,gBAAgB,CAmC3H,CAAA"}
|
package/out/checker.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transformDiagnosticsToRecords = exports.
|
|
3
|
+
exports.transformDiagnosticsToRecords = exports.Severity = void 0;
|
|
4
|
+
exports.createErrorDiagnoser = createErrorDiagnoser;
|
|
4
5
|
const decimal_js_1 = require("decimal.js");
|
|
5
6
|
const nasl_concepts_1 = require("@lcap/nasl-concepts");
|
|
6
7
|
const service_1 = require("@lcap/nasl-concepts/service");
|
|
7
8
|
const nasl_utils_1 = require("@lcap/nasl-utils");
|
|
8
9
|
const typer_1 = require("./typer");
|
|
10
|
+
const type_predicate_1 = require("./typer/type-predicate");
|
|
11
|
+
const type_manager_1 = require("./typer/type-manager");
|
|
9
12
|
var Severity;
|
|
10
13
|
(function (Severity) {
|
|
11
14
|
Severity["WARN"] = "warning";
|
|
@@ -47,6 +50,7 @@ const isContinue = (node) => node.concept === 'Continue';
|
|
|
47
50
|
* @param node
|
|
48
51
|
*/
|
|
49
52
|
const fastIsControlFlowNode = (node) => isEnd(node) || isAbort(node) || isBreak(node) || isContinue(node);
|
|
53
|
+
const isArgument = (node) => node.concept === 'Argument';
|
|
50
54
|
/**
|
|
51
55
|
* 是端类型下的参数
|
|
52
56
|
* @param node
|
|
@@ -314,7 +318,7 @@ function createErrorDiagnoser(context) {
|
|
|
314
318
|
if (diagnostics) {
|
|
315
319
|
const diagnostic = {
|
|
316
320
|
message,
|
|
317
|
-
severity: inPlayground > 0 ? Severity.WARN : severity ?? Severity.ERROR,
|
|
321
|
+
severity: inPlayground > 0 ? Severity.WARN : (severity ?? Severity.ERROR),
|
|
318
322
|
...others,
|
|
319
323
|
};
|
|
320
324
|
if (isDebug) {
|
|
@@ -375,6 +379,7 @@ function createErrorDiagnoser(context) {
|
|
|
375
379
|
timeoutConfig.values.forEach((value) => {
|
|
376
380
|
const __env = value.env;
|
|
377
381
|
const timeout = Number(value.value);
|
|
382
|
+
const label = value.envDisplayLabel;
|
|
378
383
|
if (timeout * 1000 < retryInterval * retryTimes) {
|
|
379
384
|
const HTTP_TIMEOUT_ORIGIN_MESSAGE = 'the local timeout is greater than the system timeout';
|
|
380
385
|
error(node, `${nodeType}“${node.title ?? node.name}”配置的重试间隔时间乘以重试次数大于${__env === 'dev' ? '开发环境' : '生产环境'}接口超时时间,可能导致重试失败`, {
|
|
@@ -447,6 +452,10 @@ function createErrorDiagnoser(context) {
|
|
|
447
452
|
conceptValidator = nasl_concepts_1.staticRules['EnumItemInteger'];
|
|
448
453
|
validatorMapKey = 'EnumItemInteger';
|
|
449
454
|
}
|
|
455
|
+
else if (concept === 'StructureProperty' && node?.parentNode?.concept !== 'Structure') {
|
|
456
|
+
conceptValidator = nasl_concepts_1.staticRules['TypeStructureProperty'];
|
|
457
|
+
validatorMapKey = 'TypeStructureProperty';
|
|
458
|
+
}
|
|
450
459
|
if (conceptValidator) {
|
|
451
460
|
let toBeVerifiedName = node;
|
|
452
461
|
const map = {
|
|
@@ -688,14 +697,11 @@ function createErrorDiagnoser(context) {
|
|
|
688
697
|
*/
|
|
689
698
|
function getMinArgsCount(params) {
|
|
690
699
|
const paramLen = params?.length;
|
|
691
|
-
let minArgsCount =
|
|
692
|
-
for (let i =
|
|
700
|
+
let minArgsCount = 0;
|
|
701
|
+
for (let i = 0; i < paramLen; i++) {
|
|
693
702
|
const param = params[i];
|
|
694
|
-
if (isNonRequiredParam(param)) {
|
|
695
|
-
minArgsCount
|
|
696
|
-
}
|
|
697
|
-
else { // 如果参数有默认值,则跳过
|
|
698
|
-
break;
|
|
703
|
+
if (!isNonRequiredParam(param)) {
|
|
704
|
+
minArgsCount++; // 如果参数有默认值,则跳过
|
|
699
705
|
}
|
|
700
706
|
}
|
|
701
707
|
return minArgsCount;
|
|
@@ -799,10 +805,12 @@ function createErrorDiagnoser(context) {
|
|
|
799
805
|
* @param ref
|
|
800
806
|
*/
|
|
801
807
|
function* checkCallExpressionParameters(node, ref) {
|
|
802
|
-
|
|
808
|
+
// Handle both TypeAnnotation and FunctionDefinition formats
|
|
809
|
+
const params = ref.params ?? ref.typeArguments;
|
|
803
810
|
const { arguments: args } = node;
|
|
804
811
|
const paramsLen = params?.length || 0;
|
|
805
812
|
const argsLen = args?.length || 0;
|
|
813
|
+
// For FunctionDefinition format, check spread and optional params
|
|
806
814
|
const spreadParamIndex = params?.findIndex((param) => param.spread);
|
|
807
815
|
const hasSpreadParam = spreadParamIndex !== -1;
|
|
808
816
|
const minArgsCount = getMinArgsCount(params);
|
|
@@ -814,11 +822,12 @@ function createErrorDiagnoser(context) {
|
|
|
814
822
|
}
|
|
815
823
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(args, function* (arg, index) {
|
|
816
824
|
const param = params?.[index];
|
|
817
|
-
const isParamRequired = !(hasSpreadParam && index > spreadParamIndex) && !isNonRequiredParam(param);
|
|
818
|
-
arg.paramRequired = isParamRequired;
|
|
819
825
|
if (!param)
|
|
820
826
|
return;
|
|
821
|
-
const
|
|
827
|
+
const isParamRequired = !(hasSpreadParam && index > spreadParamIndex) && !isNonRequiredParam(param);
|
|
828
|
+
arg.paramRequired = isParamRequired;
|
|
829
|
+
const paramType = param.typeAnnotation ??
|
|
830
|
+
(nasl_concepts_1.asserts.isTypeAnnotation(param) ? param : env.getType(param));
|
|
822
831
|
const argType = yield* checkNode(arg);
|
|
823
832
|
if (paramType?.typeKind === 'function' && argType?.typeKind === 'function') {
|
|
824
833
|
const argTypeArgs = argType?.typeArguments || [];
|
|
@@ -835,7 +844,7 @@ function createErrorDiagnoser(context) {
|
|
|
835
844
|
*/
|
|
836
845
|
function* checkVariableType(node) {
|
|
837
846
|
const type = env.getType(node);
|
|
838
|
-
if (
|
|
847
|
+
if (isUnresolvedType(type)) {
|
|
839
848
|
const logic = node.getAncestor('SubLogic') || node.getAncestor('Logic');
|
|
840
849
|
let used = false;
|
|
841
850
|
logic.traverseStrictChildren((item) => {
|
|
@@ -901,10 +910,11 @@ function createErrorDiagnoser(context) {
|
|
|
901
910
|
}
|
|
902
911
|
/**
|
|
903
912
|
* 未推导出的类型
|
|
913
|
+
* 这个可能有问题,因为可能是 type 的嵌套结构没有推导出类型,看使用场景了
|
|
904
914
|
* @param type
|
|
905
915
|
* @returns
|
|
906
916
|
*/
|
|
907
|
-
function
|
|
917
|
+
function isUnresolvedType(type) {
|
|
908
918
|
return !type || type?.typeKind === 'typeParam' || type?.typeName === 'Null' || type?.typeName === 'void';
|
|
909
919
|
}
|
|
910
920
|
/**
|
|
@@ -914,9 +924,14 @@ function createErrorDiagnoser(context) {
|
|
|
914
924
|
*/
|
|
915
925
|
function* checkNonNullExpression(node) {
|
|
916
926
|
const type = yield* checkNode(node);
|
|
917
|
-
if (
|
|
927
|
+
if (isUnresolvedType(type)) {
|
|
918
928
|
const scope = node?.constructor?.nodeTitle;
|
|
919
|
-
|
|
929
|
+
if (node.concept === 'Identifier') {
|
|
930
|
+
error(node, `${scope}:${node.name} 未定义。`);
|
|
931
|
+
}
|
|
932
|
+
else {
|
|
933
|
+
error(node, `${scope}:所选择的内容未定义。`);
|
|
934
|
+
}
|
|
920
935
|
return errorType;
|
|
921
936
|
}
|
|
922
937
|
return type;
|
|
@@ -1066,11 +1081,6 @@ function createErrorDiagnoser(context) {
|
|
|
1066
1081
|
return;
|
|
1067
1082
|
}
|
|
1068
1083
|
inModule = true;
|
|
1069
|
-
if (node.structures?.length) {
|
|
1070
|
-
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.structures, function* (node) {
|
|
1071
|
-
yield* checkNode(node);
|
|
1072
|
-
});
|
|
1073
|
-
}
|
|
1074
1084
|
// 启用元数据时才翻译
|
|
1075
1085
|
if ((node.type === 'sharedApp')) {
|
|
1076
1086
|
if (node.metadataTypes?.length) {
|
|
@@ -1079,41 +1089,6 @@ function createErrorDiagnoser(context) {
|
|
|
1079
1089
|
});
|
|
1080
1090
|
}
|
|
1081
1091
|
}
|
|
1082
|
-
if (node.frontends?.length) {
|
|
1083
|
-
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.frontends, function* (node) {
|
|
1084
|
-
yield* checkNode(node);
|
|
1085
|
-
});
|
|
1086
|
-
}
|
|
1087
|
-
if (node.dataSources?.length) {
|
|
1088
|
-
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.dataSources, function* (node) {
|
|
1089
|
-
yield* checkNode(node);
|
|
1090
|
-
});
|
|
1091
|
-
}
|
|
1092
|
-
if (node.interfaces?.length) {
|
|
1093
|
-
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.interfaces, function* (node) {
|
|
1094
|
-
yield* checkNode(node);
|
|
1095
|
-
});
|
|
1096
|
-
}
|
|
1097
|
-
if (node.enums?.length) {
|
|
1098
|
-
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.enums, function* (node) {
|
|
1099
|
-
yield* checkNode(node);
|
|
1100
|
-
});
|
|
1101
|
-
}
|
|
1102
|
-
if (node.logics?.length) {
|
|
1103
|
-
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.logics, function* (node) {
|
|
1104
|
-
yield* checkNode(node);
|
|
1105
|
-
});
|
|
1106
|
-
}
|
|
1107
|
-
if (node.processes?.length) {
|
|
1108
|
-
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.processes, function* (node) {
|
|
1109
|
-
yield* checkNode(node);
|
|
1110
|
-
});
|
|
1111
|
-
}
|
|
1112
|
-
if (node.processV2s?.length) {
|
|
1113
|
-
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.processV2s, function* (node) {
|
|
1114
|
-
yield* checkNode(node);
|
|
1115
|
-
});
|
|
1116
|
-
}
|
|
1117
1092
|
yield* checkNode(node.configuration);
|
|
1118
1093
|
if (node.type === 'sharedApp') {
|
|
1119
1094
|
const status = getStatusOfSharedApp(node);
|
|
@@ -1249,7 +1224,8 @@ function createErrorDiagnoser(context) {
|
|
|
1249
1224
|
*/
|
|
1250
1225
|
function* checkVariable(node) {
|
|
1251
1226
|
yield* checkNode(node.defaultValue);
|
|
1252
|
-
|
|
1227
|
+
// 前面加了报错,省点时间,报错不用那么精确
|
|
1228
|
+
// yield* checkVariableType(node);
|
|
1253
1229
|
}
|
|
1254
1230
|
/**
|
|
1255
1231
|
* 检查 前端全局变量
|
|
@@ -1305,33 +1281,16 @@ function createErrorDiagnoser(context) {
|
|
|
1305
1281
|
if (!propertyValue.value && node.name !== 'defaultDS') {
|
|
1306
1282
|
// prod 环境数据源未配置数据信息 时,不再给出其他提示
|
|
1307
1283
|
// https://projectmanage.netease-official.lcap.163yun.com/dashboard/FeatureDetail?id=2782461488301056
|
|
1308
|
-
if (propertyValue.env === '
|
|
1309
|
-
|
|
1310
|
-
|
|
1284
|
+
if (propertyValue.env === 'dev') {
|
|
1285
|
+
error(node, `数据源配置:数据源${property.name}${propertyValue.envDisplayLabel}未配置数据信息`);
|
|
1286
|
+
}
|
|
1311
1287
|
}
|
|
1312
1288
|
else if (propertyValue.value) {
|
|
1313
1289
|
const dataSource = node;
|
|
1314
1290
|
// 数据源有连接错误
|
|
1315
|
-
let envText;
|
|
1316
|
-
if (propertyValue.env === 'dev') {
|
|
1317
|
-
if (dataSource.__devConnectError) {
|
|
1318
|
-
envText = '开发';
|
|
1319
|
-
}
|
|
1320
|
-
else if (dataSource.__devConnectError === false) {
|
|
1321
|
-
return;
|
|
1322
|
-
}
|
|
1323
|
-
}
|
|
1324
|
-
else if (propertyValue.env === 'online') {
|
|
1325
|
-
if (dataSource.__onlineConnectError) {
|
|
1326
|
-
envText = '生产';
|
|
1327
|
-
}
|
|
1328
|
-
else if (dataSource.__onlineConnectError === false) {
|
|
1329
|
-
return;
|
|
1330
|
-
}
|
|
1331
|
-
}
|
|
1332
1291
|
// 手动插入报错
|
|
1333
|
-
if (
|
|
1334
|
-
error(node, `数据源配置:数据源 ${property.name} ${
|
|
1292
|
+
if (dataSource[`__${propertyValue.env}ConnectError`]) {
|
|
1293
|
+
error(node, `数据源配置:数据源 ${property.name} ${propertyValue.envDisplayLabel}环境数据源连接不通,请先检查${propertyValue.envDisplayLabel}环境数据源配置`, {
|
|
1335
1294
|
severity: Severity.WARN,
|
|
1336
1295
|
});
|
|
1337
1296
|
}
|
|
@@ -1586,7 +1545,9 @@ function createErrorDiagnoser(context) {
|
|
|
1586
1545
|
const value = numeric.value;
|
|
1587
1546
|
const decimalPlaces = value?.split('.')[1]?.length || 0;
|
|
1588
1547
|
if (decimalPlaces > +scale) {
|
|
1589
|
-
error(node, `实体字段${node.name}默认值的小数位数不能大于设置的小数位数${scale}
|
|
1548
|
+
error(node, `实体字段${node.name}默认值的小数位数不能大于设置的小数位数${scale},否则将会按照小数位数自动截断`, {
|
|
1549
|
+
severity: Severity.WARN,
|
|
1550
|
+
});
|
|
1590
1551
|
}
|
|
1591
1552
|
}
|
|
1592
1553
|
break;
|
|
@@ -1763,7 +1724,8 @@ function createErrorDiagnoser(context) {
|
|
|
1763
1724
|
*/
|
|
1764
1725
|
function* checkReturn(node) {
|
|
1765
1726
|
yield* checkNode(node.defaultValue);
|
|
1766
|
-
|
|
1727
|
+
// 前面加了报错,省点时间,报错不用那么精确
|
|
1728
|
+
// yield* checkVariableType(node);
|
|
1767
1729
|
}
|
|
1768
1730
|
/**
|
|
1769
1731
|
* 检查 接口
|
|
@@ -2104,7 +2066,9 @@ function createErrorDiagnoser(context) {
|
|
|
2104
2066
|
if (processElement || node.type === 'dynamic') {
|
|
2105
2067
|
yield* checkNode(node.destination);
|
|
2106
2068
|
}
|
|
2107
|
-
|
|
2069
|
+
if (node.name === 'externalDestination' && node.type === 'dynamic') {
|
|
2070
|
+
yield* checkNode(node.externalDestination);
|
|
2071
|
+
}
|
|
2108
2072
|
if (node.rules?.length) {
|
|
2109
2073
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.rules, function* (node) {
|
|
2110
2074
|
yield* checkNode(node);
|
|
@@ -2194,7 +2158,7 @@ function createErrorDiagnoser(context) {
|
|
|
2194
2158
|
error(node, '流程暂不支持可变参数');
|
|
2195
2159
|
}
|
|
2196
2160
|
if (node.includeTypeArgs) {
|
|
2197
|
-
error(node, '
|
|
2161
|
+
error(node, '流程暂不支持泛型参数');
|
|
2198
2162
|
}
|
|
2199
2163
|
const unbindVariables = env.temporarilyBindVariables([
|
|
2200
2164
|
...(node?.params || []),
|
|
@@ -2308,7 +2272,7 @@ function createErrorDiagnoser(context) {
|
|
|
2308
2272
|
error(node, '流程暂不支持可变参数');
|
|
2309
2273
|
}
|
|
2310
2274
|
if (node.includeTypeArgs) {
|
|
2311
|
-
error(node, '
|
|
2275
|
+
error(node, '流程暂不支持泛型参数');
|
|
2312
2276
|
}
|
|
2313
2277
|
}
|
|
2314
2278
|
/**
|
|
@@ -2396,6 +2360,8 @@ function createErrorDiagnoser(context) {
|
|
|
2396
2360
|
yield* checkNode(node);
|
|
2397
2361
|
});
|
|
2398
2362
|
}
|
|
2363
|
+
// 无人审批策略
|
|
2364
|
+
yield* checkNode(node.unmannedApprovalStrategy);
|
|
2399
2365
|
if (node.fieldPermissions?.length) {
|
|
2400
2366
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(node.fieldPermissions, function* (node) {
|
|
2401
2367
|
yield* checkNode(node);
|
|
@@ -2414,6 +2380,40 @@ function createErrorDiagnoser(context) {
|
|
|
2414
2380
|
}
|
|
2415
2381
|
unbindVariables();
|
|
2416
2382
|
}
|
|
2383
|
+
/**
|
|
2384
|
+
* 检查 无人时,自动转派审批策略
|
|
2385
|
+
* @param node
|
|
2386
|
+
*/
|
|
2387
|
+
function* checkReassignUnmannedV2(node) {
|
|
2388
|
+
return yield* checkNode(node.assignees);
|
|
2389
|
+
}
|
|
2390
|
+
/**
|
|
2391
|
+
* 检查 用户经办人
|
|
2392
|
+
* @param node
|
|
2393
|
+
*/
|
|
2394
|
+
function* checkUserAssignees(node) {
|
|
2395
|
+
if (!node.users?.length) {
|
|
2396
|
+
error(node, '转派人员为空');
|
|
2397
|
+
}
|
|
2398
|
+
}
|
|
2399
|
+
/**
|
|
2400
|
+
* 检查 角色经办人
|
|
2401
|
+
* @param node
|
|
2402
|
+
*/
|
|
2403
|
+
function* checkRoleAssignees(node) {
|
|
2404
|
+
if (!node.roles?.length) {
|
|
2405
|
+
error(node, '转派角色为空');
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2408
|
+
/**
|
|
2409
|
+
* 检查 部门经办人
|
|
2410
|
+
* @param node
|
|
2411
|
+
*/
|
|
2412
|
+
function* checkDepartmentAssignees(node) {
|
|
2413
|
+
if (!node.departments?.length) {
|
|
2414
|
+
error(node, '转派部门为空');
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
2417
|
/**
|
|
2418
2418
|
* 检查 字段权限控制详情
|
|
2419
2419
|
* @param node
|
|
@@ -2533,7 +2533,7 @@ function createErrorDiagnoser(context) {
|
|
|
2533
2533
|
if (logicReturns[0].name !== itfReturns[0].name) {
|
|
2534
2534
|
isSame = false;
|
|
2535
2535
|
}
|
|
2536
|
-
else if (!(
|
|
2536
|
+
else if (!(0, type_predicate_1.isEqualTy)(env, env.getType(logicReturns[0]), env.getType(itfReturns[0]))) {
|
|
2537
2537
|
isSame = false;
|
|
2538
2538
|
}
|
|
2539
2539
|
}
|
|
@@ -2736,8 +2736,14 @@ function createErrorDiagnoser(context) {
|
|
|
2736
2736
|
return;
|
|
2737
2737
|
}
|
|
2738
2738
|
yield* checkVoidCallUsedAsStatement(node);
|
|
2739
|
-
const ref = env.
|
|
2740
|
-
|
|
2739
|
+
const ref = env.resolvedCallInfo.get(node) ?? env.resolveRef(node);
|
|
2740
|
+
// Handle the new FunctionDefinition structure
|
|
2741
|
+
if (ref?.params && !(0, type_manager_1.hasUnresolvedTyInCallInfo)(ref)) {
|
|
2742
|
+
// It's a FunctionDefinition object
|
|
2743
|
+
yield* checkScopeOfUse(node, ref);
|
|
2744
|
+
yield* checkCallExpressionParameters(node, ref);
|
|
2745
|
+
}
|
|
2746
|
+
else if (ref && !(0, type_predicate_1.isUnResolvedTy)(ref)) {
|
|
2741
2747
|
// 检查使用范围
|
|
2742
2748
|
yield* checkScopeOfUse(node, ref);
|
|
2743
2749
|
yield* checkCallExpressionParameters(node, ref);
|
|
@@ -2793,7 +2799,7 @@ function createErrorDiagnoser(context) {
|
|
|
2793
2799
|
node.parentKey !== 'consequent' &&
|
|
2794
2800
|
node.parentNode?.parentNode?.concept !== 'CallInterface' &&
|
|
2795
2801
|
node.parentNode.concept !== 'Block' &&
|
|
2796
|
-
|
|
2802
|
+
isUnresolvedType(type)) {
|
|
2797
2803
|
let showErr = false;
|
|
2798
2804
|
if (node.parentNode?.parentNode?.concept === 'CallLogic') {
|
|
2799
2805
|
// calllogic 中别的类型会强校验,但是内置函数,不会强制校验,下面这几个其实是走的内置函数的实现,所以需要手动增加一下校验
|
|
@@ -3212,19 +3218,25 @@ function createErrorDiagnoser(context) {
|
|
|
3212
3218
|
? getPropertyOfType(node.parentNode.typeAnnotation, node.name)
|
|
3213
3219
|
: env.resolveRef(node);
|
|
3214
3220
|
if (!ref) {
|
|
3215
|
-
if (node.
|
|
3221
|
+
if (node.namespace === 'backend') {
|
|
3222
|
+
/**
|
|
3223
|
+
* 参考类型检查器的 {@link tpIdentifier}方法
|
|
3224
|
+
*/
|
|
3225
|
+
return typer_1.naslLongTy;
|
|
3226
|
+
}
|
|
3227
|
+
else if (node.name === 'it') {
|
|
3216
3228
|
return env.getType(node);
|
|
3217
3229
|
}
|
|
3218
3230
|
else {
|
|
3219
3231
|
const { name } = node;
|
|
3220
3232
|
// 之前有一些脏数据,先兼容
|
|
3221
|
-
if (['true', 'false'].includes(name)) {
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
}
|
|
3233
|
+
// if (['true', 'false'].includes(name)) {
|
|
3234
|
+
// return new TypeAnnotation({
|
|
3235
|
+
// typeKind: 'primitive',
|
|
3236
|
+
// typeName: 'Boolean',
|
|
3237
|
+
// typeNamespace: 'nasl.core',
|
|
3238
|
+
// });
|
|
3239
|
+
// }
|
|
3228
3240
|
if (
|
|
3229
3241
|
// name 是 A.B.C
|
|
3230
3242
|
name?.split('.')?.length > 1
|
|
@@ -3402,7 +3414,7 @@ function createErrorDiagnoser(context) {
|
|
|
3402
3414
|
const prop = getPropertyOfType(type, propertyName);
|
|
3403
3415
|
if (prop) {
|
|
3404
3416
|
const propertyType = yield* checkNode(property);
|
|
3405
|
-
if (
|
|
3417
|
+
if (isUnresolvedType(propertyType)) {
|
|
3406
3418
|
error(node, `${property.name}推导不出类型!请连线或手动设置`);
|
|
3407
3419
|
}
|
|
3408
3420
|
else if (type.typeKind === 'anonymousStructure') {
|
|
@@ -3774,20 +3786,6 @@ function createErrorDiagnoser(context) {
|
|
|
3774
3786
|
if (ensureNodeKeyExists(node, 'argument')) {
|
|
3775
3787
|
yield* checkNode(node.argument);
|
|
3776
3788
|
}
|
|
3777
|
-
if (node.operator === 'isNull' && !!node.getAncestor('CallQueryComponent')) {
|
|
3778
|
-
function useVariable(node) {
|
|
3779
|
-
let res = false;
|
|
3780
|
-
node.traverseStrictChildren((child) => {
|
|
3781
|
-
if (child.concept === 'Identifier' && child.namespace !== 'inner') {
|
|
3782
|
-
res = true;
|
|
3783
|
-
}
|
|
3784
|
-
});
|
|
3785
|
-
return res;
|
|
3786
|
-
}
|
|
3787
|
-
if (useVariable(node)) {
|
|
3788
|
-
error(node, '空值匹配组件暂不支持使用变量');
|
|
3789
|
-
}
|
|
3790
|
-
}
|
|
3791
3789
|
return env.getType(node);
|
|
3792
3790
|
}
|
|
3793
3791
|
/**
|
|
@@ -3942,11 +3940,11 @@ function createErrorDiagnoser(context) {
|
|
|
3942
3940
|
nasl_concepts_1.asserts.isWhileStatement(parentNode) ||
|
|
3943
3941
|
nasl_concepts_1.asserts.isIfStatement(parentNode) ||
|
|
3944
3942
|
nasl_concepts_1.asserts.isMatchCase(parentNode) && !parentNode.parentNode.isExpression ||
|
|
3945
|
-
nasl_concepts_1.asserts.
|
|
3943
|
+
nasl_concepts_1.asserts.isSwitchCase(parentNode) ||
|
|
3946
3944
|
nasl_concepts_1.asserts.isBlock(parentNode));
|
|
3947
3945
|
const nodeType = env.getType(node);
|
|
3948
|
-
if (
|
|
3949
|
-
error(node, `无返回值的${node?.constructor?.nodeTitle}不能在${parentNode?.constructor?.nodeTitle}中作为表达式使用。`);
|
|
3946
|
+
if (isUnresolvedType(nodeType) && !usedAsStatement) {
|
|
3947
|
+
error(node, `无返回值的${node?.constructor?.nodeTitle}${node.calleeName} 不能在${parentNode?.constructor?.nodeTitle}中作为表达式使用。`);
|
|
3950
3948
|
}
|
|
3951
3949
|
}
|
|
3952
3950
|
function* dispatchNode(node) {
|
|
@@ -4059,6 +4057,14 @@ function createErrorDiagnoser(context) {
|
|
|
4059
4057
|
return yield* checkProcessDefinitionV2(node);
|
|
4060
4058
|
case 'ProcessElementV2':
|
|
4061
4059
|
return yield* checkProcessElementV2(node);
|
|
4060
|
+
case 'ReassignUnmannedV2':
|
|
4061
|
+
return yield* checkReassignUnmannedV2(node);
|
|
4062
|
+
case 'UserAssignees':
|
|
4063
|
+
return yield* checkUserAssignees(node);
|
|
4064
|
+
case 'RoleAssignees':
|
|
4065
|
+
return yield* checkRoleAssignees(node);
|
|
4066
|
+
case 'DepartmentAssignees':
|
|
4067
|
+
return yield* checkDepartmentAssignees(node);
|
|
4062
4068
|
case 'FieldPermissionV2':
|
|
4063
4069
|
return yield* checkFieldPermissionV2(node);
|
|
4064
4070
|
case 'MsgTriggerLauncher':
|
|
@@ -4283,7 +4289,6 @@ function createErrorDiagnoser(context) {
|
|
|
4283
4289
|
error,
|
|
4284
4290
|
};
|
|
4285
4291
|
}
|
|
4286
|
-
exports.createErrorDiagnoser = createErrorDiagnoser;
|
|
4287
4292
|
const transformDiagnosticsToRecords = (fileNode, diagnostics) => {
|
|
4288
4293
|
const records = [];
|
|
4289
4294
|
let filePath;
|