Skip to content

Commit c45a04a

Browse files
authored
Merge pull request #10675 from tamasvajk/kotlin-enum-constants
Kotlin: extract `isEnumConstant` relation
2 parents 321c858 + 09051e7 commit c45a04a

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,7 @@ open class KotlinFileExtractor(
11611161
tw.writeFieldsKotlinType(id, type.kotlinResult.id)
11621162
val locId = tw.getLocation(ee)
11631163
tw.writeHasLocation(id, locId)
1164+
tw.writeIsEnumConst(id)
11641165

11651166
if (extractTypeAccess) {
11661167
val fieldDeclarationId = tw.getFreshIdLabel<DbFielddecl>()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
fun usesEnum(e: Enum<*>) = e.ordinal.toString() + e.name
2+
3+
enum class E { A, B, C }

java/ql/test/kotlin/library-tests/enum/test.expected

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
enumConstants
2+
| enumUser.kt:3:16:3:17 | A |
3+
| enumUser.kt:3:19:3:20 | B |
4+
| enumUser.kt:3:22:3:22 | C |
5+
#select
16
| addAll |
27
| addRange |
38
| allOf |

java/ql/test/kotlin/library-tests/enum/test.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ import java
33
from Method m
44
where m.getDeclaringType().getName().matches("Enum%")
55
select m.getName()
6+
7+
query predicate enumConstants(EnumConstant ec) { ec.fromSource() }

0 commit comments

Comments
 (0)