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

Skip to content

Commit 6cf0b75

Browse files
committed
Kotlin: Add KotlinType to localvars
1 parent 06a41b3 commit 6cf0b75

5 files changed

Lines changed: 10 additions & 6 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ open class KotlinFileExtractor(
10611061
val exprId = tw.getFreshIdLabel<DbLocalvariabledeclexpr>()
10621062
val locId = tw.getLocation(v)
10631063
val type = useType(v.type)
1064-
tw.writeLocalvars(varId, v.name.asString(), type.javaResult.id, exprId) // TODO: KT type
1064+
tw.writeLocalvars(varId, v.name.asString(), type.javaResult.id, type.kotlinResult.id, exprId)
10651065
tw.writeHasLocation(varId, locId)
10661066
tw.writeExprs_localvariabledeclexpr(exprId, type.javaResult.id, type.kotlinResult.id, parent, idx)
10671067
tw.writeHasLocation(exprId, locId)

java/ql/lib/config/semmlecode.dbscheme

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,7 @@ localvars(
785785
unique int id: @localvar,
786786
string nodeName: string ref,
787787
int typeid: @type ref,
788+
int kttypeid: @kt_type ref,
788789
int parentid: @localvariabledeclexpr ref
789790
);
790791

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ predicate hasName(Element e, string name) {
3434
name = "p" + pos
3535
)
3636
or
37-
localvars(e, name, _, _)
37+
localvars(e, name, _, _, _)
3838
or
3939
typeVars(e, name, _, _, _)
4040
or

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,7 @@ class LocalVariableDeclExpr extends Expr, @localvariabledeclexpr {
14901490
VarAccess getAnAccess() { variableBinding(result, this.getVariable()) }
14911491

14921492
/** Gets the local variable declared by this local variable declaration expression. */
1493-
LocalVariableDecl getVariable() { localvars(result, _, _, this) }
1493+
LocalVariableDecl getVariable() { localvars(result, _, _, _, this) }
14941494

14951495
/** Gets the type access of this local variable declaration expression. */
14961496
Expr getTypeAccess() {

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,16 @@ class LocalScopeVariable extends Variable, @localscopevariable {
3838
/** A local variable declaration */
3939
class LocalVariableDecl extends @localvar, LocalScopeVariable {
4040
/** Gets the type of this local variable. */
41-
override Type getType() { localvars(this, _, result, _) }
41+
override Type getType() { localvars(this, _, result, _, _) }
42+
43+
/** Gets the Kotlin type of this local variable. */
44+
override KotlinType getKotlinType() { localvars(this, _, _, result, _) }
4245

4346
/** Gets the expression declaring this variable. */
44-
LocalVariableDeclExpr getDeclExpr() { localvars(this, _, _, result) }
47+
LocalVariableDeclExpr getDeclExpr() { localvars(this, _, _, _, result) }
4548

4649
/** Gets the parent of this declaration. */
47-
Expr getParent() { localvars(this, _, _, result) }
50+
Expr getParent() { localvars(this, _, _, _, result) }
4851

4952
/** Gets the callable in which this declaration occurs. */
5053
override Callable getCallable() { result = this.getParent().getEnclosingCallable() }

0 commit comments

Comments
 (0)