From e82cf1d005ae356ef4341a7b719aca54f8e69903 Mon Sep 17 00:00:00 2001 From: Konrad Weiss Date: Mon, 10 Jun 2024 13:03:54 +0200 Subject: [PATCH] Bugfix/annotations and Missing Enums (#1585) * Removing unnecessary cast restriction that sometimes just brakes analysis * Reenabling ENums inside of records --- .../fraunhofer/aisec/cpg/frontends/java/DeclarationHandler.kt | 3 +++ .../aisec/cpg/frontends/java/JavaLanguageFrontend.kt | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cpg-language-java/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/java/DeclarationHandler.kt b/cpg-language-java/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/java/DeclarationHandler.kt index 4f6a965def..e8119feac9 100644 --- a/cpg-language-java/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/java/DeclarationHandler.kt +++ b/cpg-language-java/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/java/DeclarationHandler.kt @@ -354,6 +354,9 @@ open class DeclarationHandler(lang: JavaLanguageFrontend) : is ClassOrInterfaceDeclaration -> { frontend.scopeManager.addDeclaration(handle(decl)) } + is com.github.javaparser.ast.body.EnumDeclaration -> { + frontend.scopeManager.addDeclaration(handle(decl)) + } is InitializerDeclaration -> { val initializerBlock = frontend.statementHandler.handleBlockStatement(decl.body) diff --git a/cpg-language-java/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/java/JavaLanguageFrontend.kt b/cpg-language-java/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/java/JavaLanguageFrontend.kt index f06178d123..ad108ff396 100644 --- a/cpg-language-java/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/java/JavaLanguageFrontend.kt +++ b/cpg-language-java/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/java/JavaLanguageFrontend.kt @@ -468,7 +468,7 @@ open class JavaLanguageFrontend(language: Language, ctx: T val member = newAnnotationMember( ANNOTATION_MEMBER_VALUE, - expressionHandler.handle(value.asLiteralExpr()) as Expression, + expressionHandler.handle(value) as Expression, rawNode = value ) members.add(member)