@@ -37,6 +37,9 @@ module DataFlow {
3737 TThisNode ( StmtContainer f ) { f .( Function ) .getThisBinder ( ) = f or f instanceof TopLevel } or
3838 TUnusedParameterNode ( SimpleParameter p ) {
3939 not exists ( SsaExplicitDefinition ssa | p = ssa .getDef ( ) )
40+ } or
41+ TDestructuredModuleImportNode ( ImportDeclaration decl ) {
42+ exists ( decl .getASpecifier ( ) .getImportedName ( ) )
4043 }
4144
4245 /**
@@ -351,6 +354,25 @@ module DataFlow {
351354 override string toString ( ) { result = "reflective call" }
352355 }
353356
357+ /**
358+ * A node referring to the module imported at a named or default ES2015 import declaration.
359+ */
360+ private class DestructuredModuleImportNode extends Node , TDestructuredModuleImportNode {
361+ ImportDeclaration imprt ;
362+
363+ DestructuredModuleImportNode ( ) { this = TDestructuredModuleImportNode ( imprt ) }
364+
365+ override BasicBlock getBasicBlock ( ) { result = imprt .getBasicBlock ( ) }
366+
367+ override predicate hasLocationInfo (
368+ string filepath , int startline , int startcolumn , int endline , int endcolumn
369+ ) {
370+ imprt .getLocation ( ) .hasLocationInfo ( filepath , startline , startcolumn , endline , endcolumn )
371+ }
372+
373+ override string toString ( ) { result = imprt .toString ( ) }
374+ }
375+
354376 /**
355377 * A data flow node that reads or writes an object property or class member.
356378 *
@@ -668,6 +690,30 @@ module DataFlow {
668690 override string getPropertyName ( ) { none ( ) }
669691 }
670692
693+ /**
694+ * A named import specifier seen as a property read on the imported module.
695+ */
696+ private class ImportSpecifierAsPropRead extends PropRead {
697+ ImportDeclaration imprt ;
698+
699+ ImportSpecifier spec ;
700+
701+ ImportSpecifierAsPropRead ( ) {
702+ spec = imprt .getASpecifier ( ) and
703+ exists ( spec .getImportedName ( ) ) and
704+ exists ( SsaExplicitDefinition ssa |
705+ ssa .getDef ( ) = spec and
706+ this = TSsaDefNode ( ssa )
707+ )
708+ }
709+
710+ override Node getBase ( ) { result = TDestructuredModuleImportNode ( imprt ) }
711+
712+ override Expr getPropertyNameExpr ( ) { result = spec .getImported ( ) }
713+
714+ override string getPropertyName ( ) { result = spec .getImportedName ( ) }
715+ }
716+
671717 /**
672718 * A data flow node representing an unused parameter.
673719 *
@@ -886,6 +932,16 @@ module DataFlow {
886932 */
887933 DataFlow:: ThisNode thisNode ( StmtContainer container ) { result = TThisNode ( container ) }
888934
935+ /**
936+ * INTERNAL. DO NOT USE.
937+ *
938+ * Gets the data flow node holding the reference to the module being destructured at
939+ * the given import declaration.
940+ */
941+ DataFlow:: Node destructuredModuleImportNode ( ImportDeclaration imprt ) {
942+ result = TDestructuredModuleImportNode ( imprt )
943+ }
944+
889945 /**
890946 * A classification of flows that are not modeled, or only modeled incompletely, by
891947 * `DataFlowNode`:
0 commit comments