@@ -20,20 +20,20 @@ class ES2015Module extends Module {
20
20
override ModuleScope getScope ( ) { result .getScopeElement ( ) = this }
21
21
22
22
/** Gets the full path of the file containing this module. */
23
- override string getPath ( ) { result = getFile ( ) .getAbsolutePath ( ) }
23
+ override string getPath ( ) { result = this . getFile ( ) .getAbsolutePath ( ) }
24
24
25
25
/** Gets the short name of this module without file extension. */
26
- override string getName ( ) { result = getFile ( ) .getStem ( ) }
26
+ override string getName ( ) { result = this . getFile ( ) .getStem ( ) }
27
27
28
28
/** Gets an export declaration in this module. */
29
29
ExportDeclaration getAnExport ( ) { result .getTopLevel ( ) = this }
30
30
31
31
override DataFlow:: Node getAnExportedValue ( string name ) {
32
- exists ( ExportDeclaration ed | ed = getAnExport ( ) and result = ed .getSourceNode ( name ) )
32
+ exists ( ExportDeclaration ed | ed = this . getAnExport ( ) and result = ed .getSourceNode ( name ) )
33
33
}
34
34
35
35
/** Holds if this module exports variable `v` under the name `name`. */
36
- predicate exportsAs ( LexicalName v , string name ) { getAnExport ( ) .exportsAs ( v , name ) }
36
+ predicate exportsAs ( LexicalName v , string name ) { this . getAnExport ( ) .exportsAs ( v , name ) }
37
37
38
38
override predicate isStrict ( ) {
39
39
// modules are implicitly strict
@@ -86,9 +86,9 @@ private predicate hasBothNamedAndDefaultExports(ES2015Module mod) {
86
86
* ```
87
87
*/
88
88
class ImportDeclaration extends Stmt , Import , @import_declaration {
89
- override ES2015Module getEnclosingModule ( ) { result = getTopLevel ( ) }
89
+ override ES2015Module getEnclosingModule ( ) { result = this . getTopLevel ( ) }
90
90
91
- override PathExpr getImportedPath ( ) { result = getChildExpr ( - 1 ) }
91
+ override PathExpr getImportedPath ( ) { result = this . getChildExpr ( - 1 ) }
92
92
93
93
/**
94
94
* Gets the object literal passed as part of the `assert` clause in this import declaration.
@@ -101,24 +101,24 @@ class ImportDeclaration extends Stmt, Import, @import_declaration {
101
101
ObjectExpr getImportAssertion ( ) { result = this .getChildExpr ( - 10 ) }
102
102
103
103
/** Gets the `i`th import specifier of this import declaration. */
104
- ImportSpecifier getSpecifier ( int i ) { result = getChildExpr ( i ) }
104
+ ImportSpecifier getSpecifier ( int i ) { result = this . getChildExpr ( i ) }
105
105
106
106
/** Gets an import specifier of this import declaration. */
107
- ImportSpecifier getASpecifier ( ) { result = getSpecifier ( _) }
107
+ ImportSpecifier getASpecifier ( ) { result = this . getSpecifier ( _) }
108
108
109
109
override DataFlow:: Node getImportedModuleNode ( ) {
110
110
// `import * as http from 'http'` or `import http from `http`'
111
111
exists ( ImportSpecifier is |
112
- is = getASpecifier ( ) and
112
+ is = this . getASpecifier ( ) and
113
113
result = DataFlow:: valueNode ( is )
114
114
|
115
115
is instanceof ImportNamespaceSpecifier and
116
- count ( getASpecifier ( ) ) = 1
116
+ count ( this . getASpecifier ( ) ) = 1
117
117
or
118
118
// For compatibility with the non-standard implementation of default imports,
119
119
// treat default imports as namespace imports in cases where it can't cause ambiguity
120
120
// between named exports and the properties of a default-exported object.
121
- not hasBothNamedAndDefaultExports ( getImportedModule ( ) ) and
121
+ not hasBothNamedAndDefaultExports ( this . getImportedModule ( ) ) and
122
122
is .getImportedName ( ) = "default"
123
123
)
124
124
or
@@ -136,7 +136,7 @@ class ImportDeclaration extends Stmt, Import, @import_declaration {
136
136
private class LiteralImportPath extends PathExpr , ConstantString {
137
137
LiteralImportPath ( ) { exists ( ImportDeclaration req | this = req .getChildExpr ( - 1 ) ) }
138
138
139
- override string getValue ( ) { result = getStringValue ( ) }
139
+ override string getValue ( ) { result = this . getStringValue ( ) }
140
140
}
141
141
142
142
/**
@@ -159,7 +159,7 @@ private class LiteralImportPath extends PathExpr, ConstantString {
159
159
*/
160
160
class ImportSpecifier extends Expr , @import_specifier {
161
161
/** Gets the imported symbol; undefined for default and namespace import specifiers. */
162
- Identifier getImported ( ) { result = getChildExpr ( 0 ) }
162
+ Identifier getImported ( ) { result = this . getChildExpr ( 0 ) }
163
163
164
164
/**
165
165
* Gets the name of the imported symbol.
@@ -176,10 +176,10 @@ class ImportSpecifier extends Expr, @import_specifier {
176
176
* The names of the imported symbols for the first three of them are, respectively,
177
177
* `x`, `y` and `default`, while the last one does not import an individual symbol.
178
178
*/
179
- string getImportedName ( ) { result = getImported ( ) .getName ( ) }
179
+ string getImportedName ( ) { result = this . getImported ( ) .getName ( ) }
180
180
181
181
/** Gets the local variable into which this specifier imports. */
182
- VarDecl getLocal ( ) { result = getChildExpr ( 1 ) }
182
+ VarDecl getLocal ( ) { result = this . getChildExpr ( 1 ) }
183
183
184
184
override string getAPrimaryQlClass ( ) { result = "ImportSpecifier" }
185
185
@@ -240,10 +240,10 @@ class ImportNamespaceSpecifier extends ImportSpecifier, @import_namespace_specif
240
240
* ```
241
241
*/
242
242
class BulkImportDeclaration extends ImportDeclaration {
243
- BulkImportDeclaration ( ) { getASpecifier ( ) instanceof ImportNamespaceSpecifier }
243
+ BulkImportDeclaration ( ) { this . getASpecifier ( ) instanceof ImportNamespaceSpecifier }
244
244
245
245
/** Gets the local namespace variable under which the module is imported. */
246
- VarDecl getLocal ( ) { result = getASpecifier ( ) .getLocal ( ) }
246
+ VarDecl getLocal ( ) { result = this . getASpecifier ( ) .getLocal ( ) }
247
247
}
248
248
249
249
/**
@@ -260,12 +260,12 @@ class SelectiveImportDeclaration extends ImportDeclaration {
260
260
261
261
/** Holds if `local` is the local variable into which `imported` is imported. */
262
262
predicate importsAs ( string imported , LexicalDecl local ) {
263
- exists ( ImportSpecifier spec | spec = getASpecifier ( ) |
263
+ exists ( ImportSpecifier spec | spec = this . getASpecifier ( ) |
264
264
imported = spec .getImported ( ) .getName ( ) and
265
265
local = spec .getLocal ( )
266
266
)
267
267
or
268
- imported = "default" and local = getASpecifier ( ) .( ImportDefaultSpecifier ) .getLocal ( )
268
+ imported = "default" and local = this . getASpecifier ( ) .( ImportDefaultSpecifier ) .getLocal ( )
269
269
}
270
270
}
271
271
@@ -347,15 +347,15 @@ abstract class ExportDeclaration extends Stmt, @export_declaration {
347
347
*/
348
348
class BulkReExportDeclaration extends ReExportDeclaration , @export_all_declaration {
349
349
/** Gets the name of the module from which this declaration re-exports. */
350
- override ConstantString getImportedPath ( ) { result = getChildExpr ( 0 ) }
350
+ override ConstantString getImportedPath ( ) { result = this . getChildExpr ( 0 ) }
351
351
352
352
override predicate exportsAs ( LexicalName v , string name ) {
353
- getReExportedES2015Module ( ) .exportsAs ( v , name ) and
353
+ this . getReExportedES2015Module ( ) .exportsAs ( v , name ) and
354
354
not isShadowedFromBulkExport ( this , name )
355
355
}
356
356
357
357
override DataFlow:: Node getSourceNode ( string name ) {
358
- result = getReExportedES2015Module ( ) .getAnExport ( ) .getSourceNode ( name )
358
+ result = this . getReExportedES2015Module ( ) .getAnExport ( ) .getSourceNode ( name )
359
359
}
360
360
}
361
361
@@ -392,22 +392,22 @@ private predicate isShadowedFromBulkExport(BulkReExportDeclaration reExport, str
392
392
*/
393
393
class ExportDefaultDeclaration extends ExportDeclaration , @export_default_declaration {
394
394
/** Gets the operand statement or expression that is exported by this declaration. */
395
- ExprOrStmt getOperand ( ) { result = getChild ( 0 ) }
395
+ ExprOrStmt getOperand ( ) { result = this . getChild ( 0 ) }
396
396
397
397
override predicate exportsAs ( LexicalName v , string name ) {
398
- name = "default" and v = getADecl ( ) .getVariable ( )
398
+ name = "default" and v = this . getADecl ( ) .getVariable ( )
399
399
}
400
400
401
401
/** Gets the declaration, if any, exported by this default export. */
402
402
VarDecl getADecl ( ) {
403
- exists ( ExprOrStmt op | op = getOperand ( ) |
403
+ exists ( ExprOrStmt op | op = this . getOperand ( ) |
404
404
result = op .( FunctionDeclStmt ) .getIdentifier ( ) or
405
405
result = op .( ClassDeclStmt ) .getIdentifier ( )
406
406
)
407
407
}
408
408
409
409
override DataFlow:: Node getSourceNode ( string name ) {
410
- name = "default" and result = DataFlow:: valueNode ( getOperand ( ) )
410
+ name = "default" and result = DataFlow:: valueNode ( this . getOperand ( ) )
411
411
}
412
412
}
413
413
@@ -424,7 +424,7 @@ class ExportDefaultDeclaration extends ExportDeclaration, @export_default_declar
424
424
*/
425
425
class ExportNamedDeclaration extends ExportDeclaration , @export_named_declaration {
426
426
/** Gets the operand statement or expression that is exported by this declaration. */
427
- ExprOrStmt getOperand ( ) { result = getChild ( - 1 ) }
427
+ ExprOrStmt getOperand ( ) { result = this . getChild ( - 1 ) }
428
428
429
429
/**
430
430
* Gets an identifier, if any, exported as part of a declaration by this named export.
@@ -433,7 +433,7 @@ class ExportNamedDeclaration extends ExportDeclaration, @export_named_declaratio
433
433
* That is, it includes the `v` in `export var v` but not in `export {v}`.
434
434
*/
435
435
Identifier getAnExportedDecl ( ) {
436
- exists ( ExprOrStmt op | op = getOperand ( ) |
436
+ exists ( ExprOrStmt op | op = this . getOperand ( ) |
437
437
result = op .( DeclStmt ) .getADecl ( ) .getBindingPattern ( ) .getABindingVarRef ( ) or
438
438
result = op .( FunctionDeclStmt ) .getIdentifier ( ) or
439
439
result = op .( ClassDeclStmt ) .getIdentifier ( ) or
@@ -446,35 +446,35 @@ class ExportNamedDeclaration extends ExportDeclaration, @export_named_declaratio
446
446
}
447
447
448
448
/** Gets the variable declaration, if any, exported by this named export. */
449
- VarDecl getADecl ( ) { result = getAnExportedDecl ( ) }
449
+ VarDecl getADecl ( ) { result = this . getAnExportedDecl ( ) }
450
450
451
451
override predicate exportsAs ( LexicalName v , string name ) {
452
- exists ( LexicalDecl vd | vd = getAnExportedDecl ( ) |
452
+ exists ( LexicalDecl vd | vd = this . getAnExportedDecl ( ) |
453
453
name = vd .getName ( ) and v = vd .getALexicalName ( )
454
454
)
455
455
or
456
- exists ( ExportSpecifier spec | spec = getASpecifier ( ) and name = spec .getExportedName ( ) |
456
+ exists ( ExportSpecifier spec | spec = this . getASpecifier ( ) and name = spec .getExportedName ( ) |
457
457
v = spec .getLocal ( ) .( LexicalAccess ) .getALexicalName ( )
458
458
or
459
459
this .( ReExportDeclaration ) .getReExportedES2015Module ( ) .exportsAs ( v , spec .getLocalName ( ) )
460
460
)
461
461
}
462
462
463
463
override DataFlow:: Node getSourceNode ( string name ) {
464
- exists ( VarDef d | d .getTarget ( ) = getADecl ( ) |
464
+ exists ( VarDef d | d .getTarget ( ) = this . getADecl ( ) |
465
465
name = d .getTarget ( ) .( VarDecl ) .getName ( ) and
466
466
result = DataFlow:: valueNode ( d .getSource ( ) )
467
467
)
468
468
or
469
- exists ( ObjectPattern obj | obj = getOperand ( ) .( DeclStmt ) .getADecl ( ) .getBindingPattern ( ) |
469
+ exists ( ObjectPattern obj | obj = this . getOperand ( ) .( DeclStmt ) .getADecl ( ) .getBindingPattern ( ) |
470
470
exists ( DataFlow:: PropRead read | read = result |
471
471
read .getBase ( ) = obj .flow ( ) and
472
472
name = read .getPropertyName ( )
473
473
)
474
474
)
475
475
or
476
- exists ( ExportSpecifier spec | spec = getASpecifier ( ) and name = spec .getExportedName ( ) |
477
- not exists ( getImportedPath ( ) ) and result = DataFlow:: valueNode ( spec .getLocal ( ) )
476
+ exists ( ExportSpecifier spec | spec = this . getASpecifier ( ) and name = spec .getExportedName ( ) |
477
+ not exists ( this . getImportedPath ( ) ) and result = DataFlow:: valueNode ( spec .getLocal ( ) )
478
478
or
479
479
exists ( ReExportDeclaration red | red = this |
480
480
result = red .getReExportedES2015Module ( ) .getAnExport ( ) .getSourceNode ( spec .getLocalName ( ) )
@@ -483,20 +483,20 @@ class ExportNamedDeclaration extends ExportDeclaration, @export_named_declaratio
483
483
}
484
484
485
485
/** Gets the module from which the exports are taken if this is a re-export. */
486
- ConstantString getImportedPath ( ) { result = getChildExpr ( - 2 ) }
486
+ ConstantString getImportedPath ( ) { result = this . getChildExpr ( - 2 ) }
487
487
488
488
/** Gets the `i`th export specifier of this declaration. */
489
- ExportSpecifier getSpecifier ( int i ) { result = getChildExpr ( i ) }
489
+ ExportSpecifier getSpecifier ( int i ) { result = this . getChildExpr ( i ) }
490
490
491
491
/** Gets an export specifier of this declaration. */
492
- ExportSpecifier getASpecifier ( ) { result = getSpecifier ( _) }
492
+ ExportSpecifier getASpecifier ( ) { result = this . getSpecifier ( _) }
493
493
}
494
494
495
495
/**
496
496
* An export declaration with the `type` modifier.
497
497
*/
498
498
private class TypeOnlyExportDeclaration extends ExportNamedDeclaration {
499
- TypeOnlyExportDeclaration ( ) { isTypeOnly ( ) }
499
+ TypeOnlyExportDeclaration ( ) { this . isTypeOnly ( ) }
500
500
501
501
override predicate exportsAs ( LexicalName v , string name ) {
502
502
super .exportsAs ( v , name ) and
@@ -530,13 +530,13 @@ private class TypeOnlyExportDeclaration extends ExportNamedDeclaration {
530
530
*/
531
531
class ExportSpecifier extends Expr , @exportspecifier {
532
532
/** Gets the declaration to which this specifier belongs. */
533
- ExportDeclaration getExportDeclaration ( ) { result = getParent ( ) }
533
+ ExportDeclaration getExportDeclaration ( ) { result = this . getParent ( ) }
534
534
535
535
/** Gets the local symbol that is being exported. */
536
- Identifier getLocal ( ) { result = getChildExpr ( 0 ) }
536
+ Identifier getLocal ( ) { result = this . getChildExpr ( 0 ) }
537
537
538
538
/** Gets the name under which the symbol is exported. */
539
- Identifier getExported ( ) { result = getChildExpr ( 1 ) }
539
+ Identifier getExported ( ) { result = this . getChildExpr ( 1 ) }
540
540
541
541
/**
542
542
* Gets the local name of the exported symbol, that is, the name
@@ -562,7 +562,7 @@ class ExportSpecifier extends Expr, @exportspecifier {
562
562
* The sixth one (unlike the fourth one) _does_ have a local name
563
563
* (that is, `default`), since it is a re-export.
564
564
*/
565
- string getLocalName ( ) { result = getLocal ( ) .getName ( ) }
565
+ string getLocalName ( ) { result = this . getLocal ( ) .getName ( ) }
566
566
567
567
/**
568
568
* Gets the name under which the symbol is exported.
@@ -581,7 +581,7 @@ class ExportSpecifier extends Expr, @exportspecifier {
581
581
* `x`, `z`, `f` and `default`, while the last one does not have
582
582
* an exported name since it does not export a unique symbol.
583
583
*/
584
- string getExportedName ( ) { result = getExported ( ) .getName ( ) }
584
+ string getExportedName ( ) { result = this . getExported ( ) .getName ( ) }
585
585
586
586
override string getAPrimaryQlClass ( ) { result = "ExportSpecifier" }
587
587
}
@@ -630,11 +630,11 @@ class ExportDefaultSpecifier extends ExportSpecifier, @export_default_specifier
630
630
* ```
631
631
*/
632
632
class ReExportDefaultSpecifier extends ExportDefaultSpecifier {
633
- ReExportDefaultSpecifier ( ) { getExportDeclaration ( ) instanceof ReExportDeclaration }
633
+ ReExportDefaultSpecifier ( ) { this . getExportDeclaration ( ) instanceof ReExportDeclaration }
634
634
635
635
override string getLocalName ( ) { result = "default" }
636
636
637
- override string getExportedName ( ) { result = getExported ( ) .getName ( ) }
637
+ override string getExportedName ( ) { result = this . getExported ( ) .getName ( ) }
638
638
}
639
639
640
640
/**
@@ -671,15 +671,15 @@ abstract class ReExportDeclaration extends ExportDeclaration {
671
671
abstract ConstantString getImportedPath ( ) ;
672
672
673
673
/** Gets the module from which this declaration re-exports, if it is an ES2015 module. */
674
- ES2015Module getReExportedES2015Module ( ) { result = getReExportedModule ( ) }
674
+ ES2015Module getReExportedES2015Module ( ) { result = this . getReExportedModule ( ) }
675
675
676
676
/** Gets the module from which this declaration re-exports. */
677
677
cached
678
678
Module getReExportedModule ( ) {
679
679
Stages:: Imports:: ref ( ) and
680
- result .getFile ( ) = getEnclosingModule ( ) .resolve ( getImportedPath ( ) )
680
+ result .getFile ( ) = this . getEnclosingModule ( ) .resolve ( this . getImportedPath ( ) )
681
681
or
682
- result = resolveFromTypeRoot ( )
682
+ result = this . resolveFromTypeRoot ( )
683
683
}
684
684
685
685
/**
@@ -689,9 +689,9 @@ abstract class ReExportDeclaration extends ExportDeclaration {
689
689
result .getFile ( ) =
690
690
min ( TypeRootFolder typeRoot |
691
691
|
692
- typeRoot .getModuleFile ( getImportedPath ( ) .getStringValue ( ) )
692
+ typeRoot .getModuleFile ( this . getImportedPath ( ) .getStringValue ( ) )
693
693
order by
694
- typeRoot .getSearchPriority ( getFile ( ) .getParentContainer ( ) )
694
+ typeRoot .getSearchPriority ( this . getFile ( ) .getParentContainer ( ) )
695
695
)
696
696
}
697
697
}
@@ -700,7 +700,7 @@ abstract class ReExportDeclaration extends ExportDeclaration {
700
700
private class LiteralReExportPath extends PathExpr , ConstantString {
701
701
LiteralReExportPath ( ) { exists ( ReExportDeclaration bred | this = bred .getImportedPath ( ) ) }
702
702
703
- override string getValue ( ) { result = getStringValue ( ) }
703
+ override string getValue ( ) { result = this . getStringValue ( ) }
704
704
}
705
705
706
706
/**
0 commit comments