Skip to content

Commit b197d9f

Browse files
committed
(WIP)
1 parent 5439dac commit b197d9f

File tree

1 file changed

+12
-3
lines changed
  • sonar-kotlin-plugin/src/main/java/org/sonarsource/kotlin/plugin

1 file changed

+12
-3
lines changed

sonar-kotlin-plugin/src/main/java/org/sonarsource/kotlin/plugin/KotlinSensor.kt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import org.sonar.api.issue.NoSonarFilter
3131
import org.sonar.api.measures.FileLinesContextFactory
3232
import org.sonarsource.analyzer.commons.ProgressReport
3333
import org.sonarsource.kotlin.api.checks.hasCacheEnabled
34+
import org.sonarsource.kotlin.api.common.KOTLIN_LANGUAGE_VERSION
3435
import org.sonarsource.kotlin.api.common.KotlinLanguage
3536
import org.sonarsource.kotlin.api.common.measureDuration
3637
import org.sonarsource.kotlin.api.frontend.bindingContext
@@ -46,6 +47,7 @@ import org.sonarsource.kotlin.metrics.IssueSuppressionVisitor
4647
import org.sonarsource.kotlin.metrics.MetricVisitor
4748
import org.sonarsource.kotlin.metrics.SyntaxHighlighter
4849
import org.sonarsource.kotlin.api.visiting.KtChecksVisitor
50+
import kotlin.jvm.optionals.getOrDefault
4951

5052
import 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

Comments
 (0)