Skip to content

Commit 2aec690

Browse files
scip-kotlinc Kotlin update, fixes and improvements (#973)
Port accumulated changes from the mozsearch/semanticdb-kotlinc fork. Kotlin support: - Update to Kotlin 2.4.0 (through 2.2.20, 2.3.10, 2.3.20), adapting to FIR API renames and removals along the way; update Kotlin test repos Symbol/emission changes: - Populate SymbolInformation.Kind (distinguish constructors, better locals) - Add enclosing_symbol field (parent symbol, including for locals) - Rework getters/setters as property children: `x.get().`/`x.set().` instead of `getX().`/`setX().` - Emit occurrences for extension receiver types, enum entries (new SemanticEnumEntryChecker), and is/as type references - Fix displayName() for type aliases and type parameters Fixes: - Gradle: don't set project repositories when settings repositories are set, so builds without FAIL_ON_PROJECT_REPOS no longer fail - Route PostAnalysisExtension exceptions through the compilation's message collector as warnings instead of failing the build - Clear AnalyzerCheckers.visitors after use; ignore FirFileSymbols without warning; fix compiler warnings and LineMap docstrings --------- Co-authored-by: Ryan VanderMeulen <rvandermeulen@mozilla.com>
1 parent d9f7bb5 commit 2aec690

25 files changed

Lines changed: 2803 additions & 1050 deletions

File tree

.github/workflows/repos.yaml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,33 +98,33 @@ jobs:
9898
bazel_version: ""
9999
covers: Gradle, Java project target 21, Java 21 runtime
100100

101-
- name: gradle-kotlin-okio
102-
repository: square/okio
103-
ref: parent-3.16.0
101+
- name: gradle-kotlin-kotlinpoet
102+
repository: square/kotlinpoet
103+
ref: 0182a25089ee1f4f2378568b497f82a8ebc3017d
104104
directory: .
105105
build_tool: gradle
106-
build_command: "-Dkjs=false -Dkwasm=false :okio:compileKotlinJvm"
106+
build_command: "-Dkjs=false -Dkwasm=false compileKotlinJvm"
107107
java: 17
108108
bazel_version: ""
109-
covers: Gradle, Kotlin, Kotlin 2.2.0
109+
covers: Gradle, Kotlin, Kotlin 2.4.0
110110

111-
- name: gradle-kotlin-flowext
112-
repository: hoc081098/FlowExt
113-
ref: 7341f3853d670af0283258f57643a68ed273f8ac
111+
- name: gradle-kotlin-kotlinconf-app
112+
repository: JetBrains/kotlinconf-app
113+
ref: b5b0c8b4bb4476a59673dd857b598ef586100f52
114114
directory: .
115115
build_tool: gradle
116116
build_command: "compileKotlinJvm"
117-
java: 17
117+
java: 25
118118
bazel_version: ""
119119
expected_language: kotlin
120-
covers: Gradle, Kotlin multiplatform JVM target, Kotlin 2.2.0, Java 17 runtime
120+
covers: Gradle, Kotlin multiplatform JVM target, Kotlin 2.4.0, Java 25 runtime
121121

122-
- name: gradle-mixed-okio-jmh
123-
repository: square/okio
124-
ref: parent-3.16.0
122+
- name: gradle-mixed-kotlinpoet
123+
repository: square/kotlinpoet
124+
ref: 0182a25089ee1f4f2378568b497f82a8ebc3017d
125125
directory: .
126126
build_tool: gradle
127-
build_command: "-Dkjs=false -Dkwasm=false :okio:jvm:jmh:jmhClasses"
127+
build_command: "-Dkjs=false -Dkwasm=false compileKotlinJvm compileJava"
128128
java: 21
129129
bazel_version: ""
130130
covers: Gradle, mixed Java/Kotlin, Java 21 runtime

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
clikt = "5.1.0"
33
gradle-api = "8.11.1"
44
junit-jupiter = "5.11.4"
5-
kctfork = "0.7.1"
5+
kctfork = "0.13.0"
66
kotest = "6.2.1"
7-
kotlin = "2.2.0"
7+
kotlin = "2.4.0"
88
kotlinx-serialization = "1.11.0"
99
lombok = "1.18.46"
1010
maven-plugin-annotations = "3.15.2"

scip-gradle-plugin/src/main/java/org/scip_code/scip_java/gradle/ScipGradlePlugin.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
import java.util.ArrayList;
44
import java.util.List;
55
import java.util.Map;
6-
import org.gradle.api.InvalidUserCodeException;
76
import org.gradle.api.Plugin;
87
import org.gradle.api.Project;
98
import org.gradle.api.Task;
109
import org.gradle.api.artifacts.Configuration;
10+
import org.gradle.api.initialization.Settings;
11+
import org.gradle.api.internal.GradleInternal;
1112
import org.gradle.api.tasks.compile.JavaCompile;
1213

1314
public class ScipGradlePlugin implements Plugin<Project> {
@@ -18,18 +19,18 @@ public void apply(Project project) {
1819
}
1920

2021
private void configureProject(Project project) {
21-
// Inject Maven Central/local so the indexer (and plugins like protobuf that
22-
// resolve their own artifacts) can resolve dependencies even when the build
23-
// being indexed doesn't declare any repositories of its own.
24-
try {
22+
// See https://github.com/gradle/gradle/issues/27260
23+
Settings settings = ((GradleInternal) (project.getGradle())).getSettings();
24+
25+
if (settings.getDependencyResolutionManagement().getRepositories().isEmpty()) {
26+
// Inject Maven Central/local so the indexer (and plugins like protobuf that
27+
// resolve their own artifacts) can resolve dependencies even when the build
28+
// being indexed doesn't declare any repositories of its own.
2529
project.getRepositories().add(project.getRepositories().mavenCentral());
2630
project.getRepositories().add(project.getRepositories().mavenLocal());
27-
} catch (InvalidUserCodeException exc) {
28-
// FAIL_ON_PROJECT_REPOS forbids project repositories; they are declared
29-
// in settings instead, so the injection isn't needed (issue #847).
30-
project
31-
.getLogger()
32-
.info("scip-java: not injecting Maven Central/local repositories: " + exc.getMessage());
31+
} else {
32+
// repositories are declared in settings instead, so the injection isn't needed (issue #847).
33+
project.getLogger().info("scip-java: not injecting Maven Central/local repositories");
3334
}
3435

3536
Map<String, Object> extraProperties =

scip-java/src/test/resources/fixtures/gradle/kotlin-jvm-toolchains/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
id 'java'
3-
id 'org.jetbrains.kotlin.jvm' version '2.2.0'
3+
id 'org.jetbrains.kotlin.jvm' version '2.4.0'
44
}
55
java {
66
toolchain {

scip-java/src/test/resources/fixtures/gradle/kotlin2/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'org.jetbrains.kotlin.jvm' version '2.2.0'
2+
id 'org.jetbrains.kotlin.jvm' version '2.4.0'
33
}
44
kotlin {
55
jvmToolchain(17)

scip-kotlinc/build.gradle.kts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ dependencies {
2424
testImplementation(libs.kctfork.core)
2525
}
2626

27-
tasks.withType<KotlinCompile>().configureEach {
28-
compilerOptions.freeCompilerArgs.add("-Xcontext-parameters")
29-
}
30-
3127
tasks.named<Test>("test") {
3228
maxHeapSize = "2g"
3329
}

0 commit comments

Comments
 (0)