@@ -31,6 +31,7 @@ import org.sonar.api.issue.NoSonarFilter
31
31
import org.sonar.api.measures.FileLinesContextFactory
32
32
import org.sonarsource.analyzer.commons.ProgressReport
33
33
import org.sonarsource.kotlin.api.checks.hasCacheEnabled
34
+ import org.sonarsource.kotlin.api.common.KOTLIN_LANGUAGE_VERSION
34
35
import org.sonarsource.kotlin.api.common.KotlinLanguage
35
36
import org.sonarsource.kotlin.api.common.measureDuration
36
37
import org.sonarsource.kotlin.api.frontend.bindingContext
@@ -46,6 +47,7 @@ import org.sonarsource.kotlin.metrics.IssueSuppressionVisitor
46
47
import org.sonarsource.kotlin.metrics.MetricVisitor
47
48
import org.sonarsource.kotlin.metrics.SyntaxHighlighter
48
49
import org.sonarsource.kotlin.api.visiting.KtChecksVisitor
50
+ import kotlin.jvm.optionals.getOrDefault
49
51
50
52
import kotlin.jvm.optionals.getOrElse
51
53
@@ -57,8 +59,8 @@ class KotlinSensor(
57
59
checkFactory : CheckFactory ,
58
60
private val fileLinesContextFactory : FileLinesContextFactory ,
59
61
private val noSonarFilter : NoSonarFilter ,
60
- language : KotlinLanguage
61
- ): AbstractKotlinSensor(
62
+ language : KotlinLanguage ,
63
+ ) : AbstractKotlinSensor(
62
64
checkFactory, language, KOTLIN_CHECKS
63
65
) {
64
66
override fun describe (descriptor : SensorDescriptor ) {
@@ -67,11 +69,18 @@ class KotlinSensor(
67
69
.name(language.name + " Sensor" )
68
70
}
69
71
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
+
70
79
override fun getExecuteContext (
71
80
sensorContext : SensorContext ,
72
81
filesToAnalyze : Iterable <InputFile >,
73
82
progressReport : ProgressReport ,
74
- filenames : List <String >
83
+ filenames : List <String >,
75
84
) = object : AbstractKotlinSensorExecuteContext (
76
85
sensorContext, filesToAnalyze, progressReport, visitors(sensorContext), filenames, LOG
77
86
) {
0 commit comments