mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Kotlin: Add KotlinType to params
This commit is contained in:
@@ -894,9 +894,9 @@ open class KotlinFileExtractor(
|
||||
|
||||
fun extractValueParameter(vp: IrValueParameter, parent: Label<out DbCallable>, idx: Int) {
|
||||
val id = useValueParameter(vp)
|
||||
val typeId = useTypeOld(vp.type)
|
||||
val type = useType(vp.type)
|
||||
val locId = tw.getLocation(vp.startOffset, vp.endOffset)
|
||||
tw.writeParams(id, typeId, idx, parent, id)
|
||||
tw.writeParams(id, type.javaResult.id, type.kotlinResult.id, idx, parent, id)
|
||||
tw.writeHasLocation(id, locId)
|
||||
tw.writeParamName(id, vp.name.asString())
|
||||
}
|
||||
|
||||
@@ -382,6 +382,7 @@ methods(
|
||||
params(
|
||||
unique int id: @param,
|
||||
int typeid: @type ref,
|
||||
int kttypeid: @kt_type ref,
|
||||
int pos: int ref,
|
||||
int parentid: @callable ref,
|
||||
int sourceid: @param ref
|
||||
|
||||
@@ -29,7 +29,7 @@ predicate hasName(Element e, string name) {
|
||||
paramName(e, name)
|
||||
or
|
||||
exists(int pos |
|
||||
params(e, _, pos, _, _) and
|
||||
params(e, _, pos, _, _, _) and
|
||||
not paramName(e, _) and
|
||||
name = "p" + pos
|
||||
)
|
||||
|
||||
@@ -61,7 +61,7 @@ private predicate hasChildElement(Element parent, Element e) {
|
||||
or
|
||||
constrs(e, _, _, _, _, parent, _)
|
||||
or
|
||||
params(e, _, _, parent, _)
|
||||
params(e, _, _, _, parent, _)
|
||||
or
|
||||
fields(e, _, _, _, parent, _)
|
||||
or
|
||||
|
||||
@@ -186,10 +186,13 @@ class Callable extends StmtParent, Member, @callable {
|
||||
Parameter getAParameter() { result.getCallable() = this }
|
||||
|
||||
/** Gets the formal parameter at the specified (zero-based) position. */
|
||||
Parameter getParameter(int n) { params(result, _, n, this, _) }
|
||||
Parameter getParameter(int n) { params(result, _, _, n, this, _) }
|
||||
|
||||
/** Gets the type of the formal parameter at the specified (zero-based) position. */
|
||||
Type getParameterType(int n) { params(_, result, n, this, _) }
|
||||
Type getParameterType(int n) { params(_, result, _, n, this, _) }
|
||||
|
||||
/** Gets the type of the formal parameter at the specified (zero-based) position. */
|
||||
KotlinType getParameterKotlinType(int n) { params(_, _, result, n, this, _) }
|
||||
|
||||
/**
|
||||
* Gets the signature of this callable, including its name and the types of all
|
||||
|
||||
@@ -60,19 +60,22 @@ class LocalVariableDecl extends @localvar, LocalScopeVariable {
|
||||
/** A formal parameter of a callable. */
|
||||
class Parameter extends Element, @param, LocalScopeVariable {
|
||||
/** Gets the type of this formal parameter. */
|
||||
override Type getType() { params(this, result, _, _, _) }
|
||||
override Type getType() { params(this, result, _, _, _, _) }
|
||||
|
||||
/** Gets the Kotlin type of this formal parameter. */
|
||||
override KotlinType getKotlinType() { params(this, _, result, _, _, _) }
|
||||
|
||||
/** Holds if the parameter is never assigned a value in the body of the callable. */
|
||||
predicate isEffectivelyFinal() { not exists(this.getAnAssignedValue()) }
|
||||
|
||||
/** Gets the (zero-based) index of this formal parameter. */
|
||||
int getPosition() { params(this, _, result, _, _) }
|
||||
int getPosition() { params(this, _, _, result, _, _) }
|
||||
|
||||
/** Gets the callable that declares this formal parameter. */
|
||||
override Callable getCallable() { params(this, _, _, result, _) }
|
||||
override Callable getCallable() { params(this, _, _, _, result, _) }
|
||||
|
||||
/** Gets the source declaration of this formal parameter. */
|
||||
Parameter getSourceDeclaration() { params(this, _, _, _, result) }
|
||||
Parameter getSourceDeclaration() { params(this, _, _, _, _, result) }
|
||||
|
||||
/** Holds if this formal parameter is the same as its source declaration. */
|
||||
predicate isSourceDeclaration() { this.getSourceDeclaration() = this }
|
||||
|
||||
Reference in New Issue
Block a user