@@ -31,6 +31,7 @@ import org.sonar.api.issue.NoSonarFilter
3131import org.sonar.api.measures.FileLinesContextFactory
3232import org.sonarsource.analyzer.commons.ProgressReport
3333import org.sonarsource.kotlin.api.checks.hasCacheEnabled
34+ import org.sonarsource.kotlin.api.common.KOTLIN_LANGUAGE_VERSION
3435import org.sonarsource.kotlin.api.common.KotlinLanguage
3536import org.sonarsource.kotlin.api.common.measureDuration
3637import org.sonarsource.kotlin.api.frontend.bindingContext
@@ -46,6 +47,7 @@ import org.sonarsource.kotlin.metrics.IssueSuppressionVisitor
4647import org.sonarsource.kotlin.metrics.MetricVisitor
4748import org.sonarsource.kotlin.metrics.SyntaxHighlighter
4849import org.sonarsource.kotlin.api.visiting.KtChecksVisitor
50+ import kotlin.jvm.optionals.getOrDefault
4951
5052import kotlin.jvm.optionals.getOrElse
5153
@@ -57,8 +59,8 @@ class KotlinSensor(
5759 checkFactory : CheckFactory ,
5860 private val fileLinesContextFactory : FileLinesContextFactory ,
5961 private val noSonarFilter : NoSonarFilter ,
60- language : KotlinLanguage
61- ): AbstractKotlinSensor(
62+ language : KotlinLanguage ,
63+ ) : AbstractKotlinSensor(
6264 checkFactory, language, KOTLIN_CHECKS
6365) {
6466 override fun describe (descriptor : SensorDescriptor ) {
@@ -67,11 +69,18 @@ class KotlinSensor(
6769 .name(language.name + " Sensor" )
6870 }
6971
72+ override fun execute (sensorContext : SensorContext ) {
73+ sensorContext.config()[KOTLIN_LANGUAGE_VERSION ].ifPresent { value ->
74+ sensorContext.addTelemetryProperty(" kotlin.languageVersion" , value)
75+ }
76+ super .execute(sensorContext)
77+ }
78+
7079 override fun getExecuteContext (
7180 sensorContext : SensorContext ,
7281 filesToAnalyze : Iterable <InputFile >,
7382 progressReport : ProgressReport ,
74- filenames : List <String >
83+ filenames : List <String >,
7584 ) = object : AbstractKotlinSensorExecuteContext (
7685 sensorContext, filesToAnalyze, progressReport, visitors(sensorContext), filenames, LOG
7786 ) {
0 commit comments