Skip to content

Commit

Permalink
Pick up Kotlin version from rules_kotlin (bazelbuild/intellij PR import
Browse files Browse the repository at this point in the history
#1566)

# Checklist

- [X] I have filed an issue about this change and discussed potential changes with the maintainers.
- [?] I have received the approval from the maintainers to make this change.
- [X] This is not a stylistic, refactoring, or cleanup change.

Please note that the maintainers will not be reviewing this change until all checkboxes are ticked. See
the [Contributions](https://github.com/bazelbuild/intellij#contributions) section in the README for more
details.

# Discussion thread for this change

Issue number: `1274`

# Description of this change

This change gets the kotlin version from rules_kotlin (commit 242 - bazelbuild/rules_kotlin@a3d4d56) and updates the ide_info such that Kotlin 1.3 functionality can be accessed if compiled with Kotlin 1.3

Closes #1566

PiperOrigin-RevId: 307379159
  • Loading branch information
jin authored and copybara-github committed Apr 20, 2020
1 parent a7b6232 commit fcfc098
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions aspect/intellij_info_impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,22 @@ def collect_java_toolchain_info(target, ide_info, ide_info_file, output_groups):
update_sync_output_groups(output_groups, "intellij-info-java", depset([ide_info_file]))
return True

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):
"""Updates kotlin_toolchain-relevant output groups, returns false if not a kotlin_toolchain target."""
if not hasattr(target, "kt"):
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]))
return True

def _is_proto_library_wrapper(target, ctx):
"""Returns True if the target is an empty shim around a proto library."""
if not ctx.rule.kind.endswith("proto_library") or ctx.rule.kind == "proto_library":
Expand Down Expand Up @@ -1016,6 +1032,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

# Any extra ide info
if hasattr(semantics, "extra_ide_info"):
Expand Down

0 comments on commit fcfc098

Please sign in to comment.