@@ -345,7 +345,17 @@ abstract class ExportDeclaration extends Stmt, @export_declaration {
345345
346346 /** Holds if this export declaration exports variable `v` under the name `name`. */
347347 overlay [ global]
348- abstract predicate exportsAs ( LexicalName v , string name ) ;
348+ final predicate exportsAs ( LexicalName v , string name ) {
349+ this .exportsDirectlyAs ( v , name )
350+ or
351+ this .( ReExportDeclaration ) .reExportsAs ( v , name )
352+ }
353+
354+ /**
355+ * Holds if this export declaration exports variable `v` under the name `name`,
356+ * not counting re-exports.
357+ */
358+ predicate exportsDirectlyAs ( LexicalName v , string name ) { none ( ) }
349359
350360 /**
351361 * Gets the data flow node corresponding to the value this declaration exports
@@ -421,7 +431,7 @@ class BulkReExportDeclaration extends ReExportDeclaration, @export_all_declarati
421431 override ConstantString getImportedPath ( ) { result = this .getChildExpr ( 0 ) }
422432
423433 overlay [ global]
424- override predicate exportsAs ( LexicalName v , string name ) {
434+ override predicate reExportsAs ( LexicalName v , string name ) {
425435 this .getReExportedES2015Module ( ) .exportsAs ( v , name ) and
426436 not isShadowedFromBulkExport ( this .getEnclosingModule ( ) , name )
427437 }
@@ -468,8 +478,7 @@ class ExportDefaultDeclaration extends ExportDeclaration, @export_default_declar
468478 /** Gets the operand statement or expression that is exported by this declaration. */
469479 ExprOrStmt getOperand ( ) { result = this .getChild ( 0 ) }
470480
471- overlay [ global]
472- override predicate exportsAs ( LexicalName v , string name ) {
481+ override predicate exportsDirectlyAs ( LexicalName v , string name ) {
473482 name = "default" and v = this .getADecl ( ) .getVariable ( )
474483 }
475484
@@ -524,16 +533,13 @@ class ExportNamedDeclaration extends ExportDeclaration, @export_named_declaratio
524533 /** Gets the variable declaration, if any, exported by this named export. */
525534 VarDecl getADecl ( ) { result = this .getAnExportedDecl ( ) }
526535
527- overlay [ global]
528- override predicate exportsAs ( LexicalName v , string name ) {
536+ override predicate exportsDirectlyAs ( LexicalName v , string name ) {
529537 exists ( LexicalDecl vd | vd = this .getAnExportedDecl ( ) |
530538 name = vd .getName ( ) and v = vd .getALexicalName ( )
531539 )
532540 or
533541 exists ( ExportSpecifier spec | spec = this .getASpecifier ( ) and name = spec .getExportedName ( ) |
534542 v = spec .getLocal ( ) .( LexicalAccess ) .getALexicalName ( )
535- or
536- this .( ReExportDeclaration ) .getReExportedES2015Module ( ) .exportsAs ( v , spec .getLocalName ( ) )
537543 )
538544 }
539545
@@ -593,9 +599,8 @@ private class ExportNamespaceStep extends PreCallGraphStep {
593599private class TypeOnlyExportDeclaration extends ExportNamedDeclaration {
594600 TypeOnlyExportDeclaration ( ) { this .isTypeOnly ( ) }
595601
596- overlay [ global]
597- override predicate exportsAs ( LexicalName v , string name ) {
598- super .exportsAs ( v , name ) and
602+ override predicate exportsDirectlyAs ( LexicalName v , string name ) {
603+ super .exportsDirectlyAs ( v , name ) and
599604 not v instanceof Variable
600605 }
601606}
@@ -777,6 +782,9 @@ abstract class ReExportDeclaration extends ExportDeclaration {
777782 Stages:: Imports:: ref ( ) and
778783 result .getFile ( ) = ImportPathResolver:: resolveExpr ( this .getImportedPath ( ) )
779784 }
785+
786+ overlay [ global]
787+ abstract predicate reExportsAs ( LexicalName v , string name ) ;
780788}
781789
782790/** A literal path expression appearing in a re-export declaration. */
@@ -803,6 +811,13 @@ class SelectiveReExportDeclaration extends ReExportDeclaration, ExportNamedDecla
803811 override ConstantString getImportedPath ( ) {
804812 result = ExportNamedDeclaration .super .getImportedPath ( )
805813 }
814+
815+ overlay [ global]
816+ override predicate reExportsAs ( LexicalName v , string name ) {
817+ exists ( ExportSpecifier spec | spec = this .getASpecifier ( ) and name = spec .getExportedName ( ) |
818+ this .getReExportedES2015Module ( ) .exportsAs ( v , spec .getLocalName ( ) )
819+ )
820+ }
806821}
807822
808823/**
0 commit comments