mirror of
https://github.com/github/codeql.git
synced 2026-01-08 12:10:22 +01:00
JS: Associate symbols with external module decls
This commit is contained in:
@@ -2191,6 +2191,7 @@ public class ASTExtractor {
|
||||
visitAll(nd.getBody(), key);
|
||||
contextManager.leaveContainer();
|
||||
scopeManager.leaveScope();
|
||||
emitNodeSymbol(nd, key);
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,10 @@ import com.semmle.js.ast.Visitor;
|
||||
import java.util.List;
|
||||
|
||||
/** A statement of form <code>declare module "X" {...}</code>. */
|
||||
public class ExternalModuleDeclaration extends Statement {
|
||||
public class ExternalModuleDeclaration extends Statement implements INodeWithSymbol {
|
||||
private final Literal name;
|
||||
private final List<Statement> body;
|
||||
private int symbol = -1;
|
||||
|
||||
public ExternalModuleDeclaration(SourceLocation loc, Literal name, List<Statement> body) {
|
||||
super("ExternalModuleDeclaration", loc);
|
||||
@@ -29,4 +30,14 @@ public class ExternalModuleDeclaration extends Statement {
|
||||
public List<Statement> getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSymbol() {
|
||||
return this.symbol;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSymbol(int symbol) {
|
||||
this.symbol = symbol;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -591,7 +591,7 @@ public class TypeScriptASTConverter {
|
||||
return convertTryStatement(node, loc);
|
||||
case "TupleType":
|
||||
return convertTupleType(node, loc);
|
||||
case "NamedTupleMember":
|
||||
case "NamedTupleMember":
|
||||
return convertNamedTupleMember(node, loc);
|
||||
case "TypeAliasDeclaration":
|
||||
return convertTypeAliasDeclaration(node, loc);
|
||||
@@ -1710,7 +1710,10 @@ public class TypeScriptASTConverter {
|
||||
}
|
||||
if (nameNode instanceof Literal) {
|
||||
// Declaration of form: declare module "X" {...}
|
||||
return new ExternalModuleDeclaration(loc, (Literal) nameNode, body);
|
||||
ExternalModuleDeclaration decl = new ExternalModuleDeclaration(loc, (Literal) nameNode, body);
|
||||
attachSymbolInformation(decl, node);
|
||||
System.out.println("ExternalModuleDeclaration symbol = " + decl.getSymbol());
|
||||
return decl;
|
||||
}
|
||||
if (hasFlag(node, "GlobalAugmentation")) {
|
||||
// Declaration of form: declare global {...}
|
||||
|
||||
Reference in New Issue
Block a user