Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ef22194

Browse files
committed
Kotlin: Add KotlinType to params
1 parent 0d5e471 commit ef22194

6 files changed

Lines changed: 17 additions & 10 deletions

File tree

java/kotlin-extractor/src/main/kotlin/KotlinExtractorExtension.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -894,9 +894,9 @@ open class KotlinFileExtractor(
894894

895895
fun extractValueParameter(vp: IrValueParameter, parent: Label<out DbCallable>, idx: Int) {
896896
val id = useValueParameter(vp)
897-
val typeId = useTypeOld(vp.type)
897+
val type = useType(vp.type)
898898
val locId = tw.getLocation(vp.startOffset, vp.endOffset)
899-
tw.writeParams(id, typeId, idx, parent, id)
899+
tw.writeParams(id, type.javaResult.id, type.kotlinResult.id, idx, parent, id)
900900
tw.writeHasLocation(id, locId)
901901
tw.writeParamName(id, vp.name.asString())
902902
}

java/ql/lib/config/semmlecode.dbscheme

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ methods(
382382
params(
383383
unique int id: @param,
384384
int typeid: @type ref,
385+
int kttypeid: @kt_type ref,
385386
int pos: int ref,
386387
int parentid: @callable ref,
387388
int sourceid: @param ref

java/ql/lib/semmle/code/Location.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ predicate hasName(Element e, string name) {
2929
paramName(e, name)
3030
or
3131
exists(int pos |
32-
params(e, _, pos, _, _) and
32+
params(e, _, pos, _, _, _) and
3333
not paramName(e, _) and
3434
name = "p" + pos
3535
)

java/ql/lib/semmle/code/java/Element.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private predicate hasChildElement(Element parent, Element e) {
6161
or
6262
constrs(e, _, _, _, _, parent, _)
6363
or
64-
params(e, _, _, parent, _)
64+
params(e, _, _, _, parent, _)
6565
or
6666
fields(e, _, _, _, parent, _)
6767
or

java/ql/lib/semmle/code/java/Member.qll

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,13 @@ class Callable extends StmtParent, Member, @callable {
186186
Parameter getAParameter() { result.getCallable() = this }
187187

188188
/** Gets the formal parameter at the specified (zero-based) position. */
189-
Parameter getParameter(int n) { params(result, _, n, this, _) }
189+
Parameter getParameter(int n) { params(result, _, _, n, this, _) }
190190

191191
/** Gets the type of the formal parameter at the specified (zero-based) position. */
192-
Type getParameterType(int n) { params(_, result, n, this, _) }
192+
Type getParameterType(int n) { params(_, result, _, n, this, _) }
193+
194+
/** Gets the type of the formal parameter at the specified (zero-based) position. */
195+
KotlinType getParameterKotlinType(int n) { params(_, _, result, n, this, _) }
193196

194197
/**
195198
* Gets the signature of this callable, including its name and the types of all

java/ql/lib/semmle/code/java/Variable.qll

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,22 @@ class LocalVariableDecl extends @localvar, LocalScopeVariable {
6060
/** A formal parameter of a callable. */
6161
class Parameter extends Element, @param, LocalScopeVariable {
6262
/** Gets the type of this formal parameter. */
63-
override Type getType() { params(this, result, _, _, _) }
63+
override Type getType() { params(this, result, _, _, _, _) }
64+
65+
/** Gets the Kotlin type of this formal parameter. */
66+
override KotlinType getKotlinType() { params(this, _, result, _, _, _) }
6467

6568
/** Holds if the parameter is never assigned a value in the body of the callable. */
6669
predicate isEffectivelyFinal() { not exists(this.getAnAssignedValue()) }
6770

6871
/** Gets the (zero-based) index of this formal parameter. */
69-
int getPosition() { params(this, _, result, _, _) }
72+
int getPosition() { params(this, _, _, result, _, _) }
7073

7174
/** Gets the callable that declares this formal parameter. */
72-
override Callable getCallable() { params(this, _, _, result, _) }
75+
override Callable getCallable() { params(this, _, _, _, result, _) }
7376

7477
/** Gets the source declaration of this formal parameter. */
75-
Parameter getSourceDeclaration() { params(this, _, _, _, result) }
78+
Parameter getSourceDeclaration() { params(this, _, _, _, _, result) }
7679

7780
/** Holds if this formal parameter is the same as its source declaration. */
7881
predicate isSourceDeclaration() { this.getSourceDeclaration() = this }

0 commit comments

Comments
 (0)