mirror of
https://github.com/github/codeql.git
synced 2025-12-21 11:16:30 +01:00
add support for type-only import specifiers
This commit is contained in:
@@ -10,15 +10,25 @@ package com.semmle.js.ast;
|
||||
*/
|
||||
public class ImportSpecifier extends Expression {
|
||||
private final Identifier imported, local;
|
||||
private final boolean isTypeOnly;
|
||||
|
||||
public ImportSpecifier(SourceLocation loc, Identifier imported, Identifier local) {
|
||||
this("ImportSpecifier", loc, imported, local);
|
||||
this(loc, imported, local, false);
|
||||
}
|
||||
|
||||
public ImportSpecifier(SourceLocation loc, Identifier imported, Identifier local, boolean isTypeOnly) {
|
||||
this("ImportSpecifier", loc, imported, local, isTypeOnly);
|
||||
}
|
||||
|
||||
public ImportSpecifier(String type, SourceLocation loc, Identifier imported, Identifier local) {
|
||||
this(type, loc, imported, local, false);
|
||||
}
|
||||
|
||||
private ImportSpecifier(String type, SourceLocation loc, Identifier imported, Identifier local, boolean isTypeOnly) {
|
||||
super(type, loc);
|
||||
this.imported = imported;
|
||||
this.local = local == imported ? new NodeCopier().copy(local) : local;
|
||||
this.isTypeOnly = isTypeOnly;
|
||||
}
|
||||
|
||||
public Identifier getImported() {
|
||||
@@ -33,4 +43,8 @@ public class ImportSpecifier extends Expression {
|
||||
public <C, R> R accept(Visitor<C, R> v, C c) {
|
||||
return v.visit(this, c);
|
||||
}
|
||||
|
||||
public boolean hasTypeKeyword() {
|
||||
return isTypeOnly;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1806,6 +1806,9 @@ public class ASTExtractor {
|
||||
Label lbl = super.visit(nd, c);
|
||||
visit(nd.getImported(), lbl, 0, IdContext.LABEL);
|
||||
visit(nd.getLocal(), lbl, 1, c.idcontext);
|
||||
if (nd.hasTypeKeyword()) {
|
||||
trapwriter.addTuple("has_type_keyword", lbl);
|
||||
}
|
||||
return lbl;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user