MCPcopy Index your code
hub / github.com/nodejs/node / isMatchingReference

Function isMatchingReference

test/fixtures/snapshot/typescript.js:69309–69351  ·  view source on GitHub ↗
(source, target)

Source from the content-addressed store, hash-verified

69307 return undefined;
69308 }
69309 function isMatchingReference(source, target) {
69310 switch (target.kind) {
69311 case 212 /* SyntaxKind.ParenthesizedExpression */:
69312 case 230 /* SyntaxKind.NonNullExpression */:
69313 return isMatchingReference(source, target.expression);
69314 case 221 /* SyntaxKind.BinaryExpression */:
69315 return (ts.isAssignmentExpression(target) && isMatchingReference(source, target.left)) ||
69316 (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isMatchingReference(source, target.right));
69317 }
69318 switch (source.kind) {
69319 case 231 /* SyntaxKind.MetaProperty */:
69320 return target.kind === 231 /* SyntaxKind.MetaProperty */
69321 && source.keywordToken === target.keywordToken
69322 && source.name.escapedText === target.name.escapedText;
69323 case 79 /* SyntaxKind.Identifier */:
69324 case 80 /* SyntaxKind.PrivateIdentifier */:
69325 return ts.isThisInTypeQuery(source) ?
69326 target.kind === 108 /* SyntaxKind.ThisKeyword */ :
69327 target.kind === 79 /* SyntaxKind.Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) ||
69328 (target.kind === 254 /* SyntaxKind.VariableDeclaration */ || target.kind === 203 /* SyntaxKind.BindingElement */) &&
69329 getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target);
69330 case 108 /* SyntaxKind.ThisKeyword */:
69331 return target.kind === 108 /* SyntaxKind.ThisKeyword */;
69332 case 106 /* SyntaxKind.SuperKeyword */:
69333 return target.kind === 106 /* SyntaxKind.SuperKeyword */;
69334 case 230 /* SyntaxKind.NonNullExpression */:
69335 case 212 /* SyntaxKind.ParenthesizedExpression */:
69336 return isMatchingReference(source.expression, target);
69337 case 206 /* SyntaxKind.PropertyAccessExpression */:
69338 case 207 /* SyntaxKind.ElementAccessExpression */:
69339 var sourcePropertyName = getAccessedPropertyName(source);
69340 var targetPropertyName = ts.isAccessExpression(target) ? getAccessedPropertyName(target) : undefined;
69341 return sourcePropertyName !== undefined && targetPropertyName !== undefined && targetPropertyName === sourcePropertyName &&
69342 isMatchingReference(source.expression, target.expression);
69343 case 161 /* SyntaxKind.QualifiedName */:
69344 return ts.isAccessExpression(target) &&
69345 source.right.escapedText === getAccessedPropertyName(target) &&
69346 isMatchingReference(source.left, target.expression);
69347 case 221 /* SyntaxKind.BinaryExpression */:
69348 return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isMatchingReference(source.right, target));
69349 }
69350 return false;
69351 }
69352 function getAccessedPropertyName(access) {
69353 if (ts.isPropertyAccessExpression(access)) {
69354 return access.name.escapedText;

Calls 4

getResolvedSymbolFunction · 0.85
getSymbolOfNodeFunction · 0.85
getAccessedPropertyNameFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…