@lcap/nasl 2.12.0 → 2.13.0-beta
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/package.json +1 -1
- package/src/bak/translator.js +8 -1
- package/src/common/BaseNode.ts +1 -1
- package/src/concepts/App__.ts +38 -1
- package/src/concepts/Argument__.ts +1 -1
- package/src/concepts/Assignee__.ts +1 -1
- package/src/concepts/Assignment__.ts +1 -1
- package/src/concepts/Attribute__.ts +1 -1
- package/src/concepts/BinaryExpression__.ts +21 -4
- package/src/concepts/BindAttribute__.ts +1 -1
- package/src/concepts/BindDirective__.ts +4 -0
- package/src/concepts/BindEvent__.ts +416 -59
- package/src/concepts/BooleanLiteral__.ts +1 -1
- package/src/concepts/CallFunction__.ts +1 -1
- package/src/concepts/CallInterface__.ts +3 -1
- package/src/concepts/CallLogic__.ts +1 -1
- package/src/concepts/CallQueryComponent__.ts +1 -1
- package/src/concepts/Comment__.ts +1 -1
- package/src/concepts/CompletionProperty__.ts +1 -2
- package/src/concepts/ConfigGroup__.ts +1 -1
- package/src/concepts/ConfigPropertyValue__.ts +1 -1
- package/src/concepts/ConfigProperty__.ts +1 -1
- package/src/concepts/Configuration__.ts +1 -1
- package/src/concepts/Constant__.ts +1 -1
- package/src/concepts/DataElement__.ts +1 -1
- package/src/concepts/DataSource__.ts +1 -1
- package/src/concepts/Destination__.ts +3 -2
- package/src/concepts/End__.ts +1 -1
- package/src/concepts/EntityIndex__.ts +1 -1
- package/src/concepts/EntityProperty__.ts +1 -1
- package/src/concepts/Entity__.ts +1 -2
- package/src/concepts/EnumItem__.ts +1 -1
- package/src/concepts/Enum__.ts +1 -1
- package/src/concepts/Event__.ts +1 -1
- package/src/concepts/ForEachStatement__.ts +1 -1
- package/src/concepts/Function__.ts +65 -41
- package/src/concepts/Identifier__.ts +2 -2
- package/src/concepts/IfStatement__.ts +1 -1
- package/src/concepts/InterfaceParam__.ts +1 -1
- package/src/concepts/Interface__.ts +2 -1
- package/src/concepts/JSBlock__.ts +7 -0
- package/src/concepts/LogicItem__.ts +1 -1
- package/src/concepts/Logic__.ts +116 -14
- package/src/concepts/MemberExpression__.ts +1 -1
- package/src/concepts/Module__.ts +129 -107
- package/src/concepts/Namespace__.ts +1 -1
- package/src/concepts/NullLiteral__.ts +1 -1
- package/src/concepts/NumericLiteral__.ts +1 -1
- package/src/concepts/Param__.ts +7 -1
- package/src/concepts/Point__.ts +1 -1
- package/src/concepts/ProcessComponent__.ts +1 -1
- package/src/concepts/ProcessElement__.ts +228 -2
- package/src/concepts/ProcessOutcome__.ts +1 -1
- package/src/concepts/Process__.ts +242 -3
- package/src/concepts/QueryAggregateExpression__.ts +1 -1
- package/src/concepts/QueryFieldExpression__.ts +1 -1
- package/src/concepts/QueryFromExpression__.ts +1 -1
- package/src/concepts/QueryGroupByExpression__.ts +1 -1
- package/src/concepts/QueryJoinExpression__.ts +1 -1
- package/src/concepts/QueryLimitExpression__.ts +1 -1
- package/src/concepts/QueryOrderByExpression__.ts +1 -1
- package/src/concepts/QuerySelectExpression__.ts +1 -1
- package/src/concepts/Rect__.ts +1 -1
- package/src/concepts/Return__.ts +1 -1
- package/src/concepts/Role__.ts +1 -1
- package/src/concepts/Slot__.ts +1 -1
- package/src/concepts/SqlQueryComponent__.ts +14 -4
- package/src/concepts/Start__.ts +1 -1
- package/src/concepts/StringLiteral__.ts +1 -1
- package/src/concepts/StructureProperty__.ts +4 -0
- package/src/concepts/Structure__.ts +1 -1
- package/src/concepts/SwitchCase__.ts +1 -1
- package/src/concepts/SwitchStatement__.ts +1 -1
- package/src/concepts/Theme__.ts +1 -1
- package/src/concepts/Transactional__.ts +1 -1
- package/src/concepts/TypeAnnotation__.ts +32 -3
- package/src/concepts/TypeParam__.ts +1 -1
- package/src/concepts/UnaryExpression__.ts +1 -1
- package/src/concepts/Unparsed__.ts +1 -1
- package/src/concepts/UseComponent__.ts +1 -1
- package/src/concepts/ValidationRule__.ts +1 -1
- package/src/concepts/Variable__.ts +1 -1
- package/src/concepts/ViewComponent__.ts +1 -1
- package/src/concepts/ViewElement__.ts +34 -17
- package/src/concepts/View__.ts +75 -12
- package/src/concepts/WhileStatement__.ts +1 -1
- package/src/concepts/basics/stdlib/nasl.ui.ts +4 -0
- package/src/concepts/basics/stdlib/nasl.util.ts +2 -2
- package/src/concepts/basics/types/coreTypeList.ts +1 -0
- package/src/enums/KEYWORDS.ts +3 -0
- package/src/server/createUiTs.ts +26 -2
- package/src/server/events.yaml +89 -0
- package/src/server/getMemberIdentifier.ts +121 -28
- package/src/server/getProcesses.ts +30 -29
- package/src/server/index.ts +4 -0
- package/src/server/naslServer.ts +46 -12
- package/src/server/translator.ts +25 -13
- package/src/templator/genCreateBlock.ts +4 -0
- package/src/templator/genCurdEditMultipleKeyBlock.ts +10 -3
- package/src/templator/genCurdMultipleKeyBlock.ts +36 -21
- package/src/templator/genEditTableBlock.ts +2 -27
- package/src/templator/genGridViewBlock.ts +0 -13
- package/src/templator/genTableBlock.ts +0 -13
- package/src/templator/genUpdateBlock.ts +4 -0
- package/src/templator/utils.ts +1 -0
- package/out/automate/engine/index.d.ts +0 -4
- package/out/automate/engine/index.js +0 -436
- package/out/automate/engine/index.js.map +0 -1
- package/out/automate/engine/operators.d.ts +0 -21
- package/out/automate/engine/operators.js +0 -161
- package/out/automate/engine/operators.js.map +0 -1
- package/out/automate/engine/uniqueName.d.ts +0 -12
- package/out/automate/engine/uniqueName.js +0 -107
- package/out/automate/engine/uniqueName.js.map +0 -1
- package/out/automate/engine/utils.d.ts +0 -25
- package/out/automate/engine/utils.js +0 -404
- package/out/automate/engine/utils.js.map +0 -1
- package/out/automate/template/process.d.ts +0 -9
- package/out/automate/template/process.js +0 -10976
- package/out/automate/template/process.js.map +0 -1
- package/out/bak/translator.d.ts +0 -1
- package/out/bak/translator.js +0 -112
- package/out/bak/translator.js.map +0 -1
- package/out/common/BaseNode.d.ts +0 -256
- package/out/common/BaseNode.js +0 -891
- package/out/common/BaseNode.js.map +0 -1
- package/out/common/Command.d.ts +0 -8
- package/out/common/Command.js +0 -32
- package/out/common/Command.js.map +0 -1
- package/out/common/ComponentAPI.d.ts +0 -110
- package/out/common/ComponentAPI.js +0 -3
- package/out/common/ComponentAPI.js.map +0 -1
- package/out/common/EventEmitter.d.ts +0 -58
- package/out/common/EventEmitter.js +0 -68
- package/out/common/EventEmitter.js.map +0 -1
- package/out/common/Messager.d.ts +0 -86
- package/out/common/Messager.js +0 -187
- package/out/common/Messager.js.map +0 -1
- package/out/common/classMap.d.ts +0 -4
- package/out/common/classMap.js +0 -5
- package/out/common/classMap.js.map +0 -1
- package/out/common/index.d.ts +0 -4
- package/out/common/index.js +0 -21
- package/out/common/index.js.map +0 -1
- package/out/concepts/App__.d.ts +0 -1119
- package/out/concepts/App__.js +0 -1591
- package/out/concepts/App__.js.map +0 -1
- package/out/concepts/Argument__.d.ts +0 -58
- package/out/concepts/Argument__.js +0 -198
- package/out/concepts/Argument__.js.map +0 -1
- package/out/concepts/Assignee__.d.ts +0 -201
- package/out/concepts/Assignee__.js +0 -298
- package/out/concepts/Assignee__.js.map +0 -1
- package/out/concepts/Assignment__.d.ts +0 -70
- package/out/concepts/Assignment__.js +0 -201
- package/out/concepts/Assignment__.js.map +0 -1
- package/out/concepts/Attribute__.d.ts +0 -101
- package/out/concepts/Attribute__.js +0 -221
- package/out/concepts/Attribute__.js.map +0 -1
- package/out/concepts/BinaryExpression__.d.ts +0 -64
- package/out/concepts/BinaryExpression__.js +0 -251
- package/out/concepts/BinaryExpression__.js.map +0 -1
- package/out/concepts/BindAttribute__.d.ts +0 -231
- package/out/concepts/BindAttribute__.js +0 -450
- package/out/concepts/BindAttribute__.js.map +0 -1
- package/out/concepts/BindDirective__.d.ts +0 -93
- package/out/concepts/BindDirective__.js +0 -251
- package/out/concepts/BindDirective__.js.map +0 -1
- package/out/concepts/BindEvent__.d.ts +0 -139
- package/out/concepts/BindEvent__.js +0 -369
- package/out/concepts/BindEvent__.js.map +0 -1
- package/out/concepts/BooleanLiteral__.d.ts +0 -31
- package/out/concepts/BooleanLiteral__.js +0 -91
- package/out/concepts/BooleanLiteral__.js.map +0 -1
- package/out/concepts/CallFunction__.d.ts +0 -153
- package/out/concepts/CallFunction__.js +0 -381
- package/out/concepts/CallFunction__.js.map +0 -1
- package/out/concepts/CallInterface__.d.ts +0 -103
- package/out/concepts/CallInterface__.js +0 -441
- package/out/concepts/CallInterface__.js.map +0 -1
- package/out/concepts/CallLogic__.d.ts +0 -170
- package/out/concepts/CallLogic__.js +0 -604
- package/out/concepts/CallLogic__.js.map +0 -1
- package/out/concepts/CallQueryComponent__.d.ts +0 -345
- package/out/concepts/CallQueryComponent__.js +0 -1009
- package/out/concepts/CallQueryComponent__.js.map +0 -1
- package/out/concepts/Comment__.d.ts +0 -30
- package/out/concepts/Comment__.js +0 -93
- package/out/concepts/Comment__.js.map +0 -1
- package/out/concepts/CompletionProperty__.d.ts +0 -101
- package/out/concepts/CompletionProperty__.js +0 -237
- package/out/concepts/CompletionProperty__.js.map +0 -1
- package/out/concepts/ConfigGroup__.d.ts +0 -121
- package/out/concepts/ConfigGroup__.js +0 -221
- package/out/concepts/ConfigGroup__.js.map +0 -1
- package/out/concepts/ConfigPropertyValue__.d.ts +0 -43
- package/out/concepts/ConfigPropertyValue__.js +0 -103
- package/out/concepts/ConfigPropertyValue__.js.map +0 -1
- package/out/concepts/ConfigProperty__.d.ts +0 -129
- package/out/concepts/ConfigProperty__.js +0 -239
- package/out/concepts/ConfigProperty__.js.map +0 -1
- package/out/concepts/Configuration__.d.ts +0 -121
- package/out/concepts/Configuration__.js +0 -213
- package/out/concepts/Configuration__.js.map +0 -1
- package/out/concepts/Constant__.d.ts +0 -99
- package/out/concepts/Constant__.js +0 -237
- package/out/concepts/Constant__.js.map +0 -1
- package/out/concepts/DataElement__.d.ts +0 -45
- package/out/concepts/DataElement__.js +0 -114
- package/out/concepts/DataElement__.js.map +0 -1
- package/out/concepts/DataSource__.d.ts +0 -143
- package/out/concepts/DataSource__.js +0 -318
- package/out/concepts/DataSource__.js.map +0 -1
- package/out/concepts/Destination__.d.ts +0 -120
- package/out/concepts/Destination__.js +0 -433
- package/out/concepts/Destination__.js.map +0 -1
- package/out/concepts/End__.d.ts +0 -23
- package/out/concepts/End__.js +0 -84
- package/out/concepts/End__.js.map +0 -1
- package/out/concepts/EntityIndex__.d.ts +0 -94
- package/out/concepts/EntityIndex__.js +0 -215
- package/out/concepts/EntityIndex__.js.map +0 -1
- package/out/concepts/EntityProperty__.d.ts +0 -231
- package/out/concepts/EntityProperty__.js +0 -567
- package/out/concepts/EntityProperty__.js.map +0 -1
- package/out/concepts/Entity__.d.ts +0 -297
- package/out/concepts/Entity__.js +0 -572
- package/out/concepts/Entity__.js.map +0 -1
- package/out/concepts/EnumItem__.d.ts +0 -60
- package/out/concepts/EnumItem__.js +0 -136
- package/out/concepts/EnumItem__.js.map +0 -1
- package/out/concepts/Enum__.d.ts +0 -135
- package/out/concepts/Enum__.js +0 -293
- package/out/concepts/Enum__.js.map +0 -1
- package/out/concepts/Event__.d.ts +0 -142
- package/out/concepts/Event__.js +0 -242
- package/out/concepts/Event__.js.map +0 -1
- package/out/concepts/ForEachStatement__.d.ts +0 -191
- package/out/concepts/ForEachStatement__.js +0 -441
- package/out/concepts/ForEachStatement__.js.map +0 -1
- package/out/concepts/Function__.d.ts +0 -406
- package/out/concepts/Function__.js +0 -657
- package/out/concepts/Function__.js.map +0 -1
- package/out/concepts/Identifier__.d.ts +0 -45
- package/out/concepts/Identifier__.js +0 -203
- package/out/concepts/Identifier__.js.map +0 -1
- package/out/concepts/IfStatement__.d.ts +0 -148
- package/out/concepts/IfStatement__.js +0 -280
- package/out/concepts/IfStatement__.js.map +0 -1
- package/out/concepts/InterfaceParam__.d.ts +0 -112
- package/out/concepts/InterfaceParam__.js +0 -311
- package/out/concepts/InterfaceParam__.js.map +0 -1
- package/out/concepts/Interface__.d.ts +0 -268
- package/out/concepts/Interface__.js +0 -598
- package/out/concepts/Interface__.js.map +0 -1
- package/out/concepts/JSBlock__.d.ts +0 -31
- package/out/concepts/JSBlock__.js +0 -90
- package/out/concepts/JSBlock__.js.map +0 -1
- package/out/concepts/LogicItem__.d.ts +0 -117
- package/out/concepts/LogicItem__.js +0 -233
- package/out/concepts/LogicItem__.js.map +0 -1
- package/out/concepts/Logic__.d.ts +0 -610
- package/out/concepts/Logic__.js +0 -1203
- package/out/concepts/Logic__.js.map +0 -1
- package/out/concepts/MemberExpression__.d.ts +0 -65
- package/out/concepts/MemberExpression__.js +0 -238
- package/out/concepts/MemberExpression__.js.map +0 -1
- package/out/concepts/Module__.d.ts +0 -675
- package/out/concepts/Module__.js +0 -914
- package/out/concepts/Module__.js.map +0 -1
- package/out/concepts/Namespace__.d.ts +0 -986
- package/out/concepts/Namespace__.js +0 -1301
- package/out/concepts/Namespace__.js.map +0 -1
- package/out/concepts/NullLiteral__.d.ts +0 -23
- package/out/concepts/NullLiteral__.js +0 -73
- package/out/concepts/NullLiteral__.js.map +0 -1
- package/out/concepts/NumericLiteral__.d.ts +0 -53
- package/out/concepts/NumericLiteral__.js +0 -172
- package/out/concepts/NumericLiteral__.js.map +0 -1
- package/out/concepts/Param__.d.ts +0 -147
- package/out/concepts/Param__.js +0 -366
- package/out/concepts/Param__.js.map +0 -1
- package/out/concepts/Point__.d.ts +0 -30
- package/out/concepts/Point__.js +0 -75
- package/out/concepts/Point__.js.map +0 -1
- package/out/concepts/ProcessComponent__.d.ts +0 -218
- package/out/concepts/ProcessComponent__.js +0 -333
- package/out/concepts/ProcessComponent__.js.map +0 -1
- package/out/concepts/ProcessElement__.d.ts +0 -554
- package/out/concepts/ProcessElement__.js +0 -998
- package/out/concepts/ProcessElement__.js.map +0 -1
- package/out/concepts/ProcessOutcome__.d.ts +0 -30
- package/out/concepts/ProcessOutcome__.js +0 -87
- package/out/concepts/ProcessOutcome__.js.map +0 -1
- package/out/concepts/Process__.d.ts +0 -451
- package/out/concepts/Process__.js +0 -773
- package/out/concepts/Process__.js.map +0 -1
- package/out/concepts/QueryAggregateExpression__.d.ts +0 -50
- package/out/concepts/QueryAggregateExpression__.js +0 -144
- package/out/concepts/QueryAggregateExpression__.js.map +0 -1
- package/out/concepts/QueryFieldExpression__.d.ts +0 -48
- package/out/concepts/QueryFieldExpression__.js +0 -132
- package/out/concepts/QueryFieldExpression__.js.map +0 -1
- package/out/concepts/QueryFromExpression__.d.ts +0 -95
- package/out/concepts/QueryFromExpression__.js +0 -192
- package/out/concepts/QueryFromExpression__.js.map +0 -1
- package/out/concepts/QueryGroupByExpression__.d.ts +0 -45
- package/out/concepts/QueryGroupByExpression__.js +0 -139
- package/out/concepts/QueryGroupByExpression__.js.map +0 -1
- package/out/concepts/QueryJoinExpression__.d.ts +0 -182
- package/out/concepts/QueryJoinExpression__.js +0 -312
- package/out/concepts/QueryJoinExpression__.js.map +0 -1
- package/out/concepts/QueryLimitExpression__.d.ts +0 -56
- package/out/concepts/QueryLimitExpression__.js +0 -156
- package/out/concepts/QueryLimitExpression__.js.map +0 -1
- package/out/concepts/QueryOrderByExpression__.d.ts +0 -67
- package/out/concepts/QueryOrderByExpression__.js +0 -169
- package/out/concepts/QueryOrderByExpression__.js.map +0 -1
- package/out/concepts/QuerySelectExpression__.d.ts +0 -114
- package/out/concepts/QuerySelectExpression__.js +0 -203
- package/out/concepts/QuerySelectExpression__.js.map +0 -1
- package/out/concepts/Rect__.d.ts +0 -38
- package/out/concepts/Rect__.js +0 -89
- package/out/concepts/Rect__.js.map +0 -1
- package/out/concepts/Return__.d.ts +0 -131
- package/out/concepts/Return__.js +0 -340
- package/out/concepts/Return__.js.map +0 -1
- package/out/concepts/Role__.d.ts +0 -61
- package/out/concepts/Role__.js +0 -164
- package/out/concepts/Role__.js.map +0 -1
- package/out/concepts/Slot__.d.ts +0 -57
- package/out/concepts/Slot__.js +0 -114
- package/out/concepts/Slot__.js.map +0 -1
- package/out/concepts/SqlQueryComponent__.d.ts +0 -61
- package/out/concepts/SqlQueryComponent__.js +0 -177
- package/out/concepts/SqlQueryComponent__.js.map +0 -1
- package/out/concepts/Start__.d.ts +0 -23
- package/out/concepts/Start__.js +0 -71
- package/out/concepts/Start__.js.map +0 -1
- package/out/concepts/StringLiteral__.d.ts +0 -35
- package/out/concepts/StringLiteral__.js +0 -125
- package/out/concepts/StringLiteral__.js.map +0 -1
- package/out/concepts/StructureProperty__.d.ts +0 -124
- package/out/concepts/StructureProperty__.js +0 -324
- package/out/concepts/StructureProperty__.js.map +0 -1
- package/out/concepts/Structure__.d.ts +0 -250
- package/out/concepts/Structure__.js +0 -440
- package/out/concepts/Structure__.js.map +0 -1
- package/out/concepts/SwitchCase__.d.ts +0 -92
- package/out/concepts/SwitchCase__.js +0 -229
- package/out/concepts/SwitchCase__.js.map +0 -1
- package/out/concepts/SwitchStatement__.d.ts +0 -82
- package/out/concepts/SwitchStatement__.js +0 -175
- package/out/concepts/SwitchStatement__.js.map +0 -1
- package/out/concepts/Theme__.d.ts +0 -36
- package/out/concepts/Theme__.js +0 -86
- package/out/concepts/Theme__.js.map +0 -1
- package/out/concepts/Transactional__.d.ts +0 -76
- package/out/concepts/Transactional__.js +0 -151
- package/out/concepts/Transactional__.js.map +0 -1
- package/out/concepts/TypeAnnotation__.d.ts +0 -133
- package/out/concepts/TypeAnnotation__.js +0 -412
- package/out/concepts/TypeAnnotation__.js.map +0 -1
- package/out/concepts/TypeParam__.d.ts +0 -20
- package/out/concepts/TypeParam__.js +0 -57
- package/out/concepts/TypeParam__.js.map +0 -1
- package/out/concepts/UnaryExpression__.d.ts +0 -46
- package/out/concepts/UnaryExpression__.js +0 -166
- package/out/concepts/UnaryExpression__.js.map +0 -1
- package/out/concepts/Unparsed__.d.ts +0 -29
- package/out/concepts/Unparsed__.js +0 -88
- package/out/concepts/Unparsed__.js.map +0 -1
- package/out/concepts/UseComponent__.d.ts +0 -30
- package/out/concepts/UseComponent__.js +0 -75
- package/out/concepts/UseComponent__.js.map +0 -1
- package/out/concepts/ValidationRule__.d.ts +0 -94
- package/out/concepts/ValidationRule__.js +0 -254
- package/out/concepts/ValidationRule__.js.map +0 -1
- package/out/concepts/Variable__.d.ts +0 -130
- package/out/concepts/Variable__.js +0 -338
- package/out/concepts/Variable__.js.map +0 -1
- package/out/concepts/ViewComponent__.d.ts +0 -472
- package/out/concepts/ViewComponent__.js +0 -644
- package/out/concepts/ViewComponent__.js.map +0 -1
- package/out/concepts/ViewElement__.d.ts +0 -490
- package/out/concepts/ViewElement__.js +0 -1414
- package/out/concepts/ViewElement__.js.map +0 -1
- package/out/concepts/View__.d.ts +0 -683
- package/out/concepts/View__.js +0 -1333
- package/out/concepts/View__.js.map +0 -1
- package/out/concepts/WhileStatement__.d.ts +0 -95
- package/out/concepts/WhileStatement__.js +0 -208
- package/out/concepts/WhileStatement__.js.map +0 -1
- package/out/concepts/basics/stdlib/index.d.ts +0 -4
- package/out/concepts/basics/stdlib/index.js +0 -26
- package/out/concepts/basics/stdlib/index.js.map +0 -1
- package/out/concepts/basics/stdlib/nasl.auth.d.ts +0 -3
- package/out/concepts/basics/stdlib/nasl.auth.js +0 -50
- package/out/concepts/basics/stdlib/nasl.auth.js.map +0 -1
- package/out/concepts/basics/stdlib/nasl.browser.d.ts +0 -3
- package/out/concepts/basics/stdlib/nasl.browser.js +0 -41
- package/out/concepts/basics/stdlib/nasl.browser.js.map +0 -1
- package/out/concepts/basics/stdlib/nasl.collection.d.ts +0 -7
- package/out/concepts/basics/stdlib/nasl.collection.js +0 -83
- package/out/concepts/basics/stdlib/nasl.collection.js.map +0 -1
- package/out/concepts/basics/stdlib/nasl.configuration.d.ts +0 -3
- package/out/concepts/basics/stdlib/nasl.configuration.js +0 -25
- package/out/concepts/basics/stdlib/nasl.configuration.js.map +0 -1
- package/out/concepts/basics/stdlib/nasl.core.d.ts +0 -3
- package/out/concepts/basics/stdlib/nasl.core.js +0 -15
- package/out/concepts/basics/stdlib/nasl.core.js.map +0 -1
- package/out/concepts/basics/stdlib/nasl.interface.d.ts +0 -7
- package/out/concepts/basics/stdlib/nasl.interface.js +0 -43
- package/out/concepts/basics/stdlib/nasl.interface.js.map +0 -1
- package/out/concepts/basics/stdlib/nasl.process.d.ts +0 -7
- package/out/concepts/basics/stdlib/nasl.process.js +0 -453
- package/out/concepts/basics/stdlib/nasl.process.js.map +0 -1
- package/out/concepts/basics/stdlib/nasl.ui.d.ts +0 -7
- package/out/concepts/basics/stdlib/nasl.ui.js +0 -824
- package/out/concepts/basics/stdlib/nasl.ui.js.map +0 -1
- package/out/concepts/basics/stdlib/nasl.util.d.ts +0 -3
- package/out/concepts/basics/stdlib/nasl.util.js +0 -1030
- package/out/concepts/basics/stdlib/nasl.util.js.map +0 -1
- package/out/concepts/basics/stdlib/nasl.validation.d.ts +0 -3
- package/out/concepts/basics/stdlib/nasl.validation.js +0 -561
- package/out/concepts/basics/stdlib/nasl.validation.js.map +0 -1
- package/out/concepts/basics/stdlib/reference2TypeAnnotationList.d.ts +0 -5
- package/out/concepts/basics/stdlib/reference2TypeAnnotationList.js +0 -26
- package/out/concepts/basics/stdlib/reference2TypeAnnotationList.js.map +0 -1
- package/out/concepts/basics/types/coreTypeList.d.ts +0 -2
- package/out/concepts/basics/types/coreTypeList.js +0 -18
- package/out/concepts/basics/types/coreTypeList.js.map +0 -1
- package/out/concepts/basics/types/index.d.ts +0 -13
- package/out/concepts/basics/types/index.js +0 -27
- package/out/concepts/basics/types/index.js.map +0 -1
- package/out/concepts/index.d.ts +0 -5
- package/out/concepts/index.js +0 -24
- package/out/concepts/index.js.map +0 -1
- package/out/concepts/index__.d.ts +0 -83
- package/out/concepts/index__.js +0 -100
- package/out/concepts/index__.js.map +0 -1
- package/out/config.d.ts +0 -42
- package/out/config.js +0 -71
- package/out/config.js.map +0 -1
- package/out/decorators/index.d.ts +0 -54
- package/out/decorators/index.js +0 -149
- package/out/decorators/index.js.map +0 -1
- package/out/enums/KEYWORDS.d.ts +0 -3
- package/out/enums/KEYWORDS.js +0 -1199
- package/out/enums/KEYWORDS.js.map +0 -1
- package/out/enums/LEVEL_NAME_MAP.d.ts +0 -26
- package/out/enums/LEVEL_NAME_MAP.js +0 -30
- package/out/enums/LEVEL_NAME_MAP.js.map +0 -1
- package/out/eventBus.d.ts +0 -3
- package/out/eventBus.js +0 -7
- package/out/eventBus.js.map +0 -1
- package/out/generator/compileComponent.d.ts +0 -11
- package/out/generator/compileComponent.js +0 -12
- package/out/generator/compileComponent.js.map +0 -1
- package/out/generator/genBundleFiles.d.ts +0 -44
- package/out/generator/genBundleFiles.js +0 -387
- package/out/generator/genBundleFiles.js.map +0 -1
- package/out/generator/genHash.d.ts +0 -7
- package/out/generator/genHash.js +0 -39
- package/out/generator/genHash.js.map +0 -1
- package/out/generator/genMetaData.d.ts +0 -36
- package/out/generator/genMetaData.js +0 -121
- package/out/generator/genMetaData.js.map +0 -1
- package/out/generator/index.d.ts +0 -5
- package/out/generator/index.js +0 -22
- package/out/generator/index.js.map +0 -1
- package/out/generator/styleReplacer.d.ts +0 -3
- package/out/generator/styleReplacer.js +0 -71
- package/out/generator/styleReplacer.js.map +0 -1
- package/out/index.d.ts +0 -11
- package/out/index.js +0 -53
- package/out/index.js.map +0 -1
- package/out/manager/diagnostic.d.ts +0 -38
- package/out/manager/diagnostic.js +0 -84
- package/out/manager/diagnostic.js.map +0 -1
- package/out/manager/history.d.ts +0 -0
- package/out/manager/history.js +0 -1
- package/out/manager/history.js.map +0 -1
- package/out/manager/problem.d.ts +0 -0
- package/out/manager/problem.js +0 -1
- package/out/manager/problem.js.map +0 -1
- package/out/server/createUiTs.d.ts +0 -8
- package/out/server/createUiTs.js +0 -204
- package/out/server/createUiTs.js.map +0 -1
- package/out/server/entity2LogicNamespace.d.ts +0 -10
- package/out/server/entity2LogicNamespace.js +0 -217
- package/out/server/entity2LogicNamespace.js.map +0 -1
- package/out/server/extendBaseNode.d.ts +0 -1
- package/out/server/extendBaseNode.js +0 -323
- package/out/server/extendBaseNode.js.map +0 -1
- package/out/server/getExtensionModules.d.ts +0 -3
- package/out/server/getExtensionModules.js +0 -20
- package/out/server/getExtensionModules.js.map +0 -1
- package/out/server/getFunctions.d.ts +0 -3
- package/out/server/getFunctions.js +0 -20
- package/out/server/getFunctions.js.map +0 -1
- package/out/server/getInterfaces.d.ts +0 -2
- package/out/server/getInterfaces.js +0 -48
- package/out/server/getInterfaces.js.map +0 -1
- package/out/server/getLogics.d.ts +0 -3
- package/out/server/getLogics.js +0 -210
- package/out/server/getLogics.js.map +0 -1
- package/out/server/getMemberIdentifier.d.ts +0 -22
- package/out/server/getMemberIdentifier.js +0 -459
- package/out/server/getMemberIdentifier.js.map +0 -1
- package/out/server/getProcessComponents.d.ts +0 -2
- package/out/server/getProcessComponents.js +0 -13
- package/out/server/getProcessComponents.js.map +0 -1
- package/out/server/getProcesses.d.ts +0 -33
- package/out/server/getProcesses.js +0 -565
- package/out/server/getProcesses.js.map +0 -1
- package/out/server/getScope.d.ts +0 -13
- package/out/server/getScope.js +0 -61
- package/out/server/getScope.js.map +0 -1
- package/out/server/getValidates.d.ts +0 -3
- package/out/server/getValidates.js +0 -14
- package/out/server/getValidates.js.map +0 -1
- package/out/server/index.d.ts +0 -3
- package/out/server/index.js +0 -33
- package/out/server/index.js.map +0 -1
- package/out/server/naslServer.d.ts +0 -136
- package/out/server/naslServer.js +0 -1733
- package/out/server/naslServer.js.map +0 -1
- package/out/server/process2LogicNamespace.d.ts +0 -26
- package/out/server/process2LogicNamespace.js +0 -97
- package/out/server/process2LogicNamespace.js.map +0 -1
- package/out/server/translator.d.ts +0 -24
- package/out/server/translator.js +0 -460
- package/out/server/translator.js.map +0 -1
- package/out/service/creator/add.configs.d.ts +0 -1
- package/out/service/creator/add.configs.js +0 -68
- package/out/service/creator/add.configs.js.map +0 -1
- package/out/service/creator/errHandles.d.ts +0 -18
- package/out/service/creator/errHandles.js +0 -65
- package/out/service/creator/errHandles.js.map +0 -1
- package/out/service/creator/index.d.ts +0 -1
- package/out/service/creator/index.js +0 -72
- package/out/service/creator/index.js.map +0 -1
- package/out/service/storage/api.d.ts +0 -18
- package/out/service/storage/api.js +0 -17
- package/out/service/storage/api.js.map +0 -1
- package/out/service/storage/index.d.ts +0 -2
- package/out/service/storage/index.js +0 -10
- package/out/service/storage/index.js.map +0 -1
- package/out/service/storage/init.d.ts +0 -13
- package/out/service/storage/init.js +0 -469
- package/out/service/storage/init.js.map +0 -1
- package/out/service/storage/jsoner.d.ts +0 -29
- package/out/service/storage/jsoner.js +0 -130
- package/out/service/storage/jsoner.js.map +0 -1
- package/out/service/storage/map.d.ts +0 -4
- package/out/service/storage/map.js +0 -54
- package/out/service/storage/map.js.map +0 -1
- package/out/service/storage/service.d.ts +0 -2
- package/out/service/storage/service.js +0 -10
- package/out/service/storage/service.js.map +0 -1
- package/out/service/storage/storagePoint.d.ts +0 -17
- package/out/service/storage/storagePoint.js +0 -76
- package/out/service/storage/storagePoint.js.map +0 -1
- package/out/templator/genCallComponentLogic.d.ts +0 -17
- package/out/templator/genCallComponentLogic.js +0 -30
- package/out/templator/genCallComponentLogic.js.map +0 -1
- package/out/templator/genCreateBlock.d.ts +0 -10
- package/out/templator/genCreateBlock.js +0 -327
- package/out/templator/genCreateBlock.js.map +0 -1
- package/out/templator/genCurdEditMultipleKeyBlock.d.ts +0 -2
- package/out/templator/genCurdEditMultipleKeyBlock.js +0 -475
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +0 -1
- package/out/templator/genCurdMultipleKeyBlock.d.ts +0 -3
- package/out/templator/genCurdMultipleKeyBlock.js +0 -672
- package/out/templator/genCurdMultipleKeyBlock.js.map +0 -1
- package/out/templator/genEditTableBlock.d.ts +0 -51
- package/out/templator/genEditTableBlock.js +0 -303
- package/out/templator/genEditTableBlock.js.map +0 -1
- package/out/templator/genEnumSelectBlock.d.ts +0 -10
- package/out/templator/genEnumSelectBlock.js +0 -23
- package/out/templator/genEnumSelectBlock.js.map +0 -1
- package/out/templator/genGetBlock.d.ts +0 -6
- package/out/templator/genGetBlock.js +0 -135
- package/out/templator/genGetBlock.js.map +0 -1
- package/out/templator/genGridViewBlock.d.ts +0 -55
- package/out/templator/genGridViewBlock.js +0 -368
- package/out/templator/genGridViewBlock.js.map +0 -1
- package/out/templator/genListViewBlock.d.ts +0 -19
- package/out/templator/genListViewBlock.js +0 -141
- package/out/templator/genListViewBlock.js.map +0 -1
- package/out/templator/genQueryComponent.d.ts +0 -34
- package/out/templator/genQueryComponent.js +0 -322
- package/out/templator/genQueryComponent.js.map +0 -1
- package/out/templator/genSelectBlock.d.ts +0 -34
- package/out/templator/genSelectBlock.js +0 -143
- package/out/templator/genSelectBlock.js.map +0 -1
- package/out/templator/genTableBlock.d.ts +0 -53
- package/out/templator/genTableBlock.js +0 -305
- package/out/templator/genTableBlock.js.map +0 -1
- package/out/templator/genUpdateBlock.d.ts +0 -6
- package/out/templator/genUpdateBlock.js +0 -368
- package/out/templator/genUpdateBlock.js.map +0 -1
- package/out/templator/index.d.ts +0 -16
- package/out/templator/index.js +0 -34
- package/out/templator/index.js.map +0 -1
- package/out/templator/utils.d.ts +0 -645
- package/out/templator/utils.js +0 -426
- package/out/templator/utils.js.map +0 -1
- package/out/test/fixtures/env.d.ts +0 -5
- package/out/test/fixtures/env.js +0 -20
- package/out/test/fixtures/env.js.map +0 -1
- package/out/test/integration/connect-create-file.d.ts +0 -1
- package/out/test/integration/connect-create-file.js +0 -39
- package/out/test/integration/connect-create-file.js.map +0 -1
- package/out/test/integration/connect-file.d.ts +0 -1
- package/out/test/integration/connect-file.js +0 -49
- package/out/test/integration/connect-file.js.map +0 -1
- package/out/test/units/baseTypes/Assignment.spec.d.ts +0 -1
- package/out/test/units/baseTypes/Assignment.spec.js +0 -43
- package/out/test/units/baseTypes/Assignment.spec.js.map +0 -1
- package/out/test/units/baseTypes/CallLogic.spec.d.ts +0 -1
- package/out/test/units/baseTypes/CallLogic.spec.js +0 -44
- package/out/test/units/baseTypes/CallLogic.spec.js.map +0 -1
- package/out/test/units/baseTypes/StringLiteral.spec.d.ts +0 -1
- package/out/test/units/baseTypes/StringLiteral.spec.js +0 -75
- package/out/test/units/baseTypes/StringLiteral.spec.js.map +0 -1
- package/out/test/units/baseTypes/new.spec.d.ts +0 -1
- package/out/test/units/baseTypes/new.spec.js +0 -37
- package/out/test/units/baseTypes/new.spec.js.map +0 -1
- package/out/test/units/common/Vertex.spec.d.ts +0 -1
- package/out/test/units/common/Vertex.spec.js +0 -22
- package/out/test/units/common/Vertex.spec.js.map +0 -1
- package/out/test/units/data/Entity.spec.d.ts +0 -1
- package/out/test/units/data/Entity.spec.js +0 -12
- package/out/test/units/data/Entity.spec.js.map +0 -1
- package/out/test/units/login.spec.d.ts +0 -1
- package/out/test/units/login.spec.js +0 -12
- package/out/test/units/login.spec.js.map +0 -1
- package/out/test/units/page/Block.spec.d.ts +0 -0
- package/out/test/units/page/Block.spec.js +0 -13
- package/out/test/units/page/Block.spec.js.map +0 -1
- package/out/test/units/page/Element.spec.d.ts +0 -1
- package/out/test/units/page/Element.spec.js +0 -44
- package/out/test/units/page/Element.spec.js.map +0 -1
- package/out/test/units/temp/temp.spec.d.ts +0 -1
- package/out/test/units/temp/temp.spec.js +0 -68
- package/out/test/units/temp/temp.spec.js.map +0 -1
- package/out/translator/index.d.ts +0 -47
- package/out/translator/index.js +0 -108
- package/out/translator/index.js.map +0 -1
- package/out/translator/lsp.d.ts +0 -45
- package/out/translator/lsp.js +0 -6
- package/out/translator/lsp.js.map +0 -1
- package/out/translator/tsp.d.ts +0 -12
- package/out/translator/tsp.js +0 -3
- package/out/translator/tsp.js.map +0 -1
- package/out/utils/index.d.ts +0 -37
- package/out/utils/index.js +0 -125
- package/out/utils/index.js.map +0 -1
- package/out/utils/logger.d.ts +0 -3
- package/out/utils/logger.js +0 -11
- package/out/utils/logger.js.map +0 -1
- package/out/utils/string.d.ts +0 -38
- package/out/utils/string.js +0 -95
- package/out/utils/string.js.map +0 -1
- package/out/utils/traverse.d.ts +0 -36
- package/out/utils/traverse.js +0 -132
- package/out/utils/traverse.js.map +0 -1
package/out/server/naslServer.js
DELETED
|
@@ -1,1733 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
/// #if process.env.NODE_ENV
|
|
7
|
-
// import Worker from '../../../ts-worker/dist/bundle.js';
|
|
8
|
-
/// #else
|
|
9
|
-
// import { Worker } from 'worker_threads';
|
|
10
|
-
/// #endif
|
|
11
|
-
const Messager_1 = __importDefault(require("../common/Messager"));
|
|
12
|
-
const concepts_1 = require("../concepts");
|
|
13
|
-
const translator_1 = require("../translator");
|
|
14
|
-
const storage_1 = __importDefault(require("../service/storage"));
|
|
15
|
-
const translator_2 = require("./translator");
|
|
16
|
-
const common_1 = require("../common");
|
|
17
|
-
const diagnostic_1 = __importDefault(require("../manager/diagnostic"));
|
|
18
|
-
const createUiTs_1 = __importDefault(require("./createUiTs"));
|
|
19
|
-
const coreTypeList_1 = require("../concepts/basics/types/coreTypeList");
|
|
20
|
-
const utils_1 = require("../utils");
|
|
21
|
-
const EmbeddedTSFileLineMap = {
|
|
22
|
-
Entity: 3,
|
|
23
|
-
};
|
|
24
|
-
// 要Check的文件
|
|
25
|
-
const filesToCheck = new Set();
|
|
26
|
-
const worker = new Worker('/ts-worker.js');
|
|
27
|
-
const messager = new Messager_1.default({
|
|
28
|
-
protocol: 'ts-worker',
|
|
29
|
-
sender: 'ide',
|
|
30
|
-
context: this,
|
|
31
|
-
getReceiver: () => worker,
|
|
32
|
-
getSender: () => worker,
|
|
33
|
-
handleMessage({ data }) {
|
|
34
|
-
if (data && data.event === 'publishDiagnostics') {
|
|
35
|
-
diagnostic_1.default.pushAll(naslServer._resolveDiagnosticRecords(data.records));
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
let isChangeInterface = false; //判断是否导入接口
|
|
40
|
-
let actionArr = []; //用于导入接口收集更改的节点
|
|
41
|
-
let timer = null; //超时器用于收集导入接口相关
|
|
42
|
-
const naslServer = {
|
|
43
|
-
messager,
|
|
44
|
-
worker,
|
|
45
|
-
/**
|
|
46
|
-
* 按道理 fileSourceMap: new Map<string, SourceMap>() 比较合理,
|
|
47
|
-
* 但是要多维护一层 vertex 增删 -> file 增删的关系问题,
|
|
48
|
-
* 先用挂在点上面,简单的方法实现,后期再考虑解耦
|
|
49
|
-
*/
|
|
50
|
-
file2NodeMap: new Map(),
|
|
51
|
-
elementsLogic: {},
|
|
52
|
-
start() {
|
|
53
|
-
return this.messager.requestCommand('start');
|
|
54
|
-
},
|
|
55
|
-
async createUiTs(allComponent) {
|
|
56
|
-
const { code, elementsLogic, naslStdlibMap } = await (0, createUiTs_1.default)(allComponent);
|
|
57
|
-
// 放入生產的uits文件
|
|
58
|
-
await naslServer.addFile({
|
|
59
|
-
file: 'nasl.ui.definition.ts',
|
|
60
|
-
fileContent: code,
|
|
61
|
-
});
|
|
62
|
-
Object.keys(naslStdlibMap).forEach(async (libFileName) => {
|
|
63
|
-
await naslServer.addFile({
|
|
64
|
-
file: '/' + libFileName,
|
|
65
|
-
fileContent: naslStdlibMap[libFileName],
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
naslServer.elementsLogic = elementsLogic;
|
|
69
|
-
// 全部文件加载完毕开始初始化
|
|
70
|
-
await naslServer.getDiagnosticRecordsAndPushAll();
|
|
71
|
-
},
|
|
72
|
-
contentToFile(module, results) {
|
|
73
|
-
module.structures.forEach((structure) => {
|
|
74
|
-
try {
|
|
75
|
-
const result = structure.toEmbeddedTSFile();
|
|
76
|
-
results.push(result);
|
|
77
|
-
// sourceMap都存在目录级别内容下,在页面层级下去找
|
|
78
|
-
structure.sourceMap = result.sourceMap;
|
|
79
|
-
this.file2NodeMap.set(result.filePath, structure);
|
|
80
|
-
}
|
|
81
|
-
catch (err) {
|
|
82
|
-
console.log(err);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
module.dataSources?.forEach((dataSource) => {
|
|
86
|
-
// 本身dataSource也要生成一个文件用于改名
|
|
87
|
-
try {
|
|
88
|
-
const result = dataSource.toEmbeddedTSFile();
|
|
89
|
-
results.push(result);
|
|
90
|
-
// sourceMap都存在目录级别内容下,在页面层级下去找
|
|
91
|
-
dataSource.sourceMap = result.sourceMap;
|
|
92
|
-
this.file2NodeMap.set(result.filePath, dataSource);
|
|
93
|
-
}
|
|
94
|
-
catch (err) {
|
|
95
|
-
console.log(err);
|
|
96
|
-
}
|
|
97
|
-
dataSource.entities.forEach((entity) => {
|
|
98
|
-
try {
|
|
99
|
-
const result = entity.toEmbeddedTSFile();
|
|
100
|
-
results.push(result);
|
|
101
|
-
// sourceMap都存在目录级别内容下,在页面层级下去找
|
|
102
|
-
entity.sourceMap = result.sourceMap;
|
|
103
|
-
this.file2NodeMap.set(result.filePath, entity);
|
|
104
|
-
}
|
|
105
|
-
catch (err) {
|
|
106
|
-
console.log(err);
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
module.interfaces.forEach((_interface) => {
|
|
111
|
-
try {
|
|
112
|
-
const result = _interface.toEmbeddedTSFile();
|
|
113
|
-
results.push(result);
|
|
114
|
-
// sourceMap都存在目录级别内容下,在页面层级下去找
|
|
115
|
-
_interface.sourceMap = result.sourceMap;
|
|
116
|
-
this.file2NodeMap.set(result.filePath, _interface);
|
|
117
|
-
}
|
|
118
|
-
catch (err) {
|
|
119
|
-
console.log(err);
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
module.enums.forEach((_enum) => {
|
|
123
|
-
try {
|
|
124
|
-
const result = _enum.toEmbeddedTSFile();
|
|
125
|
-
results.push(result);
|
|
126
|
-
// sourceMap都存在目录级别内容下,在页面层级下去找
|
|
127
|
-
_enum.sourceMap = result.sourceMap;
|
|
128
|
-
this.file2NodeMap.set(result.filePath, _enum);
|
|
129
|
-
}
|
|
130
|
-
catch (err) {
|
|
131
|
-
console.log(err);
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
module.logics.forEach((logic) => {
|
|
135
|
-
try {
|
|
136
|
-
if (!(logic instanceof concepts_1.Logic))
|
|
137
|
-
return;
|
|
138
|
-
const result = logic.toEmbeddedTSFile();
|
|
139
|
-
results.push(result);
|
|
140
|
-
logic.sourceMap = result.sourceMap;
|
|
141
|
-
this.file2NodeMap.set(result.filePath, logic);
|
|
142
|
-
}
|
|
143
|
-
catch (err) {
|
|
144
|
-
console.log(err);
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
// view的生成
|
|
148
|
-
naslServer.view2TSFile(module.views, results);
|
|
149
|
-
module.processes.forEach((process) => {
|
|
150
|
-
try {
|
|
151
|
-
const result = process.toEmbeddedTSFile();
|
|
152
|
-
results.push(result);
|
|
153
|
-
process.sourceMap = result.sourceMap;
|
|
154
|
-
this.file2NodeMap.set(result.filePath, process);
|
|
155
|
-
}
|
|
156
|
-
catch (err) {
|
|
157
|
-
console.log(err);
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
if (module instanceof concepts_1.App) {
|
|
161
|
-
module.roles.forEach((role) => {
|
|
162
|
-
try {
|
|
163
|
-
const result = role.toEmbeddedTSFile();
|
|
164
|
-
results.push(result);
|
|
165
|
-
// sourceMap都存在目录级别内容下,在页面层级下去找
|
|
166
|
-
role.sourceMap = result.sourceMap;
|
|
167
|
-
this.file2NodeMap.set(result.filePath, role);
|
|
168
|
-
}
|
|
169
|
-
catch (err) {
|
|
170
|
-
console.log(err);
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
view2TSFile(viewsChildren, results) {
|
|
176
|
-
// 如果有子页面
|
|
177
|
-
if (viewsChildren && viewsChildren.length) {
|
|
178
|
-
viewsChildren.forEach((view) => {
|
|
179
|
-
try {
|
|
180
|
-
const result = view.toEmbeddedTSFile();
|
|
181
|
-
results.push(result);
|
|
182
|
-
view.sourceMap = result.sourceMap;
|
|
183
|
-
this.file2NodeMap.set(result.filePath, view);
|
|
184
|
-
if (view.children.length) {
|
|
185
|
-
naslServer.view2TSFile(view.children, results);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
catch (err) {
|
|
189
|
-
console.log(err);
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
async openApp(app) {
|
|
195
|
-
const results = [];
|
|
196
|
-
try {
|
|
197
|
-
// app的创建内容
|
|
198
|
-
naslServer.contentToFile(app, results);
|
|
199
|
-
// 其他模块的创建内容
|
|
200
|
-
app.dependencies.forEach((item) => naslServer.contentToFile(item, results));
|
|
201
|
-
app.interfaceDependencies.forEach((item) => naslServer.contentToFile(item, results));
|
|
202
|
-
app.componentDependencies.forEach((item) => naslServer.contentToFile(item, results));
|
|
203
|
-
}
|
|
204
|
-
catch (err) {
|
|
205
|
-
console.log(err);
|
|
206
|
-
}
|
|
207
|
-
const files = results.map((result) => ({
|
|
208
|
-
file: result.filePath,
|
|
209
|
-
fileContent: result.code,
|
|
210
|
-
}));
|
|
211
|
-
await this.writeFiles(files);
|
|
212
|
-
this._debugInFileStorage(app, files);
|
|
213
|
-
// 修改名称回调
|
|
214
|
-
(0, common_1.registerCommand)('tsRename.change', (value, callback) => {
|
|
215
|
-
callback(value);
|
|
216
|
-
});
|
|
217
|
-
// 删除回调
|
|
218
|
-
(0, common_1.registerCommand)('tsDelete.change', (callback) => {
|
|
219
|
-
callback();
|
|
220
|
-
});
|
|
221
|
-
},
|
|
222
|
-
async refreshApp(app) {
|
|
223
|
-
// 清除所有问题
|
|
224
|
-
diagnostic_1.default.clear();
|
|
225
|
-
await naslServer.deleteDirectoryFiles({ directoryName: '/embedded' });
|
|
226
|
-
// 清楚check count的数量
|
|
227
|
-
await this.messager.requestCommand('_clearTimeout');
|
|
228
|
-
// 重新加载app下内容
|
|
229
|
-
await naslServer.openApp(app);
|
|
230
|
-
// 重新check一遍所有内容
|
|
231
|
-
await naslServer.getDiagnosticRecordsAndPushAll();
|
|
232
|
-
},
|
|
233
|
-
/**
|
|
234
|
-
* 初始化之前添加文件
|
|
235
|
-
*/
|
|
236
|
-
addFile(file) {
|
|
237
|
-
return this.messager.requestCommand('addFile', file);
|
|
238
|
-
},
|
|
239
|
-
/**
|
|
240
|
-
* 只新增文件
|
|
241
|
-
* @param {*} files
|
|
242
|
-
*/
|
|
243
|
-
writeFiles(files) {
|
|
244
|
-
return this.messager.requestCommand('writeFiles', files);
|
|
245
|
-
},
|
|
246
|
-
/**
|
|
247
|
-
* 新增、修改
|
|
248
|
-
* 删除文件 文件用修改内容为空模拟,防止报错
|
|
249
|
-
* @param {*} args
|
|
250
|
-
*/
|
|
251
|
-
updateFiles(args) {
|
|
252
|
-
return this.messager.requestCommand('updateFiles', args);
|
|
253
|
-
},
|
|
254
|
-
/**
|
|
255
|
-
* 清除一个目录下的所有文件
|
|
256
|
-
*/
|
|
257
|
-
deleteDirectoryFiles(args) {
|
|
258
|
-
return this.messager.requestCommand('deleteDirectoryFiles', args);
|
|
259
|
-
},
|
|
260
|
-
_debugInFileStorage(node, openFiles) {
|
|
261
|
-
/// #if process.env.NODE_ENV === 'development'
|
|
262
|
-
let app = node;
|
|
263
|
-
if (node.concept !== 'App') {
|
|
264
|
-
app = node.rootNode || node.app;
|
|
265
|
-
}
|
|
266
|
-
return Promise.all(openFiles.map(async (file) => {
|
|
267
|
-
const res = await storage_1.default.post('/api/App/debugEmbedded?id=' + app.id, file);
|
|
268
|
-
return res.data;
|
|
269
|
-
})).catch((e) => {
|
|
270
|
-
console.error(e);
|
|
271
|
-
});
|
|
272
|
-
/// #endif
|
|
273
|
-
},
|
|
274
|
-
open() {
|
|
275
|
-
return this.messager.requestCommand('open');
|
|
276
|
-
},
|
|
277
|
-
updateOpen(args) {
|
|
278
|
-
return this.messager.requestCommand('updateOpen', args);
|
|
279
|
-
},
|
|
280
|
-
fileReferences(filePath) {
|
|
281
|
-
return this.messager.requestCommand('fileReferences', filePath);
|
|
282
|
-
},
|
|
283
|
-
async references(args) {
|
|
284
|
-
return (await this.messager.requestCommand('references', args))?.response;
|
|
285
|
-
},
|
|
286
|
-
getValueSelectCompletion(node, value, noFilterList) {
|
|
287
|
-
const { currentSource, fileNode } = naslServer.getCurrentSource(node);
|
|
288
|
-
// console.log(currentSource, fileNode);
|
|
289
|
-
if (currentSource && fileNode) {
|
|
290
|
-
return naslServer._getValueSelectCompletion({
|
|
291
|
-
file: fileNode.getEmbeddedFilePath(),
|
|
292
|
-
range: {
|
|
293
|
-
line: (0, translator_1.lsp2tspNumber)(currentSource.range.start.line),
|
|
294
|
-
offset: (0, translator_1.lsp2tspNumber)(currentSource.range.start.character),
|
|
295
|
-
},
|
|
296
|
-
value,
|
|
297
|
-
noFilterList,
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
else {
|
|
301
|
-
console.log('没找到节点', node, currentSource, fileNode);
|
|
302
|
-
}
|
|
303
|
-
},
|
|
304
|
-
_getValueSelectCompletion(args) {
|
|
305
|
-
return this.messager.requestCommand('getValueSelectCompletion', args);
|
|
306
|
-
},
|
|
307
|
-
// 联合类型切割取出类型
|
|
308
|
-
getDisplayString2Type(displayString) {
|
|
309
|
-
// 取出匹配的内容
|
|
310
|
-
const reg = /\<([^()]+)\>/g;
|
|
311
|
-
const types = reg.exec(displayString);
|
|
312
|
-
// 取出提示的类型,组成是数组
|
|
313
|
-
const typeList = types[1].split(' | ').map((item) => {
|
|
314
|
-
if (/\<([^()]+)\>/g.exec(item)) {
|
|
315
|
-
return item;
|
|
316
|
-
}
|
|
317
|
-
else if (item.includes(' ')) {
|
|
318
|
-
const strs = item.split(' ');
|
|
319
|
-
const type = strs[strs.length - 1];
|
|
320
|
-
return type;
|
|
321
|
-
}
|
|
322
|
-
else if (item.includes('.')) {
|
|
323
|
-
const strs = item.split('.');
|
|
324
|
-
const type = strs[strs.length - 1];
|
|
325
|
-
return type;
|
|
326
|
-
}
|
|
327
|
-
else {
|
|
328
|
-
return item;
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
return typeList;
|
|
332
|
-
},
|
|
333
|
-
async getTypeQuickinfo(node) {
|
|
334
|
-
if (node && node instanceof concepts_1.BaseNode) {
|
|
335
|
-
const callFunction = node.parentNode.parentNode;
|
|
336
|
-
/**
|
|
337
|
-
* currentSource callFunction 的节点,要去到当前节点的位置
|
|
338
|
-
* nasl.util.Convert(xxx),所以取到的位置要 + `nasl.util.C` 的长度
|
|
339
|
-
* fileNode
|
|
340
|
-
*/
|
|
341
|
-
const { currentSource, fileNode } = naslServer.getCurrentSource(callFunction);
|
|
342
|
-
try {
|
|
343
|
-
const quickInfo = await naslServer._getTypeQuickinfo({
|
|
344
|
-
file: fileNode.getEmbeddedFilePath(),
|
|
345
|
-
line: (0, translator_1.lsp2tspNumber)(currentSource.range.start.line),
|
|
346
|
-
offset: (0, translator_1.lsp2tspNumber)(currentSource.range.start.character) + `nasl.util.C`.length,
|
|
347
|
-
});
|
|
348
|
-
if (quickInfo.responseRequired) {
|
|
349
|
-
const displayString = quickInfo?.response?.displayString || '';
|
|
350
|
-
const typeList = naslServer.getDisplayString2Type(displayString);
|
|
351
|
-
const res = [];
|
|
352
|
-
typeList.forEach((type) => {
|
|
353
|
-
const typeAnnotation = coreTypeList_1.primitiveTypeList.find((typeAnnotation) => typeAnnotation.typeName === type);
|
|
354
|
-
if (typeAnnotation) {
|
|
355
|
-
res.push(typeAnnotation);
|
|
356
|
-
}
|
|
357
|
-
else if (type === 'unknown' || type === 'never') {
|
|
358
|
-
return null;
|
|
359
|
-
}
|
|
360
|
-
});
|
|
361
|
-
if (!res.length) {
|
|
362
|
-
return [];
|
|
363
|
-
}
|
|
364
|
-
else {
|
|
365
|
-
return [{ title: '基础类型', children: res }];
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
catch (err) {
|
|
370
|
-
console.log(err);
|
|
371
|
-
// 如果有异常就先放开全部可选,兜底逻辑
|
|
372
|
-
return [];
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
else {
|
|
376
|
-
// 字符串 和 inter
|
|
377
|
-
return [{ title: '基础类型', children: [coreTypeList_1.primitiveTypeList[4]] }];
|
|
378
|
-
}
|
|
379
|
-
},
|
|
380
|
-
async getDataSchemaType(node) {
|
|
381
|
-
if (!(node instanceof concepts_1.ViewElement))
|
|
382
|
-
return;
|
|
383
|
-
const { currentSource, fileNode } = naslServer.getCurrentSource(node);
|
|
384
|
-
const quickInfo = await naslServer._getTypeQuickinfo({
|
|
385
|
-
file: fileNode.getEmbeddedFilePath(),
|
|
386
|
-
line: (0, translator_1.lsp2tspNumber)(currentSource.range.start.line),
|
|
387
|
-
offset: (0, translator_1.lsp2tspNumber)(currentSource.range.start.character) + `__elements.`.length,
|
|
388
|
-
});
|
|
389
|
-
if (quickInfo.responseRequired) {
|
|
390
|
-
const displayString = quickInfo?.response?.displayString || '';
|
|
391
|
-
const flag = displayString.includes('<') && displayString.includes('>');
|
|
392
|
-
if (flag) {
|
|
393
|
-
let str = '';
|
|
394
|
-
const types = naslServer.getDisplayString2Type(displayString);
|
|
395
|
-
if (Array.isArray(types) && types.length) {
|
|
396
|
-
const type = types[0];
|
|
397
|
-
str = type === 'any' || type === 'unknown' || type === 'never' ? '' : type;
|
|
398
|
-
}
|
|
399
|
-
return str;
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
return '';
|
|
403
|
-
},
|
|
404
|
-
_getTypeQuickinfo(args) {
|
|
405
|
-
return this.messager.requestCommand('quickInfo', args);
|
|
406
|
-
},
|
|
407
|
-
getSelectNextCompletion(node, noFilterList) {
|
|
408
|
-
const { currentSource, fileNode } = naslServer.getCurrentSource(node);
|
|
409
|
-
// console.log(currentSource, fileNode);
|
|
410
|
-
if (currentSource && fileNode) {
|
|
411
|
-
return naslServer._getSelectNextCompletion({
|
|
412
|
-
file: fileNode.getEmbeddedFilePath(),
|
|
413
|
-
range: {
|
|
414
|
-
line: (0, translator_1.lsp2tspNumber)(currentSource.range.start.line),
|
|
415
|
-
offset: (0, translator_1.lsp2tspNumber)(currentSource.range.start.character),
|
|
416
|
-
},
|
|
417
|
-
noFilterList,
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
else {
|
|
421
|
-
console.log('没找到节点', currentSource, fileNode);
|
|
422
|
-
}
|
|
423
|
-
},
|
|
424
|
-
_getSelectNextCompletion(args) {
|
|
425
|
-
return this.messager.requestCommand('getSelectNextCompletion', args);
|
|
426
|
-
},
|
|
427
|
-
async getDiagnosticRecords(fileNames) {
|
|
428
|
-
const records = (await this.messager.requestCommand('getDiagnosticRecords', fileNames));
|
|
429
|
-
return this._resolveDiagnosticRecords(records);
|
|
430
|
-
},
|
|
431
|
-
async getDiagnosticRecordsAndPushAll(fileNames) {
|
|
432
|
-
const records = await this.getDiagnosticRecords(fileNames);
|
|
433
|
-
// diagnosticManager.pushAll(records);
|
|
434
|
-
},
|
|
435
|
-
_resolveDiagnosticRecords(records) {
|
|
436
|
-
records.forEach((record) => {
|
|
437
|
-
const node = this.file2NodeMap.get(record.filePath);
|
|
438
|
-
if (!node)
|
|
439
|
-
return;
|
|
440
|
-
record.id = node.id;
|
|
441
|
-
record.node = node;
|
|
442
|
-
// 先获取原来的节点先清除一下之前有异常的节点,下面重新赋值
|
|
443
|
-
const oldRecord = diagnostic_1.default.getRecord(record.id);
|
|
444
|
-
oldRecord?.semanticDiagnostics.forEach((item) => {
|
|
445
|
-
item.node ? (item.node.tsErrorDetail = undefined) : '';
|
|
446
|
-
});
|
|
447
|
-
// 语义诊断
|
|
448
|
-
if (isChangeInterface) {
|
|
449
|
-
this.existStructureFix(record.semanticDiagnostics, node, this);
|
|
450
|
-
}
|
|
451
|
-
record.semanticDiagnostics = record.semanticDiagnostics
|
|
452
|
-
.map((diag) => this._resolveDiagnostic(diag, node))
|
|
453
|
-
.filter((diag) => !!diag);
|
|
454
|
-
record.semanticDiagnostics.push(...this._attachDiagnostics(node));
|
|
455
|
-
// 建议诊断
|
|
456
|
-
// 实体下的建议不用展示,因为都是平台自己写的逻辑
|
|
457
|
-
// if (node instanceof Entity) {
|
|
458
|
-
// record.suggestionDiagnostics = [];
|
|
459
|
-
// }
|
|
460
|
-
// if (node instanceof View) {
|
|
461
|
-
// // event在view中不展示建议使用,提示关闭掉
|
|
462
|
-
// record.suggestionDiagnostics = record.suggestionDiagnostics.filter((item) => !item.text.includes(`'event'`));
|
|
463
|
-
// }
|
|
464
|
-
// if (node instanceof Logic) {
|
|
465
|
-
// // logic在for循环中,不展示any提示
|
|
466
|
-
// record.suggestionDiagnostics = record.suggestionDiagnostics.filter((item) => !item.text.includes(`implicitly has an 'any' type, but a better type may be inferred from usage.`));
|
|
467
|
-
// }
|
|
468
|
-
// record.suggestionDiagnostics = record.suggestionDiagnostics
|
|
469
|
-
// .map((diag) => this._resolveDiagnostic(diag as unknown as tsProtocol.DiagnosticWithFileName, node.sourceMap))
|
|
470
|
-
// .filter((diag) => !!diag);
|
|
471
|
-
record.suggestionDiagnostics = [];
|
|
472
|
-
// 语法诊断暂时不需要
|
|
473
|
-
});
|
|
474
|
-
return records;
|
|
475
|
-
},
|
|
476
|
-
_attachDiagnostics(fileNode) {
|
|
477
|
-
const diagnostics = [];
|
|
478
|
-
if (fileNode instanceof concepts_1.View) {
|
|
479
|
-
(0, utils_1.traverse)((current) => {
|
|
480
|
-
if (current.node.tag) {
|
|
481
|
-
current.node.bindAttrs.forEach((bindAttr) => {
|
|
482
|
-
if ((bindAttr.model || bindAttr.sync) && bindAttr.expression && bindAttr.expression.concept !== 'Identifier' && bindAttr.expression.concept !== 'MemberExpression') {
|
|
483
|
-
const diagnostic = {
|
|
484
|
-
node: bindAttr,
|
|
485
|
-
severity: 'error',
|
|
486
|
-
message: '页面元素双向绑定:只允许绑定可赋值的变量和字段。',
|
|
487
|
-
};
|
|
488
|
-
bindAttr.tsErrorDetail = diagnostic;
|
|
489
|
-
diagnostics.push(diagnostic);
|
|
490
|
-
}
|
|
491
|
-
});
|
|
492
|
-
}
|
|
493
|
-
}, { node: { children: fileNode.elements } });
|
|
494
|
-
}
|
|
495
|
-
if (fileNode instanceof concepts_1.DataSource) {
|
|
496
|
-
const dataSourceGroup = fileNode.rootNode.configuration?.getGroup('dataSource');
|
|
497
|
-
if (dataSourceGroup) {
|
|
498
|
-
const property = dataSourceGroup.getProperty(fileNode.name);
|
|
499
|
-
if (property && property.values) {
|
|
500
|
-
property.values.forEach((propertyValue) => {
|
|
501
|
-
if (!propertyValue.value && fileNode.name !== 'defaultDS') {
|
|
502
|
-
const diagnostic = {
|
|
503
|
-
node: fileNode,
|
|
504
|
-
severity: 'error',
|
|
505
|
-
message: `数据源配置:数据源${property.name}${propertyValue.env === 'dev' ? '开发环境' : '生产环境'}未配置数据信息`,
|
|
506
|
-
// 保留原来的内容方便查询一些问题
|
|
507
|
-
originalDiagnostic: {
|
|
508
|
-
fileName: '',
|
|
509
|
-
start: null,
|
|
510
|
-
end: null,
|
|
511
|
-
category: 'error',
|
|
512
|
-
text: `Data Source is not config`,
|
|
513
|
-
},
|
|
514
|
-
};
|
|
515
|
-
diagnostics.push(diagnostic);
|
|
516
|
-
}
|
|
517
|
-
});
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
return diagnostics;
|
|
522
|
-
},
|
|
523
|
-
/* 接口导入查找 */
|
|
524
|
-
existStructureFix(semanticDiagnostics, node, that) {
|
|
525
|
-
let module;
|
|
526
|
-
semanticDiagnostics.map((diag) => {
|
|
527
|
-
const minRange = this._findMinRange(diag, node);
|
|
528
|
-
if (diag.text?.includes('has no exported member named')) {
|
|
529
|
-
if (minRange.node instanceof concepts_1.Logic) {
|
|
530
|
-
return null;
|
|
531
|
-
}
|
|
532
|
-
const typeAnnotation = minRange.node instanceof concepts_1.TypeAnnotation ? minRange.node.upperNode.typeAnnotation : minRange.node.typeAnnotation;
|
|
533
|
-
const regNamespace = /<(\S*)>/;
|
|
534
|
-
const typeKey = (typeAnnotation.typeKey.match(regNamespace) && typeAnnotation.typeKey.match(regNamespace)[1]) || typeAnnotation.typeKey;
|
|
535
|
-
const typeKeyArr = typeKey.split('.');
|
|
536
|
-
if (typeKeyArr[0] === 'apis') {
|
|
537
|
-
const structureName = typeKeyArr[3];
|
|
538
|
-
const moduleName = typeKeyArr[1];
|
|
539
|
-
const app = typeAnnotation.upperNode.app;
|
|
540
|
-
if (!app) {
|
|
541
|
-
return null;
|
|
542
|
-
}
|
|
543
|
-
module = app.interfaceDependencies?.find((item) => item.name === moduleName);
|
|
544
|
-
let existStructure = module?.structures?.find((item) => item.name.toUpperCase() === structureName.toUpperCase());
|
|
545
|
-
if (!existStructure) {
|
|
546
|
-
const realName = structureName.replace(/\d*$/, (m) => String(''));
|
|
547
|
-
existStructure = module?.structures?.find((item) => item.name.toUpperCase() === realName.toUpperCase());
|
|
548
|
-
}
|
|
549
|
-
if (existStructure) {
|
|
550
|
-
const editTypeAnnotation = JSON.parse(JSON.stringify(typeAnnotation).replace(new RegExp(structureName, 'g'), existStructure.name));
|
|
551
|
-
actionArr.push({ target: typeAnnotation.parentNode, typeannotation: editTypeAnnotation });
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
return null;
|
|
555
|
-
}
|
|
556
|
-
else {
|
|
557
|
-
return diag;
|
|
558
|
-
}
|
|
559
|
-
});
|
|
560
|
-
if (actionArr.length) {
|
|
561
|
-
if (timer)
|
|
562
|
-
return;
|
|
563
|
-
timer = window.setTimeout(() => {
|
|
564
|
-
const app = actionArr[0].target.app;
|
|
565
|
-
app.emit('collect:start', {
|
|
566
|
-
actionMsg: '设置导入接口数据类型错误',
|
|
567
|
-
});
|
|
568
|
-
module.isAdd && module.setIsAdd(false);
|
|
569
|
-
actionArr.forEach((item) => {
|
|
570
|
-
item.target.setDataType(concepts_1.TypeAnnotation.from(item.typeannotation));
|
|
571
|
-
});
|
|
572
|
-
app.emit('collect:end');
|
|
573
|
-
actionArr = [];
|
|
574
|
-
isChangeInterface = false;
|
|
575
|
-
clearTimeout(timer);
|
|
576
|
-
timer = null;
|
|
577
|
-
}, 2000);
|
|
578
|
-
}
|
|
579
|
-
},
|
|
580
|
-
_resolveDiagnostic(diagnostic, fileNode) {
|
|
581
|
-
const minRange = this._findMinRange(diagnostic, fileNode);
|
|
582
|
-
const tsErrorDetail = {
|
|
583
|
-
severity: diagnostic.category === 'error' ? 'error' : 'warning',
|
|
584
|
-
message: (0, translator_2.translateDiagnosticMessage)(diagnostic.text),
|
|
585
|
-
// 保留原来的内容方便查询一些问题
|
|
586
|
-
originalDiagnostic: diagnostic,
|
|
587
|
-
};
|
|
588
|
-
if (minRange) {
|
|
589
|
-
// 节点的error要置为true
|
|
590
|
-
return (0, translator_2.naslNodeTranslateMessage)(minRange, tsErrorDetail);
|
|
591
|
-
}
|
|
592
|
-
else {
|
|
593
|
-
// 没找到节点, 先把问题暴露出来
|
|
594
|
-
return {
|
|
595
|
-
id: undefined,
|
|
596
|
-
...tsErrorDetail,
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
|
-
},
|
|
600
|
-
_findMinRange(diagnostic, fileNode) {
|
|
601
|
-
let minRange;
|
|
602
|
-
const sourceMap = fileNode.sourceMap;
|
|
603
|
-
for (const [node, item] of sourceMap.entries()) {
|
|
604
|
-
/**
|
|
605
|
-
* 当前内容的开始行 <= 诊断开始的行 &&
|
|
606
|
-
* 当前内容的结束行 >= 诊断结束的行
|
|
607
|
-
*/
|
|
608
|
-
if ((0, translator_1.lsp2tspNumber)(item.range.start.line) <= diagnostic.start.line && (0, translator_1.lsp2tspNumber)(item.range.end.line) >= diagnostic.end.line) {
|
|
609
|
-
// 如果找到某一行
|
|
610
|
-
if ((0, translator_1.lsp2tspNumber)(item.range.start.line) === diagnostic.start.line && (0, translator_1.lsp2tspNumber)(item.range.end.line) === diagnostic.end.line) {
|
|
611
|
-
// 在行的范围但是又不在列的范围,不用给默认值,给了反而不对,
|
|
612
|
-
// 需要在列的范围内
|
|
613
|
-
if ((0, translator_1.lsp2tspNumber)(item.range.start.character) <= diagnostic.start.offset && (0, translator_1.lsp2tspNumber)(item.range.end.character) >= diagnostic.end.offset) {
|
|
614
|
-
// 比列更靠近 ,满足条件且长度更短
|
|
615
|
-
// 如果先走到下面有一个默认值了就像在if for里面有个表达式
|
|
616
|
-
// if for的内容也是包括当前的所以会重新赋值
|
|
617
|
-
if (!minRange || item.code.length < minRange.item.code.length) {
|
|
618
|
-
minRange = { item, node };
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
else {
|
|
623
|
-
// 没有节点 或者 行差比较小比已有的小就可以
|
|
624
|
-
// 一般出现在一大块上,多半是if for 等等没有参数
|
|
625
|
-
if (!minRange || item.range.end.line - item.range.start.line < minRange.item.range.end.line - minRange.item.range.start.line) {
|
|
626
|
-
minRange = { node, item };
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
if (!minRange) {
|
|
632
|
-
if (fileNode instanceof concepts_1.View) {
|
|
633
|
-
return { node: fileNode, item: sourceMap.get(fileNode) };
|
|
634
|
-
}
|
|
635
|
-
console.log(diagnostic, 'diagnostic');
|
|
636
|
-
console.log(sourceMap, 'sourceMap');
|
|
637
|
-
console.log(minRange, '需要特殊看下,为什么没找到内容-------------');
|
|
638
|
-
}
|
|
639
|
-
return minRange;
|
|
640
|
-
},
|
|
641
|
-
async _isHaveRef(node) {
|
|
642
|
-
const { currentSource, fileNode } = naslServer.getCurrentSource(node);
|
|
643
|
-
let refsList = [];
|
|
644
|
-
/**
|
|
645
|
-
* 未完成创建的节点 ,或者异常情况 可能找不到节点
|
|
646
|
-
*/
|
|
647
|
-
if (currentSource) {
|
|
648
|
-
const newRefs = await naslServer.references({
|
|
649
|
-
file: fileNode.getEmbeddedFilePath(),
|
|
650
|
-
line: (0, translator_1.lsp2tspNumber)(currentSource.range.start.line),
|
|
651
|
-
offset: (0, translator_1.lsp2tspNumber)(currentSource.range.start.character),
|
|
652
|
-
});
|
|
653
|
-
refsList = [...newRefs.refs];
|
|
654
|
-
}
|
|
655
|
-
else {
|
|
656
|
-
if (node instanceof concepts_1.Module) {
|
|
657
|
-
const lists = node.logics || node.structures || node.enums;
|
|
658
|
-
const moduleName = fileNode.getEmbeddedFilePath();
|
|
659
|
-
if (lists.length) {
|
|
660
|
-
const item = lists[0];
|
|
661
|
-
const { fileNode } = naslServer.getCurrentSource(item);
|
|
662
|
-
const newRefs = await naslServer.references({
|
|
663
|
-
file: fileNode.getEmbeddedFilePath(),
|
|
664
|
-
line: 1,
|
|
665
|
-
offset: 22, //固定的位置,module的位置信息
|
|
666
|
-
});
|
|
667
|
-
refsList = newRefs.refs.filter((item) => !item.file.startsWith(moduleName));
|
|
668
|
-
// 多塞一个 ,删除的时候就有值了, 上面过滤了之后可能是空的
|
|
669
|
-
refsList.unshift(newRefs.refs[0]);
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
// 如果是DataSource就需要在单独,查一边来修改名字
|
|
674
|
-
if (node instanceof concepts_1.DataSource) {
|
|
675
|
-
// 过滤一把不需要改的信息
|
|
676
|
-
refsList = refsList.filter((item) => {
|
|
677
|
-
const dataSourceFile = fileNode.getEmbeddedFilePath();
|
|
678
|
-
const entityFilePrefix = dataSourceFile.replace('.ts', '');
|
|
679
|
-
/**
|
|
680
|
-
* 特殊处理,因为关联属性或者关联实体等等都是在实体里,在实体中因为自己不可以是自己的类型
|
|
681
|
-
* 所以全部过滤掉了,
|
|
682
|
-
* 但是在datasource里面在实体里会有大量的引用,不需要全部修改.只需要处理除了8个函数之外的引用
|
|
683
|
-
* 所以底部内容是8个函数,所以这里就 用entity的行数 减去8个函数的行数,然后其余的在进行处理
|
|
684
|
-
* 进行过滤
|
|
685
|
-
*/
|
|
686
|
-
// 不要数据源下面的实体里的引用 ,保留原始的节点内容
|
|
687
|
-
let flag = false;
|
|
688
|
-
if (item.file.includes(entityFilePrefix)) {
|
|
689
|
-
const entity = this.file2NodeMap.get(item.file);
|
|
690
|
-
const { currentSource } = naslServer.getCurrentSource(entity);
|
|
691
|
-
// 32 8个函数的总行数
|
|
692
|
-
if (item.end.line < currentSource.range.end.line - 32 && item.start.line > 1) {
|
|
693
|
-
flag = true;
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
// 属于实体而且需要修改和查到 || 不是实体前缀的 || 他本身
|
|
697
|
-
return flag || !item.file.includes(entityFilePrefix) || dataSourceFile === item.file;
|
|
698
|
-
});
|
|
699
|
-
}
|
|
700
|
-
// 如果是entity就需要在单独,查一边来修改名字
|
|
701
|
-
if (node instanceof concepts_1.Entity) {
|
|
702
|
-
// 过滤一把不需要改的信息
|
|
703
|
-
refsList = refsList.filter((item) => fileNode.getEmbeddedFilePath() !== item.file || item.isDefinition === true);
|
|
704
|
-
// 不再当前文件里
|
|
705
|
-
// 或者在当前列表但是位置小于entity的结束位置
|
|
706
|
-
}
|
|
707
|
-
if (node instanceof concepts_1.Return) {
|
|
708
|
-
// 过滤一下最后出去的值
|
|
709
|
-
refsList = refsList.filter((item) => !item.lineText.includes('return '));
|
|
710
|
-
}
|
|
711
|
-
// 如果是参数, 就需要把logic的引用 都查找出来就需要把他的父级的引用全部查找出来
|
|
712
|
-
if (node instanceof concepts_1.Param && node.parentNode instanceof concepts_1.Logic) {
|
|
713
|
-
const logicNode = node.parentNode;
|
|
714
|
-
const { currentSource } = naslServer.getCurrentSource(logicNode);
|
|
715
|
-
const parentRefs = await naslServer.references({
|
|
716
|
-
file: fileNode.getEmbeddedFilePath(),
|
|
717
|
-
line: (0, translator_1.lsp2tspNumber)(currentSource.range.start.line),
|
|
718
|
-
offset: (0, translator_1.lsp2tspNumber)(currentSource.range.start.character),
|
|
719
|
-
});
|
|
720
|
-
refsList = [...refsList, ...parentRefs.refs];
|
|
721
|
-
}
|
|
722
|
-
// 如果是参数修改, 就需要把logic的引用 都查找出来就需要把他的父级的引用全部查找出来d
|
|
723
|
-
if (node instanceof concepts_1.Param && node.parentNode instanceof concepts_1.View) {
|
|
724
|
-
const viewNode = node.parentNode;
|
|
725
|
-
const { currentSource } = naslServer.getCurrentSource(viewNode);
|
|
726
|
-
const code = currentSource.code;
|
|
727
|
-
const viewIndex = code.indexOf(' {');
|
|
728
|
-
const viewRefs = await naslServer.references({
|
|
729
|
-
file: fileNode.getEmbeddedFilePath(),
|
|
730
|
-
line: (0, translator_1.lsp2tspNumber)(currentSource.range.start.line),
|
|
731
|
-
offset: (0, translator_1.lsp2tspNumber)(currentSource.range.start.character + viewIndex),
|
|
732
|
-
});
|
|
733
|
-
const filterViewRefs = viewRefs.refs.filter((item) => item.lineText.includes('.$destination('));
|
|
734
|
-
refsList = [...refsList, ...filterViewRefs];
|
|
735
|
-
}
|
|
736
|
-
/**
|
|
737
|
-
* 暂时不要了, 因为生成的结构发生了变化
|
|
738
|
-
* view 因为不是嵌套的,所以不能用最前面的变量查找,所以要单独处理一下
|
|
739
|
-
* 找到第一个 { 之前的变量 进行修改
|
|
740
|
-
* 如果是VIew的查找,比较特殊,他查的是当前抛出的 {} 大括号前的
|
|
741
|
-
* 最后一个,因为生成的规则不一样
|
|
742
|
-
*/
|
|
743
|
-
// if (node instanceof View) {
|
|
744
|
-
// const code = currentSource.code;
|
|
745
|
-
// const viewIndex = code.indexOf(' {');
|
|
746
|
-
// const viewRefs = await naslServer.references({
|
|
747
|
-
// file: (fileNode as FileNode).getEmbeddedFilePath(),
|
|
748
|
-
// line: lsp2tspNumber(currentSource.range.start.line),
|
|
749
|
-
// offset: lsp2tspNumber(currentSource.range.start.character + viewIndex),
|
|
750
|
-
// });
|
|
751
|
-
// refsList = [...viewRefs.refs];
|
|
752
|
-
// }
|
|
753
|
-
/**
|
|
754
|
-
* elements 需要查的是__elements.后面的那个内容,过滤两个为了生成内容的节点
|
|
755
|
-
*/
|
|
756
|
-
if (node instanceof concepts_1.ViewElement) {
|
|
757
|
-
if (currentSource) {
|
|
758
|
-
const code = currentSource.code;
|
|
759
|
-
const prefix = '__elements.';
|
|
760
|
-
const prefixIndex = code.indexOf(prefix) !== -1 ? code.indexOf(prefix) : 0;
|
|
761
|
-
const methodsNameIndex = prefixIndex + prefix.length;
|
|
762
|
-
const methods = await naslServer.references({
|
|
763
|
-
file: fileNode.getEmbeddedFilePath(),
|
|
764
|
-
line: (0, translator_1.lsp2tspNumber)(currentSource.range.start.line),
|
|
765
|
-
offset: (0, translator_1.lsp2tspNumber)(currentSource.range.start.character + methodsNameIndex),
|
|
766
|
-
});
|
|
767
|
-
const methodRefs = [];
|
|
768
|
-
methods.refs.forEach((item) => {
|
|
769
|
-
// 定义里的格式,在删除的时候留下来占位
|
|
770
|
-
// 重命名的时候会过滤
|
|
771
|
-
// 这里只过滤 __elements.button = new nasl.ui.Button<any>这种格式
|
|
772
|
-
// if (item.lineText.includes('__elements.') && item.lineText.includes('new nasl.ui.'))
|
|
773
|
-
// return false;
|
|
774
|
-
// 处理声明组件名可能重复的问题, 查找引用不提示
|
|
775
|
-
const find = methodRefs.find((findItem) => item.lineText === findItem.lineText && item.lineText.includes(': nasl.ui.'));
|
|
776
|
-
if (!find) {
|
|
777
|
-
methodRefs.push(item);
|
|
778
|
-
}
|
|
779
|
-
});
|
|
780
|
-
refsList = [...methodRefs];
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
console.log(refsList, 'refsList');
|
|
784
|
-
return refsList;
|
|
785
|
-
},
|
|
786
|
-
/**
|
|
787
|
-
* 查找引用,并且做一些 修改前的准备工作,
|
|
788
|
-
* 有引用有的话,就返回集合
|
|
789
|
-
* @param node 当前重命名的节点
|
|
790
|
-
* @param newValue 传递过来的新值,给MemberExpression用的比较特殊
|
|
791
|
-
* 而且,这个新值不一定会用到,MemberExpression在批量更新的时候,可以取到新的value, 这里需要位置信息防止 a.a.a.a 中的一个a发生修改
|
|
792
|
-
* @returns 找到的引用
|
|
793
|
-
*/
|
|
794
|
-
_renamePrepare(node, refsList, newValue) {
|
|
795
|
-
const oldName = node?.name;
|
|
796
|
-
const result = refsList
|
|
797
|
-
.map((record) => {
|
|
798
|
-
const fileNode = this.file2NodeMap.get(record.file);
|
|
799
|
-
if (!fileNode)
|
|
800
|
-
return null;
|
|
801
|
-
const minRange = this._findMinRange(record, fileNode);
|
|
802
|
-
if (minRange) {
|
|
803
|
-
// 如果节点是TypeAnnotation类型,
|
|
804
|
-
// 很复杂,可能是多级嵌套结构
|
|
805
|
-
// 不一定只修改typeName
|
|
806
|
-
if (minRange.node instanceof concepts_1.TypeAnnotation) {
|
|
807
|
-
// console.log(record);
|
|
808
|
-
// 如果是fake的逻辑,内部的重命名都不需要修改
|
|
809
|
-
// if ((minRange.node?.parentNode as any).logic && (minRange.node?.parentNode as any).logic?.fake) {
|
|
810
|
-
// return null;
|
|
811
|
-
// }
|
|
812
|
-
minRange.setTypeMethods = 'setTypeName';
|
|
813
|
-
}
|
|
814
|
-
// 如果节点是logic修改引发calllogic修改
|
|
815
|
-
if (minRange.node instanceof concepts_1.CallLogic && node instanceof concepts_1.Logic) {
|
|
816
|
-
minRange.setTypeMethods = 'setCalleeName';
|
|
817
|
-
}
|
|
818
|
-
if (minRange.node instanceof concepts_1.CallLogic && node instanceof concepts_1.ViewElement) {
|
|
819
|
-
minRange.setTypeMethods = 'setCalleeNamespace';
|
|
820
|
-
minRange.newValue = 'elements.' + newValue + '.logics';
|
|
821
|
-
}
|
|
822
|
-
// 如果节点是实体修改引发calllogic修改
|
|
823
|
-
if (minRange.node instanceof concepts_1.CallLogic && (node instanceof concepts_1.Entity || node instanceof concepts_1.View || node instanceof concepts_1.Process || node instanceof concepts_1.ProcessElement)) {
|
|
824
|
-
// 匹配到的内容,当前这一行的内容;
|
|
825
|
-
// 因为要用下面的点位信息
|
|
826
|
-
/**
|
|
827
|
-
* 如果namespce是 'app.views.Student.views.404.views.505.views.update'
|
|
828
|
-
* 在ts中会是'app.views.Student.views.$404.views.$505.views.update'
|
|
829
|
-
* 但是505 要改名为 666 ,要存的是666
|
|
830
|
-
* 'app.views.Student.views.404.views.666.views.update'
|
|
831
|
-
* 1.取到转后的
|
|
832
|
-
* 2.在匹配到的内容中取转后的namespace的位置
|
|
833
|
-
* 3.然后把namespace中的 $替换成 ''
|
|
834
|
-
*
|
|
835
|
-
*/
|
|
836
|
-
const tsCalleeNamespace = minRange.node.tsCalleeNamespace;
|
|
837
|
-
// 先看下标位置
|
|
838
|
-
const lineText = record.lineText;
|
|
839
|
-
const index = lineText.indexOf(tsCalleeNamespace);
|
|
840
|
-
// 在把开始结束位置的-开始位置,来知道是哪里要替换
|
|
841
|
-
const start = record.start.offset - index - 1;
|
|
842
|
-
const end = record.end.offset - index - 1;
|
|
843
|
-
// 新的完整的value
|
|
844
|
-
let newTsNameSpace = tsCalleeNamespace.substring(0, start) + newValue + tsCalleeNamespace.substring(end, tsCalleeNamespace.length);
|
|
845
|
-
newTsNameSpace = newTsNameSpace.replace(/.\$/g, '.');
|
|
846
|
-
minRange.setTypeMethods = 'setCalleeNamespace';
|
|
847
|
-
minRange.newValue = newTsNameSpace;
|
|
848
|
-
}
|
|
849
|
-
// 如果参数修改影响了 callLogic
|
|
850
|
-
if (minRange.node instanceof concepts_1.CallLogic && node instanceof concepts_1.Param) {
|
|
851
|
-
return null;
|
|
852
|
-
// 逻辑第几个位置发生修改,对应的calllogic对应位置的内容要进行修改
|
|
853
|
-
// minRange.setTypeMethods = 'setArgumentName';
|
|
854
|
-
// const nodeArguments = minRange.node.arguments;
|
|
855
|
-
// minRange.newValue = [...nodeArguments];
|
|
856
|
-
// const LogicNode = node.parentNode;
|
|
857
|
-
// const paramIndex = (LogicNode as Logic).params.findIndex((param) => param === node);
|
|
858
|
-
// console.log(node, nodeArguments);
|
|
859
|
-
// if (paramIndex !== -1) {
|
|
860
|
-
// minRange.setTypeMethods = 'setArgumentName';
|
|
861
|
-
// minRange.newValue = {
|
|
862
|
-
// argument: nodeArguments[paramIndex],
|
|
863
|
-
// newKeyword: newValue,
|
|
864
|
-
// };
|
|
865
|
-
// } else {
|
|
866
|
-
// return null;
|
|
867
|
-
// }
|
|
868
|
-
}
|
|
869
|
-
// 如果节点是Identifier表达式
|
|
870
|
-
if (minRange.node instanceof concepts_1.Identifier) {
|
|
871
|
-
// 匹配到的内容,当前这一行的内容;
|
|
872
|
-
// 因为要用下面的点位信息
|
|
873
|
-
const name = minRange.node.name;
|
|
874
|
-
// 如果name不改,那就是要改命名空间
|
|
875
|
-
if (newValue === name) {
|
|
876
|
-
const namespace = minRange.node.namespace;
|
|
877
|
-
// 先看下标位置
|
|
878
|
-
const lineText = record.lineText;
|
|
879
|
-
const index = lineText.indexOf(namespace);
|
|
880
|
-
// 在把开始结束位置的-开始位置,来知道是哪里要替换
|
|
881
|
-
const start = record.start.offset - index - 1;
|
|
882
|
-
const end = record.end.offset - index - 1;
|
|
883
|
-
// 新的完整的value
|
|
884
|
-
const newTextValue = namespace.substring(0, start) + newValue + namespace.substring(end, namespace.length);
|
|
885
|
-
minRange.setTypeMethods = 'setNamespace';
|
|
886
|
-
minRange.newValue = newTextValue;
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
// 如果是枚举修改,枚举的值刚好在Identifier 中选了 就修改值
|
|
890
|
-
if (minRange.node instanceof concepts_1.Identifier && node instanceof concepts_1.Enum) {
|
|
891
|
-
minRange.newValue = newValue;
|
|
892
|
-
minRange.setTypeMethods = 'setName';
|
|
893
|
-
}
|
|
894
|
-
// 如果修改逻辑,改到了Identifier表达式,只能说明是在属性里有使用了
|
|
895
|
-
if (minRange.node instanceof concepts_1.Identifier && node instanceof concepts_1.Logic) {
|
|
896
|
-
minRange.newValue = newValue;
|
|
897
|
-
minRange.setTypeMethods = 'setName';
|
|
898
|
-
}
|
|
899
|
-
// 如果节点是MemberExpression表达式
|
|
900
|
-
if (minRange.node instanceof concepts_1.MemberExpression) {
|
|
901
|
-
// 枚举key的特殊性,因为它不是原来的key+value形式的
|
|
902
|
-
// 是加了中括号啥的,所以直接赋值新值
|
|
903
|
-
if (node instanceof concepts_1.EnumItem) {
|
|
904
|
-
const newTextValue = node.parentNode.name + '.' + newValue;
|
|
905
|
-
minRange.newValue = newTextValue;
|
|
906
|
-
}
|
|
907
|
-
else {
|
|
908
|
-
// 匹配到的内容,当前这一行的内容;
|
|
909
|
-
// 因为要用下面的点位信息
|
|
910
|
-
const a = record.lineText;
|
|
911
|
-
// 之前的内容
|
|
912
|
-
const oldValue = minRange.node.getValue();
|
|
913
|
-
const index = a.indexOf(oldValue);
|
|
914
|
-
const start = record.start.offset - index - 1;
|
|
915
|
-
const end = record.end.offset - index - 1;
|
|
916
|
-
const newTextValue = oldValue.substring(0, start) + newValue + oldValue.substring(end, oldValue.length);
|
|
917
|
-
// MemberExpression可能改的是多层中的某一个
|
|
918
|
-
// 倒序, 对比看是哪里发生了修改
|
|
919
|
-
// 比较特殊就把新匹配到的值返回内部自己看要改那个地方的值
|
|
920
|
-
minRange.newValue = newTextValue;
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
// 如果是修改实体,引发节点依赖实体发生改变的
|
|
924
|
-
if (minRange.node instanceof concepts_1.EntityProperty && node instanceof concepts_1.Entity) {
|
|
925
|
-
minRange.setTypeMethods = 'setRelationEntity';
|
|
926
|
-
}
|
|
927
|
-
// 如果是修改实体属性,要同步实体属性
|
|
928
|
-
if (minRange.node instanceof concepts_1.EntityProperty && node instanceof concepts_1.EntityProperty && record.lineText.includes('@nasl.annotation.EntityRelation')) {
|
|
929
|
-
minRange.setTypeMethods = 'setRelationProperty';
|
|
930
|
-
}
|
|
931
|
-
// 如果要修改索引的
|
|
932
|
-
if (minRange.node instanceof concepts_1.EntityIndex) {
|
|
933
|
-
const newPropertyNameList = [...minRange.node.propertyNames];
|
|
934
|
-
const findIndex = newPropertyNameList.findIndex((item) => item === oldName);
|
|
935
|
-
if (findIndex !== -1) {
|
|
936
|
-
// 修改数组的值
|
|
937
|
-
newPropertyNameList.splice(findIndex, 1, newValue);
|
|
938
|
-
minRange.setTypeMethods = 'setPropertyNameList';
|
|
939
|
-
minRange.newValue = newPropertyNameList;
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
// 如果是跳转逻辑的修改
|
|
943
|
-
// 跳转逻辑本身页面 都需要带 View前缀
|
|
944
|
-
if (node instanceof concepts_1.View && minRange.node instanceof concepts_1.Destination) {
|
|
945
|
-
/**
|
|
946
|
-
* 如果namespce是 'app.views.Student.views.404.views.505.views.update'
|
|
947
|
-
* 在ts中会是'app.views.Student.views.$404.views.$505.views.update'
|
|
948
|
-
* 但是505 要改名为 666 ,要存的是666
|
|
949
|
-
* 'app.views.Student.views.404.views.666.views.update'
|
|
950
|
-
* 1.取到转后的
|
|
951
|
-
* 2.在匹配到的内容中取转后的namespace的位置
|
|
952
|
-
* 3.然后把namespace中的 $替换成 ''
|
|
953
|
-
*
|
|
954
|
-
*/
|
|
955
|
-
const tsCalleeNamespace = minRange.node.tsCalleeNamespace;
|
|
956
|
-
const tsName = minRange.node.tsName;
|
|
957
|
-
const oldValue = tsCalleeNamespace + '.' + tsName;
|
|
958
|
-
// 先看下标位置
|
|
959
|
-
const lineText = record.lineText;
|
|
960
|
-
const index = lineText.indexOf(oldValue);
|
|
961
|
-
// 在把开始结束位置的-开始位置,来知道是哪里要替换
|
|
962
|
-
const start = record.start.offset - index - 1;
|
|
963
|
-
const end = record.end.offset - index - 1;
|
|
964
|
-
if (start > tsCalleeNamespace.length) {
|
|
965
|
-
minRange.setTypeMethods = 'setViewName';
|
|
966
|
-
minRange.newValue = newValue;
|
|
967
|
-
}
|
|
968
|
-
else {
|
|
969
|
-
// 新的完整的value
|
|
970
|
-
let newTsNameSpace = tsCalleeNamespace.substring(0, start) + newValue + tsCalleeNamespace.substring(end, tsCalleeNamespace.length);
|
|
971
|
-
minRange.setTypeMethods = 'setViewNamespace';
|
|
972
|
-
newTsNameSpace = newTsNameSpace.replace(/\.\$/g, '.');
|
|
973
|
-
minRange.newValue = newTsNameSpace;
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
// 如果是事件修改
|
|
977
|
-
// 如果是view也需要加前缀
|
|
978
|
-
// logic 和 views名称修改 可能会触发bindEvent修改
|
|
979
|
-
if (minRange.node instanceof concepts_1.BindEvent) {
|
|
980
|
-
// 页面逻辑直接赋值就可以, 因为是相对路径
|
|
981
|
-
if (node instanceof concepts_1.ViewElement) {
|
|
982
|
-
minRange.setTypeMethods = 'setCalleeNamespace';
|
|
983
|
-
minRange.newValue = 'elements.' + newValue + '.logics';
|
|
984
|
-
}
|
|
985
|
-
else {
|
|
986
|
-
/**
|
|
987
|
-
* 如果namespce是 'app.views.Student.views.404.views.505.views.update'
|
|
988
|
-
* 在ts中会是'app.views.Student.views.$404.views.$505.views.update'
|
|
989
|
-
* 但是505 要改名为 666 ,要存的是666
|
|
990
|
-
* 'app.views.Student.views.404.views.666.views.update'
|
|
991
|
-
* 1.取到转后的
|
|
992
|
-
* 2.在匹配到的内容中取转后的namespace的位置
|
|
993
|
-
* 3.然后把namespace中的 $替换成 ''
|
|
994
|
-
*/
|
|
995
|
-
const tsCalleeNamespace = minRange.node.tsCalleeNamespace;
|
|
996
|
-
const oldValue = tsCalleeNamespace;
|
|
997
|
-
// 先看下标位置
|
|
998
|
-
const lineText = record.lineText;
|
|
999
|
-
const index = lineText.indexOf(oldValue);
|
|
1000
|
-
// 在把开始结束位置的-开始位置,来知道是哪里要替换
|
|
1001
|
-
const start = record.start.offset - index - 1;
|
|
1002
|
-
const end = record.end.offset - index - 1;
|
|
1003
|
-
// 新的完整的value
|
|
1004
|
-
if (start > tsCalleeNamespace.length) {
|
|
1005
|
-
minRange.setTypeMethods = 'setCalleeName';
|
|
1006
|
-
minRange.newValue = newValue;
|
|
1007
|
-
}
|
|
1008
|
-
else {
|
|
1009
|
-
// 新的完整的value
|
|
1010
|
-
let newTsNameSpace = tsCalleeNamespace.substring(0, start) + newValue + tsCalleeNamespace.substring(end, tsCalleeNamespace.length);
|
|
1011
|
-
minRange.setTypeMethods = 'setCalleeNamespace';
|
|
1012
|
-
newTsNameSpace = newTsNameSpace.replace(/\.\$/g, '.');
|
|
1013
|
-
minRange.newValue = newTsNameSpace;
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
if (minRange.node instanceof concepts_1.Destination && node instanceof concepts_1.Param) {
|
|
1018
|
-
// 因为view是key value 绑定所以需要重新赋值
|
|
1019
|
-
if (node.parentNode instanceof concepts_1.View) {
|
|
1020
|
-
const nodeArguments = minRange.node.arguments;
|
|
1021
|
-
const findArgument = nodeArguments.find((item) => node.name === item.keyword);
|
|
1022
|
-
if (findArgument) {
|
|
1023
|
-
minRange.setTypeMethods = 'setArgumentsKeyWord';
|
|
1024
|
-
minRange.newValue = {
|
|
1025
|
-
findArgument,
|
|
1026
|
-
newKeyword: newValue,
|
|
1027
|
-
};
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
else {
|
|
1031
|
-
// 如果是修改param查找到Destination就不操作
|
|
1032
|
-
return null;
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1035
|
-
if (minRange.node instanceof concepts_1.Interface && node instanceof concepts_1.Logic) {
|
|
1036
|
-
minRange.setTypeMethods = 'setOriginLogicName';
|
|
1037
|
-
}
|
|
1038
|
-
// 如果是role改名,就需要查到变更后的数组
|
|
1039
|
-
if ((minRange.node instanceof concepts_1.View || minRange.node instanceof concepts_1.ViewElement) && node instanceof concepts_1.Role) {
|
|
1040
|
-
// oldName旧的节点存的值
|
|
1041
|
-
// newValue用户输入值
|
|
1042
|
-
// node.bindRoles 存的
|
|
1043
|
-
minRange.setTypeMethods = 'setBindRoles';
|
|
1044
|
-
const str = minRange.node.bindRoles.toString().replace(oldName, newValue);
|
|
1045
|
-
const newBindRoles = str.split(',');
|
|
1046
|
-
minRange.newValue = newBindRoles;
|
|
1047
|
-
}
|
|
1048
|
-
// 修改枚举值找到了EntityProperty就说明给了默认值
|
|
1049
|
-
if (minRange.node instanceof concepts_1.EntityProperty && node instanceof concepts_1.EnumItem) {
|
|
1050
|
-
minRange.setTypeMethods = 'setDefaultValue';
|
|
1051
|
-
}
|
|
1052
|
-
if (minRange.node instanceof concepts_1.QueryFieldExpression && node instanceof concepts_1.Entity) {
|
|
1053
|
-
minRange.setTypeMethods = 'setEntityAsName';
|
|
1054
|
-
}
|
|
1055
|
-
// 如果修改的是dataSource字段
|
|
1056
|
-
if (node instanceof concepts_1.DataSource) {
|
|
1057
|
-
const setTypeNamespace = (typeNamespace, record) => {
|
|
1058
|
-
// 先看下标位置
|
|
1059
|
-
const lineText = record.lineText;
|
|
1060
|
-
const index = lineText.indexOf(typeNamespace);
|
|
1061
|
-
// 在把开始结束位置的-开始位置,来知道是哪里要替换
|
|
1062
|
-
const start = record.start.offset - index - 1;
|
|
1063
|
-
const end = record.end.offset - index - 1;
|
|
1064
|
-
// 新的完整的value
|
|
1065
|
-
const newTextValue = typeNamespace.substring(0, start) + newValue + typeNamespace.substring(end, typeNamespace.length);
|
|
1066
|
-
minRange.newValue = newTextValue;
|
|
1067
|
-
return newTextValue;
|
|
1068
|
-
};
|
|
1069
|
-
if (minRange.node instanceof concepts_1.TypeAnnotation) {
|
|
1070
|
-
minRange.setTypeMethods = 'setTypeNamespace';
|
|
1071
|
-
const newValue = setTypeNamespace(minRange.node.typeNamespace, record);
|
|
1072
|
-
minRange.newValue = newValue;
|
|
1073
|
-
}
|
|
1074
|
-
else if (minRange.node instanceof concepts_1.QueryFromExpression || minRange.node instanceof concepts_1.QueryJoinExpression) {
|
|
1075
|
-
minRange.setTypeMethods = 'setEntityNamespace';
|
|
1076
|
-
const newValue = setTypeNamespace(minRange.node.entityNamespace, record);
|
|
1077
|
-
minRange.newValue = newValue;
|
|
1078
|
-
}
|
|
1079
|
-
else if (minRange.node instanceof concepts_1.QueryFieldExpression) {
|
|
1080
|
-
return null;
|
|
1081
|
-
}
|
|
1082
|
-
else if (minRange.node instanceof concepts_1.CallLogic) {
|
|
1083
|
-
minRange.setTypeMethods = 'setCalleeNamespace';
|
|
1084
|
-
const newValue = setTypeNamespace(minRange.node.calleeNamespace, record);
|
|
1085
|
-
minRange.newValue = newValue;
|
|
1086
|
-
}
|
|
1087
|
-
else if (minRange.node instanceof concepts_1.EntityProperty) {
|
|
1088
|
-
minRange.setTypeMethods = 'setRelationNamespace';
|
|
1089
|
-
const newValue = setTypeNamespace(minRange.node.relationNamespace, record);
|
|
1090
|
-
minRange.newValue = newValue;
|
|
1091
|
-
}
|
|
1092
|
-
else if (minRange.node instanceof concepts_1.SqlQueryComponent) {
|
|
1093
|
-
minRange.setTypeMethods = 'setDataSource';
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
if (minRange.node instanceof concepts_1.QueryGroupByExpression && node instanceof concepts_1.Entity) {
|
|
1097
|
-
minRange.setTypeMethods = 'setEntityAsName';
|
|
1098
|
-
}
|
|
1099
|
-
if ((minRange.node instanceof concepts_1.QueryFromExpression || minRange.node instanceof concepts_1.QueryJoinExpression) && node instanceof concepts_1.Entity) {
|
|
1100
|
-
minRange.setTypeMethods = 'setEntityName';
|
|
1101
|
-
}
|
|
1102
|
-
if (minRange.node instanceof concepts_1.QueryFieldExpression && node instanceof concepts_1.EntityProperty) {
|
|
1103
|
-
minRange.setTypeMethods = 'setPropertyName';
|
|
1104
|
-
}
|
|
1105
|
-
if (minRange.node instanceof concepts_1.QueryGroupByExpression && node instanceof concepts_1.EntityProperty) {
|
|
1106
|
-
minRange.setTypeMethods = 'setPropertyName';
|
|
1107
|
-
}
|
|
1108
|
-
// 如果跳转链接或者页面变量同一个param和TypeAnnotation 有两个过滤掉一个
|
|
1109
|
-
if ((minRange.node instanceof concepts_1.Param || minRange.node instanceof concepts_1.Variable || minRange.node instanceof concepts_1.Return)
|
|
1110
|
-
&& (node instanceof concepts_1.Entity || node instanceof concepts_1.Enum || node instanceof concepts_1.Structure)) {
|
|
1111
|
-
return null;
|
|
1112
|
-
}
|
|
1113
|
-
if (minRange.node instanceof concepts_1.Destination && (node instanceof concepts_1.Process || node instanceof concepts_1.ProcessElement)) {
|
|
1114
|
-
return null;
|
|
1115
|
-
}
|
|
1116
|
-
if (minRange.node instanceof concepts_1.Assignee && (node instanceof concepts_1.Process || node instanceof concepts_1.ProcessElement)) {
|
|
1117
|
-
return null;
|
|
1118
|
-
}
|
|
1119
|
-
// 枚举修改枚举名,比较特殊
|
|
1120
|
-
if (minRange.node instanceof concepts_1.EnumItem && node instanceof concepts_1.Enum) {
|
|
1121
|
-
// 什么都不做,用来跳过修改
|
|
1122
|
-
return null;
|
|
1123
|
-
}
|
|
1124
|
-
// params修改 查找bindevent不需要修改
|
|
1125
|
-
if (minRange.node instanceof concepts_1.BindEvent && node instanceof concepts_1.Param) {
|
|
1126
|
-
return null;
|
|
1127
|
-
}
|
|
1128
|
-
// 如果是子页面修改
|
|
1129
|
-
// 父页面引起子页面改名,就可以不改了,自动同步
|
|
1130
|
-
if (minRange.node instanceof concepts_1.View && node instanceof concepts_1.View && minRange.node !== node) {
|
|
1131
|
-
return null;
|
|
1132
|
-
}
|
|
1133
|
-
/**
|
|
1134
|
-
* 屏蔽组件生成内容块中的变量或者逻辑,出现在表格选择中。在bindAttr中还会有,所以过滤一把
|
|
1135
|
-
*/
|
|
1136
|
-
if ((minRange.node instanceof concepts_1.Identifier || minRange.node instanceof concepts_1.MemberExpression) && node instanceof concepts_1.Param && minRange.node.parentNode instanceof concepts_1.BindAttribute) {
|
|
1137
|
-
return null;
|
|
1138
|
-
}
|
|
1139
|
-
// 修改element引发view改名
|
|
1140
|
-
if (node instanceof concepts_1.ViewElement && minRange.node instanceof concepts_1.View) {
|
|
1141
|
-
return null;
|
|
1142
|
-
}
|
|
1143
|
-
// params修改 查找View不需要修改
|
|
1144
|
-
// 逻辑改名,触发了在定义里面的,element定义,的值,直接掠过
|
|
1145
|
-
if (minRange.node instanceof concepts_1.View && (node instanceof concepts_1.Logic || node instanceof concepts_1.Param)) {
|
|
1146
|
-
/**
|
|
1147
|
-
* 这里过滤一下,一些查找引用,重复的内容,直接屏蔽掉,防止操作重复
|
|
1148
|
-
* 因为在生成的时候 ,可能弄了一些副作用的引用
|
|
1149
|
-
*/
|
|
1150
|
-
// 本来是想在上面过滤一把的先放到这里匹配这两个的时候 就会找到
|
|
1151
|
-
// refsList = refsList.filter((item) => {
|
|
1152
|
-
// 屏蔽组件查找查到定义这里,也过滤一下
|
|
1153
|
-
// if (item.lineText.includes(': nasl.ui.'))
|
|
1154
|
-
// return false;
|
|
1155
|
-
// return true;
|
|
1156
|
-
// });
|
|
1157
|
-
return null;
|
|
1158
|
-
}
|
|
1159
|
-
/**
|
|
1160
|
-
* 理论上 logic setName只能自己触发,别的地方查到引用都不用重命名
|
|
1161
|
-
* 流程改名不触发Logic改名
|
|
1162
|
-
* 如果是修改param查找到logic就不操作
|
|
1163
|
-
* 除非想在内部修改别的内容所以暂时屏蔽掉
|
|
1164
|
-
*/
|
|
1165
|
-
if (minRange.node instanceof concepts_1.Logic && node !== minRange.node) {
|
|
1166
|
-
return null;
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1169
|
-
else {
|
|
1170
|
-
console.log('没找到节点需要排查');
|
|
1171
|
-
console.log(record, fileNode.sourceMap);
|
|
1172
|
-
}
|
|
1173
|
-
return minRange;
|
|
1174
|
-
})
|
|
1175
|
-
// 过滤掉不需要操作的
|
|
1176
|
-
.filter((item) => !!item);
|
|
1177
|
-
console.log(result);
|
|
1178
|
-
return result;
|
|
1179
|
-
},
|
|
1180
|
-
// 增加参数的副作用,用于更新logic和view
|
|
1181
|
-
_addParamsEffect(refsList, node) {
|
|
1182
|
-
const parantNode = node?.parentNode;
|
|
1183
|
-
refsList.forEach((record) => {
|
|
1184
|
-
const fileNode = this.file2NodeMap.get(record.file);
|
|
1185
|
-
if (!fileNode)
|
|
1186
|
-
return null;
|
|
1187
|
-
const minRange = this._findMinRange(record, fileNode);
|
|
1188
|
-
if (minRange) {
|
|
1189
|
-
// 如果找到节点是callLogic就去更新
|
|
1190
|
-
if (minRange.node instanceof concepts_1.CallLogic && node instanceof concepts_1.Param) {
|
|
1191
|
-
minRange.node.setCalleeArgName(parantNode);
|
|
1192
|
-
}
|
|
1193
|
-
// 如果节点参数增加页面也要更新
|
|
1194
|
-
if (minRange.node instanceof concepts_1.Destination && node instanceof concepts_1.Param) {
|
|
1195
|
-
minRange.node.setViewArgument(parantNode);
|
|
1196
|
-
}
|
|
1197
|
-
}
|
|
1198
|
-
});
|
|
1199
|
-
},
|
|
1200
|
-
_addParamsPrepare(node, refsList, needAdd) {
|
|
1201
|
-
if (needAdd) {
|
|
1202
|
-
const App = node?.rootNode;
|
|
1203
|
-
const parantNode = node?.parentNode;
|
|
1204
|
-
// 收集修改
|
|
1205
|
-
App.emit('collect:start', {
|
|
1206
|
-
actionMsg: '增加逻辑参数',
|
|
1207
|
-
});
|
|
1208
|
-
node.create({
|
|
1209
|
-
index: 0,
|
|
1210
|
-
parentNode: parantNode,
|
|
1211
|
-
parentKey: node.parentKey,
|
|
1212
|
-
});
|
|
1213
|
-
naslServer._addParamsEffect(refsList, node);
|
|
1214
|
-
// 结束修改 ,批量操作
|
|
1215
|
-
App.emit('collect:end');
|
|
1216
|
-
return node;
|
|
1217
|
-
}
|
|
1218
|
-
naslServer._addParamsEffect(refsList, node);
|
|
1219
|
-
return node;
|
|
1220
|
-
},
|
|
1221
|
-
// 查找引用
|
|
1222
|
-
async findReferences(node) {
|
|
1223
|
-
let refsList = await naslServer._isHaveRef(node);
|
|
1224
|
-
// 如果查找引用查到自己里面的引用不展示
|
|
1225
|
-
refsList = refsList.filter((item) =>
|
|
1226
|
-
// 自己引用自己的过滤掉
|
|
1227
|
-
// 删除的时候过滤一把组件删除提示
|
|
1228
|
-
// 展示组件自己屏蔽掉
|
|
1229
|
-
!item.isDefinition && !item.lineText.includes(' = new nasl.ui.'));
|
|
1230
|
-
// 最后返回的结果
|
|
1231
|
-
let result = new Map();
|
|
1232
|
-
// 树的构造,key: 一个file的node, 值是 [[logic, params],[logic, returns]]
|
|
1233
|
-
const resMap = new Map();
|
|
1234
|
-
// 普通节点和要输出的节点做一个映射,为了引用地址一样
|
|
1235
|
-
const nodeMap = new Map();
|
|
1236
|
-
try {
|
|
1237
|
-
refsList.forEach((record) => {
|
|
1238
|
-
const fileNode = this.file2NodeMap.get(record.file);
|
|
1239
|
-
if (!fileNode)
|
|
1240
|
-
return;
|
|
1241
|
-
const minRange = this._findMinRange(record, fileNode);
|
|
1242
|
-
// 过滤一把不需要改的信息
|
|
1243
|
-
if (minRange) {
|
|
1244
|
-
// 拼装树
|
|
1245
|
-
naslServer._getTreeMap(minRange, fileNode, resMap, nodeMap);
|
|
1246
|
-
}
|
|
1247
|
-
});
|
|
1248
|
-
console.log(resMap, 'resMap');
|
|
1249
|
-
if (resMap.size > 0) {
|
|
1250
|
-
result = naslServer.handleTreeMap(resMap);
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
catch (err) {
|
|
1254
|
-
console.log(err);
|
|
1255
|
-
}
|
|
1256
|
-
console.log(result);
|
|
1257
|
-
return result;
|
|
1258
|
-
},
|
|
1259
|
-
// 获取节点的上层渲染
|
|
1260
|
-
_getTreeMap(minRange, fileNode, resMap, nodeMap) {
|
|
1261
|
-
const minRangeNode = minRange.node;
|
|
1262
|
-
let currentNode = minRangeNode;
|
|
1263
|
-
let parantNode = currentNode.parentNode;
|
|
1264
|
-
// 顺序队列
|
|
1265
|
-
const queue = [];
|
|
1266
|
-
// 先插入自己,如果没有在往上找,
|
|
1267
|
-
// 一直到file节点的父级
|
|
1268
|
-
while (!(parantNode instanceof concepts_1.App)) {
|
|
1269
|
-
// 找到上一级 在map对象中构造出他的子集
|
|
1270
|
-
currentNode = parantNode;
|
|
1271
|
-
parantNode = parantNode.parentNode;
|
|
1272
|
-
// 如果第一次就塞入子集和父节点,以后就只用父节点了
|
|
1273
|
-
// 因为部分节点没有name,先过滤掉
|
|
1274
|
-
// if (currentNode.name) {
|
|
1275
|
-
// }
|
|
1276
|
-
// 排除一些不放入集合的节点
|
|
1277
|
-
let isNeedPush = true;
|
|
1278
|
-
// 如果不是ViewElement 或者 Assignment , 或者如果是的话, 排除l-root
|
|
1279
|
-
if (currentNode instanceof concepts_1.ViewElement && currentNode.tag === 'l-root')
|
|
1280
|
-
isNeedPush = false;
|
|
1281
|
-
else if (currentNode instanceof concepts_1.Argument)
|
|
1282
|
-
isNeedPush = false;
|
|
1283
|
-
else if (currentNode instanceof concepts_1.Assignment)
|
|
1284
|
-
isNeedPush = false;
|
|
1285
|
-
else if (currentNode instanceof concepts_1.TypeAnnotation)
|
|
1286
|
-
isNeedPush = false;
|
|
1287
|
-
else if (currentNode instanceof concepts_1.CallQueryComponent)
|
|
1288
|
-
isNeedPush = false;
|
|
1289
|
-
else if (currentNode instanceof concepts_1.QueryFromExpression)
|
|
1290
|
-
isNeedPush = false;
|
|
1291
|
-
// 需要放到数组中
|
|
1292
|
-
if (isNeedPush) {
|
|
1293
|
-
// 名称
|
|
1294
|
-
// 赋值图标
|
|
1295
|
-
let icon = '';
|
|
1296
|
-
if (currentNode instanceof concepts_1.ViewElement)
|
|
1297
|
-
icon = 'element';
|
|
1298
|
-
else if (currentNode instanceof concepts_1.BindAttribute)
|
|
1299
|
-
icon = 'attr';
|
|
1300
|
-
else if (currentNode instanceof concepts_1.Destination)
|
|
1301
|
-
icon = 'logicNode';
|
|
1302
|
-
else if (currentNode instanceof concepts_1.CallLogic) {
|
|
1303
|
-
icon = 'interface';
|
|
1304
|
-
}
|
|
1305
|
-
// 相同节点使用一个引用
|
|
1306
|
-
if (nodeMap.get(currentNode)) {
|
|
1307
|
-
queue.unshift(nodeMap.get(currentNode));
|
|
1308
|
-
}
|
|
1309
|
-
else {
|
|
1310
|
-
const quoteNode = { node: currentNode, expanded: true, icon };
|
|
1311
|
-
nodeMap.set(currentNode, quoteNode);
|
|
1312
|
-
queue.unshift(quoteNode);
|
|
1313
|
-
}
|
|
1314
|
-
}
|
|
1315
|
-
}
|
|
1316
|
-
// 一个logic 或者 view可能会有多个顺序队列
|
|
1317
|
-
if (resMap.get(currentNode)) {
|
|
1318
|
-
// 是否展示两个内容全等,但是两个queue的node可能不一样,但是只需要展示一个
|
|
1319
|
-
resMap.get(currentNode).push(queue);
|
|
1320
|
-
}
|
|
1321
|
-
else {
|
|
1322
|
-
resMap.set(currentNode, [queue]);
|
|
1323
|
-
}
|
|
1324
|
-
},
|
|
1325
|
-
handleTreeMap(resMap) {
|
|
1326
|
-
const treeNodeMap = new Map();
|
|
1327
|
-
resMap.forEach((value, fileNode) => {
|
|
1328
|
-
// 循环处理tree的queue
|
|
1329
|
-
const treeObj = naslServer.handleTreeQueue(value);
|
|
1330
|
-
treeNodeMap.set(fileNode, treeObj);
|
|
1331
|
-
});
|
|
1332
|
-
return treeNodeMap;
|
|
1333
|
-
},
|
|
1334
|
-
/**
|
|
1335
|
-
* 处理tree的队列,把相同节点进行合并
|
|
1336
|
-
* 这里把当前二维数组进行一个整合
|
|
1337
|
-
* @param arr 当前页面下的queue的二维数组,一个数组下有多条链路
|
|
1338
|
-
* @returns 最后要使用到的节点和对应的子集
|
|
1339
|
-
*/
|
|
1340
|
-
handleTreeQueue(queueLists) {
|
|
1341
|
-
const map = new Map();
|
|
1342
|
-
let root = null;
|
|
1343
|
-
if (!queueLists.length)
|
|
1344
|
-
return;
|
|
1345
|
-
for (const queueList of queueLists) {
|
|
1346
|
-
let preNode = null;
|
|
1347
|
-
for (const queueItem of queueList) {
|
|
1348
|
-
if (!map.get(queueItem)) {
|
|
1349
|
-
map.set(queueItem, []);
|
|
1350
|
-
}
|
|
1351
|
-
if (preNode) {
|
|
1352
|
-
const find = map.get(preNode).find((item) => item === queueItem);
|
|
1353
|
-
if (!find) {
|
|
1354
|
-
map.get(preNode).push(queueItem);
|
|
1355
|
-
}
|
|
1356
|
-
}
|
|
1357
|
-
else {
|
|
1358
|
-
root = queueItem;
|
|
1359
|
-
}
|
|
1360
|
-
preNode = queueItem;
|
|
1361
|
-
}
|
|
1362
|
-
}
|
|
1363
|
-
const children = naslServer._recursionCreateResult(root, map);
|
|
1364
|
-
return children;
|
|
1365
|
-
},
|
|
1366
|
-
/**
|
|
1367
|
-
* 递归调用输出结果
|
|
1368
|
-
* @param root 一个根节点
|
|
1369
|
-
* @param map 当前所有节点的map对象
|
|
1370
|
-
* @returns 当前节点,最后输出所有节点
|
|
1371
|
-
*/
|
|
1372
|
-
_recursionCreateResult(root, map) {
|
|
1373
|
-
const children = map.get(root).map((item) => naslServer._recursionCreateResult(item, map));
|
|
1374
|
-
if (children && children.length) {
|
|
1375
|
-
root.children = children;
|
|
1376
|
-
}
|
|
1377
|
-
return root;
|
|
1378
|
-
},
|
|
1379
|
-
/**
|
|
1380
|
-
* 获取
|
|
1381
|
-
* 当前this上下文 的Source 和 父级文件级别的节点
|
|
1382
|
-
*/
|
|
1383
|
-
getCurrentSource(node) {
|
|
1384
|
-
if (node instanceof concepts_1.App || node instanceof concepts_1.Theme)
|
|
1385
|
-
return { fileNode: null };
|
|
1386
|
-
let sourceMap = node.sourceMap;
|
|
1387
|
-
let fileNode = node;
|
|
1388
|
-
// 如果没有sourceMap,就继续向上找 ,或者到module结束
|
|
1389
|
-
// 如果 节点找到 app 或者module 停止 或者entity找到DataSource为止
|
|
1390
|
-
// 如果当前节点是view就不要向上查找了
|
|
1391
|
-
while (!sourceMap
|
|
1392
|
-
&& fileNode
|
|
1393
|
-
&& !(fileNode.parentNode instanceof concepts_1.App)
|
|
1394
|
-
&& !(fileNode.parentNode instanceof concepts_1.Module)
|
|
1395
|
-
&& !(fileNode.parentNode instanceof concepts_1.DataSource)
|
|
1396
|
-
&& !(fileNode instanceof concepts_1.View)) {
|
|
1397
|
-
fileNode = fileNode.parentNode;
|
|
1398
|
-
sourceMap = fileNode?.sourceMap;
|
|
1399
|
-
}
|
|
1400
|
-
const currentSource = sourceMap && sourceMap.get(node);
|
|
1401
|
-
if (currentSource) {
|
|
1402
|
-
// 这里处理一些加了注解或者需要定制位置的节点的取值
|
|
1403
|
-
naslServer.handlingCurrentSourceException(currentSource, node);
|
|
1404
|
-
return { currentSource, fileNode };
|
|
1405
|
-
}
|
|
1406
|
-
return { fileNode };
|
|
1407
|
-
},
|
|
1408
|
-
handlingCurrentSourceException(currentSource, node) {
|
|
1409
|
-
// 如果有前面的一些注解,元素在最后一行输出的值就给最后一行
|
|
1410
|
-
if (node instanceof concepts_1.EntityProperty) {
|
|
1411
|
-
if (currentSource.range.start.line !== currentSource.range.end.line) {
|
|
1412
|
-
currentSource.range.start = { ...currentSource.range.start, line: currentSource.range.end.line };
|
|
1413
|
-
}
|
|
1414
|
-
}
|
|
1415
|
-
},
|
|
1416
|
-
// 获取element方法的可选值
|
|
1417
|
-
getFieldKeySelectCompletion(node, fieldKey) {
|
|
1418
|
-
const { currentSource, fileNode } = naslServer.getCurrentSource(node);
|
|
1419
|
-
if (currentSource && fileNode) {
|
|
1420
|
-
return naslServer._getFieldKeySelectCompletion({
|
|
1421
|
-
file: fileNode.getEmbeddedFilePath(),
|
|
1422
|
-
range: {
|
|
1423
|
-
line: (0, translator_1.lsp2tspNumber)(currentSource.range.start.line),
|
|
1424
|
-
offset: (0, translator_1.lsp2tspNumber)(currentSource.range.start.character),
|
|
1425
|
-
},
|
|
1426
|
-
getFieldKey: fieldKey,
|
|
1427
|
-
});
|
|
1428
|
-
}
|
|
1429
|
-
else {
|
|
1430
|
-
console.log('没找到节点', currentSource, fileNode);
|
|
1431
|
-
}
|
|
1432
|
-
},
|
|
1433
|
-
_getFieldKeySelectCompletion(args) {
|
|
1434
|
-
return this.messager.requestCommand('getFieldKeySelectCompletion', args);
|
|
1435
|
-
},
|
|
1436
|
-
};
|
|
1437
|
-
/**
|
|
1438
|
-
* 处理删除节点
|
|
1439
|
-
* @param fileNode 当前删除节点的文件级别节点
|
|
1440
|
-
* @param targetNode 当前操作的节点
|
|
1441
|
-
* @param result toTs生成的内容
|
|
1442
|
-
*/
|
|
1443
|
-
async function handleDelete(fileNode, targetNode, result) {
|
|
1444
|
-
const filePath = fileNode.getEmbeddedFilePath();
|
|
1445
|
-
// 如果要删除,而且当前要删Logic就直接删除并且清除错误
|
|
1446
|
-
/**
|
|
1447
|
-
* 删除节点中的一个内容,删除了以后,就查一下引用的地方一起查一下异常
|
|
1448
|
-
*/
|
|
1449
|
-
let outputFiles = [];
|
|
1450
|
-
// 删除之前先查一下内容的依赖
|
|
1451
|
-
const newRefs = await naslServer.references({
|
|
1452
|
-
file: result.filePath,
|
|
1453
|
-
line: EmbeddedTSFileLineMap[fileNode.concept] ?? 2,
|
|
1454
|
-
offset: 6,
|
|
1455
|
-
});
|
|
1456
|
-
// 如果是要删除的内容,就是当前的file节点,要关闭当前文件,就把内容置为空
|
|
1457
|
-
if (fileNode === targetNode) {
|
|
1458
|
-
outputFiles = [{ file: filePath, fileContent: '' }];
|
|
1459
|
-
}
|
|
1460
|
-
else {
|
|
1461
|
-
// 如果是要删除logic一个小内容,要覆盖全部内容
|
|
1462
|
-
// 其余要删除的都是把原来的file节点的内容全部覆盖一把
|
|
1463
|
-
outputFiles = [{ file: result.filePath, fileContent: result.code }];
|
|
1464
|
-
}
|
|
1465
|
-
// 更新文件之后
|
|
1466
|
-
await naslServer.updateFiles({ outputFiles });
|
|
1467
|
-
newRefs.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
1468
|
-
}
|
|
1469
|
-
/**
|
|
1470
|
-
* 除去rename场景下的更新
|
|
1471
|
-
* @param fileNode 文件级别的节点
|
|
1472
|
-
* @param targetNode 触发修改的节点
|
|
1473
|
-
* @param result 生成代码的code 和位置信息
|
|
1474
|
-
*/
|
|
1475
|
-
async function handleChange(fileNode, targetNode, result, action) {
|
|
1476
|
-
naslServer.file2NodeMap.set(result.filePath, fileNode);
|
|
1477
|
-
const outputFiles = [{ file: result.filePath, fileContent: result.code }];
|
|
1478
|
-
// 创建和更新都用update,内部会做判断
|
|
1479
|
-
await naslServer.updateFiles({ outputFiles });
|
|
1480
|
-
// 查一下新函数名的依赖
|
|
1481
|
-
const newRefs = await naslServer.references({
|
|
1482
|
-
file: result.filePath,
|
|
1483
|
-
line: EmbeddedTSFileLineMap[fileNode.concept] ?? 2,
|
|
1484
|
-
offset: 6,
|
|
1485
|
-
});
|
|
1486
|
-
newRefs.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
1487
|
-
// 唤起建立连接弹框
|
|
1488
|
-
// 文件级别的建立连接采取提醒
|
|
1489
|
-
if (action === 'create' && targetNode.__init) {
|
|
1490
|
-
// 清除临时状态, 完成本次创建
|
|
1491
|
-
delete targetNode.__init;
|
|
1492
|
-
if (fileNode === targetNode && filesToCheck.size > 1) {
|
|
1493
|
-
const confirmParms = {
|
|
1494
|
-
actionType: 'createEstablishConnection',
|
|
1495
|
-
node: fileNode,
|
|
1496
|
-
icon: 'success',
|
|
1497
|
-
};
|
|
1498
|
-
(0, common_1.invokeCommand)('tsConfirm.open', confirmParms, () => { });
|
|
1499
|
-
}
|
|
1500
|
-
}
|
|
1501
|
-
}
|
|
1502
|
-
/**
|
|
1503
|
-
* 重命名的更新
|
|
1504
|
-
* @param fileNode 文件级别的节点
|
|
1505
|
-
* @param targetNode 触发修改的节点
|
|
1506
|
-
* @param result 生成代码的code 和位置信息
|
|
1507
|
-
* @param isRename 是不是修改名字
|
|
1508
|
-
* @param oldFilePath 如果是改名,文件级别的才会有这个参数,用于文件新增替换
|
|
1509
|
-
*/
|
|
1510
|
-
async function handleRename(fileNode, targetNode, result, oldFilePath) {
|
|
1511
|
-
// rename 场景
|
|
1512
|
-
const outputFiles = [{ file: result.filePath, fileContent: result.code }];
|
|
1513
|
-
// 如果是要修改顶级文件名
|
|
1514
|
-
// file节点和当前改得是同一节点
|
|
1515
|
-
if (fileNode === targetNode) {
|
|
1516
|
-
naslServer.file2NodeMap.delete(oldFilePath);
|
|
1517
|
-
naslServer.file2NodeMap.set(result.filePath, fileNode);
|
|
1518
|
-
// 修改名字新的添加进去,旧的置为空
|
|
1519
|
-
outputFiles.unshift({ file: oldFilePath, fileContent: '' });
|
|
1520
|
-
// 查一下旧文件名的依赖
|
|
1521
|
-
const oldRefs = await naslServer.references({
|
|
1522
|
-
file: oldFilePath,
|
|
1523
|
-
line: EmbeddedTSFileLineMap[fileNode.concept] ?? 2,
|
|
1524
|
-
offset: 6,
|
|
1525
|
-
});
|
|
1526
|
-
oldRefs.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
1527
|
-
filesToCheck.delete(oldFilePath);
|
|
1528
|
-
// 更新文件之后
|
|
1529
|
-
await naslServer.updateFiles({ outputFiles });
|
|
1530
|
-
// 查一下新函数名的依赖
|
|
1531
|
-
const newRefs = await naslServer.references({
|
|
1532
|
-
file: result.filePath,
|
|
1533
|
-
line: EmbeddedTSFileLineMap[fileNode.concept] ?? 2,
|
|
1534
|
-
offset: 6,
|
|
1535
|
-
});
|
|
1536
|
-
const newRefFileList = new Set();
|
|
1537
|
-
newRefs.refs.forEach((ref) => {
|
|
1538
|
-
filesToCheck.add(ref.file);
|
|
1539
|
-
newRefFileList.add(ref.file);
|
|
1540
|
-
});
|
|
1541
|
-
// 文件级别重命名,有依赖才唤起弹框
|
|
1542
|
-
// 唤起重命名,提示有连接弹框
|
|
1543
|
-
// 重命名建立连接先不展示弹框了
|
|
1544
|
-
// if (newRefFileList.size > 1) {
|
|
1545
|
-
// const confirmParms = {
|
|
1546
|
-
// actionType: 'renameEstablishConnection',
|
|
1547
|
-
// node: fileNode,
|
|
1548
|
-
// icon: 'success',
|
|
1549
|
-
// };
|
|
1550
|
-
// invokeCommand('tsConfirm.open', confirmParms, () => {});
|
|
1551
|
-
// }
|
|
1552
|
-
}
|
|
1553
|
-
else {
|
|
1554
|
-
// 查一下当前属性依赖的文件
|
|
1555
|
-
const { currentSource, fileNode } = naslServer.getCurrentSource(targetNode);
|
|
1556
|
-
if (currentSource) {
|
|
1557
|
-
const oldRefs = await naslServer.references({
|
|
1558
|
-
file: fileNode.getEmbeddedFilePath(),
|
|
1559
|
-
line: (0, translator_1.lsp2tspNumber)(currentSource.range.start.line),
|
|
1560
|
-
offset: (0, translator_1.lsp2tspNumber)(currentSource.range.start.character),
|
|
1561
|
-
});
|
|
1562
|
-
oldRefs.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
1563
|
-
// 更新文件之后
|
|
1564
|
-
await naslServer.updateFiles({ outputFiles });
|
|
1565
|
-
const newRefs2 = await naslServer.references({
|
|
1566
|
-
file: fileNode.getEmbeddedFilePath(),
|
|
1567
|
-
line: (0, translator_1.lsp2tspNumber)(currentSource.range.start.line),
|
|
1568
|
-
offset: (0, translator_1.lsp2tspNumber)(currentSource.range.start.character),
|
|
1569
|
-
});
|
|
1570
|
-
newRefs2.refs.forEach((ref) => filesToCheck.add(ref.file));
|
|
1571
|
-
}
|
|
1572
|
-
}
|
|
1573
|
-
}
|
|
1574
|
-
/**
|
|
1575
|
-
* 处理一些节点操作,子节点需要更新并且check的场景
|
|
1576
|
-
* 因为删除,新增父页面,或者重命名会一起
|
|
1577
|
-
* 删除或者新增view而且他有子集 就要执行同样的操作
|
|
1578
|
-
* @param action 当前操作类型
|
|
1579
|
-
* @param fileNode 文件节点
|
|
1580
|
-
* @param targetNode 操作节点 这里要两个相等才会走家去面对哦逻辑
|
|
1581
|
-
* @param oldpath 触发内容的oldpath
|
|
1582
|
-
*/
|
|
1583
|
-
async function incidentalAction(action, fileNode, targetNode, oldpath) {
|
|
1584
|
-
if ((action === 'create' || action === 'delete' || (action === 'update' && oldpath)) && fileNode === targetNode) {
|
|
1585
|
-
// 删除或者新增页面
|
|
1586
|
-
if (fileNode instanceof concepts_1.View && fileNode.children?.length) {
|
|
1587
|
-
const fileNodeChildren = fileNode.children;
|
|
1588
|
-
for (let i = 0; i < fileNodeChildren.length; i++) {
|
|
1589
|
-
const fileNodeItem = fileNodeChildren[i];
|
|
1590
|
-
const result = fileNodeItem.toEmbeddedTSFile();
|
|
1591
|
-
fileNodeItem.sourceMap = result.sourceMap;
|
|
1592
|
-
if (action === 'create') {
|
|
1593
|
-
await handleChange(fileNodeItem, fileNodeItem, result, action);
|
|
1594
|
-
await incidentalAction(action, fileNodeItem, fileNodeItem);
|
|
1595
|
-
}
|
|
1596
|
-
else if (action === 'delete') {
|
|
1597
|
-
await handleDelete(fileNodeItem, fileNodeItem, result);
|
|
1598
|
-
await incidentalAction(action, fileNodeItem, fileNodeItem);
|
|
1599
|
-
}
|
|
1600
|
-
else if (action === 'update' && oldpath) {
|
|
1601
|
-
const parentPath = oldpath.replace('.ts', '/');
|
|
1602
|
-
const currentOldPath = parentPath + fileNodeItem.name + '.ts';
|
|
1603
|
-
// 因为重命名这里只有当前修改父级的 旧名称, 所以他的子集也要根据旧名称去查依赖 更新内容
|
|
1604
|
-
await handleRename(fileNodeItem, fileNodeItem, result, currentOldPath);
|
|
1605
|
-
await incidentalAction(action, fileNodeItem, fileNodeItem, currentOldPath);
|
|
1606
|
-
}
|
|
1607
|
-
}
|
|
1608
|
-
}
|
|
1609
|
-
// 删除或新增模块
|
|
1610
|
-
// 需要把下面的哦内容全部都更新一遍
|
|
1611
|
-
if (fileNode instanceof concepts_1.Module) {
|
|
1612
|
-
if (fileNode.type === 'interface' && fileNode.isAdd && action === 'create') {
|
|
1613
|
-
isChangeInterface = true;
|
|
1614
|
-
}
|
|
1615
|
-
const module = targetNode;
|
|
1616
|
-
const results = [];
|
|
1617
|
-
naslServer.contentToFile(module, results);
|
|
1618
|
-
for (let i = 0; i < results.length; i++) {
|
|
1619
|
-
const result = results[i];
|
|
1620
|
-
const node = naslServer.file2NodeMap.get(result.filePath);
|
|
1621
|
-
if (action === 'create') {
|
|
1622
|
-
await handleChange(node, node, result, action);
|
|
1623
|
-
}
|
|
1624
|
-
else {
|
|
1625
|
-
await handleDelete(node, node, result);
|
|
1626
|
-
}
|
|
1627
|
-
}
|
|
1628
|
-
// 删除模块通知更新列表
|
|
1629
|
-
if (action === 'delete') {
|
|
1630
|
-
try {
|
|
1631
|
-
// 如果已经
|
|
1632
|
-
(0, common_1.invokeCommand)('module.delete', true);
|
|
1633
|
-
}
|
|
1634
|
-
catch (err) {
|
|
1635
|
-
console.log('module.delete', '组件销毁了,不用唤起了');
|
|
1636
|
-
}
|
|
1637
|
-
}
|
|
1638
|
-
}
|
|
1639
|
-
/**
|
|
1640
|
-
* DataSource只会重命名时候,需要把子集全部重新生成一下
|
|
1641
|
-
*/
|
|
1642
|
-
if (fileNode instanceof concepts_1.DataSource) {
|
|
1643
|
-
fileNode.entities.forEach(async (entity) => {
|
|
1644
|
-
try {
|
|
1645
|
-
const result = entity.toEmbeddedTSFile();
|
|
1646
|
-
const parentPath = oldpath.replace('.ts', '/');
|
|
1647
|
-
const currentOldPath = parentPath + '/entities/' + entity.name + '.ts';
|
|
1648
|
-
// 因为重命名这里只有当前修改父级的 旧名称, 所以他的子集也要根据旧名称去查依赖 更新内容
|
|
1649
|
-
await handleRename(entity, entity, result, currentOldPath);
|
|
1650
|
-
}
|
|
1651
|
-
catch (err) {
|
|
1652
|
-
console.log(err);
|
|
1653
|
-
}
|
|
1654
|
-
});
|
|
1655
|
-
}
|
|
1656
|
-
}
|
|
1657
|
-
}
|
|
1658
|
-
async function receiveHandleChange($event) {
|
|
1659
|
-
// 行为
|
|
1660
|
-
const action = $event.action;
|
|
1661
|
-
const targetNode = $event.target;
|
|
1662
|
-
// 当前操作的文件节点
|
|
1663
|
-
const { fileNode } = naslServer.getCurrentSource(targetNode);
|
|
1664
|
-
// 如果是导入模块就,就引入对应模块,先不处理module和Configuration,下面的内容会自动创建
|
|
1665
|
-
if (!fileNode || fileNode instanceof concepts_1.Module || fileNode instanceof concepts_1.Configuration) {
|
|
1666
|
-
// module单独处理
|
|
1667
|
-
if (fileNode instanceof concepts_1.Module) {
|
|
1668
|
-
await incidentalAction(action, fileNode, targetNode);
|
|
1669
|
-
}
|
|
1670
|
-
return;
|
|
1671
|
-
}
|
|
1672
|
-
const result = fileNode.toEmbeddedTSFile();
|
|
1673
|
-
// 当前操作的节点
|
|
1674
|
-
// 如果当前没有生成tsFile
|
|
1675
|
-
if (!result) {
|
|
1676
|
-
return;
|
|
1677
|
-
}
|
|
1678
|
-
// 修改触发修改文件
|
|
1679
|
-
naslServer._debugInFileStorage($event.currentTarget, [
|
|
1680
|
-
{
|
|
1681
|
-
file: result.filePath,
|
|
1682
|
-
fileContent: result.code,
|
|
1683
|
-
},
|
|
1684
|
-
]);
|
|
1685
|
-
fileNode.sourceMap = result.sourceMap;
|
|
1686
|
-
if (action === 'update' || action === 'create') {
|
|
1687
|
-
if ($event?.field !== 'name') {
|
|
1688
|
-
await handleChange(fileNode, targetNode, result, action);
|
|
1689
|
-
await incidentalAction(action, fileNode, targetNode);
|
|
1690
|
-
}
|
|
1691
|
-
else {
|
|
1692
|
-
const oldpath = fileNode.getEmbeddedFilePath($event.oldObject.name);
|
|
1693
|
-
await handleRename(fileNode, targetNode, result, oldpath);
|
|
1694
|
-
await incidentalAction(action, fileNode, targetNode, oldpath);
|
|
1695
|
-
}
|
|
1696
|
-
}
|
|
1697
|
-
// 删除
|
|
1698
|
-
if (action === 'delete') {
|
|
1699
|
-
await incidentalAction(action, fileNode, targetNode);
|
|
1700
|
-
await handleDelete(fileNode, targetNode, result);
|
|
1701
|
-
}
|
|
1702
|
-
return true;
|
|
1703
|
-
}
|
|
1704
|
-
// 监听所有改变操作
|
|
1705
|
-
translator_1.embeddedTSEmitter.on('change', ($event) => {
|
|
1706
|
-
// 收集到一个行为集合
|
|
1707
|
-
const eventValue = $event.value;
|
|
1708
|
-
const stackList = [];
|
|
1709
|
-
eventValue.forEach(async (item) => {
|
|
1710
|
-
stackList.push(item.originEvent);
|
|
1711
|
-
});
|
|
1712
|
-
// 异步状态机,一个完成了在执行下一个
|
|
1713
|
-
function next() {
|
|
1714
|
-
const item = stackList.shift();
|
|
1715
|
-
receiveHandleChange(item).then(async () => {
|
|
1716
|
-
if (stackList.length) {
|
|
1717
|
-
next();
|
|
1718
|
-
}
|
|
1719
|
-
else {
|
|
1720
|
-
console.log('filesToCheck', filesToCheck, filesToCheck.size);
|
|
1721
|
-
await naslServer.getDiagnosticRecordsAndPushAll(Array.from(filesToCheck));
|
|
1722
|
-
filesToCheck.clear();
|
|
1723
|
-
}
|
|
1724
|
-
});
|
|
1725
|
-
}
|
|
1726
|
-
// 如果有长度开始执行状态机
|
|
1727
|
-
if (stackList.length) {
|
|
1728
|
-
next();
|
|
1729
|
-
}
|
|
1730
|
-
});
|
|
1731
|
-
naslServer.messager.options.context = naslServer;
|
|
1732
|
-
exports.default = naslServer;
|
|
1733
|
-
//# sourceMappingURL=naslServer.js.map
|