mirror of
https://github.com/github/codeql.git
synced 2026-01-06 03:00:24 +01:00
TS: Rename IsTypeExpr -> PredicateTypeExpr
This commit is contained in:
@@ -34,13 +34,13 @@ import com.semmle.ts.ast.InferTypeExpr;
|
||||
import com.semmle.ts.ast.InterfaceDeclaration;
|
||||
import com.semmle.ts.ast.InterfaceTypeExpr;
|
||||
import com.semmle.ts.ast.IntersectionTypeExpr;
|
||||
import com.semmle.ts.ast.IsTypeExpr;
|
||||
import com.semmle.ts.ast.KeywordTypeExpr;
|
||||
import com.semmle.ts.ast.MappedTypeExpr;
|
||||
import com.semmle.ts.ast.NamespaceDeclaration;
|
||||
import com.semmle.ts.ast.NonNullAssertion;
|
||||
import com.semmle.ts.ast.OptionalTypeExpr;
|
||||
import com.semmle.ts.ast.ParenthesizedTypeExpr;
|
||||
import com.semmle.ts.ast.PredicateTypeExpr;
|
||||
import com.semmle.ts.ast.RestTypeExpr;
|
||||
import com.semmle.ts.ast.TupleTypeExpr;
|
||||
import com.semmle.ts.ast.TypeAliasDeclaration;
|
||||
@@ -634,7 +634,7 @@ public class DefaultVisitor<C, R> implements Visitor<C, R> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public R visit(IsTypeExpr nd, C c) {
|
||||
public R visit(PredicateTypeExpr nd, C c) {
|
||||
return visit((TypeExpression) nd, c);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,13 +30,13 @@ import com.semmle.ts.ast.InferTypeExpr;
|
||||
import com.semmle.ts.ast.InterfaceDeclaration;
|
||||
import com.semmle.ts.ast.InterfaceTypeExpr;
|
||||
import com.semmle.ts.ast.IntersectionTypeExpr;
|
||||
import com.semmle.ts.ast.IsTypeExpr;
|
||||
import com.semmle.ts.ast.KeywordTypeExpr;
|
||||
import com.semmle.ts.ast.MappedTypeExpr;
|
||||
import com.semmle.ts.ast.NamespaceDeclaration;
|
||||
import com.semmle.ts.ast.NonNullAssertion;
|
||||
import com.semmle.ts.ast.OptionalTypeExpr;
|
||||
import com.semmle.ts.ast.ParenthesizedTypeExpr;
|
||||
import com.semmle.ts.ast.PredicateTypeExpr;
|
||||
import com.semmle.ts.ast.RestTypeExpr;
|
||||
import com.semmle.ts.ast.TupleTypeExpr;
|
||||
import com.semmle.ts.ast.TypeAliasDeclaration;
|
||||
@@ -717,8 +717,9 @@ public class NodeCopier implements Visitor<Void, INode> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public INode visit(IsTypeExpr nd, Void c) {
|
||||
return new IsTypeExpr(visit(nd.getLoc()), copy(nd.getLeft()), copy(nd.getRight()));
|
||||
public INode visit(PredicateTypeExpr nd, Void c) {
|
||||
return new PredicateTypeExpr(
|
||||
visit(nd.getLoc()), copy(nd.getExpression()), copy(nd.getTypeExpr()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,13 +30,13 @@ import com.semmle.ts.ast.InferTypeExpr;
|
||||
import com.semmle.ts.ast.InterfaceDeclaration;
|
||||
import com.semmle.ts.ast.InterfaceTypeExpr;
|
||||
import com.semmle.ts.ast.IntersectionTypeExpr;
|
||||
import com.semmle.ts.ast.IsTypeExpr;
|
||||
import com.semmle.ts.ast.KeywordTypeExpr;
|
||||
import com.semmle.ts.ast.MappedTypeExpr;
|
||||
import com.semmle.ts.ast.NamespaceDeclaration;
|
||||
import com.semmle.ts.ast.NonNullAssertion;
|
||||
import com.semmle.ts.ast.OptionalTypeExpr;
|
||||
import com.semmle.ts.ast.ParenthesizedTypeExpr;
|
||||
import com.semmle.ts.ast.PredicateTypeExpr;
|
||||
import com.semmle.ts.ast.RestTypeExpr;
|
||||
import com.semmle.ts.ast.TupleTypeExpr;
|
||||
import com.semmle.ts.ast.TypeAliasDeclaration;
|
||||
@@ -256,7 +256,7 @@ public interface Visitor<C, R> {
|
||||
|
||||
public R visit(TypeofTypeExpr nd, C c);
|
||||
|
||||
public R visit(IsTypeExpr nd, C c);
|
||||
public R visit(PredicateTypeExpr nd, C c);
|
||||
|
||||
public R visit(InterfaceTypeExpr nd, C c);
|
||||
|
||||
|
||||
@@ -125,13 +125,13 @@ import com.semmle.ts.ast.InferTypeExpr;
|
||||
import com.semmle.ts.ast.InterfaceDeclaration;
|
||||
import com.semmle.ts.ast.InterfaceTypeExpr;
|
||||
import com.semmle.ts.ast.IntersectionTypeExpr;
|
||||
import com.semmle.ts.ast.IsTypeExpr;
|
||||
import com.semmle.ts.ast.KeywordTypeExpr;
|
||||
import com.semmle.ts.ast.MappedTypeExpr;
|
||||
import com.semmle.ts.ast.NamespaceDeclaration;
|
||||
import com.semmle.ts.ast.NonNullAssertion;
|
||||
import com.semmle.ts.ast.OptionalTypeExpr;
|
||||
import com.semmle.ts.ast.ParenthesizedTypeExpr;
|
||||
import com.semmle.ts.ast.PredicateTypeExpr;
|
||||
import com.semmle.ts.ast.RestTypeExpr;
|
||||
import com.semmle.ts.ast.TupleTypeExpr;
|
||||
import com.semmle.ts.ast.TypeAliasDeclaration;
|
||||
@@ -1707,10 +1707,10 @@ public class ASTExtractor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Label visit(IsTypeExpr nd, Context c) {
|
||||
public Label visit(PredicateTypeExpr nd, Context c) {
|
||||
Label key = super.visit(nd, c);
|
||||
visit(nd.getLeft(), key, 0, IdContext.varInTypeBind);
|
||||
visit(nd.getRight(), key, 1, IdContext.typeBind);
|
||||
visit(nd.getExpression(), key, 0, IdContext.varInTypeBind);
|
||||
visit(nd.getTypeExpr(), key, 1, IdContext.typeBind);
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,9 +46,9 @@ import com.semmle.ts.ast.InferTypeExpr;
|
||||
import com.semmle.ts.ast.InterfaceDeclaration;
|
||||
import com.semmle.ts.ast.InterfaceTypeExpr;
|
||||
import com.semmle.ts.ast.IntersectionTypeExpr;
|
||||
import com.semmle.ts.ast.IsTypeExpr;
|
||||
import com.semmle.ts.ast.NamespaceDeclaration;
|
||||
import com.semmle.ts.ast.ParenthesizedTypeExpr;
|
||||
import com.semmle.ts.ast.PredicateTypeExpr;
|
||||
import com.semmle.ts.ast.TupleTypeExpr;
|
||||
import com.semmle.ts.ast.TypeAliasDeclaration;
|
||||
import com.semmle.ts.ast.UnionTypeExpr;
|
||||
@@ -660,8 +660,8 @@ public class ScopeManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(IsTypeExpr nd, Void c) {
|
||||
return nd.getRight().accept(this, c);
|
||||
public Void visit(PredicateTypeExpr nd, Void c) {
|
||||
return nd.getTypeExpr().accept(this, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,11 +16,11 @@ import com.semmle.ts.ast.IndexedAccessTypeExpr;
|
||||
import com.semmle.ts.ast.InferTypeExpr;
|
||||
import com.semmle.ts.ast.InterfaceTypeExpr;
|
||||
import com.semmle.ts.ast.IntersectionTypeExpr;
|
||||
import com.semmle.ts.ast.IsTypeExpr;
|
||||
import com.semmle.ts.ast.KeywordTypeExpr;
|
||||
import com.semmle.ts.ast.MappedTypeExpr;
|
||||
import com.semmle.ts.ast.OptionalTypeExpr;
|
||||
import com.semmle.ts.ast.ParenthesizedTypeExpr;
|
||||
import com.semmle.ts.ast.PredicateTypeExpr;
|
||||
import com.semmle.ts.ast.RestTypeExpr;
|
||||
import com.semmle.ts.ast.TupleTypeExpr;
|
||||
import com.semmle.ts.ast.TypeParameter;
|
||||
@@ -159,7 +159,7 @@ public class TypeExprKinds {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer visit(IsTypeExpr nd, Void c) {
|
||||
public Integer visit(PredicateTypeExpr nd, Void c) {
|
||||
return isTypeExpr;
|
||||
}
|
||||
|
||||
|
||||
@@ -127,13 +127,13 @@ import com.semmle.ts.ast.InferTypeExpr;
|
||||
import com.semmle.ts.ast.InterfaceDeclaration;
|
||||
import com.semmle.ts.ast.InterfaceTypeExpr;
|
||||
import com.semmle.ts.ast.IntersectionTypeExpr;
|
||||
import com.semmle.ts.ast.IsTypeExpr;
|
||||
import com.semmle.ts.ast.KeywordTypeExpr;
|
||||
import com.semmle.ts.ast.MappedTypeExpr;
|
||||
import com.semmle.ts.ast.NamespaceDeclaration;
|
||||
import com.semmle.ts.ast.NonNullAssertion;
|
||||
import com.semmle.ts.ast.OptionalTypeExpr;
|
||||
import com.semmle.ts.ast.ParenthesizedTypeExpr;
|
||||
import com.semmle.ts.ast.PredicateTypeExpr;
|
||||
import com.semmle.ts.ast.RestTypeExpr;
|
||||
import com.semmle.ts.ast.TupleTypeExpr;
|
||||
import com.semmle.ts.ast.TypeAliasDeclaration;
|
||||
@@ -2199,7 +2199,7 @@ public class TypeScriptASTConverter {
|
||||
}
|
||||
|
||||
private Node convertTypePredicate(JsonObject node, SourceLocation loc) throws ParseError {
|
||||
return new IsTypeExpr(
|
||||
return new PredicateTypeExpr(
|
||||
loc, convertChildAsType(node, "parameterName"), convertChildAsType(node, "type"));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.semmle.ts.ast;
|
||||
|
||||
import com.semmle.js.ast.SourceLocation;
|
||||
import com.semmle.js.ast.Visitor;
|
||||
|
||||
/**
|
||||
* A type of form <tt>E is T</tt> where <tt>E</tt> is a parameter name or <tt>this</tt> and
|
||||
* <tt>T</tt> is a type.
|
||||
*/
|
||||
public class IsTypeExpr extends TypeExpression {
|
||||
private final ITypeExpression left; // Always Identifier or KeywordTypeExpr (in case of 'this')
|
||||
private final ITypeExpression right;
|
||||
|
||||
public IsTypeExpr(SourceLocation loc, ITypeExpression left, ITypeExpression right) {
|
||||
super("IsTypeExpr", loc);
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
public ITypeExpression getLeft() {
|
||||
return left;
|
||||
}
|
||||
|
||||
public ITypeExpression getRight() {
|
||||
return right;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <C, R> R accept(Visitor<C, R> v, C c) {
|
||||
return v.visit(this, c);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.semmle.ts.ast;
|
||||
|
||||
import com.semmle.js.ast.SourceLocation;
|
||||
import com.semmle.js.ast.Visitor;
|
||||
|
||||
/**
|
||||
* A type of form <tt>E is T</tt> where <tt>E</tt> is a parameter name or <tt>this</tt> and
|
||||
* <tt>T</tt> is a type.
|
||||
*/
|
||||
public class PredicateTypeExpr extends TypeExpression {
|
||||
private final ITypeExpression expression;
|
||||
private final ITypeExpression type;
|
||||
|
||||
public PredicateTypeExpr(SourceLocation loc, ITypeExpression expression, ITypeExpression type) {
|
||||
super("PredicateTypeExpr", loc);
|
||||
this.expression = expression;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/** Returns the <tt>E</tt> in <tt>E is T</tt>. */
|
||||
public ITypeExpression getExpression() {
|
||||
return expression;
|
||||
}
|
||||
|
||||
/** Returns the <tt>T</tt> in <tt>E is T</tt>. */
|
||||
public ITypeExpression getTypeExpr() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <C, R> R accept(Visitor<C, R> v, C c) {
|
||||
return v.visit(this, c);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user