mirror of
https://github.com/github/codeql.git
synced 2026-04-26 17:25:19 +02:00
JS: Preserve information about 'defer' keyword
This commit is contained in:
@@ -151,6 +151,14 @@ class ImportDeclaration extends Stmt, Import, @import_declaration {
|
||||
/** Holds if this is declared with the `type` keyword, so it only imports types. */
|
||||
predicate isTypeOnly() { has_type_keyword(this) }
|
||||
|
||||
/**
|
||||
* Holds if this is declared with the `defer` keyword, for example:
|
||||
* ```ts
|
||||
* import defer * as f from "somewhere";
|
||||
* ```
|
||||
*/
|
||||
predicate isDeferredImport() { has_defer_keyword(this) }
|
||||
|
||||
override string getAPrimaryQlClass() { result = "ImportDeclaration" }
|
||||
}
|
||||
|
||||
|
||||
@@ -516,6 +516,7 @@ has_private_keyword (int id: @property ref);
|
||||
has_protected_keyword (int id: @property ref);
|
||||
has_readonly_keyword (int id: @property ref);
|
||||
has_type_keyword (int id: @type_keyword_operand ref);
|
||||
has_defer_keyword (int id: @import_declaration ref);
|
||||
is_optional_member (int id: @property ref);
|
||||
has_definite_assignment_assertion (int id: @field_or_vardeclarator ref);
|
||||
is_optional_parameter_declaration (unique int parameter: @pattern ref);
|
||||
|
||||
@@ -4319,6 +4319,17 @@
|
||||
<dependencies/>
|
||||
</relation>
|
||||
<relation>
|
||||
<name>has_defer_keyword</name>
|
||||
<cardinality>1000</cardinality>
|
||||
<columnsizes>
|
||||
<e>
|
||||
<k>id</k>
|
||||
<v>1000</v>
|
||||
</e>
|
||||
</columnsizes>
|
||||
<dependencies/>
|
||||
</relation>
|
||||
<relation>
|
||||
<name>is_optional_member</name>
|
||||
<cardinality>3668</cardinality>
|
||||
<columnsizes>
|
||||
|
||||
@@ -1 +1 @@
|
||||
| tst.ts:1:1:1:31 | import ... m "fs"; |
|
||||
| tst.ts:1:1:1:44 | import ... where"; |
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import javascript
|
||||
|
||||
from ImportDeclaration decl
|
||||
select decl
|
||||
|
||||
query predicate deferredImports(ImportDeclaration decl) { decl.isDeferredImport() }
|
||||
|
||||
@@ -1 +1,4 @@
|
||||
import defer * as fs from "fs";
|
||||
import defer * as deferred from "somewhere";
|
||||
import type * as t from "somewhere";
|
||||
import * as normal from "somewhere";
|
||||
import defer from "somewhere";
|
||||
|
||||
Reference in New Issue
Block a user