Hopefully last questions for this week: is it poss...
# scripting
j
Hopefully last questions for this week: is it possible to create an IntelliJ plugin that restricts the suggestions ? (I want to remove all suggestions coming from the stdlib). Also is it possible to easily create a plugin instead of relying on host discovery that doesn't seem to always work ? (especially once we add compilation configuration, etc)
i
Depends on your intensions: - If you want to leave stdlib in dependencies, but just remove it from completion suggestions - then I don’t know, but you can ask it in #intellij channel,maybe somebody will be able to give some pointers. But I’d say it would be weird. - If you want to make stdlib inaccessible from script - you can use compiler options in the script compilation configurations - adding
-no-stdlib
to it will remove stdlib from dependencies. - If you want to restrict stdlib (or any other dependency) usages in scripts, then there are plans to implement this, but it is not yet available.
j
The -no-stdlib flag sounds like exactly what I need! Will try that, thanks 🙂
I guess this was to be expected, but with this flag I get this kind of errors:
Copy code
Cannot access built-in declaration 'kotlin.Unit'. Ensure that you have a dependency on the Kotlin standard library
Same with String. What I'd need is to allows scripts to use the basic types String/Int/Boolean/Unit/etc but none of all the stdlib methods which pollute the autocompletion in IntelliJ (and that I don't want them to be able to use)
Actually even with that flag I still have way too much autocomplete suggestions. I think the best way would be able to easily filter/modify suggestions using either a plugin (or wildcard restrictions as suggested in the keep). If I can help getting that in the next release, please tell me 🙂
i
Yes, right, my suggestion was probably misleading, kotlin cannot work without stdlib. This option is intended for the cases then you want to specify stdlib explicitly in the calsspath. You can still experiment with creating your own reduced version of the stdlib from the standard one by throwing out unneeded classes. I’m not sure though that completion will handle it properly though - this is an untested path. Restrictions are in plans for some of the next releases. Thank you for offering help, but I think that implementation will require quite a lot of knowledge about our compiler internals, I’m not sure that it it makes sense for you to go that deep into it.
j
Sounds good,hope it will be available soon 🙂