@lcap/nasl 3.3.0-alpha.3 → 3.4.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/concepts/BindEvent__.js +1 -1
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +1 -1
- package/out/concepts/Logic__.js +47 -38
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/View__.d.ts +1 -1
- package/out/concepts/View__.js +37 -7
- package/out/concepts/View__.js.map +1 -1
- package/out/natural/genNaturalTS.js +31 -21
- package/out/natural/genNaturalTS.js.map +1 -1
- package/out/natural/transformTSCode.js +199 -55
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/server/naslServer.d.ts +3 -3
- package/out/server/naslServer.js +105 -123
- package/out/server/naslServer.js.map +1 -1
- package/out/service/storage/init.js +3 -3
- package/out/service/storage/init.js.map +1 -1
- package/out/translator/index.js +1 -1
- package/out/translator/index.js.map +1 -1
- package/out/utils/time-slicing.js +1 -1
- package/out/utils/time-slicing.js.map +1 -1
- package/package.json +1 -1
- package/sandbox-natural/stdlib/nasl.ui.ts +7 -0
- package/sandbox-natural/stdlib/nasl.util.ts +35 -1
- package/src/concepts/BindEvent__.ts +1 -1
- package/src/concepts/Logic__.ts +50 -38
- package/src/concepts/View__.ts +42 -7
- package/src/natural/genNaturalTS.ts +75 -66
- package/src/natural/transformTSCode.ts +761 -607
- package/src/server/naslServer.ts +102 -101
- package/src/service/storage/init.ts +3 -3
- package/src/translator/index.ts +1 -1
- package/src/utils/time-slicing.ts +1 -1
package/src/server/naslServer.ts
CHANGED
|
@@ -4,11 +4,12 @@ import * as path from 'path';
|
|
|
4
4
|
import { Worker } from 'worker_threads';
|
|
5
5
|
/// #endif
|
|
6
6
|
|
|
7
|
+
import * as tsProtocol from 'typescript/lib/protocol';
|
|
8
|
+
import { Decimal } from 'decimal.js';
|
|
7
9
|
import { config } from '../config';
|
|
8
10
|
import { sentryMonitorNaslServer, sentryMonitorTSWorkerMessager } from '../sentry';
|
|
9
11
|
import Messager from '../common/Messager';
|
|
10
|
-
import
|
|
11
|
-
import { formatEnums } from '../server/getMemberIdentifier';
|
|
12
|
+
import { formatEnums } from "./getMemberIdentifier";
|
|
12
13
|
|
|
13
14
|
import {
|
|
14
15
|
Module,
|
|
@@ -100,7 +101,6 @@ import { EventEmitter } from '../common/EventEmitter';
|
|
|
100
101
|
import { traverse } from '../utils';
|
|
101
102
|
import { withQueueExecute } from '../decorators';
|
|
102
103
|
|
|
103
|
-
import { Decimal } from 'decimal.js';
|
|
104
104
|
import { getNodeByNodeCallee } from '../automate/engine/utils';
|
|
105
105
|
|
|
106
106
|
const EmbeddedTSFileLineMap: { [name: string]: number } = {
|
|
@@ -141,10 +141,10 @@ interface QuoteNode {
|
|
|
141
141
|
// 批量查找节点位置的节点信息类型
|
|
142
142
|
type QuickInfoNodes = Array<{ filePath: string; node: BaseNode; item: SourceMapItem }>;
|
|
143
143
|
|
|
144
|
-
let isChangeInterface = false;
|
|
144
|
+
let isChangeInterface = false; // 判断是否导入接口
|
|
145
145
|
type ActionNode = { target: Variable; typeannotation: TypeAnnotation };
|
|
146
|
-
let actionArr: Array<ActionNode> = [];
|
|
147
|
-
let timer: number = null;
|
|
146
|
+
let actionArr: Array<ActionNode> = []; // 用于导入接口收集更改的节点
|
|
147
|
+
let timer: number = null; // 超时器用于收集导入接口相关
|
|
148
148
|
const __naslStdlibFileCacheMap: Map<tsProtocol.OpenRequestArgs['file'], tsProtocol.OpenRequestArgs> = new Map(); // naslStdlib文件缓存
|
|
149
149
|
|
|
150
150
|
// 联合类型切割取出类型
|
|
@@ -164,17 +164,17 @@ export function getDisplayString2Type(displayString: string) {
|
|
|
164
164
|
const typeList: string[] = types[1].split(' | ').map((item: string) => {
|
|
165
165
|
if (/<([^()]+)>/g.exec(item)) {
|
|
166
166
|
return item;
|
|
167
|
-
}
|
|
167
|
+
} if (item.includes(' ')) {
|
|
168
168
|
const strs = item.split(' ');
|
|
169
169
|
const type = strs[strs.length - 1];
|
|
170
170
|
return type;
|
|
171
|
-
}
|
|
171
|
+
} if (item.includes('.')) {
|
|
172
172
|
const strs = item.split('.');
|
|
173
173
|
const type = strs[strs.length - 1];
|
|
174
174
|
return type;
|
|
175
|
-
}
|
|
175
|
+
}
|
|
176
176
|
return item;
|
|
177
|
-
|
|
177
|
+
|
|
178
178
|
});
|
|
179
179
|
|
|
180
180
|
if (targetType) {
|
|
@@ -186,6 +186,7 @@ export function getDisplayString2Type(displayString: string) {
|
|
|
186
186
|
@sentryMonitorNaslServer
|
|
187
187
|
class NaslServer {
|
|
188
188
|
naslStdlibFileCacheMap = __naslStdlibFileCacheMap;
|
|
189
|
+
|
|
189
190
|
messager: Messager = undefined;
|
|
190
191
|
|
|
191
192
|
worker: Worker = undefined;
|
|
@@ -249,6 +250,8 @@ class NaslServer {
|
|
|
249
250
|
// 结束诊断和标注
|
|
250
251
|
invokeCommand('naslServer:endWork');
|
|
251
252
|
invokeCommand('naslServer:nodeChange');
|
|
253
|
+
this.embeddedTSEmitter.emit('naslServer:endWork');
|
|
254
|
+
this.embeddedTSEmitter.emit('naslServer:nodeChange');
|
|
252
255
|
} catch (e) {
|
|
253
256
|
console.log('no "naslServer:nodeChange" event received');
|
|
254
257
|
}
|
|
@@ -277,7 +280,7 @@ class NaslServer {
|
|
|
277
280
|
// 这个方法是 5.0 加入标准库的,但是这里 ts 版本是 4.x,ci 会挂,所以需要忽略
|
|
278
281
|
// @ts-ignore
|
|
279
282
|
const findLastIndex = this.changeStackList.findLastIndex((changeStackItem: EventPayload) => {
|
|
280
|
-
const target = changeStackItem
|
|
283
|
+
const {target} = changeStackItem;
|
|
281
284
|
const { fileNode: targetFileNode } = this.getCurrentSource(target);
|
|
282
285
|
return targetFileNode === fileNode;
|
|
283
286
|
});
|
|
@@ -287,10 +290,10 @@ class NaslServer {
|
|
|
287
290
|
if (this.changeStackList[findLastIndex]?.field) {
|
|
288
291
|
// 如果当前列表里有,这个文件节点,最后一个是field的话,直接return掉,不用塞这个update了
|
|
289
292
|
return;
|
|
290
|
-
}
|
|
293
|
+
}
|
|
291
294
|
// 如果最后一项是普通的update的话,就可以去掉,后面那个会在塞过来
|
|
292
295
|
this.changeStackList.pop();
|
|
293
|
-
|
|
296
|
+
|
|
294
297
|
}
|
|
295
298
|
this.changeStackList.push(item.originEvent);
|
|
296
299
|
} catch (err) {
|
|
@@ -327,7 +330,7 @@ class NaslServer {
|
|
|
327
330
|
Object.keys(naslStdlibMap).forEach(async (libFileName: string) => {
|
|
328
331
|
await this.addFile(
|
|
329
332
|
{
|
|
330
|
-
file:
|
|
333
|
+
file: `/${ libFileName}`,
|
|
331
334
|
fileContent: naslStdlibMap[libFileName],
|
|
332
335
|
},
|
|
333
336
|
{ cache: true }
|
|
@@ -640,12 +643,13 @@ class NaslServer {
|
|
|
640
643
|
cache && this.cacheFile(file);
|
|
641
644
|
return this.messager.requestCommand('addFile', file);
|
|
642
645
|
}
|
|
646
|
+
|
|
643
647
|
// 缓存添加过的文件
|
|
644
648
|
cacheFile(options: tsProtocol.OpenRequestArgs) {
|
|
645
649
|
__naslStdlibFileCacheMap.set(options.file, options);
|
|
646
650
|
}
|
|
647
651
|
|
|
648
|
-
/**u
|
|
652
|
+
/** u
|
|
649
653
|
* 只新增文件
|
|
650
654
|
* @param {*} files
|
|
651
655
|
*/
|
|
@@ -677,18 +681,18 @@ class NaslServer {
|
|
|
677
681
|
}
|
|
678
682
|
/// #if process.env.NODE_ENV === 'development'
|
|
679
683
|
// 首次尝试请求
|
|
680
|
-
await axios.post(
|
|
684
|
+
await axios.post(`/api/App/debugEmbedded?id=${ app.id}`, openFiles[0]).catch(() => (openDebugEmbedded = false));
|
|
681
685
|
|
|
682
686
|
if (openDebugEmbedded && globalThis.window) {
|
|
683
687
|
// For TS build
|
|
684
688
|
try {
|
|
685
689
|
let canDebug = true;
|
|
686
|
-
await axios.post(
|
|
690
|
+
await axios.post(`/api/App/debugEmbedded?id=${ app.id}`, openFiles[0]).catch(() => (canDebug = false));
|
|
687
691
|
|
|
688
692
|
if (canDebug) {
|
|
689
693
|
await Promise.all(
|
|
690
694
|
openFiles.map(async (file) => {
|
|
691
|
-
const res = await axios.post(
|
|
695
|
+
const res = await axios.post(`/api/App/debugEmbedded?id=${ app.id}`, file);
|
|
692
696
|
return res.data;
|
|
693
697
|
})
|
|
694
698
|
);
|
|
@@ -740,9 +744,9 @@ class NaslServer {
|
|
|
740
744
|
value,
|
|
741
745
|
noFilterList,
|
|
742
746
|
});
|
|
743
|
-
}
|
|
747
|
+
}
|
|
744
748
|
console.log('没找到节点', node, currentSource, fileNode);
|
|
745
|
-
|
|
749
|
+
|
|
746
750
|
}
|
|
747
751
|
|
|
748
752
|
_getValueSelectCompletion(args: any) {
|
|
@@ -786,9 +790,9 @@ class NaslServer {
|
|
|
786
790
|
});
|
|
787
791
|
if (!res.length) {
|
|
788
792
|
return [];
|
|
789
|
-
}
|
|
793
|
+
}
|
|
790
794
|
return [{ title: '基础类型', children: res }];
|
|
791
|
-
|
|
795
|
+
|
|
792
796
|
}
|
|
793
797
|
} catch (err) {
|
|
794
798
|
console.log(err);
|
|
@@ -832,7 +836,7 @@ class NaslServer {
|
|
|
832
836
|
.replaceAll('\n', '')
|
|
833
837
|
.replace(/__name:"AStructure_\w{8}";/g, '')
|
|
834
838
|
.replace(/dataSources.([^.]+).entities.([^;]+)/g, ($1, $2, $3) => `${$3}(${$2})`);
|
|
835
|
-
}
|
|
839
|
+
} if (typeStr.startsWith('{') && typeStr.endsWith('}')) {
|
|
836
840
|
/**
|
|
837
841
|
* {
|
|
838
842
|
text: nasl.core.String;
|
|
@@ -864,6 +868,7 @@ class NaslServer {
|
|
|
864
868
|
}
|
|
865
869
|
return '';
|
|
866
870
|
}
|
|
871
|
+
|
|
867
872
|
async getDataSchemaStructureOrTypeAnnotation(node: ViewElement) {
|
|
868
873
|
if (!(node instanceof ViewElement)) return;
|
|
869
874
|
|
|
@@ -883,7 +888,7 @@ class NaslServer {
|
|
|
883
888
|
|
|
884
889
|
const types = /<([^()]+)>/g.exec(displayString);
|
|
885
890
|
const typeStr = types && types[1];
|
|
886
|
-
const app = node
|
|
891
|
+
const {app} = node;
|
|
887
892
|
if (typeStr.includes('__name: "AStructure_')) {
|
|
888
893
|
const properties: StructureProperty[] = [];
|
|
889
894
|
typeStr.replace(/([^:\s]+):\s+([^;]+);/g, ($1, name, typeKey) => {
|
|
@@ -906,7 +911,7 @@ class NaslServer {
|
|
|
906
911
|
return '';
|
|
907
912
|
});
|
|
908
913
|
return TypeAnnotation.createTypeAnonymousStructure(properties);
|
|
909
|
-
}
|
|
914
|
+
} if (typeStr.startsWith('structures')) return app.findNodeByCompleteName(`app.${typeStr}`);
|
|
910
915
|
}
|
|
911
916
|
}
|
|
912
917
|
|
|
@@ -973,9 +978,9 @@ class NaslServer {
|
|
|
973
978
|
},
|
|
974
979
|
noFilterList,
|
|
975
980
|
});
|
|
976
|
-
}
|
|
981
|
+
}
|
|
977
982
|
console.log('没找到节点', currentSource, fileNode);
|
|
978
|
-
|
|
983
|
+
|
|
979
984
|
}
|
|
980
985
|
|
|
981
986
|
_getSelectNextCompletion(args: any) {
|
|
@@ -994,6 +999,7 @@ class NaslServer {
|
|
|
994
999
|
if (node.tsErrorDetail) return;
|
|
995
1000
|
node.tsErrorDetail = tsErrorDetail;
|
|
996
1001
|
}
|
|
1002
|
+
|
|
997
1003
|
/**
|
|
998
1004
|
* 处理诊断结果
|
|
999
1005
|
* @param records 结果
|
|
@@ -1007,7 +1013,7 @@ class NaslServer {
|
|
|
1007
1013
|
}
|
|
1008
1014
|
await Promise.all(
|
|
1009
1015
|
records.map(async (record) => {
|
|
1010
|
-
const node = record
|
|
1016
|
+
const {node} = record;
|
|
1011
1017
|
if (!node) return;
|
|
1012
1018
|
|
|
1013
1019
|
// 先获取原来的节点先清除一下之前有异常的节点,下面重新赋值
|
|
@@ -1067,7 +1073,7 @@ class NaslServer {
|
|
|
1067
1073
|
if (diagnostic.severity === 'warning') {
|
|
1068
1074
|
record.suggestionDiagnostics.push(diagnostic);
|
|
1069
1075
|
return null;
|
|
1070
|
-
}
|
|
1076
|
+
} if (currentNode.concept === 'OqlQueryComponent') {
|
|
1071
1077
|
// OQL别名错误降级为警告
|
|
1072
1078
|
if (diagnostic.originalDiagnostic && diagnostic.originalDiagnostic?.text.includes('__OQL_ALIAS_WARNING__')) {
|
|
1073
1079
|
// 重置 图标和错误等级
|
|
@@ -1112,7 +1118,7 @@ class NaslServer {
|
|
|
1112
1118
|
if (diag?.node) {
|
|
1113
1119
|
return diag;
|
|
1114
1120
|
// 一些已知警告的单独处理
|
|
1115
|
-
}
|
|
1121
|
+
} if (
|
|
1116
1122
|
[
|
|
1117
1123
|
`'__LogicEmpty' is declared but its value is never read.`,
|
|
1118
1124
|
`'__destinationEmpty__' is declared but its value is never read.`,
|
|
@@ -1122,7 +1128,7 @@ class NaslServer {
|
|
|
1122
1128
|
].includes(diag.text)
|
|
1123
1129
|
) {
|
|
1124
1130
|
return this._resolveDiagnostic(diag as unknown as tsProtocol.DiagnosticWithFileName, record.node as FileNode, record);
|
|
1125
|
-
}
|
|
1131
|
+
} if (diag.text.includes(` is declared but its value is never read.`)) {
|
|
1126
1132
|
// 局部变量和输入变量未使用的警告
|
|
1127
1133
|
const fromModule = record.node.parentNode.concept === 'Module';
|
|
1128
1134
|
const fromConnector = record.node.parentNode.concept === 'Connector';
|
|
@@ -1151,7 +1157,7 @@ class NaslServer {
|
|
|
1151
1157
|
message: `未使用的输入参数${minRange.node.name}`,
|
|
1152
1158
|
};
|
|
1153
1159
|
return diagnostic;
|
|
1154
|
-
}
|
|
1160
|
+
} if (minRange.node instanceof Variable) {
|
|
1155
1161
|
const diagnostic = {
|
|
1156
1162
|
node: minRange.node,
|
|
1157
1163
|
severity: 'warning',
|
|
@@ -1335,7 +1341,7 @@ class NaslServer {
|
|
|
1335
1341
|
const typeAnnotation = item.__TypeAnnotation;
|
|
1336
1342
|
// 仅处理有类型的情况,返回类型为void的情况由其他地方处理成报错
|
|
1337
1343
|
if (typeAnnotation) {
|
|
1338
|
-
const sortedTypeKey = typeAnnotation
|
|
1344
|
+
const {sortedTypeKey} = typeAnnotation;
|
|
1339
1345
|
if (!typeAnnotationMap[sortedTypeKey]) {
|
|
1340
1346
|
typeAnnotationMap[sortedTypeKey] = {
|
|
1341
1347
|
typeAnnotation,
|
|
@@ -1387,7 +1393,7 @@ class NaslServer {
|
|
|
1387
1393
|
const typeAnnotation = value.__TypeAnnotation;
|
|
1388
1394
|
// 仅处理有类型的情况,返回类型为void的情况由其他地方处理成报错
|
|
1389
1395
|
if (typeAnnotation) {
|
|
1390
|
-
const sortedTypeKey = typeAnnotation
|
|
1396
|
+
const {sortedTypeKey} = typeAnnotation;
|
|
1391
1397
|
if (!typeAnnotationMap[sortedTypeKey]) {
|
|
1392
1398
|
typeAnnotationMap[sortedTypeKey] = {
|
|
1393
1399
|
typeAnnotation,
|
|
@@ -1710,17 +1716,17 @@ class NaslServer {
|
|
|
1710
1716
|
if (Array.isArray(node.bindExpressions)) {
|
|
1711
1717
|
const exp = node.bindExpressions.find((bindExpression) => this.hasComponentLogics(bindExpression));
|
|
1712
1718
|
if (exp) {
|
|
1713
|
-
//const element: any = node.getAncestor('ViewElement');
|
|
1714
|
-
//const api = config.allNodesAPI[element?.tag];
|
|
1715
|
-
//const attr = api?.attrs?.find?.((attr) => {
|
|
1719
|
+
// const element: any = node.getAncestor('ViewElement');
|
|
1720
|
+
// const api = config.allNodesAPI[element?.tag];
|
|
1721
|
+
// const attr = api?.attrs?.find?.((attr) => {
|
|
1716
1722
|
// return attr.name === node.name;
|
|
1717
|
-
//});
|
|
1723
|
+
// });
|
|
1718
1724
|
const map = {
|
|
1719
1725
|
BindAttribute: '属性',
|
|
1720
1726
|
BindDirective: '指令',
|
|
1721
1727
|
BindStyle: '样式属性',
|
|
1722
1728
|
};
|
|
1723
|
-
|
|
1729
|
+
// “${attr?.title || node.title || node.name}”
|
|
1724
1730
|
const diagnostic = {
|
|
1725
1731
|
node,
|
|
1726
1732
|
severity: 'error',
|
|
@@ -1882,7 +1888,7 @@ class NaslServer {
|
|
|
1882
1888
|
const { default: defaultVal } = precisionOption || {};
|
|
1883
1889
|
const precision = databaseTypeAnnotation ? (databaseTypeAnnotation.arguments as any)?.precision : defaultVal;
|
|
1884
1890
|
const ruleScale = (typeAnnotation?.ruleMap as any)?.scale;
|
|
1885
|
-
const scale = ruleScale !== undefined ? ruleScale
|
|
1891
|
+
const scale = ruleScale !== undefined ? `${ruleScale }` : '';
|
|
1886
1892
|
let ensureScale = true;
|
|
1887
1893
|
switch (typeName) {
|
|
1888
1894
|
case 'String': {
|
|
@@ -1981,7 +1987,7 @@ class NaslServer {
|
|
|
1981
1987
|
// 储存小数部分
|
|
1982
1988
|
const memoryScaleStr = memoryStr.slice(0, +(scale || '0'));
|
|
1983
1989
|
// 储存绝对值
|
|
1984
|
-
const memoryAbsVal = memoryIntAbsStr + (memoryScaleStr ?
|
|
1990
|
+
const memoryAbsVal = memoryIntAbsStr + (memoryScaleStr ? `.${ memoryScaleStr}` : '');
|
|
1985
1991
|
const decimalMemoryAbsVal = new Decimal(memoryAbsVal);
|
|
1986
1992
|
[
|
|
1987
1993
|
{
|
|
@@ -2049,7 +2055,7 @@ class NaslServer {
|
|
|
2049
2055
|
diagnostics.push(diagnostic);
|
|
2050
2056
|
}
|
|
2051
2057
|
fileNode?.sourceMap.forEach((value, node) => {
|
|
2052
|
-
//OQL支持返回复合类型数据了
|
|
2058
|
+
// OQL支持返回复合类型数据了
|
|
2053
2059
|
// SqlQueryComponent内部返回值类型,如果是嵌套的就需要报错
|
|
2054
2060
|
// if ((node instanceof OqlQueryComponent || node instanceof SqlQueryComponent) && (node as SqlQueryComponent).getTypeBanError()) {
|
|
2055
2061
|
// const diagnostic = {
|
|
@@ -2065,7 +2071,7 @@ class NaslServer {
|
|
|
2065
2071
|
const typeAnnotation = type2TypeAnnotation((node as any).__nodeType);
|
|
2066
2072
|
if (!node.typeAnnotation && typeAnnotation) {
|
|
2067
2073
|
if (typeAnnotation.typeName === 'List' && typeAnnotation.typeKind === 'generic') {
|
|
2068
|
-
const typeArguments = typeAnnotation
|
|
2074
|
+
const {typeArguments} = typeAnnotation;
|
|
2069
2075
|
if (typeArguments.length && typeArguments[0].isComplexType()) {
|
|
2070
2076
|
const diagnostic = {
|
|
2071
2077
|
node,
|
|
@@ -2123,7 +2129,6 @@ class NaslServer {
|
|
|
2123
2129
|
this.checkNodeError(node, diagnostics);
|
|
2124
2130
|
});
|
|
2125
2131
|
}
|
|
2126
|
-
console.timeEnd('_attachDiagnostics');
|
|
2127
2132
|
return diagnostics;
|
|
2128
2133
|
}
|
|
2129
2134
|
|
|
@@ -2354,7 +2359,7 @@ class NaslServer {
|
|
|
2354
2359
|
// 先特殊处理等 类型合并后就可以去掉了
|
|
2355
2360
|
if (excludeList.includes(leftType.sortedTypeKey) && excludeList.includes(rightType.sortedTypeKey)) {
|
|
2356
2361
|
return null;
|
|
2357
|
-
}
|
|
2362
|
+
} if (excludeList2.includes(leftType.sortedTypeKey) || excludeList2.includes(rightType.sortedTypeKey)) {
|
|
2358
2363
|
return null;
|
|
2359
2364
|
}
|
|
2360
2365
|
const diagnostic = {
|
|
@@ -2394,7 +2399,7 @@ class NaslServer {
|
|
|
2394
2399
|
if (typeKeyArr[0] === 'apis') {
|
|
2395
2400
|
const structureName = typeKeyArr[3];
|
|
2396
2401
|
const moduleName = typeKeyArr[1];
|
|
2397
|
-
const app = (typeAnnotation.upperNode as Variable)
|
|
2402
|
+
const {app} = (typeAnnotation.upperNode as Variable);
|
|
2398
2403
|
if (!app) {
|
|
2399
2404
|
return null;
|
|
2400
2405
|
}
|
|
@@ -2410,14 +2415,14 @@ class NaslServer {
|
|
|
2410
2415
|
}
|
|
2411
2416
|
}
|
|
2412
2417
|
return null;
|
|
2413
|
-
}
|
|
2418
|
+
}
|
|
2414
2419
|
return diag;
|
|
2415
|
-
|
|
2420
|
+
|
|
2416
2421
|
});
|
|
2417
2422
|
if (actionArr.length) {
|
|
2418
2423
|
if (timer) return;
|
|
2419
2424
|
timer = window.setTimeout(() => {
|
|
2420
|
-
const app = actionArr[0].target
|
|
2425
|
+
const {app} = actionArr[0].target;
|
|
2421
2426
|
app.emit('collect:start', {
|
|
2422
2427
|
actionMsg: '设置导入接口数据类型错误',
|
|
2423
2428
|
});
|
|
@@ -2481,7 +2486,7 @@ class NaslServer {
|
|
|
2481
2486
|
*/
|
|
2482
2487
|
_findMinRange(diagnostic: tsProtocol.DiagnosticWithFileName | tsProtocol.ReferencesResponseItem, fileNode: FileNode) {
|
|
2483
2488
|
let minRange: MinRange;
|
|
2484
|
-
const sourceMap
|
|
2489
|
+
const {sourceMap} = fileNode;
|
|
2485
2490
|
// 是否找到了行内准确的,是的话,就不走多行的
|
|
2486
2491
|
let haveLineNode = false;
|
|
2487
2492
|
for (const [node, item] of sourceMap.entries()) {
|
|
@@ -2521,11 +2526,9 @@ class NaslServer {
|
|
|
2521
2526
|
// 找到的内容的开始位置, 要大于申明内容开始的位置,要不就不包含在内了
|
|
2522
2527
|
if (diagnostic.start.offset - item.range.start.character <= diagnostic.start.offset - minRange.item.range.start.character) {
|
|
2523
2528
|
minRange = { node, item };
|
|
2524
|
-
} else {
|
|
2525
|
-
if (diagnostic.start.offset < lsp2tspNumber(minRange.item.range.start.character)) {
|
|
2529
|
+
} else if (diagnostic.start.offset < lsp2tspNumber(minRange.item.range.start.character)) {
|
|
2526
2530
|
minRange = { node, item };
|
|
2527
2531
|
}
|
|
2528
|
-
}
|
|
2529
2532
|
} else if (item.range.end.line - item.range.start.line <= minRange.item.range.end.line - minRange.item.range.start.line) {
|
|
2530
2533
|
// 行都一致 ,比较列
|
|
2531
2534
|
if (minRange.item.range.start.line === item.range.start.line && minRange.item.range.end.line === item.range.end.line) {
|
|
@@ -2568,8 +2571,7 @@ class NaslServer {
|
|
|
2568
2571
|
offset: lsp2tspNumber(currentSource.range.start.character),
|
|
2569
2572
|
});
|
|
2570
2573
|
refsList = [...newRefs.refs];
|
|
2571
|
-
} else {
|
|
2572
|
-
if (node instanceof Module) {
|
|
2574
|
+
} else if (node instanceof Module) {
|
|
2573
2575
|
const lists = node.logics || node.structures || node.enums;
|
|
2574
2576
|
const moduleName = (fileNode as FileNode).getEmbeddedFilePath();
|
|
2575
2577
|
if (lists.length) {
|
|
@@ -2579,7 +2581,7 @@ class NaslServer {
|
|
|
2579
2581
|
const newRefs = await this.references({
|
|
2580
2582
|
file: (fileNode as FileNode).getEmbeddedFilePath(),
|
|
2581
2583
|
line: 1,
|
|
2582
|
-
offset: 22,
|
|
2584
|
+
offset: 22, // 固定的位置,module的位置信息
|
|
2583
2585
|
});
|
|
2584
2586
|
refsList = newRefs.refs.filter((item) => !item.file.startsWith(moduleName));
|
|
2585
2587
|
// 多塞一个 ,删除的时候就有值了, 上面过滤了之后可能是空的
|
|
@@ -2587,7 +2589,6 @@ class NaslServer {
|
|
|
2587
2589
|
}
|
|
2588
2590
|
}
|
|
2589
2591
|
}
|
|
2590
|
-
}
|
|
2591
2592
|
|
|
2592
2593
|
// 如果是DataSource就需要在单独,查一边来修改名字
|
|
2593
2594
|
if (node instanceof DataSource) {
|
|
@@ -2647,7 +2648,7 @@ class NaslServer {
|
|
|
2647
2648
|
).length;
|
|
2648
2649
|
if (!groupByLength && !aggregateLength && callQueryComponentTypeAnnotation.typeKind === 'anonymousStructure') {
|
|
2649
2650
|
// 拿到 List 的泛型(匿名数据结构)的所有属性
|
|
2650
|
-
const properties = callQueryComponentTypeAnnotation.properties[0].typeAnnotation.typeArguments[0]
|
|
2651
|
+
const {properties} = callQueryComponentTypeAnnotation.properties[0].typeAnnotation.typeArguments[0];
|
|
2651
2652
|
const targetProperty = properties.find((p) => p.name === utils.firstLowerCase(node.name));
|
|
2652
2653
|
if (!targetProperty) {
|
|
2653
2654
|
continue;
|
|
@@ -2699,7 +2700,7 @@ class NaslServer {
|
|
|
2699
2700
|
if (node instanceof Param && (node.parentNode instanceof View || node.parentNode instanceof Process)) {
|
|
2700
2701
|
const viewNode = node.parentNode;
|
|
2701
2702
|
const { currentSource } = this.getCurrentSource(viewNode);
|
|
2702
|
-
const code = currentSource
|
|
2703
|
+
const {code} = currentSource;
|
|
2703
2704
|
const viewIndex = code.indexOf(' {');
|
|
2704
2705
|
const viewRefs = await this.references({
|
|
2705
2706
|
file: (fileNode as FileNode).getEmbeddedFilePath(),
|
|
@@ -2737,7 +2738,7 @@ class NaslServer {
|
|
|
2737
2738
|
*/
|
|
2738
2739
|
if (node instanceof ViewElement) {
|
|
2739
2740
|
if (currentSource) {
|
|
2740
|
-
const code = currentSource
|
|
2741
|
+
const {code} = currentSource;
|
|
2741
2742
|
const prefix = '__elements.';
|
|
2742
2743
|
const prefixIndex = code.indexOf(prefix) !== -1 ? code.indexOf(prefix) : 0;
|
|
2743
2744
|
const methodsNameIndex = prefixIndex + prefix.length;
|
|
@@ -2763,7 +2764,7 @@ class NaslServer {
|
|
|
2763
2764
|
}
|
|
2764
2765
|
if (node instanceof Process) {
|
|
2765
2766
|
if (currentSource) {
|
|
2766
|
-
const code = currentSource
|
|
2767
|
+
const {code} = currentSource;
|
|
2767
2768
|
const prefix = '__ProcessIdentification__';
|
|
2768
2769
|
let positions = [];
|
|
2769
2770
|
let pos = code.indexOf(prefix);
|
|
@@ -2790,7 +2791,7 @@ class NaslServer {
|
|
|
2790
2791
|
if ((node instanceof Param || node instanceof Return) && node.parentNode instanceof Process) {
|
|
2791
2792
|
const { currentSource } = this.getCurrentSource(node.parentNode);
|
|
2792
2793
|
if (currentSource) {
|
|
2793
|
-
const code = currentSource
|
|
2794
|
+
const {code} = currentSource;
|
|
2794
2795
|
const prefix = '__ProcessIdentification__';
|
|
2795
2796
|
const positions = [];
|
|
2796
2797
|
let pos = code.indexOf(prefix);
|
|
@@ -2820,7 +2821,7 @@ class NaslServer {
|
|
|
2820
2821
|
}
|
|
2821
2822
|
if (node instanceof ProcessElement) {
|
|
2822
2823
|
if (currentSource) {
|
|
2823
|
-
const code = currentSource
|
|
2824
|
+
const {code} = currentSource;
|
|
2824
2825
|
const prefix = '__ProcessIdentification__';
|
|
2825
2826
|
let positions = [];
|
|
2826
2827
|
let pos = code.indexOf(prefix);
|
|
@@ -2846,7 +2847,7 @@ class NaslServer {
|
|
|
2846
2847
|
if (node instanceof Return && node.parentNode instanceof ProcessElement) {
|
|
2847
2848
|
const { currentSource } = this.getCurrentSource(node.parentNode);
|
|
2848
2849
|
if (currentSource) {
|
|
2849
|
-
const code = currentSource
|
|
2850
|
+
const {code} = currentSource;
|
|
2850
2851
|
const prefix = '__ProcessIdentification__';
|
|
2851
2852
|
const positions = [];
|
|
2852
2853
|
let pos = code.indexOf(prefix);
|
|
@@ -2921,7 +2922,7 @@ class NaslServer {
|
|
|
2921
2922
|
}
|
|
2922
2923
|
if (minRange.node instanceof CallLogic && node instanceof ViewElement) {
|
|
2923
2924
|
minRange.setTypeMethods = 'setCalleeNamespace';
|
|
2924
|
-
minRange.newValue =
|
|
2925
|
+
minRange.newValue = `elements.${ newValue }.logics`;
|
|
2925
2926
|
}
|
|
2926
2927
|
// 如果节点是实体修改引发calllogic修改
|
|
2927
2928
|
if (
|
|
@@ -2940,9 +2941,9 @@ class NaslServer {
|
|
|
2940
2941
|
* 3.然后把namespace中的 $替换成 ''
|
|
2941
2942
|
*
|
|
2942
2943
|
*/
|
|
2943
|
-
const tsCalleeNamespace = minRange.node
|
|
2944
|
+
const {tsCalleeNamespace} = minRange.node;
|
|
2944
2945
|
// 先看下标位置
|
|
2945
|
-
const lineText = record
|
|
2946
|
+
const {lineText} = record;
|
|
2946
2947
|
const index = lineText.indexOf(tsCalleeNamespace);
|
|
2947
2948
|
// 在把开始结束位置的-开始位置,来知道是哪里要替换
|
|
2948
2949
|
const start = record.start.offset - index - 1;
|
|
@@ -2977,12 +2978,12 @@ class NaslServer {
|
|
|
2977
2978
|
if (minRange.node instanceof Identifier) {
|
|
2978
2979
|
// 匹配到的内容,当前这一行的内容;
|
|
2979
2980
|
// 因为要用下面的点位信息
|
|
2980
|
-
const name = minRange.node
|
|
2981
|
+
const {name} = minRange.node;
|
|
2981
2982
|
// 如果name不改,那就是要改命名空间
|
|
2982
2983
|
if (node instanceof Frontend || newValue === name) {
|
|
2983
|
-
const namespace = minRange.node
|
|
2984
|
+
const {namespace} = minRange.node;
|
|
2984
2985
|
// 先看下标位置
|
|
2985
|
-
const lineText = record
|
|
2986
|
+
const {lineText} = record;
|
|
2986
2987
|
const index = lineText.indexOf(namespace);
|
|
2987
2988
|
// 在把开始结束位置的-开始位置,来知道是哪里要替换
|
|
2988
2989
|
const start = record.start.offset - index - 1;
|
|
@@ -3013,7 +3014,7 @@ class NaslServer {
|
|
|
3013
3014
|
// 枚举key的特殊性,因为它不是原来的key+value形式的
|
|
3014
3015
|
// 是加了中括号啥的,所以直接赋值新值
|
|
3015
3016
|
if (node instanceof EnumItem) {
|
|
3016
|
-
const newTextValue = node.parentNode.name
|
|
3017
|
+
const newTextValue = `${node.parentNode.name }.${ newValue}`;
|
|
3017
3018
|
minRange.newValue = newTextValue;
|
|
3018
3019
|
} else {
|
|
3019
3020
|
// 匹配到的内容,当前这一行的内容;
|
|
@@ -3048,7 +3049,7 @@ class NaslServer {
|
|
|
3048
3049
|
minRange.setTypeMethods = 'setEntityNameAndEffect';
|
|
3049
3050
|
} else if (minRange.node instanceof BindAttribute && minRange.node.name === 'url') {
|
|
3050
3051
|
// 如果是查找到 上传地址的链接引用
|
|
3051
|
-
let newName = newValue.replace(/[A-Z]/g, (item) =>
|
|
3052
|
+
let newName = newValue.replace(/[A-Z]/g, (item) => `-${ item.toLowerCase()}`);
|
|
3052
3053
|
newName = newName[0] === '-' ? newName.slice(1) : newName;
|
|
3053
3054
|
const newTextValue = node.parentNode.name === 'defaultDS' ? `/api/${newName}/import` : `/api/${node.parentNode.name}/${newName}/import`;
|
|
3054
3055
|
minRange.setTypeMethods = 'setUrlValue';
|
|
@@ -3090,11 +3091,11 @@ class NaslServer {
|
|
|
3090
3091
|
* 3.然后把namespace中的 $替换成 ''
|
|
3091
3092
|
*
|
|
3092
3093
|
*/
|
|
3093
|
-
const tsCalleeNamespace = minRange.node
|
|
3094
|
-
const tsName = minRange.node
|
|
3095
|
-
const oldValue = tsCalleeNamespace
|
|
3094
|
+
const {tsCalleeNamespace} = minRange.node;
|
|
3095
|
+
const {tsName} = minRange.node;
|
|
3096
|
+
const oldValue = `${tsCalleeNamespace }.${ tsName}`;
|
|
3096
3097
|
// 先看下标位置
|
|
3097
|
-
const lineText = record
|
|
3098
|
+
const {lineText} = record;
|
|
3098
3099
|
const index = lineText.indexOf(oldValue);
|
|
3099
3100
|
// 在把开始结束位置的-开始位置,来知道是哪里要替换
|
|
3100
3101
|
const start = record.start.offset - index - 1;
|
|
@@ -3111,11 +3112,11 @@ class NaslServer {
|
|
|
3111
3112
|
}
|
|
3112
3113
|
}
|
|
3113
3114
|
if (node instanceof Frontend && minRange.node instanceof Destination) {
|
|
3114
|
-
const tsCalleeNamespace = minRange.node
|
|
3115
|
-
const tsName = minRange.node
|
|
3116
|
-
const oldValue = tsCalleeNamespace
|
|
3115
|
+
const {tsCalleeNamespace} = minRange.node;
|
|
3116
|
+
const {tsName} = minRange.node;
|
|
3117
|
+
const oldValue = `${tsCalleeNamespace }.${ tsName}`;
|
|
3117
3118
|
// 先看下标位置
|
|
3118
|
-
const lineText = record
|
|
3119
|
+
const {lineText} = record;
|
|
3119
3120
|
const index = lineText.indexOf(oldValue);
|
|
3120
3121
|
// 在把开始结束位置的-开始位置,来知道是哪里要替换
|
|
3121
3122
|
const start = record.start.offset - index - 1;
|
|
@@ -3135,7 +3136,7 @@ class NaslServer {
|
|
|
3135
3136
|
// 页面逻辑直接赋值就可以, 因为是相对路径
|
|
3136
3137
|
if (node instanceof ViewElement) {
|
|
3137
3138
|
minRange.setTypeMethods = 'setCalleeNamespace';
|
|
3138
|
-
minRange.newValue =
|
|
3139
|
+
minRange.newValue = `elements.${ newValue }.logics`;
|
|
3139
3140
|
} else {
|
|
3140
3141
|
/**
|
|
3141
3142
|
* 如果namespce是 'app.views.Student.views.404.views.505.views.update'
|
|
@@ -3146,11 +3147,11 @@ class NaslServer {
|
|
|
3146
3147
|
* 2.在匹配到的内容中取转后的namespace的位置
|
|
3147
3148
|
* 3.然后把namespace中的 $替换成 ''
|
|
3148
3149
|
*/
|
|
3149
|
-
const tsCalleeNamespace = minRange.node
|
|
3150
|
+
const {tsCalleeNamespace} = minRange.node;
|
|
3150
3151
|
const oldValue = tsCalleeNamespace;
|
|
3151
3152
|
|
|
3152
3153
|
// 先看下标位置
|
|
3153
|
-
const lineText = record
|
|
3154
|
+
const {lineText} = record;
|
|
3154
3155
|
const index = lineText.indexOf(oldValue);
|
|
3155
3156
|
|
|
3156
3157
|
// 在把开始结束位置的-开始位置,来知道是哪里要替换
|
|
@@ -3213,7 +3214,7 @@ class NaslServer {
|
|
|
3213
3214
|
if (node instanceof DataSource) {
|
|
3214
3215
|
const setTypeNamespace = (typeNamespace: string, record: any) => {
|
|
3215
3216
|
// 先看下标位置
|
|
3216
|
-
const lineText = record
|
|
3217
|
+
const {lineText} = record;
|
|
3217
3218
|
const index = lineText.indexOf(typeNamespace);
|
|
3218
3219
|
// 在把开始结束位置的-开始位置,来知道是哪里要替换
|
|
3219
3220
|
const start = record.start.offset - index - 1;
|
|
@@ -3338,7 +3339,7 @@ class NaslServer {
|
|
|
3338
3339
|
.sort((a, b) => {
|
|
3339
3340
|
if (a.node.concept === 'QueryFieldExpression') {
|
|
3340
3341
|
return 1;
|
|
3341
|
-
}
|
|
3342
|
+
} if (b.node.concept === 'QueryFieldExpression') {
|
|
3342
3343
|
return -1;
|
|
3343
3344
|
}
|
|
3344
3345
|
return 0;
|
|
@@ -3580,7 +3581,7 @@ class NaslServer {
|
|
|
3580
3581
|
*/
|
|
3581
3582
|
getCurrentSource(node: BaseNode) {
|
|
3582
3583
|
if (node instanceof App || node instanceof Theme) return { fileNode: null };
|
|
3583
|
-
let sourceMap = node
|
|
3584
|
+
let {sourceMap} = node;
|
|
3584
3585
|
let fileNode = node;
|
|
3585
3586
|
// 如果没有sourceMap,就继续向上找 ,或者到module结束
|
|
3586
3587
|
// 如果 节点找到 app 或者module 停止 或者entity找到DataSource为止
|
|
@@ -3631,18 +3632,18 @@ class NaslServer {
|
|
|
3631
3632
|
range.line = currentSource.range.end.line;
|
|
3632
3633
|
range.offset = 0;
|
|
3633
3634
|
} else if (node.concept === 'BindAttribute') {
|
|
3634
|
-
range.offset
|
|
3635
|
+
range.offset += 7;
|
|
3635
3636
|
} else if (node.concept === 'BindDirective') {
|
|
3636
|
-
range.offset
|
|
3637
|
+
range.offset += 5;
|
|
3637
3638
|
}
|
|
3638
3639
|
return this._getFieldKeySelectCompletion({
|
|
3639
3640
|
file: (fileNode as FileNode).getEmbeddedFilePath(),
|
|
3640
3641
|
range,
|
|
3641
3642
|
getFieldKey: fieldKey,
|
|
3642
3643
|
});
|
|
3643
|
-
}
|
|
3644
|
+
}
|
|
3644
3645
|
console.log('没找到节点', currentSource, fileNode);
|
|
3645
|
-
|
|
3646
|
+
|
|
3646
3647
|
}
|
|
3647
3648
|
|
|
3648
3649
|
_getFieldKeySelectCompletion(args: any) {
|
|
@@ -3692,7 +3693,7 @@ class NaslServer {
|
|
|
3692
3693
|
return [...fileNodes];
|
|
3693
3694
|
}
|
|
3694
3695
|
|
|
3695
|
-
|
|
3696
|
+
/** 获取当前节点的已知类型
|
|
3696
3697
|
* @param node 当前要获取类型的节点
|
|
3697
3698
|
* @returns 不需要去查就可以返回类型的节点
|
|
3698
3699
|
*/
|
|
@@ -3864,7 +3865,7 @@ class NaslServer {
|
|
|
3864
3865
|
const lastLen = codeArr?.[codeArr.length - 1]?.length;
|
|
3865
3866
|
indexOf = subStr.length - lastLen;
|
|
3866
3867
|
}
|
|
3867
|
-
fileDetail.offset
|
|
3868
|
+
fileDetail.offset += indexOf;
|
|
3868
3869
|
} else if (
|
|
3869
3870
|
node.concept === 'MemberExpression' ||
|
|
3870
3871
|
node.concept === 'Identifier' ||
|
|
@@ -3876,7 +3877,7 @@ class NaslServer {
|
|
|
3876
3877
|
const lastLen = codeArr?.[codeArr.length - 1]?.length;
|
|
3877
3878
|
// MemberExpression取最后一位当做类型
|
|
3878
3879
|
const indexOf = item.code.length - lastLen;
|
|
3879
|
-
fileDetail.offset
|
|
3880
|
+
fileDetail.offset += indexOf;
|
|
3880
3881
|
}
|
|
3881
3882
|
} else if (node.concept === 'Match') {
|
|
3882
3883
|
// 去查return 后面的返回值,变成函数调用
|
|
@@ -3908,7 +3909,7 @@ class NaslServer {
|
|
|
3908
3909
|
const item = (resultMap as any)?.[file]?.[line]?.[offset];
|
|
3909
3910
|
const itemType = item?.[0]?.nodeType;
|
|
3910
3911
|
const nodeTypeAnnotation = type2TypeAnnotation(itemType);
|
|
3911
|
-
const node = newQuickInfoNodes[index]
|
|
3912
|
+
const {node} = newQuickInfoNodes[index];
|
|
3912
3913
|
|
|
3913
3914
|
types.set(node, Object.freeze(nodeTypeAnnotation) as TypeAnnotation);
|
|
3914
3915
|
|
|
@@ -3945,7 +3946,7 @@ class NaslServer {
|
|
|
3945
3946
|
const typeAnnotation = value as TypeAnnotation;
|
|
3946
3947
|
if (!node.typeAnnotation && typeAnnotation) {
|
|
3947
3948
|
if (typeAnnotation.typeName === 'List' && typeAnnotation.typeKind === 'generic') {
|
|
3948
|
-
const typeArguments = typeAnnotation
|
|
3949
|
+
const {typeArguments} = typeAnnotation;
|
|
3949
3950
|
if (typeArguments.length && typeArguments[0].isComplexType()) {
|
|
3950
3951
|
node.__TypeAnnotation = null;
|
|
3951
3952
|
return;
|
|
@@ -4180,7 +4181,7 @@ class NaslServer {
|
|
|
4180
4181
|
}
|
|
4181
4182
|
}
|
|
4182
4183
|
// 用户自己声明的用用户的
|
|
4183
|
-
const callObj = App.findNodeByCompleteName(parent.calleeNamespace
|
|
4184
|
+
const callObj = App.findNodeByCompleteName(`${parent.calleeNamespace }.${ parent.calleeName}`);
|
|
4184
4185
|
const index = parent.arguments.indexOf(node);
|
|
4185
4186
|
const param = callObj?.params?.[index] || {};
|
|
4186
4187
|
// 取出参数的类型
|
|
@@ -4456,7 +4457,7 @@ class NaslServer {
|
|
|
4456
4457
|
*/
|
|
4457
4458
|
async incidentalAction(action: string, fileNode: BaseNode, targetNode: BaseNode, oldpath?: string) {
|
|
4458
4459
|
if ((action === 'create' || action === 'delete' || (action === 'update' && oldpath)) && fileNode === targetNode) {
|
|
4459
|
-
|
|
4460
|
+
// 删除、更改、新增端
|
|
4460
4461
|
if (fileNode instanceof Frontend && (fileNode.views?.length || fileNode.variables?.length)) {
|
|
4461
4462
|
const fileNodeChildren = [...fileNode.views, ...fileNode.variables];
|
|
4462
4463
|
for (let i = 0; i < fileNodeChildren.length; i++) {
|
|
@@ -4472,7 +4473,7 @@ class NaslServer {
|
|
|
4472
4473
|
} else if (action === 'update' && oldpath) {
|
|
4473
4474
|
const parentPath = oldpath.replace('.ts', '/');
|
|
4474
4475
|
const foldName = fileNodeItem.concept === 'View' ? 'views' : 'variables';
|
|
4475
|
-
const currentOldPath = parentPath + foldName
|
|
4476
|
+
const currentOldPath = `${parentPath + foldName }/${ fileNodeItem.name }.ts`;
|
|
4476
4477
|
// 因为重命名这里只有当前修改父级的 旧名称, 所以他的子集也要根据旧名称去查依赖 更新内容
|
|
4477
4478
|
await this.handleRename(fileNodeItem, fileNodeItem, result, currentOldPath);
|
|
4478
4479
|
await this.incidentalAction(action, fileNodeItem, fileNodeItem, currentOldPath);
|
|
@@ -4494,7 +4495,7 @@ class NaslServer {
|
|
|
4494
4495
|
await this.incidentalAction(action, fileNodeItem, fileNodeItem);
|
|
4495
4496
|
} else if (action === 'update' && oldpath) {
|
|
4496
4497
|
const parentPath = oldpath.replace('.ts', '/');
|
|
4497
|
-
const currentOldPath = parentPath + fileNodeItem.name
|
|
4498
|
+
const currentOldPath = `${parentPath + fileNodeItem.name }.ts`;
|
|
4498
4499
|
// 因为重命名这里只有当前修改父级的 旧名称, 所以他的子集也要根据旧名称去查依赖 更新内容
|
|
4499
4500
|
await this.handleRename(fileNodeItem, fileNodeItem, result, currentOldPath);
|
|
4500
4501
|
await this.incidentalAction(action, fileNodeItem, fileNodeItem, currentOldPath);
|
|
@@ -4538,7 +4539,7 @@ class NaslServer {
|
|
|
4538
4539
|
try {
|
|
4539
4540
|
const result = entity.toEmbeddedTSFile();
|
|
4540
4541
|
const parentPath = oldpath.replace('.ts', '/');
|
|
4541
|
-
const currentOldPath = parentPath
|
|
4542
|
+
const currentOldPath = `${parentPath }/entities/${ entity.name }.ts`;
|
|
4542
4543
|
// 因为重命名这里只有当前修改父级的 旧名称, 所以他的子集也要根据旧名称去查依赖 更新内容
|
|
4543
4544
|
await this.handleRename(entity, entity, result, currentOldPath);
|
|
4544
4545
|
} catch (err) {
|
|
@@ -4552,7 +4553,7 @@ class NaslServer {
|
|
|
4552
4553
|
async receiveHandleChange($event: EventPayload) {
|
|
4553
4554
|
this.singleFileChangeIng = true;
|
|
4554
4555
|
// 行为
|
|
4555
|
-
const action = $event
|
|
4556
|
+
const {action} = $event;
|
|
4556
4557
|
const targetNode = $event.target;
|
|
4557
4558
|
// Connection 相关配置的更新不需要写入文件
|
|
4558
4559
|
if (targetNode?.parentNode instanceof Connection) {
|