Skip to content

Commit

Permalink
Merge branch 'mk/handlerGetRandom' into mk/forLoopMultiVar
Browse files Browse the repository at this point in the history
  • Loading branch information
maximiliankaul committed Sep 25, 2024
2 parents c606f56 + 6ef5616 commit a55d281
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/cpg.common-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ kotlin {

tasks.withType<KotlinCompile> {
compilerOptions {
freeCompilerArgs = listOf("-opt-in=kotlin.RequiresOptIn", "-Xcontext-receivers")
freeCompilerArgs = listOf("-opt-in=kotlin.RequiresOptIn", "-opt-in=kotlin.uuid.ExperimentalUuidApi", "-Xcontext-receivers")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import de.fraunhofer.aisec.cpg.helpers.Util.errorWithFileLocation
import java.lang.reflect.ParameterizedType
import java.lang.reflect.Type
import java.util.function.Supplier
import kotlin.uuid.Uuid
import org.slf4j.Logger
import org.slf4j.LoggerFactory

Expand Down Expand Up @@ -166,6 +167,13 @@ abstract class Handler<ResultNode : Node?, HandlerNode, L : LanguageFrontend<in
return null
}

/** Creates a random name starting with a prefix plus a random UUID (version 4). */
fun getRandomTempName(): Name {
val prefix = "TEMP-RANDOM-NAME"
val randomPart = Uuid.random().toString()
return newName(name = prefix + "-" + randomPart)
}

companion object {
@JvmStatic protected val log: Logger = LoggerFactory.getLogger(Handler::class.java)
}
Expand Down

0 comments on commit a55d281

Please sign in to comment.