Fix type access extraction in field declarations

This commit is contained in:
Tamas Vajk
2021-12-20 13:35:32 +01:00
committed by Ian Lynagh
parent e5003e4032
commit 6950f868fb
3 changed files with 16 additions and 8 deletions

View File

@@ -509,8 +509,7 @@ open class KotlinFileExtractor(
tw.writeFieldDeclaredIn(id, fieldDeclarationId, 0)
tw.writeHasLocation(fieldDeclarationId, locId)
val typeAccessId = tw.getFreshIdLabel<DbUnannotatedtypeaccess>()
tw.writeExprs_unannotatedtypeaccess(typeAccessId, type.javaResult.id, type.kotlinResult.id, fieldDeclarationId, 0)
extractTypeAccess(type, locId, fieldDeclarationId, 0)
}
return id
@@ -1948,14 +1947,19 @@ open class KotlinFileExtractor(
}
private fun extractTypeAccess(type: TypeResults, location: Label<DbLocation>, callable: Label<out DbCallable>, parent: Label<out DbExprparent>, idx: Int, enclosingStmt: Label<out DbStmt>): Label<out DbExpr> {
val id = extractTypeAccess(type, location, parent, idx)
tw.writeCallableEnclosingExpr(id, callable)
tw.writeStatementEnclosingExpr(id, enclosingStmt)
return id
}
private fun extractTypeAccess(type: TypeResults, location: Label<DbLocation>, parent: Label<out DbExprparent>, idx: Int): Label<out DbExpr> {
// TODO: elementForLocation allows us to give some sort of
// location, but a proper location for the type access will
// require upstream changes
val id = tw.getFreshIdLabel<DbUnannotatedtypeaccess>()
tw.writeExprs_unannotatedtypeaccess(id, type.javaResult.id, type.kotlinResult.id, parent, idx)
tw.writeHasLocation(id, location)
tw.writeCallableEnclosingExpr(id, callable)
tw.writeStatementEnclosingExpr(id, enclosingStmt)
return id
}

View File

@@ -748,6 +748,7 @@ exprs.kt:
# 142| 0: [ReturnStmt] return ...
# 142| 0: [VarAccess] n
# 142| 3: [FieldDeclaration] int n;
# 142| -1: [TypeAccess] int
# 143| 5: [Method] foo
# 143| 5: [BlockStmt] { ... }
# 143| 0: [ReturnStmt] return ...
@@ -809,6 +810,7 @@ exprs.kt:
# 172| 0: [ReturnStmt] return ...
# 172| 0: [VarAccess] rgb
# 172| 7: [FieldDeclaration] int rgb;
# 172| -1: [TypeAccess] int
# 183| 8: [Interface] Interface1
# 185| 9: [Class] Class1
# 185| 1: [Constructor] Class1
@@ -821,6 +823,7 @@ exprs.kt:
# 186| 0: [ReturnStmt] return ...
# 186| 0: [VarAccess] a1
# 186| 3: [FieldDeclaration] int a1;
# 186| -1: [TypeAccess] int
# 186| 0: [IntegerLiteral] 1
# 187| 5: [Method] getObject
# 187| 5: [BlockStmt] { ... }
@@ -842,6 +845,7 @@ exprs.kt:
# 190| 0: [ReturnStmt] return ...
# 190| 0: [VarAccess] a3
# 190| 3: [FieldDeclaration] String a3;
# 190| -1: [TypeAccess] String
# 190| 0: [MethodAccess] toString(...)
# 190| -1: [AddExpr] ... + ...
# 190| 0: [MethodAccess] getA1(...)

View File

@@ -476,6 +476,7 @@
| exprs.kt:139:13:139:16 | true | exprs.kt:138:1:140:1 | getClass | BooleanLiteral |
| exprs.kt:139:13:139:23 | ::class | exprs.kt:138:1:140:1 | getClass | ClassExpr |
| exprs.kt:142:1:144:1 | <obinit>(...) | exprs.kt:142:1:144:1 | C | MethodAccess |
| exprs.kt:142:9:142:18 | int | file://:0:0:0:0 | <none> | TypeAccess |
| exprs.kt:142:9:142:18 | n | exprs.kt:142:9:142:18 | getN | VarAccess |
| exprs.kt:143:27:143:31 | C | exprs.kt:143:5:143:33 | foo | TypeAccess |
| exprs.kt:143:27:143:31 | new C(...) | exprs.kt:143:5:143:33 | foo | ClassInstanceExpr |
@@ -539,6 +540,7 @@
| exprs.kt:172:1:176:1 | Color | exprs.kt:172:6:176:1 | Color | TypeAccess |
| exprs.kt:172:1:176:1 | Unit | exprs.kt:172:6:176:1 | Color | TypeAccess |
| exprs.kt:172:1:176:1 | new Enum(...) | exprs.kt:172:6:176:1 | Color | ClassInstanceExpr |
| exprs.kt:172:18:172:29 | int | file://:0:0:0:0 | <none> | TypeAccess |
| exprs.kt:172:18:172:29 | rgb | exprs.kt:172:18:172:29 | getRgb | VarAccess |
| exprs.kt:179:5:179:31 | south | exprs.kt:178:1:181:1 | enums | LocalVariableDeclExpr |
| exprs.kt:179:27:179:31 | SOUTH | exprs.kt:178:1:181:1 | enums | VarAccess |
@@ -548,6 +550,7 @@
| exprs.kt:186:5:186:14 | ...=... | exprs.kt:185:1:193:1 | <obinit> | AssignExpr |
| exprs.kt:186:5:186:14 | a1 | exprs.kt:185:1:193:1 | <obinit> | VarAccess |
| exprs.kt:186:5:186:14 | a1 | exprs.kt:186:5:186:14 | getA1 | VarAccess |
| exprs.kt:186:5:186:14 | int | file://:0:0:0:0 | <none> | TypeAccess |
| exprs.kt:186:14:186:14 | 1 | exprs.kt:185:1:193:1 | <obinit> | IntegerLiteral |
| exprs.kt:188:9:188:18 | a2 | exprs.kt:187:13:192:5 | getObject | LocalVariableDeclExpr |
| exprs.kt:188:18:188:18 | 2 | exprs.kt:187:13:192:5 | getObject | IntegerLiteral |
@@ -556,6 +559,7 @@
| exprs.kt:189:16:191:9 | Interface1 | exprs.kt:187:13:192:5 | getObject | TypeAccess |
| exprs.kt:189:16:191:9 | new (...) | exprs.kt:187:13:192:5 | getObject | ClassInstanceExpr |
| exprs.kt:190:13:190:49 | ...=... | exprs.kt:189:16:191:9 | <obinit> | AssignExpr |
| exprs.kt:190:13:190:49 | String | file://:0:0:0:0 | <none> | TypeAccess |
| exprs.kt:190:13:190:49 | a3 | exprs.kt:189:16:191:9 | <obinit> | VarAccess |
| exprs.kt:190:13:190:49 | a3 | exprs.kt:190:13:190:49 | getA3 | VarAccess |
| exprs.kt:190:31:190:32 | getA1(...) | exprs.kt:189:16:191:9 | <obinit> | MethodAccess |
@@ -608,10 +612,6 @@
| exprs.kt:220:5:220:29 | x | exprs.kt:219:1:221:1 | fnClassRef | LocalVariableDeclExpr |
| exprs.kt:220:13:220:29 | SomeClass1 | exprs.kt:219:1:221:1 | fnClassRef | TypeAccess |
| exprs.kt:220:13:220:29 | SomeClass1.class | exprs.kt:219:1:221:1 | fnClassRef | TypeLiteral |
| file://:0:0:0:0 | String | file://:0:0:0:0 | <none> | TypeAccess |
| file://:0:0:0:0 | int | file://:0:0:0:0 | <none> | TypeAccess |
| file://:0:0:0:0 | int | file://:0:0:0:0 | <none> | TypeAccess |
| file://:0:0:0:0 | int | file://:0:0:0:0 | <none> | TypeAccess |
| funcExprs.kt:14:5:14:33 | functionExpression0a(...) | funcExprs.kt:13:1:29:1 | call | MethodAccess |
| funcExprs.kt:14:26:14:33 | ...->... | funcExprs.kt:13:1:29:1 | call | LambdaExpr |
| funcExprs.kt:14:26:14:33 | Function0<Integer> | funcExprs.kt:13:1:29:1 | call | TypeAccess |