fix(session-query): checkpoint review round 3

This commit is contained in:
Hypatia May
2026-07-11 10:19:34 +08:00
parent 18028cad4f
commit 352ea6cf4f
15 changed files with 153 additions and 51 deletions

View File

@@ -531,7 +531,7 @@ function collectEventRelations(): Map<string, EventRelation> {
const visit = (node: ts.Node): void => {
if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression)) {
const method = node.expression.name.text
if (!isCordisContextReceiver(node.expression, sf)) {
if (!isCordisContextReceiver(node.expression)) {
ts.forEachChild(node, visit)
return
}
@@ -561,9 +561,12 @@ function collectEventRelations(): Map<string, EventRelation> {
return out
}
function isCordisContextReceiver(expr: ts.PropertyAccessExpression, sf: ts.SourceFile): boolean {
const target = expr.expression.getText(sf)
return target === 'ctx' || target === 'this.ctx'
function isCordisContextReceiver(expr: ts.PropertyAccessExpression): boolean {
const receiver = expr.expression
if (ts.isIdentifier(receiver)) return receiver.text === 'ctx' || receiver.text === '_ctx'
return ts.isPropertyAccessExpression(receiver)
&& receiver.expression.kind === ts.SyntaxKind.ThisKeyword
&& (receiver.name.text === 'ctx' || receiver.name.text === '_ctx')
}
function eventArg(args: ts.NodeArray<ts.Expression>, method: string): string | undefined {