Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for new Kotlin K2 mode. #49

Open
sureshg opened this issue Aug 20, 2024 · 14 comments
Open

Add support for new Kotlin K2 mode. #49

sureshg opened this issue Aug 20, 2024 · 14 comments
Assignees
Labels

Comments

@sureshg
Copy link

sureshg commented Aug 20, 2024

Since IJ2024.2, the new k2 compiler mode is in beta and ready for most of the use cases.

Screenshot 2024-08-20 at 11 25 33 AM

But after enabling k2, JTE plugin stopped working.

Screenshot 2024-08-20 at 11 25 01 AM

Please add support for the new k2 mode.

@casid
Copy link
Owner

casid commented Aug 22, 2024

Thanks for reporting @sureshg.

The IntelliJ plugin is a bit outdated by now. I'm pretty sure K2 wasn't even a thing back then.

Tomorrow Next Friday I should have a bit of time to look into upgrading the plugin to the latest IntelliJ version. I'll have a look at K2 support while doing the upgrade.

@casid casid self-assigned this Aug 22, 2024
@casid casid added the 2.2 label Aug 22, 2024
@casid
Copy link
Owner

casid commented Aug 30, 2024

@sureshg I could not find the option when debugging the plugin with the latest IntelliJ version (2024.2.1, Community Edition). The quick action search somehow suggested this section, but when opening it there was no checkbox.

Nevertheless, I've created a new version of the jte plugin, since quite a few things have piled up there since the last release. The release 2.2.0 is out the door and now pending Jetbrains Approval.

Would be interested to see if this solves the problem with K2.

The only info regarding this I found was this blog post, which is a bit outdated by now but haven't found anything newer:
https://blog.jetbrains.com/idea/2024/03/k2-kotlin-mode-alpha-in-intellij-idea/

Third-party IntelliJ IDEA plugins depending on the Kotlin plugin will be disabled. We will provide migration guidance for third-party plugin authors soon!

Which sounds like it won't work? Or, maybe they got it working without plugin authors doing anything..

@sureshg
Copy link
Author

sureshg commented Aug 30, 2024

Which sounds like it won't work?

@casid I am not sure about that.

Anyway, I can test 2.2.0 once it's available and let you know the result. Thanks for taking care of this.

@sureshg
Copy link
Author

sureshg commented Sep 3, 2024

@casid 2.2 is still not available on the plugin portal... Usually how long will it take to get the approval?

@sureshg
Copy link
Author

sureshg commented Sep 4, 2024

jfyi: they have published the migration guide - https://blog.jetbrains.com/platform/2024/09/migrating-your-kotlin-plugin-to-k2-mode/

@casid
Copy link
Owner

casid commented Sep 6, 2024

@sureshg sorry for the late reply!

Jetbrains rejected the update, because the plugin is using an internal API. This hasn't been a problem before, but I think with the new publishing plugin they got a bit stricter about it. The internal API isn't used for a core feature, so it doesn't look too bad. Its a convenience thing, that when typing $, or @ the autocomplete popup shows up in HTML documents. I'm currently discussing a solution with Jetbrains and they wanted to come back to me if there's a solution without internal API usage.

If you want to give it a try, you could download the latest version here and install it manually.
https://plugins.jetbrains.com/plugin/download?rel=true&updateId=595996

Thanks for sharing the migration guide! I think next Friday I should have some slack time at work to look into the plugin.

@sureshg
Copy link
Author

sureshg commented Sep 6, 2024

@casid thanks..plugin 2.2.0 is still shows the same error.
Screenshot 2024-09-06 at 9 57 57 AM

@casid
Copy link
Owner

casid commented Sep 13, 2024

@sureshg I looked through my code and it looks like I don't use the packages listed in the migration article. I've marked the plugin as compatible with K2 in the plugin.xml and published a new version. This one also has the internal API usage removed.

If you don't want to wait for approval, you can have a look at it here already:
https://plugins.jetbrains.com/plugin/14521-jte/edit/versions/stable/602884

@sureshg
Copy link
Author

sureshg commented Sep 13, 2024

@casid Thanks, the plugin is enabled (IntelliJ IDEA 2024.3 EAP). It seems many things are broken except syntax highlighting. Autocompletion is not working, and the import is showing an error.
Screenshot 2024-09-13 at 10 51 01 AM

@casid
Copy link
Owner

casid commented Sep 14, 2024

Oh no, that does not look good. It kinda looks like the language injection approach the plugin uses does not work the same as it did in K2 mode.

When switching back to the previous mode it is working, I guess?

@schowave
Copy link
Contributor

Do you have any ideas how to fix that issue? Can I support somehow?

@casid
Copy link
Owner

casid commented Nov 20, 2024

Thank you for asking! That's the thing. I don't have any good idea how to fix it. So far I only have:

  1. Remove the K2 support marker from the plugin. Maybe this way the plugin will behave the old way even with new IntelliJ versions. However, this is probably only a temporary fix, since K2 will become the default at some point and the old way won't be supported anymore. It will also block users from having the benefits of K2.

  2. Use an alternative approach to KteKotlinLanguageInjector, but I have no idea if this is feasible. Anyways, I guess this will be a huge amount of work, which I currently don't have the capacity for.

  3. Hope for Jetbrains to fully support MultiHostInjector to the extend that was possible in non-K2 mode.

That being said, I'm currently hoping and doing option 3.

@schowave
Copy link
Contributor

Thank you for your thoughts on this. Is there any possibility how to test the plugin locally in the IDE with the checked out code from this repository?

@casid
Copy link
Owner

casid commented Jan 3, 2025

Sorry for the late reply, I just returned from a long vacation!

Yes, you can just clone the repository and then run the runIde gradle task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants