@@ -8,6 +8,7 @@ private import codeql.unified.internal.NameBindingPlugin
88
99private newtype TNameBindingNode =
1010 TIdentifier ( Identifier n ) or
11+ TBulkImport ( BulkImportingPattern p ) or
1112 TLocalName ( LocalName local ) or
1213 TExportedNamespace ( ClassLikeDeclaration cls ) or
1314 TLocalNamespace ( AstNode n ) {
@@ -26,6 +27,8 @@ class NameBindingNode extends TNameBindingNode {
2627
2728 Identifier asIdentifier ( ) { this .isIdentifier ( result ) }
2829
30+ predicate isBulkImport ( BulkImportingPattern p ) { this = TBulkImport ( p ) }
31+
2932 predicate isLocalName ( LocalName local ) { this = TLocalName ( local ) }
3033
3134 /** Holds if this represents the set of static members available in the given namespace. */
@@ -43,6 +46,8 @@ class NameBindingNode extends TNameBindingNode {
4346 string toString ( ) {
4447 exists ( Identifier n | this .isIdentifier ( n ) and result = "Identifier(" + n + ")" )
4548 or
49+ exists ( BulkImportingPattern p | this .isBulkImport ( p ) and result = "BulkImport(" + p + ")" )
50+ or
4651 exists ( LocalName local | this .isLocalName ( local ) and result = "LocalName(" + local + ")" )
4752 or
4853 exists ( ClassLikeDeclaration cls |
@@ -63,6 +68,8 @@ class NameBindingNode extends TNameBindingNode {
6368 Location getLocation ( ) {
6469 exists ( Identifier n | this .isIdentifier ( n ) and result = n .getLocation ( ) )
6570 or
71+ exists ( BulkImportingPattern p | this .isBulkImport ( p ) and result = p .getLocation ( ) )
72+ or
6673 exists ( LocalName local | this .isLocalName ( local ) and result = local .getLocation ( ) )
6774 or
6875 exists ( ClassLikeDeclaration cls | this .isExportedNamespace ( cls ) and result = cls .getLocation ( ) )
@@ -86,7 +93,11 @@ Identifier getIdentifierFromRef(AstNode n) {
8693 result = n .( NamedTypeExpr ) .getName ( )
8794}
8895
89- NameBindingNode getNodeFromRef ( AstNode n ) { result .isIdentifier ( getIdentifierFromRef ( n ) ) }
96+ NameBindingNode getNodeFromRef ( AstNode n ) {
97+ result .isIdentifier ( getIdentifierFromRef ( n ) )
98+ or
99+ result .isBulkImport ( n )
100+ }
90101
91102NameBindingNode getModuleNodeFromFile ( File f ) {
92103 exists ( ModuleScopeRepr mod |
@@ -186,6 +197,20 @@ predicate valueStep(NameBindingNode node1, NameBindingNode node2) {
186197 node1 = getNodeFromRef ( imprt .getImportedExpr ( ) ) and
187198 node2 = getNodeFromRef ( imprt .getPattern ( ) )
188199 )
200+ or
201+ exists ( BulkImportingPattern p , AstNode scope , AstNode declaration |
202+ bindingContext ( p , scope , declaration ) and
203+ node1 = getNodeFromRef ( p )
204+ |
205+ node2 = getNodeFromUncertainScope ( scope )
206+ or
207+ // Bulk re-exporting declarations
208+ exists ( TopLevel top |
209+ declaration = top .getBody ( ) .getAStmt ( ) and
210+ not isPrivateToLocalScope ( declaration ) and
211+ node2 = getModuleNodeFromFile ( top .getFile ( ) )
212+ )
213+ )
189214}
190215
191216predicate inheritanceStep ( NameBindingNode supertype , NameBindingNode subtype ) {
0 commit comments