@lcap/nasl 3.3.0-alpha.1 → 3.3.0-alpha.3
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/upgrader/2.20.js.map +1 -1
- package/out/bak/translator.js +52 -1
- package/out/bak/translator.js.map +1 -1
- package/out/breakpoint/shared/utils.js +0 -2
- package/out/breakpoint/shared/utils.js.map +1 -1
- package/out/common/Command.d.ts +1 -0
- package/out/common/Command.js +9 -1
- package/out/common/Command.js.map +1 -1
- package/out/concepts/Abort__.js +2 -1
- package/out/concepts/Abort__.js.map +1 -1
- package/out/concepts/Anchor__.js +1 -1
- package/out/concepts/Anchor__.js.map +1 -1
- package/out/concepts/AnonymousFunction__.js +2 -2
- package/out/concepts/AnonymousFunction__.js.map +1 -1
- package/out/concepts/Argument__.js +1 -1
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/Assignee__.js.map +1 -1
- package/out/concepts/AssignmentLine__.js +1 -1
- package/out/concepts/AssignmentLine__.js.map +1 -1
- package/out/concepts/Assignment__.js +2 -2
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/BackendVariable__.js +1 -1
- package/out/concepts/BackendVariable__.js.map +1 -1
- package/out/concepts/Backend__.js +1 -1
- package/out/concepts/Backend__.js.map +1 -1
- package/out/concepts/BatchAssignment__.js +2 -2
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BinaryExpression__.js +2 -2
- package/out/concepts/BinaryExpression__.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts +2 -0
- package/out/concepts/BindAttribute__.js +79 -4
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +1 -1
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.d.ts +2 -1
- package/out/concepts/BindEvent__.js +44 -37
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BindStyle__.js +1 -1
- package/out/concepts/BindStyle__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.js +1 -1
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/CallAuthInterface__.js +1 -1
- package/out/concepts/CallAuthInterface__.js.map +1 -1
- package/out/concepts/CallConnector__.js +1 -1
- package/out/concepts/CallConnector__.js.map +1 -1
- package/out/concepts/CallFunction__.js +2 -2
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.js +2 -2
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.js +69 -12
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.d.ts +1 -1
- package/out/concepts/CallQueryComponent__.js +1 -1
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Comment__.js +1 -1
- package/out/concepts/Comment__.js.map +1 -1
- package/out/concepts/ConfigProperty__.js +1 -1
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Connection__.js +9 -10
- package/out/concepts/Connection__.js.map +1 -1
- package/out/concepts/Constant__.js +1 -1
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/DataSource__.js +1 -1
- package/out/concepts/DataSource__.js.map +1 -1
- package/out/concepts/Destination__.js +2 -2
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +1 -1
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityIndex__.js +1 -1
- package/out/concepts/EntityIndex__.js.map +1 -1
- package/out/concepts/EntityProperty__.js +2 -2
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.js +2 -2
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/EnumItem__.js +2 -2
- package/out/concepts/EnumItem__.js.map +1 -1
- package/out/concepts/Enum__.js +2 -2
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +27 -37
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Frontend__.js +1 -1
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/Function__.js +2 -2
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.js +1 -1
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.js +2 -2
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/Interface__.js +1 -1
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/JSBlock__.js +1 -1
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/JavaLogic__.js +1 -1
- package/out/concepts/JavaLogic__.js.map +1 -1
- package/out/concepts/LogicItem__.js +3 -2
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.js +2 -1
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MatchCase__.js +1 -1
- package/out/concepts/MatchCase__.js.map +1 -1
- package/out/concepts/Match__.js +2 -2
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/MemberExpression__.d.ts +1 -0
- package/out/concepts/MemberExpression__.js +117 -2
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.d.ts +1 -1
- package/out/concepts/Module__.js +34 -35
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/NewComposite__.js +2 -2
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/NewList__.js +2 -2
- package/out/concepts/NewList__.js.map +1 -1
- package/out/concepts/NewMap__.js +2 -2
- package/out/concepts/NewMap__.js.map +1 -1
- package/out/concepts/New__.js +1 -1
- package/out/concepts/New__.js.map +1 -1
- package/out/concepts/NullLiteral__.js +1 -1
- package/out/concepts/NullLiteral__.js.map +1 -1
- package/out/concepts/NumericLiteral__.js +1 -1
- package/out/concepts/NumericLiteral__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.js +2 -2
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/Param__.js +1 -1
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +1 -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 -1
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/QueryAggregateExpression__.js +1 -1
- package/out/concepts/QueryAggregateExpression__.js.map +1 -1
- package/out/concepts/QueryFieldExpression__.js +1 -1
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.js +1 -1
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.js +1 -1
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/QueryLimitExpression__.js +1 -1
- package/out/concepts/QueryLimitExpression__.js.map +1 -1
- package/out/concepts/QueryOrderByExpression__.js +1 -1
- package/out/concepts/QueryOrderByExpression__.js.map +1 -1
- package/out/concepts/Return__.js +2 -2
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/Role__.js +1 -1
- package/out/concepts/Role__.js.map +1 -1
- package/out/concepts/SelectMembers__.js +1 -1
- package/out/concepts/SelectMembers__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.js +2 -2
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/Start__.js +1 -1
- package/out/concepts/Start__.js.map +1 -1
- package/out/concepts/StringInterpolation__.js +2 -2
- package/out/concepts/StringInterpolation__.js.map +1 -1
- package/out/concepts/StringLiteral__.js +1 -1
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.js +2 -2
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.js +2 -2
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SwitchCase__.js +1 -1
- package/out/concepts/SwitchCase__.js.map +1 -1
- package/out/concepts/SwitchStatement__.js +2 -2
- package/out/concepts/SwitchStatement__.js.map +1 -1
- package/out/concepts/TriggerLauncher__.js +1 -1
- package/out/concepts/TriggerLauncher__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +4 -3
- package/out/concepts/TypeAnnotation__.js +116 -75
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/TypeParam__.js +1 -1
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/UnaryExpression__.js +2 -2
- package/out/concepts/UnaryExpression__.js.map +1 -1
- package/out/concepts/ValidationRule__.d.ts +14 -14
- package/out/concepts/ValidationRule__.js +28 -24
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.js +2 -2
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +88 -87
- package/out/concepts/ViewElement__.js +268 -204
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +6 -0
- package/out/concepts/View__.js +254 -11
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.js +2 -2
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.browser.js +1 -0
- package/out/concepts/basics/stdlib/nasl.browser.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.event.js +2 -0
- package/out/concepts/basics/stdlib/nasl.event.js.map +1 -1
- package/out/generator/genBundleFiles.js +90 -1
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genReleaseBody.js +1 -1
- package/out/generator/genReleaseBody.js.map +1 -1
- package/out/generator/permission.js +3 -3
- package/out/generator/permission.js.map +1 -1
- package/out/index.d.ts +1 -0
- package/out/index.js +1 -0
- package/out/index.js.map +1 -1
- package/out/natural/genNaturalTS.js +7 -3
- package/out/natural/genNaturalTS.js.map +1 -1
- package/out/natural/knowledgeMap.js +12 -12
- package/out/natural/knowledgeMap.js.map +1 -1
- package/out/natural/transformTSCode.d.ts +1 -1
- package/out/natural/transformTSCode.js +115 -141
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/server/extendBaseNode.js +69 -44
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/formatTsUtils.js +72 -63
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getLogics.js +20 -23
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.d.ts +1 -0
- package/out/server/getMemberIdentifier.js +149 -1
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/naslServer.d.ts +3 -3
- package/out/server/naslServer.js +182 -132
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +43 -33
- package/out/server/translator.js.map +1 -1
- package/out/service/defaultErrorMessage.json +6 -6
- package/out/service/storage/init.js +16 -0
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +5 -3
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +12 -8
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +8 -7
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.d.ts +1 -1
- package/out/templator/genEditTableBlock.js +12 -6
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genEnumSelectBlock.js +2 -2
- package/out/templator/genEnumSelectBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +1 -1
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.d.ts +2 -2
- package/out/templator/genGridViewBlock.js +20 -7
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.d.ts +2 -2
- package/out/templator/genListViewBlock.js +13 -5
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genSelectBlock.d.ts +2 -2
- package/out/templator/genSelectBlock.js +8 -6
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.d.ts +1 -1
- package/out/templator/genTableBlock.js +10 -5
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +5 -3
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/package.json +3 -1
- package/sandbox/stdlib/nasl.auth.ts +40 -44
- package/sandbox/stdlib/nasl.core.ts +8 -1
- package/sandbox/stdlib/nasl.http.ts +22 -22
- package/sandbox-natural/stdlib/nasl.util.ts +74 -15
- package/src/automate/upgrader/2.20.js +17 -13
- package/src/bak/translator.js +50 -1
- package/src/breakpoint/shared/utils.ts +0 -2
- package/src/common/Command.ts +8 -0
- package/src/concepts/Abort__.ts +2 -2
- package/src/concepts/Anchor__.ts +2 -2
- package/src/concepts/AnonymousFunction__.ts +3 -3
- package/src/concepts/Argument__.ts +2 -2
- package/src/concepts/Assignee__.ts +1 -1
- package/src/concepts/AssignmentLine__.ts +2 -2
- package/src/concepts/Assignment__.ts +3 -3
- package/src/concepts/BackendVariable__.ts +2 -2
- package/src/concepts/Backend__.ts +1 -1
- package/src/concepts/BatchAssignment__.ts +3 -3
- package/src/concepts/BinaryExpression__.ts +3 -3
- package/src/concepts/BindAttribute__.ts +69 -4
- package/src/concepts/BindDirective__.ts +2 -2
- package/src/concepts/BindEvent__.ts +44 -64
- package/src/concepts/BindStyle__.ts +2 -2
- package/src/concepts/BooleanLiteral__.ts +2 -2
- package/src/concepts/CallAuthInterface__.ts +2 -2
- package/src/concepts/CallConnector__.ts +2 -2
- package/src/concepts/CallFunction__.ts +3 -3
- package/src/concepts/CallInterface__.ts +3 -3
- package/src/concepts/CallLogic__.ts +69 -13
- package/src/concepts/CallQueryComponent__.ts +2 -2
- package/src/concepts/Comment__.ts +2 -2
- package/src/concepts/ConfigProperty__.ts +2 -2
- package/src/concepts/Connection__.ts +15 -21
- package/src/concepts/Constant__.ts +2 -2
- package/src/concepts/DataSource__.ts +1 -1
- package/src/concepts/Destination__.ts +3 -3
- package/src/concepts/End__.ts +2 -2
- package/src/concepts/EntityIndex__.ts +2 -2
- package/src/concepts/EntityProperty__.ts +3 -3
- package/src/concepts/Entity__.ts +2 -2
- package/src/concepts/EnumItem__.ts +3 -3
- package/src/concepts/Enum__.ts +2 -2
- package/src/concepts/ForEachStatement__.ts +35 -46
- package/src/concepts/Frontend__.ts +1 -1
- package/src/concepts/Function__.ts +3 -3
- package/src/concepts/Identifier__.ts +2 -2
- package/src/concepts/IfStatement__.ts +3 -3
- package/src/concepts/Interface__.ts +1 -1
- package/src/concepts/JSBlock__.ts +2 -2
- package/src/concepts/JavaLogic__.ts +2 -2
- package/src/concepts/LogicItem__.ts +3 -3
- package/src/concepts/Logic__.ts +2 -1
- package/src/concepts/MatchCase__.ts +2 -2
- package/src/concepts/Match__.ts +3 -3
- package/src/concepts/MemberExpression__.ts +112 -4
- package/src/concepts/Module__.ts +41 -58
- package/src/concepts/NewComposite__.ts +3 -3
- package/src/concepts/NewList__.ts +3 -3
- package/src/concepts/NewMap__.ts +3 -3
- package/src/concepts/New__.ts +2 -2
- package/src/concepts/NullLiteral__.ts +2 -2
- package/src/concepts/NumericLiteral__.ts +2 -2
- package/src/concepts/OqlQueryComponent__.ts +3 -3
- package/src/concepts/Param__.ts +2 -2
- package/src/concepts/ProcessElement__.ts +2 -2
- package/src/concepts/ProcessOutcome__.ts +2 -2
- package/src/concepts/ProcessOutcomes__.ts +2 -2
- package/src/concepts/Process__.ts +1 -1
- package/src/concepts/QueryAggregateExpression__.ts +2 -2
- package/src/concepts/QueryFieldExpression__.ts +2 -2
- package/src/concepts/QueryFromExpression__.ts +2 -2
- package/src/concepts/QueryJoinExpression__.ts +2 -2
- package/src/concepts/QueryLimitExpression__.ts +2 -2
- package/src/concepts/QueryOrderByExpression__.ts +2 -2
- package/src/concepts/Return__.ts +3 -3
- package/src/concepts/Role__.ts +1 -1
- package/src/concepts/SelectMembers__.ts +2 -2
- package/src/concepts/SqlQueryComponent__.ts +3 -3
- package/src/concepts/Start__.ts +2 -2
- package/src/concepts/StringInterpolation__.ts +3 -3
- package/src/concepts/StringLiteral__.ts +2 -2
- package/src/concepts/StructureProperty__.ts +3 -3
- package/src/concepts/Structure__.ts +2 -2
- package/src/concepts/SwitchCase__.ts +2 -2
- package/src/concepts/SwitchStatement__.ts +3 -3
- package/src/concepts/TriggerLauncher__.ts +1 -1
- package/src/concepts/TypeAnnotation__.ts +145 -125
- package/src/concepts/TypeParam__.ts +2 -2
- package/src/concepts/UnaryExpression__.ts +3 -3
- package/src/concepts/ValidationRule__.ts +554 -524
- package/src/concepts/Variable__.ts +3 -3
- package/src/concepts/ViewElement__.ts +2445 -2498
- package/src/concepts/View__.ts +258 -10
- package/src/concepts/WhileStatement__.ts +3 -3
- package/src/concepts/basics/stdlib/nasl.browser.ts +1 -0
- package/src/concepts/basics/stdlib/nasl.event.ts +2 -0
- package/src/generator/genBundleFiles.ts +91 -1
- package/src/generator/genReleaseBody.ts +1 -1
- package/src/generator/permission.ts +3 -3
- package/src/index.ts +1 -0
- package/src/natural/genNaturalTS.ts +8 -4
- package/src/natural/knowledgeMap.ts +12 -12
- package/src/natural/transformTSCode.ts +139 -151
- package/src/server/extendBaseNode.ts +71 -45
- package/src/server/formatTsUtils.ts +64 -64
- package/src/server/getLogics.ts +23 -30
- package/src/server/getMemberIdentifier.ts +143 -0
- package/src/server/naslServer.ts +174 -148
- package/src/server/translator.ts +40 -39
- package/src/service/defaultErrorMessage.json +6 -6
- package/src/service/storage/init.ts +17 -0
- package/src/templator/genCreateBlock.ts +5 -3
- package/src/templator/genCurdEditMultipleKeyBlock.ts +12 -8
- package/src/templator/genCurdMultipleKeyBlock.ts +8 -7
- package/src/templator/genEditTableBlock.ts +12 -7
- package/src/templator/genEnumSelectBlock.ts +2 -2
- package/src/templator/genGetBlock.ts +6 -6
- package/src/templator/genGridViewBlock.ts +22 -9
- package/src/templator/genListViewBlock.ts +14 -5
- package/src/templator/genSelectBlock.ts +8 -6
- package/src/templator/genTableBlock.ts +10 -9
- package/src/templator/genUpdateBlock.ts +5 -3
- package/test/concepts/validation-rule/__snapshots__/toEmbeddedTS.spec.ts.snap +11 -0
- package/test/concepts/validation-rule/__snapshots__/toJS.spec.ts.snap +10 -0
- package/test/concepts/validation-rule/fixtures/argument-without-keyword.json +34 -0
- package/test/concepts/validation-rule/fixtures/empty-rule.json +9 -0
- package/test/concepts/validation-rule/validation-rule.spec.ts +15 -0
package/src/server/naslServer.ts
CHANGED
|
@@ -4,12 +4,11 @@ import * as path from 'path';
|
|
|
4
4
|
import { Worker } from 'worker_threads';
|
|
5
5
|
/// #endif
|
|
6
6
|
|
|
7
|
-
import * as tsProtocol from 'typescript/lib/protocol';
|
|
8
|
-
import { Decimal } from 'decimal.js';
|
|
9
7
|
import { config } from '../config';
|
|
10
8
|
import { sentryMonitorNaslServer, sentryMonitorTSWorkerMessager } from '../sentry';
|
|
11
9
|
import Messager from '../common/Messager';
|
|
12
|
-
import
|
|
10
|
+
import * as tsProtocol from 'typescript/lib/protocol';
|
|
11
|
+
import { formatEnums } from '../server/getMemberIdentifier';
|
|
13
12
|
|
|
14
13
|
import {
|
|
15
14
|
Module,
|
|
@@ -83,6 +82,7 @@ import {
|
|
|
83
82
|
SynatxNode,
|
|
84
83
|
Connection,
|
|
85
84
|
TriggerLauncher,
|
|
85
|
+
CallConnector,
|
|
86
86
|
} from '../concepts';
|
|
87
87
|
import { lsp2tspNumber, SourceMap, SourceMapItem } from '../translator';
|
|
88
88
|
import axios from '../service/storage';
|
|
@@ -100,6 +100,7 @@ import { EventEmitter } from '../common/EventEmitter';
|
|
|
100
100
|
import { traverse } from '../utils';
|
|
101
101
|
import { withQueueExecute } from '../decorators';
|
|
102
102
|
|
|
103
|
+
import { Decimal } from 'decimal.js';
|
|
103
104
|
import { getNodeByNodeCallee } from '../automate/engine/utils';
|
|
104
105
|
|
|
105
106
|
const EmbeddedTSFileLineMap: { [name: string]: number } = {
|
|
@@ -140,10 +141,10 @@ interface QuoteNode {
|
|
|
140
141
|
// 批量查找节点位置的节点信息类型
|
|
141
142
|
type QuickInfoNodes = Array<{ filePath: string; node: BaseNode; item: SourceMapItem }>;
|
|
142
143
|
|
|
143
|
-
let isChangeInterface = false;
|
|
144
|
+
let isChangeInterface = false; //判断是否导入接口
|
|
144
145
|
type ActionNode = { target: Variable; typeannotation: TypeAnnotation };
|
|
145
|
-
let actionArr: Array<ActionNode> = [];
|
|
146
|
-
let timer: number = null;
|
|
146
|
+
let actionArr: Array<ActionNode> = []; //用于导入接口收集更改的节点
|
|
147
|
+
let timer: number = null; //超时器用于收集导入接口相关
|
|
147
148
|
const __naslStdlibFileCacheMap: Map<tsProtocol.OpenRequestArgs['file'], tsProtocol.OpenRequestArgs> = new Map(); // naslStdlib文件缓存
|
|
148
149
|
|
|
149
150
|
// 联合类型切割取出类型
|
|
@@ -163,18 +164,17 @@ export function getDisplayString2Type(displayString: string) {
|
|
|
163
164
|
const typeList: string[] = types[1].split(' | ').map((item: string) => {
|
|
164
165
|
if (/<([^()]+)>/g.exec(item)) {
|
|
165
166
|
return item;
|
|
166
|
-
}
|
|
167
|
-
if (item.includes(' ')) {
|
|
167
|
+
} else if (item.includes(' ')) {
|
|
168
168
|
const strs = item.split(' ');
|
|
169
169
|
const type = strs[strs.length - 1];
|
|
170
170
|
return type;
|
|
171
|
-
}
|
|
172
|
-
if (item.includes('.')) {
|
|
171
|
+
} else if (item.includes('.')) {
|
|
173
172
|
const strs = item.split('.');
|
|
174
173
|
const type = strs[strs.length - 1];
|
|
175
174
|
return type;
|
|
175
|
+
} else {
|
|
176
|
+
return item;
|
|
176
177
|
}
|
|
177
|
-
return item;
|
|
178
178
|
});
|
|
179
179
|
|
|
180
180
|
if (targetType) {
|
|
@@ -186,7 +186,6 @@ export function getDisplayString2Type(displayString: string) {
|
|
|
186
186
|
@sentryMonitorNaslServer
|
|
187
187
|
class NaslServer {
|
|
188
188
|
naslStdlibFileCacheMap = __naslStdlibFileCacheMap;
|
|
189
|
-
|
|
190
189
|
messager: Messager = undefined;
|
|
191
190
|
|
|
192
191
|
worker: Worker = undefined;
|
|
@@ -278,7 +277,7 @@ class NaslServer {
|
|
|
278
277
|
// 这个方法是 5.0 加入标准库的,但是这里 ts 版本是 4.x,ci 会挂,所以需要忽略
|
|
279
278
|
// @ts-ignore
|
|
280
279
|
const findLastIndex = this.changeStackList.findLastIndex((changeStackItem: EventPayload) => {
|
|
281
|
-
const
|
|
280
|
+
const target = changeStackItem.target;
|
|
282
281
|
const { fileNode: targetFileNode } = this.getCurrentSource(target);
|
|
283
282
|
return targetFileNode === fileNode;
|
|
284
283
|
});
|
|
@@ -288,9 +287,10 @@ class NaslServer {
|
|
|
288
287
|
if (this.changeStackList[findLastIndex]?.field) {
|
|
289
288
|
// 如果当前列表里有,这个文件节点,最后一个是field的话,直接return掉,不用塞这个update了
|
|
290
289
|
return;
|
|
290
|
+
} else {
|
|
291
|
+
// 如果最后一项是普通的update的话,就可以去掉,后面那个会在塞过来
|
|
292
|
+
this.changeStackList.pop();
|
|
291
293
|
}
|
|
292
|
-
// 如果最后一项是普通的update的话,就可以去掉,后面那个会在塞过来
|
|
293
|
-
this.changeStackList.pop();
|
|
294
294
|
}
|
|
295
295
|
this.changeStackList.push(item.originEvent);
|
|
296
296
|
} catch (err) {
|
|
@@ -327,7 +327,7 @@ class NaslServer {
|
|
|
327
327
|
Object.keys(naslStdlibMap).forEach(async (libFileName: string) => {
|
|
328
328
|
await this.addFile(
|
|
329
329
|
{
|
|
330
|
-
file:
|
|
330
|
+
file: '/' + libFileName,
|
|
331
331
|
fileContent: naslStdlibMap[libFileName],
|
|
332
332
|
},
|
|
333
333
|
{ cache: true }
|
|
@@ -536,7 +536,7 @@ class NaslServer {
|
|
|
536
536
|
}
|
|
537
537
|
|
|
538
538
|
if (module instanceof App) {
|
|
539
|
-
module.connections
|
|
539
|
+
module.connections?.forEach?.((connection) => {
|
|
540
540
|
try {
|
|
541
541
|
const result = connection.toEmbeddedTSFile();
|
|
542
542
|
results.push(result);
|
|
@@ -545,7 +545,7 @@ class NaslServer {
|
|
|
545
545
|
this.file2NodeMap.set(result.filePath, connection);
|
|
546
546
|
} catch (err) {}
|
|
547
547
|
});
|
|
548
|
-
module.triggerLaunchers
|
|
548
|
+
module.triggerLaunchers?.forEach?.((triggerLauncher) => {
|
|
549
549
|
try {
|
|
550
550
|
const result = triggerLauncher.toEmbeddedTSFile();
|
|
551
551
|
results.push(result);
|
|
@@ -640,13 +640,12 @@ class NaslServer {
|
|
|
640
640
|
cache && this.cacheFile(file);
|
|
641
641
|
return this.messager.requestCommand('addFile', file);
|
|
642
642
|
}
|
|
643
|
-
|
|
644
643
|
// 缓存添加过的文件
|
|
645
644
|
cacheFile(options: tsProtocol.OpenRequestArgs) {
|
|
646
645
|
__naslStdlibFileCacheMap.set(options.file, options);
|
|
647
646
|
}
|
|
648
647
|
|
|
649
|
-
/**
|
|
648
|
+
/**u
|
|
650
649
|
* 只新增文件
|
|
651
650
|
* @param {*} files
|
|
652
651
|
*/
|
|
@@ -678,18 +677,18 @@ class NaslServer {
|
|
|
678
677
|
}
|
|
679
678
|
/// #if process.env.NODE_ENV === 'development'
|
|
680
679
|
// 首次尝试请求
|
|
681
|
-
await axios.post(
|
|
680
|
+
await axios.post('/api/App/debugEmbedded?id=' + app.id, openFiles[0]).catch(() => (openDebugEmbedded = false));
|
|
682
681
|
|
|
683
682
|
if (openDebugEmbedded && globalThis.window) {
|
|
684
683
|
// For TS build
|
|
685
684
|
try {
|
|
686
685
|
let canDebug = true;
|
|
687
|
-
await axios.post(
|
|
686
|
+
await axios.post('/api/App/debugEmbedded?id=' + app.id, openFiles[0]).catch(() => (canDebug = false));
|
|
688
687
|
|
|
689
688
|
if (canDebug) {
|
|
690
689
|
await Promise.all(
|
|
691
690
|
openFiles.map(async (file) => {
|
|
692
|
-
const res = await axios.post(
|
|
691
|
+
const res = await axios.post('/api/App/debugEmbedded?id=' + app.id, file);
|
|
693
692
|
return res.data;
|
|
694
693
|
})
|
|
695
694
|
);
|
|
@@ -741,8 +740,9 @@ class NaslServer {
|
|
|
741
740
|
value,
|
|
742
741
|
noFilterList,
|
|
743
742
|
});
|
|
743
|
+
} else {
|
|
744
|
+
console.log('没找到节点', node, currentSource, fileNode);
|
|
744
745
|
}
|
|
745
|
-
console.log('没找到节点', node, currentSource, fileNode);
|
|
746
746
|
}
|
|
747
747
|
|
|
748
748
|
_getValueSelectCompletion(args: any) {
|
|
@@ -786,8 +786,9 @@ class NaslServer {
|
|
|
786
786
|
});
|
|
787
787
|
if (!res.length) {
|
|
788
788
|
return [];
|
|
789
|
+
} else {
|
|
790
|
+
return [{ title: '基础类型', children: res }];
|
|
789
791
|
}
|
|
790
|
-
return [{ title: '基础类型', children: res }];
|
|
791
792
|
}
|
|
792
793
|
} catch (err) {
|
|
793
794
|
console.log(err);
|
|
@@ -831,8 +832,7 @@ class NaslServer {
|
|
|
831
832
|
.replaceAll('\n', '')
|
|
832
833
|
.replace(/__name:"AStructure_\w{8}";/g, '')
|
|
833
834
|
.replace(/dataSources.([^.]+).entities.([^;]+)/g, ($1, $2, $3) => `${$3}(${$2})`);
|
|
834
|
-
}
|
|
835
|
-
if (typeStr.startsWith('{') && typeStr.endsWith('}')) {
|
|
835
|
+
} else if (typeStr.startsWith('{') && typeStr.endsWith('}')) {
|
|
836
836
|
/**
|
|
837
837
|
* {
|
|
838
838
|
text: nasl.core.String;
|
|
@@ -864,7 +864,6 @@ class NaslServer {
|
|
|
864
864
|
}
|
|
865
865
|
return '';
|
|
866
866
|
}
|
|
867
|
-
|
|
868
867
|
async getDataSchemaStructureOrTypeAnnotation(node: ViewElement) {
|
|
869
868
|
if (!(node instanceof ViewElement)) return;
|
|
870
869
|
|
|
@@ -884,7 +883,7 @@ class NaslServer {
|
|
|
884
883
|
|
|
885
884
|
const types = /<([^()]+)>/g.exec(displayString);
|
|
886
885
|
const typeStr = types && types[1];
|
|
887
|
-
const
|
|
886
|
+
const app = node.app;
|
|
888
887
|
if (typeStr.includes('__name: "AStructure_')) {
|
|
889
888
|
const properties: StructureProperty[] = [];
|
|
890
889
|
typeStr.replace(/([^:\s]+):\s+([^;]+);/g, ($1, name, typeKey) => {
|
|
@@ -907,8 +906,7 @@ class NaslServer {
|
|
|
907
906
|
return '';
|
|
908
907
|
});
|
|
909
908
|
return TypeAnnotation.createTypeAnonymousStructure(properties);
|
|
910
|
-
}
|
|
911
|
-
if (typeStr.startsWith('structures')) return app.findNodeByCompleteName(`app.${typeStr}`);
|
|
909
|
+
} else if (typeStr.startsWith('structures')) return app.findNodeByCompleteName(`app.${typeStr}`);
|
|
912
910
|
}
|
|
913
911
|
}
|
|
914
912
|
|
|
@@ -975,8 +973,9 @@ class NaslServer {
|
|
|
975
973
|
},
|
|
976
974
|
noFilterList,
|
|
977
975
|
});
|
|
976
|
+
} else {
|
|
977
|
+
console.log('没找到节点', currentSource, fileNode);
|
|
978
978
|
}
|
|
979
|
-
console.log('没找到节点', currentSource, fileNode);
|
|
980
979
|
}
|
|
981
980
|
|
|
982
981
|
_getSelectNextCompletion(args: any) {
|
|
@@ -995,7 +994,6 @@ class NaslServer {
|
|
|
995
994
|
if (node.tsErrorDetail) return;
|
|
996
995
|
node.tsErrorDetail = tsErrorDetail;
|
|
997
996
|
}
|
|
998
|
-
|
|
999
997
|
/**
|
|
1000
998
|
* 处理诊断结果
|
|
1001
999
|
* @param records 结果
|
|
@@ -1009,7 +1007,7 @@ class NaslServer {
|
|
|
1009
1007
|
}
|
|
1010
1008
|
await Promise.all(
|
|
1011
1009
|
records.map(async (record) => {
|
|
1012
|
-
const
|
|
1010
|
+
const node = record.node;
|
|
1013
1011
|
if (!node) return;
|
|
1014
1012
|
|
|
1015
1013
|
// 先获取原来的节点先清除一下之前有异常的节点,下面重新赋值
|
|
@@ -1069,8 +1067,7 @@ class NaslServer {
|
|
|
1069
1067
|
if (diagnostic.severity === 'warning') {
|
|
1070
1068
|
record.suggestionDiagnostics.push(diagnostic);
|
|
1071
1069
|
return null;
|
|
1072
|
-
}
|
|
1073
|
-
if (currentNode.concept === 'OqlQueryComponent') {
|
|
1070
|
+
} else if (currentNode.concept === 'OqlQueryComponent') {
|
|
1074
1071
|
// OQL别名错误降级为警告
|
|
1075
1072
|
if (diagnostic.originalDiagnostic && diagnostic.originalDiagnostic?.text.includes('__OQL_ALIAS_WARNING__')) {
|
|
1076
1073
|
// 重置 图标和错误等级
|
|
@@ -1115,8 +1112,7 @@ class NaslServer {
|
|
|
1115
1112
|
if (diag?.node) {
|
|
1116
1113
|
return diag;
|
|
1117
1114
|
// 一些已知警告的单独处理
|
|
1118
|
-
}
|
|
1119
|
-
if (
|
|
1115
|
+
} else if (
|
|
1120
1116
|
[
|
|
1121
1117
|
`'__LogicEmpty' is declared but its value is never read.`,
|
|
1122
1118
|
`'__destinationEmpty__' is declared but its value is never read.`,
|
|
@@ -1126,8 +1122,7 @@ class NaslServer {
|
|
|
1126
1122
|
].includes(diag.text)
|
|
1127
1123
|
) {
|
|
1128
1124
|
return this._resolveDiagnostic(diag as unknown as tsProtocol.DiagnosticWithFileName, record.node as FileNode, record);
|
|
1129
|
-
}
|
|
1130
|
-
if (diag.text.includes(` is declared but its value is never read.`)) {
|
|
1125
|
+
} else if (diag.text.includes(` is declared but its value is never read.`)) {
|
|
1131
1126
|
// 局部变量和输入变量未使用的警告
|
|
1132
1127
|
const fromModule = record.node.parentNode.concept === 'Module';
|
|
1133
1128
|
const fromConnector = record.node.parentNode.concept === 'Connector';
|
|
@@ -1156,8 +1151,7 @@ class NaslServer {
|
|
|
1156
1151
|
message: `未使用的输入参数${minRange.node.name}`,
|
|
1157
1152
|
};
|
|
1158
1153
|
return diagnostic;
|
|
1159
|
-
}
|
|
1160
|
-
if (minRange.node instanceof Variable) {
|
|
1154
|
+
} else if (minRange.node instanceof Variable) {
|
|
1161
1155
|
const diagnostic = {
|
|
1162
1156
|
node: minRange.node,
|
|
1163
1157
|
severity: 'warning',
|
|
@@ -1341,7 +1335,7 @@ class NaslServer {
|
|
|
1341
1335
|
const typeAnnotation = item.__TypeAnnotation;
|
|
1342
1336
|
// 仅处理有类型的情况,返回类型为void的情况由其他地方处理成报错
|
|
1343
1337
|
if (typeAnnotation) {
|
|
1344
|
-
const
|
|
1338
|
+
const sortedTypeKey = typeAnnotation.sortedTypeKey;
|
|
1345
1339
|
if (!typeAnnotationMap[sortedTypeKey]) {
|
|
1346
1340
|
typeAnnotationMap[sortedTypeKey] = {
|
|
1347
1341
|
typeAnnotation,
|
|
@@ -1393,7 +1387,7 @@ class NaslServer {
|
|
|
1393
1387
|
const typeAnnotation = value.__TypeAnnotation;
|
|
1394
1388
|
// 仅处理有类型的情况,返回类型为void的情况由其他地方处理成报错
|
|
1395
1389
|
if (typeAnnotation) {
|
|
1396
|
-
const
|
|
1390
|
+
const sortedTypeKey = typeAnnotation.sortedTypeKey;
|
|
1397
1391
|
if (!typeAnnotationMap[sortedTypeKey]) {
|
|
1398
1392
|
typeAnnotationMap[sortedTypeKey] = {
|
|
1399
1393
|
typeAnnotation,
|
|
@@ -1668,16 +1662,16 @@ class NaslServer {
|
|
|
1668
1662
|
} catch (err) {
|
|
1669
1663
|
console.log(err);
|
|
1670
1664
|
}
|
|
1671
|
-
if (!jsCode.
|
|
1665
|
+
if (!jsCode.startsWith(`${node.name} = `)) return;
|
|
1672
1666
|
// 页面局部变量
|
|
1673
1667
|
if (node instanceof Variable && node.parentNode instanceof View) {
|
|
1674
1668
|
// 跟页面局部变量无关的赋值过滤
|
|
1675
|
-
if (!jsCode.
|
|
1669
|
+
if (!jsCode.startsWith(`this.${node.name} = `)) return;
|
|
1676
1670
|
// 直接赋值 logic 内局部变量、输入参数直接提示系统无法推断类型
|
|
1677
1671
|
if (
|
|
1678
|
-
nodeIn.logic?.params.find((param) => jsCode.
|
|
1679
|
-
nodeIn.logic?.virtualParams.find((vParam) => jsCode.
|
|
1680
|
-
nodeIn.logic?.variables.find((variable) => jsCode.
|
|
1672
|
+
nodeIn.logic?.params.find((param) => jsCode.startsWith(param.name)) ||
|
|
1673
|
+
nodeIn.logic?.virtualParams.find((vParam) => jsCode.startsWith(vParam.name)) ||
|
|
1674
|
+
nodeIn.logic?.variables.find((variable) => jsCode.startsWith(variable.name))
|
|
1681
1675
|
) {
|
|
1682
1676
|
if (!nodeIn.tsErrorDetail) {
|
|
1683
1677
|
const diagnostic = {
|
|
@@ -1716,17 +1710,17 @@ class NaslServer {
|
|
|
1716
1710
|
if (Array.isArray(node.bindExpressions)) {
|
|
1717
1711
|
const exp = node.bindExpressions.find((bindExpression) => this.hasComponentLogics(bindExpression));
|
|
1718
1712
|
if (exp) {
|
|
1719
|
-
//
|
|
1720
|
-
//
|
|
1721
|
-
//
|
|
1713
|
+
//const element: any = node.getAncestor('ViewElement');
|
|
1714
|
+
//const api = config.allNodesAPI[element?.tag];
|
|
1715
|
+
//const attr = api?.attrs?.find?.((attr) => {
|
|
1722
1716
|
// return attr.name === node.name;
|
|
1723
|
-
//
|
|
1717
|
+
//});
|
|
1724
1718
|
const map = {
|
|
1725
1719
|
BindAttribute: '属性',
|
|
1726
1720
|
BindDirective: '指令',
|
|
1727
1721
|
BindStyle: '样式属性',
|
|
1728
1722
|
};
|
|
1729
|
-
|
|
1723
|
+
//“${attr?.title || node.title || node.name}”
|
|
1730
1724
|
const diagnostic = {
|
|
1731
1725
|
node,
|
|
1732
1726
|
severity: 'error',
|
|
@@ -1888,7 +1882,7 @@ class NaslServer {
|
|
|
1888
1882
|
const { default: defaultVal } = precisionOption || {};
|
|
1889
1883
|
const precision = databaseTypeAnnotation ? (databaseTypeAnnotation.arguments as any)?.precision : defaultVal;
|
|
1890
1884
|
const ruleScale = (typeAnnotation?.ruleMap as any)?.scale;
|
|
1891
|
-
const scale = ruleScale !== undefined ?
|
|
1885
|
+
const scale = ruleScale !== undefined ? ruleScale + '' : '';
|
|
1892
1886
|
let ensureScale = true;
|
|
1893
1887
|
switch (typeName) {
|
|
1894
1888
|
case 'String': {
|
|
@@ -1987,7 +1981,7 @@ class NaslServer {
|
|
|
1987
1981
|
// 储存小数部分
|
|
1988
1982
|
const memoryScaleStr = memoryStr.slice(0, +(scale || '0'));
|
|
1989
1983
|
// 储存绝对值
|
|
1990
|
-
const memoryAbsVal = memoryIntAbsStr + (memoryScaleStr ?
|
|
1984
|
+
const memoryAbsVal = memoryIntAbsStr + (memoryScaleStr ? '.' + memoryScaleStr : '');
|
|
1991
1985
|
const decimalMemoryAbsVal = new Decimal(memoryAbsVal);
|
|
1992
1986
|
[
|
|
1993
1987
|
{
|
|
@@ -2055,7 +2049,7 @@ class NaslServer {
|
|
|
2055
2049
|
diagnostics.push(diagnostic);
|
|
2056
2050
|
}
|
|
2057
2051
|
fileNode?.sourceMap.forEach((value, node) => {
|
|
2058
|
-
//
|
|
2052
|
+
//OQL支持返回复合类型数据了
|
|
2059
2053
|
// SqlQueryComponent内部返回值类型,如果是嵌套的就需要报错
|
|
2060
2054
|
// if ((node instanceof OqlQueryComponent || node instanceof SqlQueryComponent) && (node as SqlQueryComponent).getTypeBanError()) {
|
|
2061
2055
|
// const diagnostic = {
|
|
@@ -2071,7 +2065,7 @@ class NaslServer {
|
|
|
2071
2065
|
const typeAnnotation = type2TypeAnnotation((node as any).__nodeType);
|
|
2072
2066
|
if (!node.typeAnnotation && typeAnnotation) {
|
|
2073
2067
|
if (typeAnnotation.typeName === 'List' && typeAnnotation.typeKind === 'generic') {
|
|
2074
|
-
const
|
|
2068
|
+
const typeArguments = typeAnnotation.typeArguments;
|
|
2075
2069
|
if (typeArguments.length && typeArguments[0].isComplexType()) {
|
|
2076
2070
|
const diagnostic = {
|
|
2077
2071
|
node,
|
|
@@ -2096,7 +2090,7 @@ class NaslServer {
|
|
|
2096
2090
|
} catch (err) {
|
|
2097
2091
|
console.log(err);
|
|
2098
2092
|
}
|
|
2099
|
-
if (jsCode.
|
|
2093
|
+
if (jsCode.startsWith(`${node.name} = `)) {
|
|
2100
2094
|
used = true;
|
|
2101
2095
|
if (!nodeIn.tsErrorDetail) {
|
|
2102
2096
|
const diagnostic = {
|
|
@@ -2266,6 +2260,17 @@ class NaslServer {
|
|
|
2266
2260
|
node.tsErrorDetail = diagnostic;
|
|
2267
2261
|
diagnostics.push(diagnostic);
|
|
2268
2262
|
}
|
|
2263
|
+
if (node instanceof ForEachStatement && !node.end && node.each) {
|
|
2264
|
+
if (!['List'].includes(node.each.__TypeAnnotation?.typeName)) {
|
|
2265
|
+
const diagnostic = {
|
|
2266
|
+
node,
|
|
2267
|
+
severity: 'error',
|
|
2268
|
+
message: `ForEac1:循环列表:参数类型不匹配!结束值自动推导失败。`,
|
|
2269
|
+
};
|
|
2270
|
+
node.tsErrorDetail = diagnostic;
|
|
2271
|
+
diagnostics.push(diagnostic);
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2269
2274
|
/**
|
|
2270
2275
|
* 如果节点是内置函数
|
|
2271
2276
|
* 穷举在线上的情况,不在线上就void报错, callinterface 因为原来有报错,所以就忽略掉
|
|
@@ -2349,8 +2354,7 @@ class NaslServer {
|
|
|
2349
2354
|
// 先特殊处理等 类型合并后就可以去掉了
|
|
2350
2355
|
if (excludeList.includes(leftType.sortedTypeKey) && excludeList.includes(rightType.sortedTypeKey)) {
|
|
2351
2356
|
return null;
|
|
2352
|
-
}
|
|
2353
|
-
if (excludeList2.includes(leftType.sortedTypeKey) || excludeList2.includes(rightType.sortedTypeKey)) {
|
|
2357
|
+
} else if (excludeList2.includes(leftType.sortedTypeKey) || excludeList2.includes(rightType.sortedTypeKey)) {
|
|
2354
2358
|
return null;
|
|
2355
2359
|
}
|
|
2356
2360
|
const diagnostic = {
|
|
@@ -2390,7 +2394,7 @@ class NaslServer {
|
|
|
2390
2394
|
if (typeKeyArr[0] === 'apis') {
|
|
2391
2395
|
const structureName = typeKeyArr[3];
|
|
2392
2396
|
const moduleName = typeKeyArr[1];
|
|
2393
|
-
const
|
|
2397
|
+
const app = (typeAnnotation.upperNode as Variable).app;
|
|
2394
2398
|
if (!app) {
|
|
2395
2399
|
return null;
|
|
2396
2400
|
}
|
|
@@ -2406,13 +2410,14 @@ class NaslServer {
|
|
|
2406
2410
|
}
|
|
2407
2411
|
}
|
|
2408
2412
|
return null;
|
|
2413
|
+
} else {
|
|
2414
|
+
return diag;
|
|
2409
2415
|
}
|
|
2410
|
-
return diag;
|
|
2411
2416
|
});
|
|
2412
2417
|
if (actionArr.length) {
|
|
2413
2418
|
if (timer) return;
|
|
2414
2419
|
timer = window.setTimeout(() => {
|
|
2415
|
-
const
|
|
2420
|
+
const app = actionArr[0].target.app;
|
|
2416
2421
|
app.emit('collect:start', {
|
|
2417
2422
|
actionMsg: '设置导入接口数据类型错误',
|
|
2418
2423
|
});
|
|
@@ -2476,8 +2481,9 @@ class NaslServer {
|
|
|
2476
2481
|
*/
|
|
2477
2482
|
_findMinRange(diagnostic: tsProtocol.DiagnosticWithFileName | tsProtocol.ReferencesResponseItem, fileNode: FileNode) {
|
|
2478
2483
|
let minRange: MinRange;
|
|
2479
|
-
const
|
|
2480
|
-
|
|
2484
|
+
const sourceMap: SourceMap = fileNode.sourceMap;
|
|
2485
|
+
// 是否找到了行内准确的,是的话,就不走多行的
|
|
2486
|
+
let haveLineNode = false;
|
|
2481
2487
|
for (const [node, item] of sourceMap.entries()) {
|
|
2482
2488
|
/**
|
|
2483
2489
|
* 当前内容的开始行 <= 诊断开始的行 &&
|
|
@@ -2497,6 +2503,7 @@ class NaslServer {
|
|
|
2497
2503
|
// if for的内容也是包括当前的所以会重新赋值
|
|
2498
2504
|
if (!minRange || item.code.length < minRange.item.code.length) {
|
|
2499
2505
|
minRange = { item, node };
|
|
2506
|
+
haveLineNode = true;
|
|
2500
2507
|
}
|
|
2501
2508
|
}
|
|
2502
2509
|
} else {
|
|
@@ -2504,27 +2511,31 @@ class NaslServer {
|
|
|
2504
2511
|
// 一般出现在一大块上,多半是if for 等等没有参数
|
|
2505
2512
|
if (!minRange) {
|
|
2506
2513
|
minRange = { node, item };
|
|
2507
|
-
} else if (
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2514
|
+
} else if (!haveLineNode) {
|
|
2515
|
+
if (
|
|
2516
|
+
lsp2tspNumber(item.range.start.line) === diagnostic.start.line &&
|
|
2517
|
+
diagnostic.start.offset >= lsp2tspNumber(item.range.start.character)
|
|
2518
|
+
) {
|
|
2519
|
+
// 如果当前遍历的内容的行和列都 小于之前的, 而且是有效的
|
|
2520
|
+
// 如果两个内容位置行数是一样的,就比较下找到内容的位置信息
|
|
2521
|
+
// 找到的内容的开始位置, 要大于申明内容开始的位置,要不就不包含在内了
|
|
2522
|
+
if (diagnostic.start.offset - item.range.start.character <= diagnostic.start.offset - minRange.item.range.start.character) {
|
|
2523
|
+
minRange = { node, item };
|
|
2524
|
+
} else {
|
|
2525
|
+
if (diagnostic.start.offset < lsp2tspNumber(minRange.item.range.start.character)) {
|
|
2526
|
+
minRange = { node, item };
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
} else if (item.range.end.line - item.range.start.line <= minRange.item.range.end.line - minRange.item.range.start.line) {
|
|
2530
|
+
// 行都一致 ,比较列
|
|
2531
|
+
if (minRange.item.range.start.line === item.range.start.line && minRange.item.range.end.line === item.range.end.line) {
|
|
2532
|
+
// 如果两个起始和结束的行都一样,那么就比较开始列, 要比原来大,说明更精准
|
|
2533
|
+
if (item.range.start.character > minRange.item.range.start.character) {
|
|
2534
|
+
minRange = { node, item };
|
|
2535
|
+
}
|
|
2536
|
+
} else {
|
|
2524
2537
|
minRange = { node, item };
|
|
2525
2538
|
}
|
|
2526
|
-
} else {
|
|
2527
|
-
minRange = { node, item };
|
|
2528
2539
|
}
|
|
2529
2540
|
}
|
|
2530
2541
|
}
|
|
@@ -2557,21 +2568,23 @@ class NaslServer {
|
|
|
2557
2568
|
offset: lsp2tspNumber(currentSource.range.start.character),
|
|
2558
2569
|
});
|
|
2559
2570
|
refsList = [...newRefs.refs];
|
|
2560
|
-
} else
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2571
|
+
} else {
|
|
2572
|
+
if (node instanceof Module) {
|
|
2573
|
+
const lists = node.logics || node.structures || node.enums;
|
|
2574
|
+
const moduleName = (fileNode as FileNode).getEmbeddedFilePath();
|
|
2575
|
+
if (lists.length) {
|
|
2576
|
+
const item = lists[0];
|
|
2577
|
+
const { fileNode } = this.getCurrentSource(item);
|
|
2578
|
+
if (fileNode) {
|
|
2579
|
+
const newRefs = await this.references({
|
|
2580
|
+
file: (fileNode as FileNode).getEmbeddedFilePath(),
|
|
2581
|
+
line: 1,
|
|
2582
|
+
offset: 22, //固定的位置,module的位置信息
|
|
2583
|
+
});
|
|
2584
|
+
refsList = newRefs.refs.filter((item) => !item.file.startsWith(moduleName));
|
|
2585
|
+
// 多塞一个 ,删除的时候就有值了, 上面过滤了之后可能是空的
|
|
2586
|
+
refsList.unshift(newRefs.refs[0]);
|
|
2587
|
+
}
|
|
2575
2588
|
}
|
|
2576
2589
|
}
|
|
2577
2590
|
}
|
|
@@ -2634,7 +2647,7 @@ class NaslServer {
|
|
|
2634
2647
|
).length;
|
|
2635
2648
|
if (!groupByLength && !aggregateLength && callQueryComponentTypeAnnotation.typeKind === 'anonymousStructure') {
|
|
2636
2649
|
// 拿到 List 的泛型(匿名数据结构)的所有属性
|
|
2637
|
-
const
|
|
2650
|
+
const properties = callQueryComponentTypeAnnotation.properties[0].typeAnnotation.typeArguments[0].properties;
|
|
2638
2651
|
const targetProperty = properties.find((p) => p.name === utils.firstLowerCase(node.name));
|
|
2639
2652
|
if (!targetProperty) {
|
|
2640
2653
|
continue;
|
|
@@ -2686,7 +2699,7 @@ class NaslServer {
|
|
|
2686
2699
|
if (node instanceof Param && (node.parentNode instanceof View || node.parentNode instanceof Process)) {
|
|
2687
2700
|
const viewNode = node.parentNode;
|
|
2688
2701
|
const { currentSource } = this.getCurrentSource(viewNode);
|
|
2689
|
-
const
|
|
2702
|
+
const code = currentSource.code;
|
|
2690
2703
|
const viewIndex = code.indexOf(' {');
|
|
2691
2704
|
const viewRefs = await this.references({
|
|
2692
2705
|
file: (fileNode as FileNode).getEmbeddedFilePath(),
|
|
@@ -2724,7 +2737,7 @@ class NaslServer {
|
|
|
2724
2737
|
*/
|
|
2725
2738
|
if (node instanceof ViewElement) {
|
|
2726
2739
|
if (currentSource) {
|
|
2727
|
-
const
|
|
2740
|
+
const code = currentSource.code;
|
|
2728
2741
|
const prefix = '__elements.';
|
|
2729
2742
|
const prefixIndex = code.indexOf(prefix) !== -1 ? code.indexOf(prefix) : 0;
|
|
2730
2743
|
const methodsNameIndex = prefixIndex + prefix.length;
|
|
@@ -2750,7 +2763,7 @@ class NaslServer {
|
|
|
2750
2763
|
}
|
|
2751
2764
|
if (node instanceof Process) {
|
|
2752
2765
|
if (currentSource) {
|
|
2753
|
-
const
|
|
2766
|
+
const code = currentSource.code;
|
|
2754
2767
|
const prefix = '__ProcessIdentification__';
|
|
2755
2768
|
let positions = [];
|
|
2756
2769
|
let pos = code.indexOf(prefix);
|
|
@@ -2777,7 +2790,7 @@ class NaslServer {
|
|
|
2777
2790
|
if ((node instanceof Param || node instanceof Return) && node.parentNode instanceof Process) {
|
|
2778
2791
|
const { currentSource } = this.getCurrentSource(node.parentNode);
|
|
2779
2792
|
if (currentSource) {
|
|
2780
|
-
const
|
|
2793
|
+
const code = currentSource.code;
|
|
2781
2794
|
const prefix = '__ProcessIdentification__';
|
|
2782
2795
|
const positions = [];
|
|
2783
2796
|
let pos = code.indexOf(prefix);
|
|
@@ -2807,7 +2820,7 @@ class NaslServer {
|
|
|
2807
2820
|
}
|
|
2808
2821
|
if (node instanceof ProcessElement) {
|
|
2809
2822
|
if (currentSource) {
|
|
2810
|
-
const
|
|
2823
|
+
const code = currentSource.code;
|
|
2811
2824
|
const prefix = '__ProcessIdentification__';
|
|
2812
2825
|
let positions = [];
|
|
2813
2826
|
let pos = code.indexOf(prefix);
|
|
@@ -2833,7 +2846,7 @@ class NaslServer {
|
|
|
2833
2846
|
if (node instanceof Return && node.parentNode instanceof ProcessElement) {
|
|
2834
2847
|
const { currentSource } = this.getCurrentSource(node.parentNode);
|
|
2835
2848
|
if (currentSource) {
|
|
2836
|
-
const
|
|
2849
|
+
const code = currentSource.code;
|
|
2837
2850
|
const prefix = '__ProcessIdentification__';
|
|
2838
2851
|
const positions = [];
|
|
2839
2852
|
let pos = code.indexOf(prefix);
|
|
@@ -2899,13 +2912,16 @@ class NaslServer {
|
|
|
2899
2912
|
// }
|
|
2900
2913
|
minRange.setTypeMethods = 'setTypeName';
|
|
2901
2914
|
}
|
|
2915
|
+
if (minRange.node instanceof CallConnector) {
|
|
2916
|
+
minRange.setTypeMethods = 'setCalleeConnectionName';
|
|
2917
|
+
}
|
|
2902
2918
|
// 如果节点是logic修改引发calllogic修改
|
|
2903
2919
|
if (minRange.node instanceof CallLogic && node instanceof Logic) {
|
|
2904
2920
|
minRange.setTypeMethods = 'setCalleeName';
|
|
2905
2921
|
}
|
|
2906
2922
|
if (minRange.node instanceof CallLogic && node instanceof ViewElement) {
|
|
2907
2923
|
minRange.setTypeMethods = 'setCalleeNamespace';
|
|
2908
|
-
minRange.newValue =
|
|
2924
|
+
minRange.newValue = 'elements.' + newValue + '.logics';
|
|
2909
2925
|
}
|
|
2910
2926
|
// 如果节点是实体修改引发calllogic修改
|
|
2911
2927
|
if (
|
|
@@ -2924,9 +2940,9 @@ class NaslServer {
|
|
|
2924
2940
|
* 3.然后把namespace中的 $替换成 ''
|
|
2925
2941
|
*
|
|
2926
2942
|
*/
|
|
2927
|
-
const
|
|
2943
|
+
const tsCalleeNamespace = minRange.node.tsCalleeNamespace;
|
|
2928
2944
|
// 先看下标位置
|
|
2929
|
-
const
|
|
2945
|
+
const lineText = record.lineText;
|
|
2930
2946
|
const index = lineText.indexOf(tsCalleeNamespace);
|
|
2931
2947
|
// 在把开始结束位置的-开始位置,来知道是哪里要替换
|
|
2932
2948
|
const start = record.start.offset - index - 1;
|
|
@@ -2961,12 +2977,12 @@ class NaslServer {
|
|
|
2961
2977
|
if (minRange.node instanceof Identifier) {
|
|
2962
2978
|
// 匹配到的内容,当前这一行的内容;
|
|
2963
2979
|
// 因为要用下面的点位信息
|
|
2964
|
-
const
|
|
2980
|
+
const name = minRange.node.name;
|
|
2965
2981
|
// 如果name不改,那就是要改命名空间
|
|
2966
2982
|
if (node instanceof Frontend || newValue === name) {
|
|
2967
|
-
const
|
|
2983
|
+
const namespace = minRange.node.namespace;
|
|
2968
2984
|
// 先看下标位置
|
|
2969
|
-
const
|
|
2985
|
+
const lineText = record.lineText;
|
|
2970
2986
|
const index = lineText.indexOf(namespace);
|
|
2971
2987
|
// 在把开始结束位置的-开始位置,来知道是哪里要替换
|
|
2972
2988
|
const start = record.start.offset - index - 1;
|
|
@@ -2997,7 +3013,7 @@ class NaslServer {
|
|
|
2997
3013
|
// 枚举key的特殊性,因为它不是原来的key+value形式的
|
|
2998
3014
|
// 是加了中括号啥的,所以直接赋值新值
|
|
2999
3015
|
if (node instanceof EnumItem) {
|
|
3000
|
-
const newTextValue =
|
|
3016
|
+
const newTextValue = node.parentNode.name + '.' + newValue;
|
|
3001
3017
|
minRange.newValue = newTextValue;
|
|
3002
3018
|
} else {
|
|
3003
3019
|
// 匹配到的内容,当前这一行的内容;
|
|
@@ -3032,7 +3048,7 @@ class NaslServer {
|
|
|
3032
3048
|
minRange.setTypeMethods = 'setEntityNameAndEffect';
|
|
3033
3049
|
} else if (minRange.node instanceof BindAttribute && minRange.node.name === 'url') {
|
|
3034
3050
|
// 如果是查找到 上传地址的链接引用
|
|
3035
|
-
let newName = newValue.replace(/[A-Z]/g, (item) =>
|
|
3051
|
+
let newName = newValue.replace(/[A-Z]/g, (item) => '-' + item.toLowerCase());
|
|
3036
3052
|
newName = newName[0] === '-' ? newName.slice(1) : newName;
|
|
3037
3053
|
const newTextValue = node.parentNode.name === 'defaultDS' ? `/api/${newName}/import` : `/api/${node.parentNode.name}/${newName}/import`;
|
|
3038
3054
|
minRange.setTypeMethods = 'setUrlValue';
|
|
@@ -3074,11 +3090,11 @@ class NaslServer {
|
|
|
3074
3090
|
* 3.然后把namespace中的 $替换成 ''
|
|
3075
3091
|
*
|
|
3076
3092
|
*/
|
|
3077
|
-
const
|
|
3078
|
-
const
|
|
3079
|
-
const oldValue =
|
|
3093
|
+
const tsCalleeNamespace = minRange.node.tsCalleeNamespace;
|
|
3094
|
+
const tsName = minRange.node.tsName;
|
|
3095
|
+
const oldValue = tsCalleeNamespace + '.' + tsName;
|
|
3080
3096
|
// 先看下标位置
|
|
3081
|
-
const
|
|
3097
|
+
const lineText = record.lineText;
|
|
3082
3098
|
const index = lineText.indexOf(oldValue);
|
|
3083
3099
|
// 在把开始结束位置的-开始位置,来知道是哪里要替换
|
|
3084
3100
|
const start = record.start.offset - index - 1;
|
|
@@ -3095,11 +3111,11 @@ class NaslServer {
|
|
|
3095
3111
|
}
|
|
3096
3112
|
}
|
|
3097
3113
|
if (node instanceof Frontend && minRange.node instanceof Destination) {
|
|
3098
|
-
const
|
|
3099
|
-
const
|
|
3100
|
-
const oldValue =
|
|
3114
|
+
const tsCalleeNamespace = minRange.node.tsCalleeNamespace;
|
|
3115
|
+
const tsName = minRange.node.tsName;
|
|
3116
|
+
const oldValue = tsCalleeNamespace + '.' + tsName;
|
|
3101
3117
|
// 先看下标位置
|
|
3102
|
-
const
|
|
3118
|
+
const lineText = record.lineText;
|
|
3103
3119
|
const index = lineText.indexOf(oldValue);
|
|
3104
3120
|
// 在把开始结束位置的-开始位置,来知道是哪里要替换
|
|
3105
3121
|
const start = record.start.offset - index - 1;
|
|
@@ -3119,7 +3135,7 @@ class NaslServer {
|
|
|
3119
3135
|
// 页面逻辑直接赋值就可以, 因为是相对路径
|
|
3120
3136
|
if (node instanceof ViewElement) {
|
|
3121
3137
|
minRange.setTypeMethods = 'setCalleeNamespace';
|
|
3122
|
-
minRange.newValue =
|
|
3138
|
+
minRange.newValue = 'elements.' + newValue + '.logics';
|
|
3123
3139
|
} else {
|
|
3124
3140
|
/**
|
|
3125
3141
|
* 如果namespce是 'app.views.Student.views.404.views.505.views.update'
|
|
@@ -3130,11 +3146,11 @@ class NaslServer {
|
|
|
3130
3146
|
* 2.在匹配到的内容中取转后的namespace的位置
|
|
3131
3147
|
* 3.然后把namespace中的 $替换成 ''
|
|
3132
3148
|
*/
|
|
3133
|
-
const
|
|
3149
|
+
const tsCalleeNamespace = minRange.node.tsCalleeNamespace;
|
|
3134
3150
|
const oldValue = tsCalleeNamespace;
|
|
3135
3151
|
|
|
3136
3152
|
// 先看下标位置
|
|
3137
|
-
const
|
|
3153
|
+
const lineText = record.lineText;
|
|
3138
3154
|
const index = lineText.indexOf(oldValue);
|
|
3139
3155
|
|
|
3140
3156
|
// 在把开始结束位置的-开始位置,来知道是哪里要替换
|
|
@@ -3197,7 +3213,7 @@ class NaslServer {
|
|
|
3197
3213
|
if (node instanceof DataSource) {
|
|
3198
3214
|
const setTypeNamespace = (typeNamespace: string, record: any) => {
|
|
3199
3215
|
// 先看下标位置
|
|
3200
|
-
const
|
|
3216
|
+
const lineText = record.lineText;
|
|
3201
3217
|
const index = lineText.indexOf(typeNamespace);
|
|
3202
3218
|
// 在把开始结束位置的-开始位置,来知道是哪里要替换
|
|
3203
3219
|
const start = record.start.offset - index - 1;
|
|
@@ -3322,8 +3338,7 @@ class NaslServer {
|
|
|
3322
3338
|
.sort((a, b) => {
|
|
3323
3339
|
if (a.node.concept === 'QueryFieldExpression') {
|
|
3324
3340
|
return 1;
|
|
3325
|
-
}
|
|
3326
|
-
if (b.node.concept === 'QueryFieldExpression') {
|
|
3341
|
+
} else if (b.node.concept === 'QueryFieldExpression') {
|
|
3327
3342
|
return -1;
|
|
3328
3343
|
}
|
|
3329
3344
|
return 0;
|
|
@@ -3454,7 +3469,7 @@ class NaslServer {
|
|
|
3454
3469
|
const queue: any[] = [];
|
|
3455
3470
|
// 先插入自己,如果没有在往上找,
|
|
3456
3471
|
// 一直到file节点的父级
|
|
3457
|
-
while (!(parantNode instanceof App)) {
|
|
3472
|
+
while (parantNode && !(parantNode instanceof App)) {
|
|
3458
3473
|
// 找到上一级 在map对象中构造出他的子集
|
|
3459
3474
|
currentNode = parantNode;
|
|
3460
3475
|
parantNode = parantNode.parentNode;
|
|
@@ -3565,7 +3580,7 @@ class NaslServer {
|
|
|
3565
3580
|
*/
|
|
3566
3581
|
getCurrentSource(node: BaseNode) {
|
|
3567
3582
|
if (node instanceof App || node instanceof Theme) return { fileNode: null };
|
|
3568
|
-
let
|
|
3583
|
+
let sourceMap = node.sourceMap;
|
|
3569
3584
|
let fileNode = node;
|
|
3570
3585
|
// 如果没有sourceMap,就继续向上找 ,或者到module结束
|
|
3571
3586
|
// 如果 节点找到 app 或者module 停止 或者entity找到DataSource为止
|
|
@@ -3607,16 +3622,27 @@ class NaslServer {
|
|
|
3607
3622
|
getFieldKeySelectCompletion(node: BaseNode, fieldKey?: string) {
|
|
3608
3623
|
const { currentSource, fileNode } = this.getCurrentSource(node);
|
|
3609
3624
|
if (currentSource && fileNode) {
|
|
3625
|
+
const range = {
|
|
3626
|
+
line: lsp2tspNumber(currentSource.range.start.line),
|
|
3627
|
+
offset: lsp2tspNumber(currentSource.range.start.character),
|
|
3628
|
+
};
|
|
3629
|
+
// foreach 在最后一行自动补全
|
|
3630
|
+
if (node.concept === 'ForEachStatement') {
|
|
3631
|
+
range.line = currentSource.range.end.line;
|
|
3632
|
+
range.offset = 0;
|
|
3633
|
+
} else if (node.concept === 'BindAttribute') {
|
|
3634
|
+
range.offset = range.offset + 7;
|
|
3635
|
+
} else if (node.concept === 'BindDirective') {
|
|
3636
|
+
range.offset = range.offset + 5;
|
|
3637
|
+
}
|
|
3610
3638
|
return this._getFieldKeySelectCompletion({
|
|
3611
3639
|
file: (fileNode as FileNode).getEmbeddedFilePath(),
|
|
3612
|
-
range
|
|
3613
|
-
line: lsp2tspNumber(currentSource.range.start.line),
|
|
3614
|
-
offset: lsp2tspNumber(currentSource.range.start.character),
|
|
3615
|
-
},
|
|
3640
|
+
range,
|
|
3616
3641
|
getFieldKey: fieldKey,
|
|
3617
3642
|
});
|
|
3643
|
+
} else {
|
|
3644
|
+
console.log('没找到节点', currentSource, fileNode);
|
|
3618
3645
|
}
|
|
3619
|
-
console.log('没找到节点', currentSource, fileNode);
|
|
3620
3646
|
}
|
|
3621
3647
|
|
|
3622
3648
|
_getFieldKeySelectCompletion(args: any) {
|
|
@@ -3666,7 +3692,7 @@ class NaslServer {
|
|
|
3666
3692
|
return [...fileNodes];
|
|
3667
3693
|
}
|
|
3668
3694
|
|
|
3669
|
-
|
|
3695
|
+
/**获取当前节点的已知类型
|
|
3670
3696
|
* @param node 当前要获取类型的节点
|
|
3671
3697
|
* @returns 不需要去查就可以返回类型的节点
|
|
3672
3698
|
*/
|
|
@@ -3838,7 +3864,7 @@ class NaslServer {
|
|
|
3838
3864
|
const lastLen = codeArr?.[codeArr.length - 1]?.length;
|
|
3839
3865
|
indexOf = subStr.length - lastLen;
|
|
3840
3866
|
}
|
|
3841
|
-
fileDetail.offset
|
|
3867
|
+
fileDetail.offset = fileDetail.offset + indexOf;
|
|
3842
3868
|
} else if (
|
|
3843
3869
|
node.concept === 'MemberExpression' ||
|
|
3844
3870
|
node.concept === 'Identifier' ||
|
|
@@ -3850,7 +3876,7 @@ class NaslServer {
|
|
|
3850
3876
|
const lastLen = codeArr?.[codeArr.length - 1]?.length;
|
|
3851
3877
|
// MemberExpression取最后一位当做类型
|
|
3852
3878
|
const indexOf = item.code.length - lastLen;
|
|
3853
|
-
fileDetail.offset
|
|
3879
|
+
fileDetail.offset = fileDetail.offset + indexOf;
|
|
3854
3880
|
}
|
|
3855
3881
|
} else if (node.concept === 'Match') {
|
|
3856
3882
|
// 去查return 后面的返回值,变成函数调用
|
|
@@ -3882,7 +3908,7 @@ class NaslServer {
|
|
|
3882
3908
|
const item = (resultMap as any)?.[file]?.[line]?.[offset];
|
|
3883
3909
|
const itemType = item?.[0]?.nodeType;
|
|
3884
3910
|
const nodeTypeAnnotation = type2TypeAnnotation(itemType);
|
|
3885
|
-
const
|
|
3911
|
+
const node = newQuickInfoNodes[index].node;
|
|
3886
3912
|
|
|
3887
3913
|
types.set(node, Object.freeze(nodeTypeAnnotation) as TypeAnnotation);
|
|
3888
3914
|
|
|
@@ -3919,7 +3945,7 @@ class NaslServer {
|
|
|
3919
3945
|
const typeAnnotation = value as TypeAnnotation;
|
|
3920
3946
|
if (!node.typeAnnotation && typeAnnotation) {
|
|
3921
3947
|
if (typeAnnotation.typeName === 'List' && typeAnnotation.typeKind === 'generic') {
|
|
3922
|
-
const
|
|
3948
|
+
const typeArguments = typeAnnotation.typeArguments;
|
|
3923
3949
|
if (typeArguments.length && typeArguments[0].isComplexType()) {
|
|
3924
3950
|
node.__TypeAnnotation = null;
|
|
3925
3951
|
return;
|
|
@@ -3949,7 +3975,7 @@ class NaslServer {
|
|
|
3949
3975
|
@withQueueExecute('annotation')
|
|
3950
3976
|
async getNaslAnnotatedJSON(app: App, releaseFlag: boolean) {
|
|
3951
3977
|
if (this.changeStackList?.length) {
|
|
3952
|
-
throw new Error(`当前还有${this.changeStackList.length}
|
|
3978
|
+
throw new Error(`当前还有${this.changeStackList.length}个文件还在执行更新操作`);
|
|
3953
3979
|
}
|
|
3954
3980
|
const nodes: QuickInfoNodes = [];
|
|
3955
3981
|
this.file2NodeMap.forEach((fileNode, filePath) => {
|
|
@@ -4154,7 +4180,7 @@ class NaslServer {
|
|
|
4154
4180
|
}
|
|
4155
4181
|
}
|
|
4156
4182
|
// 用户自己声明的用用户的
|
|
4157
|
-
const callObj = App.findNodeByCompleteName(
|
|
4183
|
+
const callObj = App.findNodeByCompleteName(parent.calleeNamespace + '.' + parent.calleeName);
|
|
4158
4184
|
const index = parent.arguments.indexOf(node);
|
|
4159
4185
|
const param = callObj?.params?.[index] || {};
|
|
4160
4186
|
// 取出参数的类型
|
|
@@ -4430,7 +4456,7 @@ class NaslServer {
|
|
|
4430
4456
|
*/
|
|
4431
4457
|
async incidentalAction(action: string, fileNode: BaseNode, targetNode: BaseNode, oldpath?: string) {
|
|
4432
4458
|
if ((action === 'create' || action === 'delete' || (action === 'update' && oldpath)) && fileNode === targetNode) {
|
|
4433
|
-
|
|
4459
|
+
//删除、更改、新增端
|
|
4434
4460
|
if (fileNode instanceof Frontend && (fileNode.views?.length || fileNode.variables?.length)) {
|
|
4435
4461
|
const fileNodeChildren = [...fileNode.views, ...fileNode.variables];
|
|
4436
4462
|
for (let i = 0; i < fileNodeChildren.length; i++) {
|
|
@@ -4446,7 +4472,7 @@ class NaslServer {
|
|
|
4446
4472
|
} else if (action === 'update' && oldpath) {
|
|
4447
4473
|
const parentPath = oldpath.replace('.ts', '/');
|
|
4448
4474
|
const foldName = fileNodeItem.concept === 'View' ? 'views' : 'variables';
|
|
4449
|
-
const currentOldPath =
|
|
4475
|
+
const currentOldPath = parentPath + foldName + '/' + fileNodeItem.name + '.ts';
|
|
4450
4476
|
// 因为重命名这里只有当前修改父级的 旧名称, 所以他的子集也要根据旧名称去查依赖 更新内容
|
|
4451
4477
|
await this.handleRename(fileNodeItem, fileNodeItem, result, currentOldPath);
|
|
4452
4478
|
await this.incidentalAction(action, fileNodeItem, fileNodeItem, currentOldPath);
|
|
@@ -4468,7 +4494,7 @@ class NaslServer {
|
|
|
4468
4494
|
await this.incidentalAction(action, fileNodeItem, fileNodeItem);
|
|
4469
4495
|
} else if (action === 'update' && oldpath) {
|
|
4470
4496
|
const parentPath = oldpath.replace('.ts', '/');
|
|
4471
|
-
const currentOldPath =
|
|
4497
|
+
const currentOldPath = parentPath + fileNodeItem.name + '.ts';
|
|
4472
4498
|
// 因为重命名这里只有当前修改父级的 旧名称, 所以他的子集也要根据旧名称去查依赖 更新内容
|
|
4473
4499
|
await this.handleRename(fileNodeItem, fileNodeItem, result, currentOldPath);
|
|
4474
4500
|
await this.incidentalAction(action, fileNodeItem, fileNodeItem, currentOldPath);
|
|
@@ -4512,7 +4538,7 @@ class NaslServer {
|
|
|
4512
4538
|
try {
|
|
4513
4539
|
const result = entity.toEmbeddedTSFile();
|
|
4514
4540
|
const parentPath = oldpath.replace('.ts', '/');
|
|
4515
|
-
const currentOldPath =
|
|
4541
|
+
const currentOldPath = parentPath + '/entities/' + entity.name + '.ts';
|
|
4516
4542
|
// 因为重命名这里只有当前修改父级的 旧名称, 所以他的子集也要根据旧名称去查依赖 更新内容
|
|
4517
4543
|
await this.handleRename(entity, entity, result, currentOldPath);
|
|
4518
4544
|
} catch (err) {
|
|
@@ -4526,7 +4552,7 @@ class NaslServer {
|
|
|
4526
4552
|
async receiveHandleChange($event: EventPayload) {
|
|
4527
4553
|
this.singleFileChangeIng = true;
|
|
4528
4554
|
// 行为
|
|
4529
|
-
const
|
|
4555
|
+
const action = $event.action;
|
|
4530
4556
|
const targetNode = $event.target;
|
|
4531
4557
|
// Connection 相关配置的更新不需要写入文件
|
|
4532
4558
|
if (targetNode?.parentNode instanceof Connection) {
|