@lcap/nasl-language-server-core 4.0.1-rc.0 → 4.0.1-rc.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/README.md +85 -0
- package/out/checker.d.ts.map +1 -1
- package/out/checker.js +28 -13
- package/out/checker.js.map +1 -1
- package/out/index.d.ts +2 -1
- package/out/index.d.ts.map +1 -1
- package/out/index.js +2 -1
- package/out/index.js.map +1 -1
- package/out/query/context-variable-query.d.ts +31 -0
- package/out/query/context-variable-query.d.ts.map +1 -0
- package/out/query/context-variable-query.js +105 -0
- package/out/query/context-variable-query.js.map +1 -0
- package/out/query/index.d.ts +2 -0
- package/out/query/index.d.ts.map +1 -0
- package/out/query/index.js +18 -0
- package/out/query/index.js.map +1 -0
- package/out/reference-manager/builtin-q-name.d.ts +1 -1
- package/out/reference-manager/builtin-q-name.d.ts.map +1 -1
- package/out/reference-manager/builtin-q-name.js +2 -2
- package/out/reference-manager/builtin-q-name.js.map +1 -1
- package/out/reference-manager/collect-q-name.d.ts +2 -1
- package/out/reference-manager/collect-q-name.d.ts.map +1 -1
- package/out/reference-manager/collect-q-name.js +8 -4
- package/out/reference-manager/collect-q-name.js.map +1 -1
- package/out/reference-manager/get-q-name.d.ts +1 -1
- package/out/reference-manager/get-q-name.d.ts.map +1 -1
- package/out/reference-manager/get-q-name.js +35 -31
- package/out/reference-manager/get-q-name.js.map +1 -1
- package/out/reference-manager/reference-manager.d.ts +6 -7
- package/out/reference-manager/reference-manager.d.ts.map +1 -1
- package/out/reference-manager/reference-manager.js +7 -6
- package/out/reference-manager/reference-manager.js.map +1 -1
- package/out/reference-manager/remove-q-name.d.ts +30 -28
- package/out/reference-manager/remove-q-name.d.ts.map +1 -1
- package/out/reference-manager/remove-q-name.js +54 -47
- package/out/reference-manager/remove-q-name.js.map +1 -1
- package/out/reference-manager/rename-q-name.d.ts +2 -1
- package/out/reference-manager/rename-q-name.d.ts.map +1 -1
- package/out/reference-manager/rename-q-name.js +31 -36
- package/out/reference-manager/rename-q-name.js.map +1 -1
- package/out/reference-manager/symbol-type.d.ts +2 -2
- package/out/reference-manager/symbol-type.d.ts.map +1 -1
- package/out/reference-manager/symbol-type.js +1 -1
- package/out/reference-manager/symbol-type.js.map +1 -1
- package/out/reference-manager/update-nasl-fragment.d.ts +2 -1
- package/out/reference-manager/update-nasl-fragment.d.ts.map +1 -1
- package/out/reference-manager/update-nasl-fragment.js +9 -1
- package/out/reference-manager/update-nasl-fragment.js.map +1 -1
- package/out/typer/collectGlobalDefs.d.ts.map +1 -1
- package/out/typer/collectGlobalDefs.js.map +1 -1
- package/out/typer/component-def-manager/component-def-manager.d.ts +32 -5
- package/out/typer/component-def-manager/component-def-manager.d.ts.map +1 -1
- package/out/typer/component-def-manager/component-def-manager.js +96 -19
- package/out/typer/component-def-manager/component-def-manager.js.map +1 -1
- package/out/typer/component-def-manager/utils.d.ts.map +1 -1
- package/out/typer/component-def-manager/utils.js +39 -12
- package/out/typer/component-def-manager/utils.js.map +1 -1
- package/out/typer/dispatch-all.d.ts +1 -1
- package/out/typer/dispatch-all.d.ts.map +1 -1
- package/out/typer/dispatch-all.js +3 -7
- package/out/typer/dispatch-all.js.map +1 -1
- package/out/typer/dispatch-def.d.ts +1 -1
- package/out/typer/dispatch-def.d.ts.map +1 -1
- package/out/typer/dispatch-def.js +7 -5
- package/out/typer/dispatch-def.js.map +1 -1
- package/out/typer/dispatch-expr.d.ts +1 -1
- package/out/typer/dispatch-expr.d.ts.map +1 -1
- package/out/typer/dispatch-expr.js +28 -14
- package/out/typer/dispatch-expr.js.map +1 -1
- package/out/typer/dispatch-stmt.d.ts.map +1 -1
- package/out/typer/dispatch-stmt.js +10 -1
- package/out/typer/dispatch-stmt.js.map +1 -1
- package/out/typer/dispatch-view.d.ts.map +1 -1
- package/out/typer/dispatch-view.js +115 -115
- package/out/typer/dispatch-view.js.map +1 -1
- package/out/typer/helper.js +3 -3
- package/out/typer/helper.js.map +1 -1
- package/out/typer/incremental-update.d.ts +15 -13
- package/out/typer/incremental-update.d.ts.map +1 -1
- package/out/typer/incremental-update.js +89 -42
- package/out/typer/incremental-update.js.map +1 -1
- package/out/typer/nasl-predicate.d.ts +1 -1
- package/out/typer/nasl-predicate.d.ts.map +1 -1
- package/out/typer/solver.d.ts +37 -24
- package/out/typer/solver.d.ts.map +1 -1
- package/out/typer/solver.js +205 -426
- package/out/typer/solver.js.map +1 -1
- package/out/typer/subster.d.ts +2 -4
- package/out/typer/subster.d.ts.map +1 -1
- package/out/typer/subster.js +42 -34
- package/out/typer/subster.js.map +1 -1
- package/out/typer/topo-sort.d.ts.map +1 -1
- package/out/typer/topo-sort.js +9 -2
- package/out/typer/topo-sort.js.map +1 -1
- package/out/typer/type-hint-manager/type-hint-manager.d.ts +3 -0
- package/out/typer/type-hint-manager/type-hint-manager.d.ts.map +1 -1
- package/out/typer/type-hint-manager/type-hint-manager.js +2 -0
- package/out/typer/type-hint-manager/type-hint-manager.js.map +1 -1
- package/out/typer/type-manager.d.ts +6 -2
- package/out/typer/type-manager.d.ts.map +1 -1
- package/out/typer/type-manager.js.map +1 -1
- package/out/typer/type-predicate.d.ts.map +1 -1
- package/out/typer/type-predicate.js +61 -6
- package/out/typer/type-predicate.js.map +1 -1
- package/out/typer/typer.d.ts +10 -5
- package/out/typer/typer.d.ts.map +1 -1
- package/out/typer/typer.js +34 -60
- package/out/typer/typer.js.map +1 -1
- package/out/typer/unifier.d.ts +0 -3
- package/out/typer/unifier.d.ts.map +1 -1
- package/out/typer/unifier.js +58 -35
- package/out/typer/unifier.js.map +1 -1
- package/out/utils/nasl-type-manipulation.d.ts +1 -0
- package/out/utils/nasl-type-manipulation.d.ts.map +1 -1
- package/out/utils/nasl-type-manipulation.js +3 -1
- package/out/utils/nasl-type-manipulation.js.map +1 -1
- package/out/utils/parseTsClassType.d.ts.map +1 -1
- package/out/utils/parseTsClassType.js +7 -3
- package/out/utils/parseTsClassType.js.map +1 -1
- package/out/utils/type-operator.d.ts.map +1 -1
- package/out/utils/type-operator.js.map +1 -1
- package/package.json +13 -6
|
@@ -8,6 +8,7 @@ const type_predicate_2 = require("./type-predicate");
|
|
|
8
8
|
const asserts_1 = require("@lcap/nasl-concepts/asserts");
|
|
9
9
|
const dispatch_expr_1 = require("./dispatch-expr");
|
|
10
10
|
const subster_1 = require("./subster");
|
|
11
|
+
const nasl_type_manipulation_1 = require("../utils/nasl-type-manipulation");
|
|
11
12
|
function dispatchStmt(env, nd) {
|
|
12
13
|
if (!nd) {
|
|
13
14
|
return;
|
|
@@ -214,6 +215,9 @@ function tpBatchAssignment(env, nd) {
|
|
|
214
215
|
return;
|
|
215
216
|
// 报错
|
|
216
217
|
}
|
|
218
|
+
if (nd.left.expression && (0, nasl_type_manipulation_1.isEnumIdentifier)(nd.left.expression)) {
|
|
219
|
+
env.addError(`批量赋值中 ${nd.left.expression.toNaturalTS()} 枚举类不能直接使用,请取它的枚举项`, undefined, nd.left.expression);
|
|
220
|
+
}
|
|
217
221
|
// 左侧连的是 x.a x.b x.c 这样的
|
|
218
222
|
if (nd.left.members.length) {
|
|
219
223
|
// 与 NewComposite 十分相似但是不一样,这里左侧列表是 a.b 这样的 MemberExpression,NewComposite 左侧是属性名 Identifier
|
|
@@ -223,6 +227,9 @@ function tpBatchAssignment(env, nd) {
|
|
|
223
227
|
const lIdx = line.leftIndex[1];
|
|
224
228
|
const lNode = (0, exports.toRaw)(nd.left.members[lIdx]);
|
|
225
229
|
const lPropName = lNode.property.name;
|
|
230
|
+
if (right && (0, nasl_type_manipulation_1.isEnumIdentifier)(right)) {
|
|
231
|
+
env.addError(`批量赋值中 ${right.toNaturalTS()} 枚举类不能直接使用,请取它的枚举项`, undefined, right);
|
|
232
|
+
}
|
|
226
233
|
if (nd.left.expression && lPropName) {
|
|
227
234
|
/**
|
|
228
235
|
* member expr 要标注 nd, nd.object, nd.property 三个,直接 set nd 自己还不够
|
|
@@ -239,6 +246,9 @@ function tpBatchAssignment(env, nd) {
|
|
|
239
246
|
if (line) {
|
|
240
247
|
const right = (0, dispatch_expr_1.getRightByLine)(nd, line.rightIndex[0], line.rightIndex.length > 1 ? line.rightIndex[1] : undefined);
|
|
241
248
|
const rTy = env.getRawType(right);
|
|
249
|
+
if (right && (0, nasl_type_manipulation_1.isEnumIdentifier)(right)) {
|
|
250
|
+
env.addError(`批量赋值中 ${right.toNaturalTS()} 枚举类不能直接使用,请取它的枚举项`, undefined, right);
|
|
251
|
+
}
|
|
242
252
|
env.unifier.unifyWithBoundary(rTy, lIdentTy, right);
|
|
243
253
|
// 上面 const lIdentTy = dispatchExpr(nd.left.expression, undefined); 已经处理过
|
|
244
254
|
}
|
|
@@ -249,7 +259,6 @@ function tpBatchAssignment(env, nd) {
|
|
|
249
259
|
if (!env.typeBindings.get(mem.property)) {
|
|
250
260
|
const propName = mem.property.name;
|
|
251
261
|
if (!propName) {
|
|
252
|
-
// FIXME wudengke 没有属性名
|
|
253
262
|
continue;
|
|
254
263
|
}
|
|
255
264
|
(0, index_1.dispatchExpr)(env, mem, undefined);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch-stmt.js","sourceRoot":"","sources":["../../src/typer/dispatch-stmt.ts"],"names":[],"mappings":";;;AAOA,mCAiBiB;AAEjB,
|
|
1
|
+
{"version":3,"file":"dispatch-stmt.js","sourceRoot":"","sources":["../../src/typer/dispatch-stmt.ts"],"names":[],"mappings":";;;AAOA,mCAiBiB;AAEjB,qDAI0B;AAC1B,iDAA6E;AAC7E,qDAA4C;AAC5C,yDAAqD;AAErD,mDAAgE;AAChE,uCAAkD;AAClD,4EAAmE;AAEnE,SAAgB,YAAY,CAAC,GAAW,EAAE,EAAc;IACtD,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,OAAO;IACT,CAAC;IAED,MAAM,cAAc,GAAG,GAAG,CAAC,WAAW,CAAC;IACvC,GAAG,CAAC,WAAW,GAAG,EAAE,CAAC;IACrB,QAAQ,EAAE,CAAC,OAAO,EAAE,CA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D,+BAA+B;IAC/B,qBAAqB;AACvB,CAAC;AAND,sDAMC;AAEM,MAAM,KAAK,GAAG,CAAI,EAAK,EAAK,EAAE;IACnC,mBAAmB;IACnB,OAAO,EAAE,EAAE,OAAO,IAAI,EAAE,CAAC;AAC3B,CAAC,CAAC;AAHW,QAAA,KAAK,SAGhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch-view.d.ts","sourceRoot":"","sources":["../../src/typer/dispatch-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EAIjB,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,cAAc,EAGd,SAAS,EAOV,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"dispatch-view.d.ts","sourceRoot":"","sources":["../../src/typer/dispatch-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EAIjB,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,cAAc,EAGd,SAAS,EAOV,MAAM,qBAAqB,CAAC;AAiC7B,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAWtC;;GAEG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAY7E;AAkHD,wBAAiB,mBAAmB,CAClC,GAAG,EAAE,MAAM,EACX,EAAE,EAAE,iBAAiB,GACpB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAuHhC;AAED,wBAAgB,WAAW,CACzB,GAAG,EAAE,MAAM,EACX,EAAE,EAAE,SAAS,EACb,KAAK,EAAE,cAAc,GAAG,SAAS,GAChC,cAAc,CAsBhB;AA4vBD,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,cAAc,GAAG,cAAc,CAMpF;AA6BD,eAAO,MAAM,cAAc,mBAGzB,CAAC;AACH,eAAO,MAAM,iBAAiB,mBAG5B,CAAC;AACH,eAAO,MAAM,oBAAoB,mBAG/B,CAAC;AACH,eAAO,MAAM,cAAc,mBAGzB,CAAC;AAqBH,wBAAgB,aAAa,CAAC,OAAO,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,uBAUvE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,WAMpD"}
|
|
@@ -5,6 +5,7 @@ const nasl_concepts_1 = require("@lcap/nasl-concepts");
|
|
|
5
5
|
const type_manager_1 = require("./type-manager");
|
|
6
6
|
const type_predicate_1 = require("./type-predicate");
|
|
7
7
|
const assertion_1 = require("../utils/assertion");
|
|
8
|
+
const get_q_name_1 = require("../reference-manager/get-q-name");
|
|
8
9
|
const reference_manager_1 = require("../reference-manager/reference-manager");
|
|
9
10
|
const types_1 = require("../utils/types");
|
|
10
11
|
const asserts_1 = require("@lcap/nasl-concepts/asserts");
|
|
@@ -97,6 +98,15 @@ function* dispatchViewGenerator(env, nd) {
|
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
function* tpFrontendType(env, nd) {
|
|
101
|
+
// HACK: 跑两遍。因为业务组件可能可以互相引用。跑两遍可以解开长度为 2 的循环引用和前向引用。
|
|
102
|
+
env.suppressErrorReporting();
|
|
103
|
+
yield* (0, nasl_utils_1.wrapForEachToGenerator)(nd.businessComponents, function* (bc) {
|
|
104
|
+
yield* dispatchViewGenerator(env, bc);
|
|
105
|
+
});
|
|
106
|
+
env.enableErrorReporting();
|
|
107
|
+
yield* (0, nasl_utils_1.wrapForEachToGenerator)(nd.businessComponents, function* (bc) {
|
|
108
|
+
yield* dispatchViewGenerator(env, bc);
|
|
109
|
+
});
|
|
100
110
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(nd.frontends, function* (fe) {
|
|
101
111
|
yield* dispatchViewGenerator(env, fe);
|
|
102
112
|
});
|
|
@@ -141,7 +151,7 @@ function* tpBusinessComponent(env, nd) {
|
|
|
141
151
|
const isViewCopy = env.isView;
|
|
142
152
|
env.isView = true;
|
|
143
153
|
env.unifier.clearCs();
|
|
144
|
-
const assocProcess = env.processViewBindings.get((0,
|
|
154
|
+
const assocProcess = env.processViewBindings.get((0, get_q_name_1.getTokenQualifiedName)(nd));
|
|
145
155
|
const allocatedProcessVars = new Array();
|
|
146
156
|
if (assocProcess) {
|
|
147
157
|
env.viewAssocProcess = assocProcess;
|
|
@@ -165,7 +175,7 @@ function* tpBusinessComponent(env, nd) {
|
|
|
165
175
|
traverseViewElements(e, (ve) => {
|
|
166
176
|
const ty = env.unifier.nextFreshTyAnn('free');
|
|
167
177
|
env.setType(ve, ty);
|
|
168
|
-
const qName = (0,
|
|
178
|
+
const qName = (0, get_q_name_1.getTokenQualifiedName)(ve);
|
|
169
179
|
(0, assertion_1.assertTrusy)(qName);
|
|
170
180
|
env.allocatedVEQNames.push(qName);
|
|
171
181
|
env.refMgr.addQNameDef(qName,
|
|
@@ -177,7 +187,7 @@ function* tpBusinessComponent(env, nd) {
|
|
|
177
187
|
const dropList = [];
|
|
178
188
|
const sortedLogics = sortLogicsForFrontendDomain(env, nd.logics);
|
|
179
189
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(sortedLogics, function* (l) {
|
|
180
|
-
env.refMgr.qNameDefs.set((0,
|
|
190
|
+
env.refMgr.qNameDefs.set((0, get_q_name_1.getTokenQualifiedName)(l), l);
|
|
181
191
|
(0, helper_1.createOnPush)(env.nameBindings, l.name, l);
|
|
182
192
|
dropList.push(l);
|
|
183
193
|
(0, helper_1.createOnPush)(env.allocatedVirtualNodes, env.getCurFileNode(), l);
|
|
@@ -191,6 +201,7 @@ function* tpBusinessComponent(env, nd) {
|
|
|
191
201
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(nd.elements, function* (e) {
|
|
192
202
|
yield* tpViewElementFirstPass(env, e);
|
|
193
203
|
});
|
|
204
|
+
(0, subster_1.traverseSubstRunCheck)(env, nd);
|
|
194
205
|
// 从logics字段中筛选isPublic=true的元素
|
|
195
206
|
const readableProps = nd.logics
|
|
196
207
|
.filter((logic) => logic.isPublic === true)
|
|
@@ -225,11 +236,10 @@ function* tpBusinessComponent(env, nd) {
|
|
|
225
236
|
returnType: [
|
|
226
237
|
nasl_concepts_1.TypeAnnotation.createTypeAnonymousStructure([...eventHandlers, ...readableProps].map((x) => {
|
|
227
238
|
return nasl_concepts_1.StructureProperty.createProtoTypeOnly({ name: x.name, typeAnnotation: x.type });
|
|
228
|
-
})
|
|
239
|
+
})),
|
|
229
240
|
],
|
|
230
241
|
});
|
|
231
242
|
env.refMgr.compDefMgr.overwriteBusinessComponentDef(nd, ty);
|
|
232
|
-
(0, subster_1.traverseSubstRunCheck)(env, nd);
|
|
233
243
|
yield;
|
|
234
244
|
for (const nd of dropList) {
|
|
235
245
|
(0, helper_1.removeLastOne)(env.nameBindings, nd.name);
|
|
@@ -272,7 +282,7 @@ function* tpView(env, nd) {
|
|
|
272
282
|
const isViewCopy = env.isView;
|
|
273
283
|
env.isView = true;
|
|
274
284
|
env.unifier.clearCs();
|
|
275
|
-
const assocProcess = env.processViewBindings.get((0,
|
|
285
|
+
const assocProcess = env.processViewBindings.get((0, get_q_name_1.getTokenQualifiedName)(nd));
|
|
276
286
|
const allocatedProcessVars = new Array();
|
|
277
287
|
if (assocProcess) {
|
|
278
288
|
env.viewAssocProcess = assocProcess;
|
|
@@ -303,7 +313,7 @@ function* tpView(env, nd) {
|
|
|
303
313
|
traverseViewElements(e, (ve) => {
|
|
304
314
|
const ty = env.unifier.nextFreshTyAnn('free');
|
|
305
315
|
env.setType(ve, ty);
|
|
306
|
-
const qName = (0,
|
|
316
|
+
const qName = (0, get_q_name_1.getTokenQualifiedName)(ve);
|
|
307
317
|
(0, assertion_1.assertTrusy)(qName);
|
|
308
318
|
env.allocatedVEQNames.push(qName);
|
|
309
319
|
env.refMgr.addQNameDef(qName,
|
|
@@ -313,7 +323,7 @@ function* tpView(env, nd) {
|
|
|
313
323
|
});
|
|
314
324
|
const sortedLogics = sortLogicsForFrontendDomain(env, nd.logics);
|
|
315
325
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(sortedLogics, (l) => {
|
|
316
|
-
const qName = (0,
|
|
326
|
+
const qName = (0, get_q_name_1.getTokenQualifiedName)(l);
|
|
317
327
|
env.refMgr.qNameDefs.set(qName, l);
|
|
318
328
|
dropList.push(l);
|
|
319
329
|
(0, helper_1.createOnPush)(env.nameBindings, l.name, l);
|
|
@@ -422,93 +432,59 @@ function* tpViewElementFirstPass(env, nd) {
|
|
|
422
432
|
if (!env.strict) {
|
|
423
433
|
if (name === 'text') {
|
|
424
434
|
// HACK Vue2 文本组件
|
|
425
|
-
return;
|
|
435
|
+
return type_manager_1.naslAnyTy;
|
|
426
436
|
}
|
|
427
437
|
else if (name === 'children' && nd.tag === 'Text') {
|
|
428
438
|
// HACK React 文本组件
|
|
429
|
-
return;
|
|
439
|
+
return type_manager_1.naslAnyTy;
|
|
430
440
|
}
|
|
431
441
|
}
|
|
432
|
-
|
|
442
|
+
const prop = initProp?.properties?.find((prop) => prop.name === name);
|
|
443
|
+
// 如果属性标记为implicitToString,则返回any类型
|
|
444
|
+
if (prop && componentDef?.isPropertyImplicitToString(name)) {
|
|
445
|
+
return type_manager_1.naslAnyTy;
|
|
446
|
+
}
|
|
447
|
+
return prop?.typeAnnotation ?? type_manager_1.naslAnyTy;
|
|
433
448
|
};
|
|
434
449
|
const typeParamWrappers = componentDef?.getRenamedTypeParamWrappers() ?? [];
|
|
435
450
|
function makeCurrentManager(nd) {
|
|
436
|
-
//
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
const
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
const hasDataSourceInInitProp = !!componentDef
|
|
445
|
-
.getInitPropsTypeAnnotation()
|
|
446
|
-
?.properties?.some((x) => x.name === 'dataSource');
|
|
447
|
-
const shouldStealAncestorT = !hasDataSourceInInitProp;
|
|
448
|
-
if (shouldStealAncestorT) {
|
|
449
|
-
const ancestorTableTypeParam = findAncestorWhichHasTypeParamT(env, nd)?.renamed ?? type_manager_1.naslAnyTy;
|
|
450
|
-
env.unifier.unify(thisDataSourceTVWrapper.renamed, ancestorTableTypeParam);
|
|
451
|
-
}
|
|
451
|
+
// currentManager机制分为两部分:
|
|
452
|
+
// 1. 维护类型变元的约束
|
|
453
|
+
// 2. current变量的创建和销毁
|
|
454
|
+
// FIXME wudengke 这个判断可以去掉得到更加泛化的机制
|
|
455
|
+
const T1 = typeParamWrappers.find((x) => x.rawName === 'T1');
|
|
456
|
+
const T = typeParamWrappers.find((x) => x.rawName === 'T');
|
|
457
|
+
if (!(componentDef && T)) {
|
|
458
|
+
return;
|
|
452
459
|
}
|
|
453
|
-
if (
|
|
454
|
-
//
|
|
455
|
-
const
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
],
|
|
477
|
-
});
|
|
478
|
-
env.unifier.unifyEq(curTy, anonStruct);
|
|
479
|
-
}
|
|
480
|
-
else {
|
|
481
|
-
const itemProp = nasl_concepts_1.StructureProperty.createProtoTypeOnly({
|
|
482
|
-
name: 'item',
|
|
483
|
-
typeAnnotation: thisDataSourceTVWrapper.renamed,
|
|
484
|
-
id: 'placeholder',
|
|
485
|
-
});
|
|
486
|
-
const anonStruct = nasl_concepts_1.TypeAnnotation.createProtoTypeOnly({
|
|
487
|
-
typeKind: 'anonymousStructure',
|
|
488
|
-
properties: [
|
|
489
|
-
itemProp,
|
|
490
|
-
exports.singletonIndex,
|
|
491
|
-
exports.singletonRowIndex,
|
|
492
|
-
exports.singletonColumnIndex,
|
|
493
|
-
exports.singletonValue,
|
|
494
|
-
],
|
|
495
|
-
});
|
|
496
|
-
env.unifier.unifyEq(curTy, anonStruct);
|
|
497
|
-
}
|
|
498
|
-
return {
|
|
499
|
-
create: (options) => {
|
|
460
|
+
if (T1) {
|
|
461
|
+
// 如果T1存在,那么就从祖先组件中获取T
|
|
462
|
+
const ancestorTableTypeParam = findAncestorWhichHasTypeParamT(env, nd)?.renamed ?? type_manager_1.naslAnyTy;
|
|
463
|
+
env.unifier.unify(T.renamed, ancestorTableTypeParam);
|
|
464
|
+
}
|
|
465
|
+
const hasDataSourceInInitProp = !!componentDef
|
|
466
|
+
.getInitPropsTypeAnnotation()
|
|
467
|
+
?.properties?.some((x) => x.name === 'dataSource');
|
|
468
|
+
const shouldStealAncestorT = !hasDataSourceInInitProp;
|
|
469
|
+
if (shouldStealAncestorT) {
|
|
470
|
+
const ancestorTableTypeParam = findAncestorWhichHasTypeParamT(env, nd)?.renamed ?? type_manager_1.naslAnyTy;
|
|
471
|
+
env.unifier.unify(T.renamed, ancestorTableTypeParam);
|
|
472
|
+
}
|
|
473
|
+
return {
|
|
474
|
+
create: (options) => {
|
|
475
|
+
if (options.templateElement?.tag !== 'template') {
|
|
476
|
+
return undefined;
|
|
477
|
+
}
|
|
478
|
+
const slotTarget = options.templateElement?.slotTarget ?? 'default';
|
|
479
|
+
const slotScopeType = componentDef?.getSlotScopeTypeBySlotTarget(slotTarget);
|
|
480
|
+
// 如果curTy非空,那么才需要引入current变量。否则完全不需要引入。
|
|
481
|
+
let curTy = slotScopeType?.[0]?.type;
|
|
482
|
+
if (curTy) {
|
|
500
483
|
// 引入变量 current_i: CurTy
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
let curVar = undefined;
|
|
506
|
-
if (!options?.noPushToNameBindings) {
|
|
507
|
-
curName = getCurName();
|
|
508
|
-
curVar = (0, collectGlobalDefs_1.createVarAndSetParentNode)(curName, curTy, nd);
|
|
509
|
-
env.setType(curVar, curTy);
|
|
510
|
-
(0, helper_1.createOnPush)(env.nameBindings, curName, curVar);
|
|
511
|
-
}
|
|
484
|
+
const curName = env.unifier.nextFreshCurrent();
|
|
485
|
+
const curVar = (0, collectGlobalDefs_1.createVarAndSetParentNode)(curName, curTy, nd);
|
|
486
|
+
env.setType(curVar, curTy);
|
|
487
|
+
(0, helper_1.createOnPush)(env.nameBindings, curName, curVar);
|
|
512
488
|
return {
|
|
513
489
|
createdVar: curVar,
|
|
514
490
|
revoke: () => {
|
|
@@ -518,10 +494,9 @@ function* tpViewElementFirstPass(env, nd) {
|
|
|
518
494
|
}
|
|
519
495
|
},
|
|
520
496
|
};
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
return undefined;
|
|
497
|
+
}
|
|
498
|
+
},
|
|
499
|
+
};
|
|
525
500
|
}
|
|
526
501
|
yield;
|
|
527
502
|
const readableProps = instanceProps
|
|
@@ -539,10 +514,13 @@ function* tpViewElementFirstPass(env, nd) {
|
|
|
539
514
|
}) ?? [], { id: 'placeholder' });
|
|
540
515
|
const references = env.getForwardReference(nd);
|
|
541
516
|
if (references) {
|
|
542
|
-
references.forEach((
|
|
543
|
-
const prop = veTy.properties?.find((i) => i.name ===
|
|
517
|
+
references.forEach((refRecord) => {
|
|
518
|
+
const prop = veTy.properties?.find((i) => i.name === refRecord.name);
|
|
544
519
|
if (prop) {
|
|
545
|
-
env.
|
|
520
|
+
const oldBoundary = env.errBoundary;
|
|
521
|
+
env.errBoundary = refRecord.errBoundarySnapshot;
|
|
522
|
+
env.unifier.unify(prop.typeAnnotation, refRecord.placeholderFnTy);
|
|
523
|
+
env.errBoundary = oldBoundary;
|
|
546
524
|
}
|
|
547
525
|
});
|
|
548
526
|
env.removeForwardReferenceForNode(nd);
|
|
@@ -574,7 +552,10 @@ function* tpViewElementFirstPass(env, nd) {
|
|
|
574
552
|
return !excludedViewElementPropNames.has(x.name);
|
|
575
553
|
});
|
|
576
554
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(bindAttrsToBeChecked, (attr) => {
|
|
555
|
+
const oldBoundary = env.errBoundary;
|
|
556
|
+
env.errBoundary = attr;
|
|
577
557
|
collectTypeConstraints(attr);
|
|
558
|
+
env.errBoundary = oldBoundary;
|
|
578
559
|
});
|
|
579
560
|
// FIXME wudengke 和收集约束合并?
|
|
580
561
|
bindAttrsToBeChecked.forEach((attr) => {
|
|
@@ -607,15 +588,16 @@ function* tpViewElementFirstPass(env, nd) {
|
|
|
607
588
|
const currentManager = makeCurrentManager(nd);
|
|
608
589
|
yield;
|
|
609
590
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(nd.children, function* (e) {
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
591
|
+
const popper = currentManager?.create({
|
|
592
|
+
templateElement: e,
|
|
593
|
+
});
|
|
613
594
|
if (popper?.createdVar) {
|
|
614
|
-
|
|
615
|
-
env.
|
|
616
|
-
|
|
595
|
+
env.addPostCheckTask(nd, (env, pSubst) => {
|
|
596
|
+
const curTy = pSubst(env.getRawType(popper.createdVar));
|
|
597
|
+
env.scopeManager.collectVariable(e, popper.createdVar.name, curTy, `slot:${e.slotTarget}:${nd.tag}`);
|
|
598
|
+
});
|
|
617
599
|
dropList.push(popper.createdVar);
|
|
618
|
-
(0, helper_1.createOnPush)(env.allocatedVirtualNodes, env.getCurFileNode(), popper
|
|
600
|
+
(0, helper_1.createOnPush)(env.allocatedVirtualNodes, env.getCurFileNode(), popper.createdVar);
|
|
619
601
|
}
|
|
620
602
|
yield* tpViewElementFirstPass(env, e);
|
|
621
603
|
popper?.revoke();
|
|
@@ -668,7 +650,8 @@ function* tpViewElementFirstPass(env, nd) {
|
|
|
668
650
|
!!vThisLevel &&
|
|
669
651
|
env.unifier.containsEmptyBounds(vThisLevel);
|
|
670
652
|
yield* (0, nasl_utils_1.wrapForEachToGenerator)(nd.children, function* (e) {
|
|
671
|
-
|
|
653
|
+
// HACK: 简单的关联组件判断,后续可以考虑更复杂的判断
|
|
654
|
+
if (shouldVThisLevelBeInferred && e.tag.startsWith(nd.tag)) {
|
|
672
655
|
const vChild = env.getDataSourceTyParam(e)?.find((x) => x.rawName === 'V')?.renamed;
|
|
673
656
|
if (vChild) {
|
|
674
657
|
env.unifier.unify(vChild, vThisLevel);
|
|
@@ -683,11 +666,6 @@ function* tpViewElementFirstPass(env, nd) {
|
|
|
683
666
|
dropList.forEach((x) => {
|
|
684
667
|
(0, helper_1.removeLastOne)(env.nameBindings, x.name);
|
|
685
668
|
});
|
|
686
|
-
// 先不要删,待确认流程变量使用范围
|
|
687
|
-
// for (const v of allocatedProcessVars) {
|
|
688
|
-
// removeLastOne(env.nameBindings, v.name);
|
|
689
|
-
// env.typeBindings.delete(v);
|
|
690
|
-
// }
|
|
691
669
|
// TODO wudengke 考虑一下这个规则是否放在solver里面
|
|
692
670
|
// 确保任何声明了的类型变元都至少有一条有效约束(非indexedType引入的约束),保证可以至少被推成顶类型。
|
|
693
671
|
// 否则约束集中不会有它存在。
|
|
@@ -748,20 +726,31 @@ function* tpViewElementFirstPass(env, nd) {
|
|
|
748
726
|
}
|
|
749
727
|
}
|
|
750
728
|
});
|
|
729
|
+
env.addPostCheckTask(nd, (_, pSubst) => {
|
|
730
|
+
nd.__ViewElementTV = typeParamWrappers.map((w) => ({
|
|
731
|
+
rawName: w.rawName,
|
|
732
|
+
renamed: pSubst(w.renamed),
|
|
733
|
+
}));
|
|
734
|
+
});
|
|
751
735
|
/**
|
|
752
736
|
* @deprecated
|
|
753
737
|
* 存在一种ts类型标注为(item: T) => V,但prop里面存了个string的情况。这种情况需要hack
|
|
754
738
|
*/
|
|
755
739
|
function handleStringPropForSpecialCase(tgtTy, prop) {
|
|
740
|
+
if (!(prop.value && typeof prop.value === 'string')) {
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
if (prop.name === 'sorting' && tgtTy.typeKind === 'anonymousStructure') {
|
|
744
|
+
// HACK: sorting 有一些脏数据
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
756
747
|
const args = (0, nasl_type_manipulation_1.extractArgPairsFromFnTy)(tgtTy);
|
|
757
748
|
if (prop.type === 'string' &&
|
|
758
749
|
tgtTy.typeKind === 'function' &&
|
|
759
750
|
args &&
|
|
760
751
|
args.length === 1 &&
|
|
761
752
|
args[0].name === 'item' &&
|
|
762
|
-
tgtTy.returnType?.length === 1
|
|
763
|
-
typeof prop.value === 'string' &&
|
|
764
|
-
prop.value) {
|
|
753
|
+
tgtTy.returnType?.length === 1) {
|
|
765
754
|
// 若类型标注为(item: T) => V,
|
|
766
755
|
// prop中存的值为"a.b",此时应该将它等效地视作 item => item.a.b
|
|
767
756
|
// 应当将 T['a']['b'] 和 V 进行 unify
|
|
@@ -830,9 +819,12 @@ function* tpViewElementFirstPass(env, nd) {
|
|
|
830
819
|
});
|
|
831
820
|
}
|
|
832
821
|
}
|
|
822
|
+
else if (tgtTy.typeKind !== 'function') {
|
|
823
|
+
env.unifier.unify(type_manager_1.naslStringTy, tgtTy);
|
|
824
|
+
}
|
|
833
825
|
}
|
|
834
826
|
function collectTypeConstraints(prop) {
|
|
835
|
-
const tgtTy = getPropType(prop.name)
|
|
827
|
+
const tgtTy = getPropType(prop.name);
|
|
836
828
|
// HACK 此组件存在脏数据,有未定义的属性
|
|
837
829
|
if (!env.strict) {
|
|
838
830
|
if (prop.name === 'item' && nd.tag === 'u-table-view-expander') {
|
|
@@ -847,8 +839,11 @@ function* tpViewElementFirstPass(env, nd) {
|
|
|
847
839
|
args &&
|
|
848
840
|
args.length === 1 &&
|
|
849
841
|
args[0].name === 'item' &&
|
|
850
|
-
tgtTy.returnType?.length === 1
|
|
851
|
-
//
|
|
842
|
+
tgtTy.returnType?.length === 1 &&
|
|
843
|
+
// HACK: 如果nasl上放的是一个 anonymousFunction (例如 TableView 的 canDropinHandler 的属性),不需要走这个特殊逻辑
|
|
844
|
+
// 注意:如果表达式是一个指向函数的 Identifier,那么也无能为力
|
|
845
|
+
!(0, asserts_1.isAnonymousFunction)(expr)) {
|
|
846
|
+
// HACK: 类型标注为(item: T) => V,但prop里面存了个非 AnonymousFunction 表达式的情形,需要把 V 拿出来,和 expr 的类型进行unify
|
|
852
847
|
(0, dispatch_expr_1.dispatchExpr)(env, expr, tgtTy.returnType[0]);
|
|
853
848
|
}
|
|
854
849
|
else {
|
|
@@ -859,7 +854,11 @@ function* tpViewElementFirstPass(env, nd) {
|
|
|
859
854
|
if (prop.name === 'dataSource') {
|
|
860
855
|
env.typeHintManager.setHint(tgtTy, type_hint_manager_1.TypeHintEnum.isFromDataSource);
|
|
861
856
|
}
|
|
862
|
-
if (prop.name === '
|
|
857
|
+
if (prop.name === 'sorting' && tgtTy.typeKind === 'anonymousStructure') {
|
|
858
|
+
// HACK: sorting 中放置新建匿名数据结构,无法取名field字段。因此先忽略
|
|
859
|
+
(0, dispatch_expr_1.dispatchExpr)(env, expr, undefined);
|
|
860
|
+
}
|
|
861
|
+
else if (prop.name === 'field') {
|
|
863
862
|
(0, dispatch_expr_1.dispatchExpr)(env, expr, undefined);
|
|
864
863
|
}
|
|
865
864
|
else {
|
|
@@ -891,10 +890,10 @@ function* tpViewElementFirstPass(env, nd) {
|
|
|
891
890
|
// 选择1. 需要拼on-,再做名字转换(先用这个)
|
|
892
891
|
// 选择2. 读组件的ViewComponentDeclaration定义来找?
|
|
893
892
|
const properEventName = (0, nasl_concepts_1.kebab2Camel2)(`on-${nd.name}`);
|
|
894
|
-
const
|
|
893
|
+
const propTy = getPropType(properEventName) ?? type_manager_1.naslAnyTy;
|
|
895
894
|
nd.logics.forEach((l) => {
|
|
896
895
|
l.virtualParams = [];
|
|
897
|
-
const args = (0, nasl_type_manipulation_1.extractArgPairsFromFnTy)(
|
|
896
|
+
const args = (0, nasl_type_manipulation_1.extractArgPairsFromFnTy)(propTy);
|
|
898
897
|
args?.forEach((arg) => {
|
|
899
898
|
// pointToSymbol机制要求类型必须是类型变元才会被替换
|
|
900
899
|
const ty = env.unifier.nextFreshTyAnn('bound');
|
|
@@ -958,7 +957,7 @@ function* tpViewElementFirstPass(env, nd) {
|
|
|
958
957
|
return params;
|
|
959
958
|
}
|
|
960
959
|
const logicTy = (0, dispatch_def_1.tpLogic)(env, l);
|
|
961
|
-
env.unifier.unify(logicTy,
|
|
960
|
+
env.unifier.unify(logicTy, propTy);
|
|
962
961
|
});
|
|
963
962
|
}
|
|
964
963
|
}
|
|
@@ -1011,6 +1010,7 @@ exports.singletonValue = nasl_concepts_1.StructureProperty.createProtoTypeOnly({
|
|
|
1011
1010
|
typeAnnotation: type_manager_1.naslStringTy,
|
|
1012
1011
|
});
|
|
1013
1012
|
const ignoreAll = Symbol();
|
|
1013
|
+
// TODO wudengke 目前已经尊重了 implicitToString。这些属性或许不需要 hardcode 在这了
|
|
1014
1014
|
const skipCheckDataBase = {
|
|
1015
1015
|
'u-input': ['value', 'placeholder'],
|
|
1016
1016
|
'u-capsule': ['value', 'placeholder'],
|