mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
JS: Add partial backwards compatibility with ASTNode
This commit is contained in:
@@ -42,6 +42,8 @@ abstract class Documentable extends ASTNode {
|
||||
class JSDocTypeExprParent extends @jsdoc_type_expr_parent {
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { none() }
|
||||
|
||||
JSDoc getJSDocComment() { none() }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,6 +85,10 @@ class JSDocTag extends @jsdoc_tag, JSDocTypeExprParent, Locatable {
|
||||
|
||||
/** Gets the toplevel in which this tag appears. */
|
||||
TopLevel getTopLevel() { result = getParent().getComment().getTopLevel() }
|
||||
|
||||
override JSDoc getJSDocComment() {
|
||||
result.getATag() = this
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,6 +129,20 @@ class JSDocTypeExpr extends @jsdoc_type_expr, JSDocTypeExprParent, TypeAnnotatio
|
||||
JSDocTypeExpr getChild(int i) { jsdoc_type_exprs(result, _, this, i, _) }
|
||||
|
||||
override string toString() { jsdoc_type_exprs(this, _, _, _, result) }
|
||||
|
||||
override JSDoc getJSDocComment() {
|
||||
result = getParent().getJSDocComment()
|
||||
}
|
||||
|
||||
override Stmt getEnclosingStmt() {
|
||||
result.getDocumentation() = getJSDocComment()
|
||||
}
|
||||
|
||||
override StmtContainer getContainer() { result = getEnclosingStmt().getContainer() }
|
||||
|
||||
override Function getEnclosingFunction() { result = getContainer() }
|
||||
|
||||
override TopLevel getTopLevel() { result = getEnclosingStmt().getTopLevel() }
|
||||
}
|
||||
|
||||
/** An `any` type expression `*`. */
|
||||
|
||||
@@ -85,4 +85,20 @@ class TypeAnnotation extends @type_annotation {
|
||||
* Holds if this is a reference to the type exported from `moduleName` under the name `exportedName`.
|
||||
*/
|
||||
predicate hasQualifiedName(string moduleName, string exportedName) { none() }
|
||||
|
||||
/** Gets the statement in which this type appears. */
|
||||
Stmt getEnclosingStmt() { none() }
|
||||
|
||||
/** Gets the function in which this type appears, if any. */
|
||||
Function getEnclosingFunction() { none() }
|
||||
|
||||
/**
|
||||
* Gets the statement container (function or toplevel) in which this type appears.
|
||||
*/
|
||||
StmtContainer getContainer() { none() }
|
||||
|
||||
/**
|
||||
* Gets the top-level containing this type annotation.
|
||||
*/
|
||||
TopLevel getTopLevel() { none() }
|
||||
}
|
||||
|
||||
@@ -540,6 +540,14 @@ class TypeExpr extends ExprOrType, @typeexpr, TypeAnnotation {
|
||||
* without type information.
|
||||
*/
|
||||
Type getType() { ast_node_type(this, result) }
|
||||
|
||||
override Stmt getEnclosingStmt() { result = ExprOrType.super.getEnclosingStmt() }
|
||||
|
||||
override Function getEnclosingFunction() { result = ExprOrType.super.getEnclosingFunction() }
|
||||
|
||||
override StmtContainer getContainer() { result = ExprOrType.super.getContainer() }
|
||||
|
||||
override TopLevel getTopLevel() { result = ExprOrType.super.getTopLevel() }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user