Skip to content

Commit

Permalink
V2024.11.19 hotfix 2 (#7125)
Browse files Browse the repository at this point in the history
* fix: Sync failure after non-fatal bazel failure (#7119)

* Fix reading of _kt_toolchain attribute (#7115)

Fixes #7114.

rules_kotlin has moved to using a special _kt_toolchain attribute, but it looks like the plugin is unable to properly read them.
This commit fixes the output group `intellij-info-kt` (instead of `intellij-info-kotlin`) and adds rule kinds so that the plugin
recognizes the toolchain.

Change-Id: Iee168c264e81c17ffbb509045275faf0a88e1b72

* fix: Kotlin toolchain detection (#7122)

It has been accidentally removed here
a88c6db#diff-7e834e0a725805ad4dfd127ba905e50964c78307ddb756da99d15a0a1ea28a46L1117-R1124

* doc: Update changelog for hotfix

* Update CHANGELOG

---------

Co-authored-by: Jack Dai <[email protected]>
Co-authored-by: Mai Hussien <[email protected]>
  • Loading branch information
3 people authored Dec 6, 2024
1 parent 13f4b87 commit 66c9e5b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
v2024.11.19.0.4
===============
Fixes:
* fix: Kotlin toolchain detection (#7122)
* fix: reading of _kt_toolchain attribute (#7115)
* fix: Sync failure after non-fatal bazel failure (#7119)

v2024.11.19.0.3
===============
Fixes:
Expand Down
14 changes: 9 additions & 5 deletions aspect/intellij_info_impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1117,17 +1117,21 @@ def collect_java_toolchain_info(target, ide_info, ide_info_file, output_groups):
def artifact_to_path(artifact):
return artifact.root_execution_path_fragment + "/" + artifact.relative_path

def collect_kotlin_toolchain_info(target, ide_info, ide_info_file, output_groups):
def collect_kotlin_toolchain_info(target, ctx, ide_info, ide_info_file, output_groups):
"""Updates kotlin_toolchain-relevant output groups, returns false if not a kotlin_toolchain target."""
if not hasattr(target, "kt"):
if ctx.rule.kind == "_kt_toolchain" and platform_common.ToolchainInfo in target:
kt = target[platform_common.ToolchainInfo]
elif hasattr(target, "kt") and hasattr(target.kt, "language_version"):
kt = target.kt # Legacy struct provider mechanism
else:
return False
kt = target.kt

if not hasattr(kt, "language_version"):
return False
ide_info["kt_toolchain_ide_info"] = struct(
language_version = kt.language_version,
)
update_sync_output_groups(output_groups, "intellij-info-kotlin", depset([ide_info_file]))
update_sync_output_groups(output_groups, "intellij-info-kt", depset([ide_info_file]))
return True

def _is_proto_library_wrapper(target, ctx):
Expand Down Expand Up @@ -1293,7 +1297,7 @@ def intellij_info_aspect_impl(target, ctx, semantics):
handled = collect_java_info(target, ctx, semantics, ide_info, ide_info_file, output_groups) or handled
handled = collect_java_toolchain_info(target, ide_info, ide_info_file, output_groups) or handled
handled = collect_android_info(target, ctx, semantics, ide_info, ide_info_file, output_groups) or handled
handled = collect_kotlin_toolchain_info(target, ide_info, ide_info_file, output_groups) or handled
handled = collect_kotlin_toolchain_info(target, ctx, ide_info, ide_info_file, output_groups) or handled

# Any extra ide info
if hasattr(semantics, "extra_ide_info"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class BazelExecService(private val project: Project) : Disposable {

parseJob.cancelAndJoin()

if (result.status != BuildResult.Status.SUCCESS) {
if (result.status == BuildResult.Status.FATAL_ERROR) {
BlazeBuildOutputs.noOutputs(result)
} else {
BlazeBuildOutputs.fromParsedBepOutput(result, provider.getBuildOutput())
Expand Down
2 changes: 2 additions & 0 deletions kotlin/src/com/google/idea/blaze/kotlin/KotlinBlazeRules.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public final class KotlinBlazeRules implements Kind.Provider {

/** Kotlin-specific blaze rule types. */
public enum RuleTypes {
KT_TOOLCHAIN("_kt_toolchain", LanguageClass.KOTLIN, RuleType.UNKNOWN),
KT_TOOLCHAIN_ALIAS("_kt_toolchain_alias", LanguageClass.KOTLIN, RuleType.UNKNOWN),
KT_JVM_TOOLCHAIN("kt_jvm_toolchain", LanguageClass.KOTLIN, RuleType.UNKNOWN),
// TODO(b/157683101): remove once https://youtrack.jetbrains.com/issue/KT-24309 is fixed
KT_JVM_LIBRARY_HELPER("kt_jvm_library_helper", LanguageClass.KOTLIN, RuleType.LIBRARY),
Expand Down

0 comments on commit 66c9e5b

Please sign in to comment.