解决了在for循环中无法检测context调用的bug

This commit is contained in:
Pan Qiancheng 2024-10-25 17:23:09 +08:00
parent d299404d19
commit 9f9f499c10
1 changed files with 20 additions and 12 deletions

View File

@ -716,7 +716,9 @@ export const checkTrigger = (
// 如果是一个block递归其内部的内容
if (ts.isBlock(child)) {
walkBlock(child);
ts.forEachChild(child, (c) => {
walkBlock(c);
});
}
// 如果是if或者switch继续递归
@ -759,6 +761,12 @@ export const checkTrigger = (
ts.isForStatement(child)
) {
walkBlock(child.statement);
ts.forEachChild(child.statement, (c) => {
walkBlock(c);
});
}
if (ts.isWhileStatement(child)) {
walkBlock(child.statement);
}
if (ts.isTryStatement(child)) {
walkBlock(child.tryBlock);
@ -778,17 +786,17 @@ export const checkTrigger = (
if (ts.isPropertyAccessExpression(expression)) {
// 如果是context.xxx的调用
if (expression.expression.getText() === 'context') {
// // 无论如何显示一个警告先debug
// diagnostics.push(
// createDiagnostic(
// trigger.tsInfo.sourceFile,
// child.getStart(),
// child.getEnd(),
// 'trigger.invalidContextCall',
// 'test warning',
// vscode.DiagnosticSeverity.Warning
// )
// );
// 无论如何显示一个警告先debug
diagnostics.push(
createDiagnostic(
trigger.tsInfo.sourceFile,
child.getStart(),
child.getEnd(),
'trigger.invalidContextCall',
'test warning',
vscode.DiagnosticSeverity.Warning
)
);
// 检查是不是await的调用否则出现警告
const parent = child.parent;
if (