mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Kotlin: Autoformat QL
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
import java
|
||||
|
||||
from BinaryExpr be, string reason
|
||||
where not exists(be.getLeftOperand()) and reason = "No left operand"
|
||||
or not exists(be.getRightOperand()) and reason = "No right operand"
|
||||
or exists(Expr e, int i | e.isNthChildOf(be, i) and i != 0 and i != 1 and reason = "Unexpected operand " + i.toString())
|
||||
or be.getOp() = " ?? " and reason = "No operator name"
|
||||
where
|
||||
not exists(be.getLeftOperand()) and reason = "No left operand"
|
||||
or
|
||||
not exists(be.getRightOperand()) and reason = "No right operand"
|
||||
or
|
||||
exists(Expr e, int i |
|
||||
e.isNthChildOf(be, i) and i != 0 and i != 1 and reason = "Unexpected operand " + i.toString()
|
||||
)
|
||||
or
|
||||
be.getOp() = " ?? " and reason = "No operator name"
|
||||
select be, reason
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import java
|
||||
|
||||
from UnaryExpr ue
|
||||
where not exists(ue.getExpr())
|
||||
or exists(Expr e, int i | e.isNthChildOf(ue, i) and i != 0)
|
||||
where
|
||||
not exists(ue.getExpr())
|
||||
or
|
||||
exists(Expr e, int i | e.isNthChildOf(ue, i) and i != 0)
|
||||
select ue
|
||||
|
||||
@@ -3,4 +3,3 @@ import java
|
||||
from BlockStmt b, Expr e
|
||||
where e.getParent() = b
|
||||
select b, e
|
||||
|
||||
|
||||
@@ -2,37 +2,63 @@ import java
|
||||
import semmle.code.java.ControlFlowGraph
|
||||
|
||||
predicate shouldBeDeadEnd(ControlFlowNode n) {
|
||||
n instanceof BreakStmt and n.getFile().isKotlinSourceFile() or // TODO
|
||||
n instanceof ReturnStmt and n.getFile().isKotlinSourceFile() or // TODO
|
||||
n instanceof Interface or // TODO
|
||||
n instanceof Class or // TODO
|
||||
n instanceof Parameter or // TODO
|
||||
n instanceof Field or // TODO
|
||||
n instanceof Annotation or // TODO
|
||||
n instanceof TypeAccess or // TODO
|
||||
n instanceof ArrayTypeAccess or // TODO
|
||||
n instanceof UnionTypeAccess or // TODO
|
||||
n instanceof IntersectionTypeAccess or // TODO
|
||||
n instanceof ArrayAccess or // TODO
|
||||
n instanceof AddExpr or // TODO
|
||||
n instanceof MinusExpr or // TODO
|
||||
n instanceof LocalVariableDecl or // TODO
|
||||
n instanceof FieldDeclaration or // TODO
|
||||
n instanceof ArrayInit or // TODO
|
||||
n instanceof VarAccess or // TODO
|
||||
n instanceof Literal or // TODO
|
||||
n instanceof TypeLiteral or // TODO
|
||||
n instanceof TypeVariable or // TODO
|
||||
n instanceof WildcardTypeAccess or // TODO
|
||||
n instanceof MethodAccess or // TODO
|
||||
n instanceof Method or
|
||||
n instanceof Constructor or
|
||||
not exists(n.getFile().getRelativePath()) or // TODO
|
||||
n instanceof BreakStmt and n.getFile().isKotlinSourceFile() // TODO
|
||||
or
|
||||
n instanceof ReturnStmt and n.getFile().isKotlinSourceFile() // TODO
|
||||
or
|
||||
n instanceof Interface // TODO
|
||||
or
|
||||
n instanceof Class // TODO
|
||||
or
|
||||
n instanceof Parameter // TODO
|
||||
or
|
||||
n instanceof Field // TODO
|
||||
or
|
||||
n instanceof Annotation // TODO
|
||||
or
|
||||
n instanceof TypeAccess // TODO
|
||||
or
|
||||
n instanceof ArrayTypeAccess // TODO
|
||||
or
|
||||
n instanceof UnionTypeAccess // TODO
|
||||
or
|
||||
n instanceof IntersectionTypeAccess // TODO
|
||||
or
|
||||
n instanceof ArrayAccess // TODO
|
||||
or
|
||||
n instanceof AddExpr // TODO
|
||||
or
|
||||
n instanceof MinusExpr // TODO
|
||||
or
|
||||
n instanceof LocalVariableDecl // TODO
|
||||
or
|
||||
n instanceof FieldDeclaration // TODO
|
||||
or
|
||||
n instanceof ArrayInit // TODO
|
||||
or
|
||||
n instanceof VarAccess // TODO
|
||||
or
|
||||
n instanceof Literal // TODO
|
||||
or
|
||||
n instanceof TypeLiteral // TODO
|
||||
or
|
||||
n instanceof TypeVariable // TODO
|
||||
or
|
||||
n instanceof WildcardTypeAccess // TODO
|
||||
or
|
||||
n instanceof MethodAccess // TODO
|
||||
or
|
||||
n instanceof Method
|
||||
or
|
||||
n instanceof Constructor
|
||||
or
|
||||
not exists(n.getFile().getRelativePath()) // TODO
|
||||
or
|
||||
n = any(ConstCase c).getValue(_) // TODO
|
||||
}
|
||||
|
||||
from ControlFlowNode n, string s
|
||||
where // TODO: exists(n.getASuccessor()) and shouldBeDeadEnd(n) and s = "expected dead end"
|
||||
not exists(n.getASuccessor()) and not shouldBeDeadEnd(n) and s = "unexpected dead end"
|
||||
where
|
||||
// TODO: exists(n.getASuccessor()) and shouldBeDeadEnd(n) and s = "expected dead end"
|
||||
not exists(n.getASuccessor()) and not shouldBeDeadEnd(n) and s = "unexpected dead end"
|
||||
select n, n.getPrimaryQlClasses(), s
|
||||
|
||||
|
||||
@@ -6,65 +6,69 @@ Element nthChildOf(Element e, int i) {
|
||||
}
|
||||
|
||||
predicate duplicateChildren(Element e, int i) {
|
||||
nthChildOf(e, i) != nthChildOf(e, i)
|
||||
nthChildOf(e, i) != nthChildOf(e, i) and
|
||||
// Java #165
|
||||
and not e instanceof Method
|
||||
not e instanceof Method and
|
||||
// Java #165
|
||||
and not e instanceof Constructor
|
||||
not e instanceof Constructor
|
||||
}
|
||||
|
||||
predicate gapInChildren(Element e, int i) {
|
||||
exists(int left, int right |
|
||||
left = min(int l | exists(nthChildOf(e, l))) and
|
||||
right = max(int r | exists(nthChildOf(e, r))) and
|
||||
i in [left .. right] and
|
||||
not exists(nthChildOf(e, i)))
|
||||
left = min(int l | exists(nthChildOf(e, l))) and
|
||||
right = max(int r | exists(nthChildOf(e, r))) and
|
||||
i in [left .. right] and
|
||||
not exists(nthChildOf(e, i))
|
||||
) and
|
||||
// Annotations are child 0 upwards, 'implements' are -2 downwards,
|
||||
// and there may or may not be an 'extends' for child -1.
|
||||
and not (e instanceof ClassOrInterface and i = -1)
|
||||
not (e instanceof ClassOrInterface and i = -1) and
|
||||
// A class instance creation expression has the type as child -3,
|
||||
// may or may not have a qualifier as child -2, and will never have
|
||||
// a child -1.
|
||||
and not (e instanceof ClassInstanceExpr and i = [-2, -1])
|
||||
not (e instanceof ClassInstanceExpr and i = [-2, -1]) and
|
||||
// Type access have annotations from -2 down, and type
|
||||
// arguments from 0 up, but may or may not have a qualifier
|
||||
// at -1.
|
||||
and not (e instanceof TypeAccess and i = -1)
|
||||
not (e instanceof TypeAccess and i = -1) and
|
||||
// Try statements have their 'finally' clause as child 2,
|
||||
// and that may or may not exist.
|
||||
and not (e instanceof TryStmt and i = -2)
|
||||
not (e instanceof TryStmt and i = -2) and
|
||||
// For statements may or may not declare a new variable (child 0), or
|
||||
// have a condition (child 1).
|
||||
and not (e instanceof ForStmt and i = [0, 1])
|
||||
not (e instanceof ForStmt and i = [0, 1]) and
|
||||
// TODO: Clarify situation with Kotlin and MethodAccess.
|
||||
// -1 can be skipped (type arguments from -2 down, no qualifier at -1,
|
||||
// then arguments from 0).
|
||||
// Can we also skip arguments, e.g. due to defaults for parameters?
|
||||
and not (e instanceof MethodAccess and e.getFile().isKotlinSourceFile())
|
||||
not (e instanceof MethodAccess and e.getFile().isKotlinSourceFile())
|
||||
}
|
||||
|
||||
predicate lateFirstChild(Element e, int i) {
|
||||
i > 0
|
||||
and exists(nthChildOf(e, i))
|
||||
and forex(int j | exists(nthChildOf(e, j)) | j >= i)
|
||||
i > 0 and
|
||||
exists(nthChildOf(e, i)) and
|
||||
forex(int j | exists(nthChildOf(e, j)) | j >= i) and
|
||||
// A wildcard type access can be `?` with no children,
|
||||
// `? extends T` with only a child 0, or `? super T`
|
||||
// with only a child 1.
|
||||
and not (e instanceof WildcardTypeAccess and i = 1)
|
||||
not (e instanceof WildcardTypeAccess and i = 1) and
|
||||
// For a normal local variable decl, child 0 is the type.
|
||||
// However, for a Java 10 `var x = ...` declaration, there is
|
||||
// no type, so the first child is the variable as child 1.
|
||||
// There can only be one variable declared in these declarations,
|
||||
// so there will never be a child 2.
|
||||
and not (e instanceof LocalVariableDeclStmt and i = 1 and not exists(nthChildOf(e, 2)))
|
||||
not (e instanceof LocalVariableDeclStmt and i = 1 and not exists(nthChildOf(e, 2))) and
|
||||
// For statements may or may not declare a new variable (child 0), or
|
||||
// have a condition (child 1).
|
||||
and not (e instanceof ForStmt and i = [1, 2])
|
||||
not (e instanceof ForStmt and i = [1, 2])
|
||||
}
|
||||
|
||||
from Element e, int i, string problem
|
||||
where problem = "duplicate" and duplicateChildren(e, i)
|
||||
or problem = "gap" and gapInChildren(e, i)
|
||||
or problem = "late" and lateFirstChild(e, i)
|
||||
where
|
||||
problem = "duplicate" and duplicateChildren(e, i)
|
||||
or
|
||||
problem = "gap" and gapInChildren(e, i)
|
||||
or
|
||||
problem = "late" and lateFirstChild(e, i)
|
||||
select e, e.getPrimaryQlClasses(), i, problem,
|
||||
concat(int j | exists(nthChildOf(e, j)) | j.toString(), ", " order by j)
|
||||
concat(int j | exists(nthChildOf(e, j)) | j.toString(), ", " order by j)
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
import java
|
||||
|
||||
predicate goodCompilation(Compilation c) {
|
||||
forex(int i |
|
||||
exists(c.getFileCompiled(i)) |
|
||||
(exists(c.getFileCompiled(i - 1)) or i = 0)
|
||||
and c.fileCompiledSuccessful(i)) and
|
||||
forex(int i |
|
||||
exists(c.getArgument(i)) |
|
||||
exists(c.getArgument(i - 1)) or i = 0) and
|
||||
forex(int i | exists(c.getFileCompiled(i)) |
|
||||
(exists(c.getFileCompiled(i - 1)) or i = 0) and
|
||||
c.fileCompiledSuccessful(i)
|
||||
) and
|
||||
forex(int i | exists(c.getArgument(i)) | exists(c.getArgument(i - 1)) or i = 0) and
|
||||
c.extractionStarted() and
|
||||
c.extractionSuccessful()
|
||||
}
|
||||
|
||||
from Compilation c
|
||||
where c.isKotlin()
|
||||
and not goodCompilation(c)
|
||||
where
|
||||
c.isKotlin() and
|
||||
not goodCompilation(c)
|
||||
select c
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import java
|
||||
|
||||
from Expr e, int n
|
||||
where n = count(e.getType())
|
||||
and n != 1
|
||||
where
|
||||
n = count(e.getType()) and
|
||||
n != 1 and
|
||||
// Java #144
|
||||
and not e instanceof ReflectiveAccessAnnotation
|
||||
not e instanceof ReflectiveAccessAnnotation
|
||||
select e, n
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import java
|
||||
// File classes should only be extracted if we need somewhere to
|
||||
// put top-level members.
|
||||
from Class c
|
||||
where file_class(c)
|
||||
and not exists(c.getAMember())
|
||||
where
|
||||
file_class(c) and
|
||||
not exists(c.getAMember())
|
||||
select c
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import java
|
||||
|
||||
from Top t
|
||||
where t.getAPrimaryQlClass() = "???"
|
||||
where
|
||||
t.getAPrimaryQlClass() = "???" and
|
||||
// TypeBound doesn't extend Top (but probably should); part of Kotlin #6
|
||||
and not t instanceof TypeBound
|
||||
not t instanceof TypeBound and
|
||||
// XMLLocatable doesn't extend Top (but probably should); part of Kotlin #6
|
||||
and not t instanceof XMLLocatable
|
||||
select t,
|
||||
concat(t.getAPrimaryQlClass(), ",")
|
||||
not t instanceof XMLLocatable
|
||||
select t, concat(t.getAPrimaryQlClass(), ",")
|
||||
|
||||
@@ -10,9 +10,9 @@ predicate badKotlinType(Element e, int i) {
|
||||
}
|
||||
|
||||
from Element e, int i
|
||||
where // TODO: Java extractor doesn't populate these yet
|
||||
e.getFile().isKotlinSourceFile()
|
||||
and badKotlinType(e, i)
|
||||
and i != 1
|
||||
where
|
||||
// TODO: Java extractor doesn't populate these yet
|
||||
e.getFile().isKotlinSourceFile() and
|
||||
badKotlinType(e, i) and
|
||||
i != 1
|
||||
select e, i
|
||||
|
||||
|
||||
@@ -18,26 +18,30 @@ Location backwardsLocation() {
|
||||
|
||||
// Normally a location should tag at least one locatable entity.
|
||||
// Note this is not absolutely necessarily a bug (it does not always indicate a location is
|
||||
// an orphan in database terms), because classes that are seen both as source code and as a
|
||||
// .class file are extracted using both locations, with `Top.getLocation` filtering out the
|
||||
// class-file location when both a source- and a class-file location are present in the
|
||||
// database. However at present the Java extractor always uses the class-file location at
|
||||
// an orphan in database terms), because classes that are seen both as source code and as a
|
||||
// .class file are extracted using both locations, with `Top.getLocation` filtering out the
|
||||
// class-file location when both a source- and a class-file location are present in the
|
||||
// database. However at present the Java extractor always uses the class-file location at
|
||||
// least to locate a `File`, so such a location does end up with a single use.
|
||||
Location unusedLocation() {
|
||||
not exists(Top t | t.getLocation() = result) and
|
||||
not exists(XMLLocatable x | x.getLocation() = result) and
|
||||
not exists(ConfigLocatable c | c.getLocation() = result) and
|
||||
not exists(@diagnostic d | diagnostics(d, _, _, _, _, _, result)) and
|
||||
not (result.getFile().getExtension() = "xml" and
|
||||
result.getStartLine() = 0 and
|
||||
result.getStartColumn() = 0 and
|
||||
result.getEndLine() = 0 and
|
||||
result.getEndColumn() = 0)
|
||||
not (
|
||||
result.getFile().getExtension() = "xml" and
|
||||
result.getStartLine() = 0 and
|
||||
result.getStartColumn() = 0 and
|
||||
result.getEndLine() = 0 and
|
||||
result.getEndColumn() = 0
|
||||
)
|
||||
}
|
||||
|
||||
from string reason, Location l
|
||||
where reason = "Bad location" and l = badLocation()
|
||||
or reason = "Backwards location" and l = backwardsLocation()
|
||||
or reason = "Unused location" and l = unusedLocation()
|
||||
where
|
||||
reason = "Bad location" and l = badLocation()
|
||||
or
|
||||
reason = "Backwards location" and l = backwardsLocation()
|
||||
or
|
||||
reason = "Unused location" and l = unusedLocation()
|
||||
select reason, l
|
||||
|
||||
|
||||
@@ -16,18 +16,27 @@ string topToString(Top t) {
|
||||
t instanceof Javadoc and not exists(t.toString()) and result = "<Javadoc>"
|
||||
or
|
||||
// Java #144
|
||||
t instanceof ReflectiveAccessAnnotation and not exists(t.toString()) and result = "<ReflectiveAccessAnnotation>"
|
||||
t instanceof ReflectiveAccessAnnotation and
|
||||
not exists(t.toString()) and
|
||||
result = "<ReflectiveAccessAnnotation>"
|
||||
}
|
||||
|
||||
string not1ToString() {
|
||||
exists(Top t | count(topToString(t)) != 1 and result = "Top which doesn't have exactly 1 toString")
|
||||
exists(Top t |
|
||||
count(topToString(t)) != 1 and result = "Top which doesn't have exactly 1 toString"
|
||||
)
|
||||
or
|
||||
exists(Location l | count(l.toString()) != 1 and result = "Location which doesn't have exactly 1 toString")
|
||||
exists(Location l |
|
||||
count(l.toString()) != 1 and result = "Location which doesn't have exactly 1 toString"
|
||||
)
|
||||
or
|
||||
exists(Module m | count(m.toString()) != 1 and result = "Module which doesn't have exactly 1 toString")
|
||||
exists(Module m |
|
||||
count(m.toString()) != 1 and result = "Module which doesn't have exactly 1 toString"
|
||||
)
|
||||
or
|
||||
exists(Directive d | count(d.toString()) != 1 and result = "Directive which doesn't have exactly 1 toString")
|
||||
exists(Directive d |
|
||||
count(d.toString()) != 1 and result = "Directive which doesn't have exactly 1 toString"
|
||||
)
|
||||
}
|
||||
|
||||
select not1ToString()
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ Type getATypeUsedInClass(RefType type) {
|
||||
result = type.getAMethod().getParameterType(_)
|
||||
or
|
||||
result = any(Expr e | e.getEnclosingCallable().getDeclaringType() = type).getType()
|
||||
// Structural recursion over types:
|
||||
or
|
||||
// Structural recursion over types:
|
||||
result = getAMentionedType(getATypeUsedInClass(type))
|
||||
}
|
||||
|
||||
@@ -35,5 +35,6 @@ TypeVariable getATypeVariableInScope(RefType type) {
|
||||
}
|
||||
|
||||
from ClassOrInterface typeUser, TypeVariable outOfScope
|
||||
where outOfScope = getAMentionedType(typeUser) and not outOfScope = getATypeVariableInScope(typeUser)
|
||||
select "Type " + typeUser + " uses out-of-scope type variable " + outOfScope
|
||||
where
|
||||
outOfScope = getAMentionedType(typeUser) and not outOfScope = getATypeVariableInScope(typeUser)
|
||||
select "Type " + typeUser + " uses out-of-scope type variable " + outOfScope
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import java
|
||||
|
||||
from Variable v, int n
|
||||
where n = count(v.getType())
|
||||
and n != 1
|
||||
where
|
||||
n = count(v.getType()) and
|
||||
n != 1
|
||||
select v, n
|
||||
|
||||
|
||||
@@ -40,10 +40,14 @@ class Compilation extends @compilation {
|
||||
predicate fileCompiledSuccessful(int i) { compilation_compiling_files_completed(this, i, 0) }
|
||||
|
||||
/** Holds if the `i`th file during this invocation had recoverable extraction errors. */
|
||||
predicate fileCompiledRecoverableErrors(int i) { compilation_compiling_files_completed(this, i, 1) }
|
||||
predicate fileCompiledRecoverableErrors(int i) {
|
||||
compilation_compiling_files_completed(this, i, 1)
|
||||
}
|
||||
|
||||
/** Holds if the `i`th file during this invocation had non-recoverable extraction errors. */
|
||||
predicate fileCompiledNonRecoverableErrors(int i) { compilation_compiling_files_completed(this, i, 2) }
|
||||
predicate fileCompiledNonRecoverableErrors(int i) {
|
||||
compilation_compiling_files_completed(this, i, 2)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the amount of CPU time spent processing file number `i` in the
|
||||
|
||||
@@ -4,31 +4,32 @@
|
||||
|
||||
import java
|
||||
|
||||
class KotlinType extends Element, @kt_type {
|
||||
}
|
||||
class KotlinType extends Element, @kt_type { }
|
||||
|
||||
class KotlinNullableType extends KotlinType, @kt_nullable_type {
|
||||
override string toString() {
|
||||
exists(RefType javaType |
|
||||
kt_nullable_types(this, javaType) and
|
||||
result = "Kotlin nullable " + javaType.toString())
|
||||
kt_nullable_types(this, javaType) and
|
||||
result = "Kotlin nullable " + javaType.toString()
|
||||
)
|
||||
}
|
||||
|
||||
override string getAPrimaryQlClass() { result = "KotlinNullableType" }
|
||||
}
|
||||
|
||||
class KotlinNotnullType extends KotlinType, @kt_notnull_type {
|
||||
override string toString() {
|
||||
exists(RefType javaType |
|
||||
kt_notnull_types(this, javaType) and
|
||||
result = "Kotlin not-null " + javaType.toString())
|
||||
kt_notnull_types(this, javaType) and
|
||||
result = "Kotlin not-null " + javaType.toString()
|
||||
)
|
||||
}
|
||||
|
||||
override string getAPrimaryQlClass() { result = "KotlinNotnullType" }
|
||||
}
|
||||
|
||||
class KotlinTypeAlias extends Element, @kt_type_alias {
|
||||
override string getAPrimaryQlClass() { result = "KotlinTypeAlias" }
|
||||
|
||||
KotlinType getKotlinType() {
|
||||
kt_type_alias(this, _, result)
|
||||
}
|
||||
KotlinType getKotlinType() { kt_type_alias(this, _, result) }
|
||||
}
|
||||
|
||||
@@ -273,9 +273,7 @@ private class PpCastExpr extends PpAst, CastExpr {
|
||||
}
|
||||
|
||||
private class PpSafeCastExpr extends PpAst, SafeCastExpr {
|
||||
override string getPart(int i) {
|
||||
i = 1 and result = "as?"
|
||||
}
|
||||
override string getPart(int i) { i = 1 and result = "as?" }
|
||||
|
||||
override PpAst getChild(int i) {
|
||||
i = 0 and result = this.getExpr()
|
||||
@@ -285,21 +283,15 @@ private class PpSafeCastExpr extends PpAst, SafeCastExpr {
|
||||
}
|
||||
|
||||
private class PpImplicitCastExpr extends PpAst, ImplicitCastExpr {
|
||||
override PpAst getChild(int i) {
|
||||
i = 0 and result = this.getExpr()
|
||||
}
|
||||
override PpAst getChild(int i) { i = 0 and result = this.getExpr() }
|
||||
}
|
||||
|
||||
private class PpImplicitNotNullExpr extends PpAst, ImplicitNotNullExpr {
|
||||
override PpAst getChild(int i) {
|
||||
i = 0 and result = this.getExpr()
|
||||
}
|
||||
override PpAst getChild(int i) { i = 0 and result = this.getExpr() }
|
||||
}
|
||||
|
||||
private class PpImplicitCoercionToUnitExpr extends PpAst, ImplicitCoercionToUnitExpr {
|
||||
override PpAst getChild(int i) {
|
||||
i = 0 and result = this.getExpr()
|
||||
}
|
||||
override PpAst getChild(int i) { i = 0 and result = this.getExpr() }
|
||||
}
|
||||
|
||||
private class PpCall extends PpAst, Call {
|
||||
|
||||
@@ -700,14 +700,10 @@ class Class extends ClassOrInterface, @class {
|
||||
|
||||
/** A Kotlin `object`. */
|
||||
class ClassObject extends Class {
|
||||
ClassObject() {
|
||||
class_object(this, _)
|
||||
}
|
||||
ClassObject() { class_object(this, _) }
|
||||
|
||||
/** Gets the instance variable that implements this `object`. */
|
||||
Field getInstance() {
|
||||
class_object(this, result)
|
||||
}
|
||||
Field getInstance() { class_object(this, result) }
|
||||
}
|
||||
|
||||
/** A Kotlin `companion object`. */
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import java
|
||||
|
||||
from AssignOp ae
|
||||
select ae, ae.getOp(), ae.getType().toString(), ae.getDest(), ae.getDest().getType().toString(), ae.getRhs(), ae.getRhs().getType().toString()
|
||||
select ae, ae.getOp(), ae.getType().toString(), ae.getDest(), ae.getDest().getType().toString(),
|
||||
ae.getRhs(), ae.getRhs().getType().toString()
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import java
|
||||
|
||||
class InterestingParameter extends Parameter {
|
||||
InterestingParameter() {
|
||||
this.getFile().getBaseName() = "primitiveArrays.kt"
|
||||
}
|
||||
InterestingParameter() { this.getFile().getBaseName() = "primitiveArrays.kt" }
|
||||
}
|
||||
|
||||
from InterestingParameter p, Array a, KotlinType ktType
|
||||
where p.getType() = a and ktType = p.getKotlinType()
|
||||
select p, a, a.getComponentType().toString(), a.getElementType().toString(), ktType
|
||||
|
||||
query predicate cloneMethods(Method m, string signature, Array declType, Type returnType, KotlinType ktReturnType) {
|
||||
query predicate cloneMethods(
|
||||
Method m, string signature, Array declType, Type returnType, KotlinType ktReturnType
|
||||
) {
|
||||
any(InterestingParameter p).getType() = declType and
|
||||
signature = m.getSignature() and
|
||||
declType = m.getDeclaringType() and
|
||||
|
||||
@@ -3,4 +3,3 @@ import java
|
||||
from Class c
|
||||
where c.fromSource()
|
||||
select c, c.getQualifiedName(), concat(string s | c.hasModifier(s) | s, ", ")
|
||||
|
||||
|
||||
@@ -3,4 +3,3 @@ import java
|
||||
from Interface i
|
||||
where i.fromSource()
|
||||
select i
|
||||
|
||||
|
||||
@@ -3,15 +3,14 @@ import java
|
||||
// Stop external filepaths from appearing in the results
|
||||
class ClassOrInterfaceLocation extends ClassOrInterface {
|
||||
override predicate hasLocationInfo(string path, int sl, int sc, int el, int ec) {
|
||||
exists(string fullPath |
|
||||
super.hasLocationInfo(fullPath, sl, sc, el, ec) |
|
||||
if exists(this.getFile().getRelativePath())
|
||||
then path = fullPath
|
||||
else path = fullPath.regexpReplaceAll(".*/", "<external>/"))
|
||||
exists(string fullPath | super.hasLocationInfo(fullPath, sl, sc, el, ec) |
|
||||
if exists(this.getFile().getRelativePath())
|
||||
then path = fullPath
|
||||
else path = fullPath.regexpReplaceAll(".*/", "<external>/")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
from ParameterizedClass c, int i
|
||||
where c.getSourceDeclaration().fromSource()
|
||||
select c, i, c.getTypeArgument(i)
|
||||
|
||||
|
||||
@@ -3,16 +3,16 @@ import java
|
||||
// Stop external filepaths from appearing in the results
|
||||
class ClassOrInterfaceLocation extends ClassOrInterface {
|
||||
override predicate hasLocationInfo(string path, int sl, int sc, int el, int ec) {
|
||||
exists(string fullPath |
|
||||
super.hasLocationInfo(fullPath, sl, sc, el, ec) |
|
||||
if exists(this.getFile().getRelativePath())
|
||||
then path = fullPath
|
||||
else path = fullPath.regexpReplaceAll(".*/", "<external>/"))
|
||||
exists(string fullPath | super.hasLocationInfo(fullPath, sl, sc, el, ec) |
|
||||
if exists(this.getFile().getRelativePath())
|
||||
then path = fullPath
|
||||
else path = fullPath.regexpReplaceAll(".*/", "<external>/")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
from Class c, Type superType
|
||||
where c.getSourceDeclaration().fromSource() and
|
||||
superType = c.getASupertype()
|
||||
where
|
||||
c.getSourceDeclaration().fromSource() and
|
||||
superType = c.getASupertype()
|
||||
select c, superType
|
||||
|
||||
|
||||
@@ -6,22 +6,31 @@ newtype TMaybeControlFlowNode =
|
||||
|
||||
class MaybeControlFlowNode extends TMaybeControlFlowNode {
|
||||
abstract string toString();
|
||||
|
||||
abstract Location getLocation();
|
||||
|
||||
abstract string getPrimaryQlClasses();
|
||||
}
|
||||
|
||||
class YesMaybeControlFlowNode extends MaybeControlFlowNode {
|
||||
ControlFlowNode c;
|
||||
|
||||
YesMaybeControlFlowNode() { this = TControlFlowNode(c) }
|
||||
|
||||
override string toString() { result = c.toString() }
|
||||
|
||||
override Location getLocation() { result = c.getLocation() }
|
||||
|
||||
override string getPrimaryQlClasses() { result = c.getPrimaryQlClasses() }
|
||||
}
|
||||
|
||||
class NoMaybeControlFlowNode extends MaybeControlFlowNode {
|
||||
NoMaybeControlFlowNode() { this = TNoControlFlowNode() }
|
||||
|
||||
override string toString() { result = "<none>" }
|
||||
|
||||
override Location getLocation() { result.toString() = "file://:0:0:0:0" }
|
||||
|
||||
override string getPrimaryQlClasses() { result = "<none>" }
|
||||
}
|
||||
|
||||
@@ -32,7 +41,7 @@ MaybeControlFlowNode maybeSuccessor(ControlFlowNode n) {
|
||||
}
|
||||
|
||||
from ControlFlowNode n, MaybeControlFlowNode m
|
||||
where m = maybeSuccessor(n)
|
||||
and n.getFile().(CompilationUnit).fromSource()
|
||||
where
|
||||
m = maybeSuccessor(n) and
|
||||
n.getFile().(CompilationUnit).fromSource()
|
||||
select n, n.getPrimaryQlClasses(), m, m.getPrimaryQlClasses()
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ newtype TMaybeElement =
|
||||
|
||||
class MaybeElement extends TMaybeElement {
|
||||
abstract string toString();
|
||||
|
||||
abstract Location getLocation();
|
||||
}
|
||||
|
||||
@@ -13,7 +14,9 @@ class YesMaybeElement extends MaybeElement {
|
||||
Element e;
|
||||
|
||||
YesMaybeElement() { this = TElement(e) }
|
||||
|
||||
override string toString() { result = e.toString() }
|
||||
|
||||
override Location getLocation() { result = e.getLocation() }
|
||||
}
|
||||
|
||||
@@ -21,6 +24,7 @@ class NoMaybeElement extends MaybeElement {
|
||||
NoMaybeElement() { this = TNoElement() }
|
||||
|
||||
override string toString() { result = "<none>" }
|
||||
|
||||
override Location getLocation() { none() }
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ newtype TMaybeElement =
|
||||
|
||||
class MaybeElement extends TMaybeElement {
|
||||
abstract string toString();
|
||||
|
||||
abstract Location getLocation();
|
||||
}
|
||||
|
||||
@@ -13,7 +14,9 @@ class YesMaybeElement extends MaybeElement {
|
||||
Element e;
|
||||
|
||||
YesMaybeElement() { this = TElement(e) }
|
||||
|
||||
override string toString() { result = e.toString() }
|
||||
|
||||
override Location getLocation() { result = e.getLocation() }
|
||||
}
|
||||
|
||||
@@ -21,6 +24,7 @@ class NoMaybeElement extends MaybeElement {
|
||||
NoMaybeElement() { this = TNoElement() }
|
||||
|
||||
override string toString() { result = "<none>" }
|
||||
|
||||
override Location getLocation() { none() }
|
||||
}
|
||||
|
||||
|
||||
@@ -3,14 +3,14 @@ import java
|
||||
// Stop external filepaths from appearing in the results
|
||||
class ClassOrInterfaceLocation extends ClassOrInterface {
|
||||
override predicate hasLocationInfo(string path, int sl, int sc, int el, int ec) {
|
||||
exists(string fullPath |
|
||||
super.hasLocationInfo(fullPath, sl, sc, el, ec) |
|
||||
if exists(this.getFile().getRelativePath())
|
||||
then path = fullPath
|
||||
else path = fullPath.regexpReplaceAll(".*/", "<external>/"))
|
||||
exists(string fullPath | super.hasLocationInfo(fullPath, sl, sc, el, ec) |
|
||||
if exists(this.getFile().getRelativePath())
|
||||
then path = fullPath
|
||||
else path = fullPath.regexpReplaceAll(".*/", "<external>/")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
from Method m
|
||||
where m.fromSource()
|
||||
select m, m.getReturnType()
|
||||
select m, m.getReturnType()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import java
|
||||
|
||||
from MethodAccess c
|
||||
select c, c.getCallee(), c.getCallee().getDeclaringType(), c.getCallee().getDeclaringType().(NestedType).getEnclosingType()
|
||||
select c, c.getCallee(), c.getCallee().getDeclaringType(),
|
||||
c.getCallee().getDeclaringType().(NestedType).getEnclosingType()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import java
|
||||
|
||||
from MethodAccess c
|
||||
select c, c.getCallee(), c.getCallee().getDeclaringType(), c.getCallee().getDeclaringType().(NestedType).getEnclosingType()
|
||||
select c, c.getCallee(), c.getCallee().getDeclaringType(),
|
||||
c.getCallee().getDeclaringType().(NestedType).getEnclosingType()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import java
|
||||
|
||||
from MethodAccess c
|
||||
select c, c.getCallee(), c.getCallee().getDeclaringType(), c.getCallee().getDeclaringType().(NestedType).getEnclosingType()
|
||||
select c, c.getCallee(), c.getCallee().getDeclaringType(),
|
||||
c.getCallee().getDeclaringType().(NestedType).getEnclosingType()
|
||||
|
||||
@@ -2,4 +2,5 @@ import java
|
||||
|
||||
from Parameter p
|
||||
where p.fromSource()
|
||||
select p, p.getType().toString(), p.getType().getFile().getBaseName(), p.getType().getLocation().getStartLine()
|
||||
select p, p.getType().toString(), p.getType().getFile().getBaseName(),
|
||||
p.getType().getLocation().getStartLine()
|
||||
|
||||
@@ -6,17 +6,20 @@ string paramTypeIfPresent(Callable m) {
|
||||
else result = "No parameters"
|
||||
}
|
||||
|
||||
query predicate calls(MethodAccess ma, Callable caller, RefType callerType, Callable called, RefType calledType) {
|
||||
|
||||
query predicate calls(
|
||||
MethodAccess ma, Callable caller, RefType callerType, Callable called, RefType calledType
|
||||
) {
|
||||
ma.getEnclosingCallable() = caller and
|
||||
ma.getCallee() = called and
|
||||
caller.fromSource() and
|
||||
callerType = caller.getDeclaringType() and
|
||||
calledType = called.getDeclaringType()
|
||||
|
||||
}
|
||||
|
||||
query predicate constructors(RefType t, Constructor c, string signature, string paramType, string returnType, RefType sourceDeclType, Constructor sourceDecl) {
|
||||
query predicate constructors(
|
||||
RefType t, Constructor c, string signature, string paramType, string returnType,
|
||||
RefType sourceDeclType, Constructor sourceDecl
|
||||
) {
|
||||
t.getSourceDeclaration().fromSource() and
|
||||
c.getDeclaringType() = t and
|
||||
signature = c.getSignature() and
|
||||
@@ -31,13 +34,13 @@ query predicate constructorCalls(ConstructorCall cc, Constructor callee) {
|
||||
callee.getSourceDeclaration().fromSource()
|
||||
}
|
||||
|
||||
query predicate refTypes(RefType rt) {
|
||||
rt.fromSource()
|
||||
}
|
||||
query predicate refTypes(RefType rt) { rt.fromSource() }
|
||||
|
||||
from RefType t, Method m, Method sourceDecl, RefType sourceDeclType
|
||||
where t.getSourceDeclaration().fromSource()
|
||||
and m.getDeclaringType() = t
|
||||
and sourceDecl = m.getSourceDeclaration()
|
||||
and sourceDeclType = sourceDecl.getDeclaringType()
|
||||
select t, m, m.getSignature(), paramTypeIfPresent(m), m.getReturnType().toString(), sourceDeclType, sourceDecl
|
||||
where
|
||||
t.getSourceDeclaration().fromSource() and
|
||||
m.getDeclaringType() = t and
|
||||
sourceDecl = m.getSourceDeclaration() and
|
||||
sourceDeclType = sourceDecl.getDeclaringType()
|
||||
select t, m, m.getSignature(), paramTypeIfPresent(m), m.getReturnType().toString(), sourceDeclType,
|
||||
sourceDecl
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import java
|
||||
|
||||
from MethodAccess ma
|
||||
select ma.getQualifier(), ma.getCallee(), ma.getCallee().getSignature(), ma.getCallee().getAParamType().toString(), ma.getCallee().getDeclaringType()
|
||||
select ma.getQualifier(), ma.getCallee(), ma.getCallee().getSignature(),
|
||||
ma.getCallee().getAParamType().toString(), ma.getCallee().getDeclaringType()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import java
|
||||
|
||||
from RefType rt, Member m
|
||||
where rt.getSourceDeclaration().fromSource()
|
||||
and m.getDeclaringType() = rt
|
||||
where
|
||||
rt.getSourceDeclaration().fromSource() and
|
||||
m.getDeclaringType() = rt
|
||||
select rt, m
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
import java
|
||||
|
||||
query predicate classTVs(TypeVariable tv, GenericType declType, string bound) {
|
||||
tv.getGenericType() = declType and tv.getUpperBoundType().toString() = bound and declType.fromSource()
|
||||
tv.getGenericType() = declType and
|
||||
tv.getUpperBoundType().toString() = bound and
|
||||
declType.fromSource()
|
||||
}
|
||||
|
||||
query predicate functionTVs(TypeVariable tv, GenericCallable callable, string bound) {
|
||||
tv.getGenericCallable() = callable and tv.getUpperBoundType().toString() = bound and callable.fromSource()
|
||||
tv.getGenericCallable() = callable and
|
||||
tv.getUpperBoundType().toString() = bound and
|
||||
callable.fromSource()
|
||||
}
|
||||
|
||||
@@ -7,10 +7,11 @@ RefType getADatabaseSubtype(RefType rt) {
|
||||
}
|
||||
|
||||
from Parameter p, RefType paramType, KotlinType paramKtType, string paramAncestorType
|
||||
where p.fromSource()
|
||||
and p.getCallable().getName() = "user"
|
||||
and p.getType() = paramType
|
||||
and p.getKotlinType() = paramKtType
|
||||
// Stringified to avoid printing the source-location (i.e. stdlib path) of `Any?`
|
||||
and getADatabaseSubtype+(paramType).toString() = paramAncestorType
|
||||
select p, paramType, paramKtType, paramAncestorType
|
||||
where
|
||||
p.fromSource() and
|
||||
p.getCallable().getName() = "user" and
|
||||
p.getType() = paramType and
|
||||
p.getKotlinType() = paramKtType and
|
||||
// Stringified to avoid printing the source-location (i.e. stdlib path) of `Any?`
|
||||
getADatabaseSubtype+(paramType).toString() = paramAncestorType
|
||||
select p, paramType, paramKtType, paramAncestorType
|
||||
|
||||
@@ -7,6 +7,8 @@ query predicate methods(RefType declType, Method m, string signature, string mod
|
||||
modifiers = concat(string s | m.hasModifier(s) | s, ", ")
|
||||
}
|
||||
|
||||
query predicate constructors(RefType declType, Constructor c, string signature) { c.fromSource() and declType = c.getDeclaringType() and signature = c.getSignature() }
|
||||
query predicate constructors(RefType declType, Constructor c, string signature) {
|
||||
c.fromSource() and declType = c.getDeclaringType() and signature = c.getSignature()
|
||||
}
|
||||
|
||||
query predicate extensions(ExtensionMethod m, Type t) { m.getExtendedType() = t and m.fromSource() }
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import java
|
||||
|
||||
from Method m, Parameter p, int i
|
||||
where m.getParameter(i) = p
|
||||
and m.fromSource()
|
||||
where
|
||||
m.getParameter(i) = p and
|
||||
m.fromSource()
|
||||
select m, p, i
|
||||
|
||||
@@ -3,5 +3,4 @@ import java
|
||||
from File f
|
||||
where f.isSourceFile()
|
||||
select f
|
||||
|
||||
// This test is mainly a consistency test; just checking that both the Java and Kotlin source were extracted here
|
||||
|
||||
@@ -3,4 +3,3 @@ import java
|
||||
from Class c
|
||||
where c.fromSource()
|
||||
select c, c.getQualifiedName()
|
||||
|
||||
|
||||
@@ -3,25 +3,26 @@ import java
|
||||
// Stop external filepaths from appearing in the results
|
||||
class ClassOrInterfaceLocation extends ClassOrInterface {
|
||||
override predicate hasLocationInfo(string path, int sl, int sc, int el, int ec) {
|
||||
exists(string fullPath |
|
||||
super.hasLocationInfo(fullPath, sl, sc, el, ec) |
|
||||
if exists(this.getFile().getRelativePath())
|
||||
then path = fullPath
|
||||
else path = fullPath.regexpReplaceAll(".*/", "<external>/"))
|
||||
exists(string fullPath | super.hasLocationInfo(fullPath, sl, sc, el, ec) |
|
||||
if exists(this.getFile().getRelativePath())
|
||||
then path = fullPath
|
||||
else path = fullPath.regexpReplaceAll(".*/", "<external>/")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class MethodLocation extends Method {
|
||||
override predicate hasLocationInfo(string path, int sl, int sc, int el, int ec) {
|
||||
exists(string fullPath |
|
||||
super.hasLocationInfo(fullPath, sl, sc, el, ec) |
|
||||
if exists(this.getFile().getRelativePath())
|
||||
then path = fullPath
|
||||
else path = fullPath.regexpReplaceAll(".*/", "<external>/"))
|
||||
exists(string fullPath | super.hasLocationInfo(fullPath, sl, sc, el, ec) |
|
||||
if exists(this.getFile().getRelativePath())
|
||||
then path = fullPath
|
||||
else path = fullPath.regexpReplaceAll(".*/", "<external>/")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
from MethodAccess ma, Method m
|
||||
where ma.getFile().(CompilationUnit).fromSource()
|
||||
and m = ma.getMethod()
|
||||
where
|
||||
ma.getFile().(CompilationUnit).fromSource() and
|
||||
m = ma.getMethod()
|
||||
select ma, m, m.getQualifiedName(), m.getDeclaringType()
|
||||
|
||||
|
||||
@@ -3,4 +3,3 @@ import java
|
||||
from Method m
|
||||
where m.fromSource()
|
||||
select m, m.getQualifiedName(), m.getDeclaringType()
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import java
|
||||
|
||||
from ClassObject co, Field f
|
||||
where co.fromSource()
|
||||
and f = co.getInstance()
|
||||
where
|
||||
co.fromSource() and
|
||||
f = co.getInstance()
|
||||
select co, f, concat(f.getAModifier().toString(), ",")
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import java
|
||||
|
||||
from KtComment c, string s, int len
|
||||
where s = c.getText()
|
||||
and len = s.length()
|
||||
where
|
||||
s = c.getText() and
|
||||
len = s.length() and
|
||||
// Ignore the comments that are describing what's going on, and only
|
||||
// select the large ones
|
||||
and len > 1000
|
||||
select c.getLocation(),
|
||||
len,
|
||||
s.prefix(5) + "..." + s.suffix(len - 5),
|
||||
c.getPrimaryQlClasses()
|
||||
len > 1000
|
||||
select c.getLocation(), len, s.prefix(5) + "..." + s.suffix(len - 5), c.getPrimaryQlClasses()
|
||||
|
||||
@@ -2,4 +2,6 @@ import semmle.code.java.Diagnostics
|
||||
|
||||
from Diagnostic d
|
||||
select d, d.getGeneratedBy(), d.getSeverity(), d.getTag(), d.getMessage(),
|
||||
d.getFullMessage().regexpReplaceAll("^\\[[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} K\\] ", "[DATE TIME K] ")
|
||||
d.getFullMessage()
|
||||
.regexpReplaceAll("^\\[[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} K\\] ",
|
||||
"[DATE TIME K] ")
|
||||
|
||||
@@ -2,7 +2,5 @@ import java
|
||||
|
||||
from Literal l, int len
|
||||
where len = l.getValue().length()
|
||||
select l.getLocation(),
|
||||
len,
|
||||
l.getValue().prefix(5) + "..." + l.getValue().suffix(len - 5),
|
||||
l.getPrimaryQlClasses()
|
||||
select l.getLocation(), len, l.getValue().prefix(5) + "..." + l.getValue().suffix(len - 5),
|
||||
l.getPrimaryQlClasses()
|
||||
|
||||
@@ -3,16 +3,16 @@ import java
|
||||
// Stop external filepaths from appearing in the results
|
||||
class ClassOrInterfaceLocation extends ClassOrInterface {
|
||||
override predicate hasLocationInfo(string path, int sl, int sc, int el, int ec) {
|
||||
exists(string fullPath |
|
||||
super.hasLocationInfo(fullPath, sl, sc, el, ec) |
|
||||
if exists(this.getFile().getRelativePath())
|
||||
then path = fullPath
|
||||
else path = fullPath.regexpReplaceAll(".*/", "<external>/"))
|
||||
exists(string fullPath | super.hasLocationInfo(fullPath, sl, sc, el, ec) |
|
||||
if exists(this.getFile().getRelativePath())
|
||||
then path = fullPath
|
||||
else path = fullPath.regexpReplaceAll(".*/", "<external>/")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
from Method m, int i, Parameter p
|
||||
where m.getName().matches("foo%")
|
||||
and p = m.getParameter(i)
|
||||
where
|
||||
m.getName().matches("foo%") and
|
||||
p = m.getParameter(i)
|
||||
select m, m.getReturnType(), i, p, p.getType()
|
||||
|
||||
|
||||
@@ -2,4 +2,3 @@ import java
|
||||
|
||||
from Type t
|
||||
select t.toString(), concat(t.getAPrimaryQlClass(), ", ")
|
||||
|
||||
|
||||
@@ -15,4 +15,4 @@ class Config extends DataFlow::Configuration {
|
||||
|
||||
from DataFlow::Node source, DataFlow::Node sink, Config c
|
||||
where c.hasFlow(source, sink)
|
||||
select source, sink
|
||||
select source, sink
|
||||
|
||||
@@ -6,6 +6,7 @@ newtype TMaybeExpr =
|
||||
|
||||
class MaybeExpr extends TMaybeExpr {
|
||||
abstract string toString();
|
||||
|
||||
abstract Location getLocation();
|
||||
}
|
||||
|
||||
@@ -13,7 +14,9 @@ class YesMaybeExpr extends MaybeExpr {
|
||||
Expr c;
|
||||
|
||||
YesMaybeExpr() { this = TExpr(c) }
|
||||
|
||||
override string toString() { result = c.toString() }
|
||||
|
||||
override Location getLocation() { result = c.getLocation() }
|
||||
}
|
||||
|
||||
@@ -21,16 +24,14 @@ class NoMaybeExpr extends MaybeExpr {
|
||||
NoMaybeExpr() { this = TNoExpr() }
|
||||
|
||||
override string toString() { result = "<none>" }
|
||||
|
||||
override Location getLocation() { none() }
|
||||
}
|
||||
|
||||
MaybeExpr initializer(Variable v) {
|
||||
if exists(v.getInitializer())
|
||||
then result = TExpr(v.getInitializer())
|
||||
else result = TNoExpr()
|
||||
if exists(v.getInitializer()) then result = TExpr(v.getInitializer()) else result = TNoExpr()
|
||||
}
|
||||
|
||||
from Variable v
|
||||
where v.fromSource()
|
||||
select v, v.getType().toString(), initializer(v)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user