https://kotlinlang.org logo
#compiler
Title
# compiler
l

Liam

10/16/2023, 11:36 PM
Hi! I'm playing around with the K2 IDE integration and a custom compiler plugin, and so far its working pretty nicely (and a lot of fun to work with!). The IDE doesn't mark anything as missing, and except for one case completion and stuff works as well. Completion doesn't work when I'm generating a top-level class using my
FirDeclarationGenerationExtension
, and I'm trying to "complete and import" it from a source file. I've been browsing/debugging through the IntelliJ/Kotlin compiler code, and the relevant place in the IDE code seems to be here: FirClassifierCompletionContributor.kt Completions there are gathered from two places: 1. The result of
getAvailableClassifiersCurrentScope
, which ultimately ends up using the tower context here: KtFirScopeProvider.kt 2. The index built from the source files When I actually put the source file I'm completing "from" into the same package as the generated class, or manually import it, I can actually complete it, because its in the tower context and 1. covers it. But when its in a different package, it doesn't work. I'm assuming the appropriate place for my class to show up here would be in 2., since that is how its handled for sources as well, and its probably better to not check every single generated declaration ever. I also see that there is this line here in: KtSymbolFromIndexProvider.kt, which ends up looking for and using this resolve extension thing here: KtResolveExtension.kt. Do I have to somehow provide my own resolve extension if I want to be able to have completion for my generated top level declarations if they are not in the current scope already? (I see that there is an extension point for
KtResolveExtensionProvider
, but I can't find any example of it being extended).
d

dmitriy.novozhilov

10/17/2023, 6:28 AM
cc @Roman Golyshev
r

Roman Golyshev

10/17/2023, 9:02 AM
Thanks for pointing that out @Liam - this looks like an oversight on our part I will create an issue for that, and we’ll come up with a solution Most probably it will not require any kind of additional resolve extensions from the compiler plugin
l

Liam

10/17/2023, 2:12 PM
Okay, sounds good, thanks! 🙂
r

Roman Golyshev

10/30/2023, 1:16 PM
Here’s the tracking issue for that: KTIJ-27574