@@ -313,7 +313,7 @@ module API {
313
313
module Node {
314
314
/** Gets a node whose type has the given qualified name. */
315
315
Node ofType ( string moduleName , string exportedName ) {
316
- result = Impl:: MkHasUnderlyingType ( moduleName , exportedName ) .( Node ) .getInstance ( )
316
+ result = Impl:: MkTypeUse ( moduleName , exportedName ) .( Node ) .getInstance ( )
317
317
}
318
318
}
319
319
@@ -374,27 +374,22 @@ module API {
374
374
exists ( SSA:: implicitInit ( [ nm .getModuleVariable ( ) , nm .getExportsVariable ( ) ] ) )
375
375
)
376
376
)
377
- or
378
- m = any ( CanonicalName n | isDefined ( n ) ) .getExternalModuleName ( )
379
377
} or
380
378
MkModuleImport ( string m ) {
381
379
imports ( _, m )
382
380
or
383
- m = any ( CanonicalName n | isUsed ( n ) ) .getExternalModuleName ( )
384
- or
385
381
any ( TypeAnnotation n ) .hasQualifiedName ( m , _)
382
+ or
383
+ any ( Type t ) .hasUnderlyingType ( m , _)
386
384
} or
387
385
MkClassInstance ( DataFlow:: ClassNode cls ) { cls = trackDefNode ( _) and hasSemantics ( cls ) } or
388
386
MkAsyncFuncResult ( DataFlow:: FunctionNode f ) {
389
387
f = trackDefNode ( _) and f .getFunction ( ) .isAsync ( ) and hasSemantics ( f )
390
388
} or
391
389
MkDef ( DataFlow:: Node nd ) { rhs ( _, _, nd ) } or
392
390
MkUse ( DataFlow:: Node nd ) { use ( _, _, nd ) } or
393
- /**
394
- * A TypeScript type, identified by name of the type-annotation.
395
- * This API node is exclusively used by `API::Node::ofType`.
396
- */
397
- MkHasUnderlyingType ( string moduleName , string exportName ) {
391
+ /** A use of a TypeScript type. */
392
+ MkTypeUse ( string moduleName , string exportName ) {
398
393
any ( TypeAnnotation n ) .hasQualifiedName ( moduleName , exportName )
399
394
or
400
395
any ( Type t ) .hasUnderlyingType ( moduleName , exportName )
@@ -408,7 +403,7 @@ module API {
408
403
class TNonModuleDef =
409
404
MkModuleExport or MkClassInstance or MkAsyncFuncResult or MkDef or MkSyntheticCallbackArg ;
410
405
411
- class TUse = MkModuleUse or MkModuleImport or MkUse or MkHasUnderlyingType ;
406
+ class TUse = MkModuleUse or MkModuleImport or MkUse or MkTypeUse ;
412
407
413
408
private predicate hasSemantics ( DataFlow:: Node nd ) { not nd .getTopLevel ( ) .isExterns ( ) }
414
409
@@ -431,20 +426,6 @@ module API {
431
426
)
432
427
}
433
428
434
- private predicate isUsed ( CanonicalName n ) {
435
- exists ( n .( TypeName ) .getAnAccess ( ) ) or
436
- exists ( n .( Namespace ) .getAnAccess ( ) )
437
- }
438
-
439
- private predicate isDefined ( CanonicalName n ) {
440
- exists ( ASTNode def |
441
- def = n .( TypeName ) .getADefinition ( ) or
442
- def = n .( Namespace ) .getADefinition ( )
443
- |
444
- not def .isAmbient ( )
445
- )
446
- }
447
-
448
429
/**
449
430
* Holds if `rhs` is the right-hand side of a definition of a node that should have an
450
431
* incoming edge from `base` labeled `lbl` in the API graph.
@@ -600,7 +581,7 @@ module API {
600
581
)
601
582
or
602
583
exists ( string moduleName , string exportName |
603
- base = MkHasUnderlyingType ( moduleName , exportName ) and
584
+ base = MkTypeUse ( moduleName , exportName ) and
604
585
lbl = Label:: instance ( ) and
605
586
ref .( DataFlow:: SourceNode ) .hasUnderlyingType ( moduleName , exportName )
606
587
)
@@ -839,7 +820,7 @@ module API {
839
820
exists ( string moduleName , string exportName |
840
821
pred = MkModuleImport ( moduleName ) and
841
822
lbl = Label:: member ( exportName ) and
842
- succ = MkHasUnderlyingType ( moduleName , exportName )
823
+ succ = MkTypeUse ( moduleName , exportName )
843
824
)
844
825
or
845
826
exists ( DataFlow:: Node nd , DataFlow:: FunctionNode f |
0 commit comments