-
Notifications
You must be signed in to change notification settings - Fork 2
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
Support declaring a function that can accept a throwing lambda #33
Comments
Hi, //for rethrows / callthough
csense.kotlin.annotations.exceptions.RethrowsExceptions
org.csenseoss.kotlin.annotations.exceptions.RethrowsExceptions
//for catching
csense.kotlin.annotations.exceptions.CatchesExceptions
org.csenseoss.kotlin.annotations.exceptions.CatchesExceptions I'm at this point not aware of any regular annotation libraries that have these types of annotations. (and or any that is kotlin MPP as well). There might also be some cases that I have not yet covered in the plugin, but it should work just fine (just as fine as the custom files). |
Hello, Sorry, but is there any way to do the same thing with library functions, such as |
Thanks @Tvede-dk ! These annotations are exactly what I was looking for! |
Hi @GeorgeVoloshin |
@daniel-jasinski hehe, that depends. If you have directly access to the code via say a submodule it would work with source retention. BUT as soon as its turned into any binary files (jar, war, apk .... etc), then binary retention is needed. Thus if it is a published package at a maven repo, it would need to be binary. (otherwise the plugin usually have no way of getting the annotation(s)). I have seen examples where the plugin gets the source code instead of binary code, however, that is super flaky to rely on. (I have no idea how IDEA / IntelliJ decides what "code" to present to a plugin, its a hit and miss thing). To be on the safe side I would do binary retention. |
@Tvede-dk I followed everything mentioned here (https://github.com/csense-oss/csense-kotlin-annotations?tab=readme-ov-file#installation) (just changed the version to 0.0.63), but it still doesn't work for me. |
@GeorgeVoloshin Ah, so that is because I have not suppoted type annotations in the plugin. |
@GeorgeVoloshin No need to apologize. Not only was I expecting your example to work, but its also not easy to understand the difference (and the real challenge is to update the plugin, which is on me :) ) Now with regards to launch / async ect. The real problem is the flow of exception is NOT linear. it prints Now this does highlight a potential consideration: when dealing with coroutines there might be a few constructs that would be easy to recognize (as seen from this talk from kotlin conf https://www.youtube.com/watch?v=a3agLJQ6vt8) the end result is very often (also in my experience) a launch / async on a parent scope, usually on a SupervisorJob. That however does not stop the plugin from potentially highlighting "join / await" locations. (although, you cannot annotate a job / Deferred with throws ... ) and yes, coroutineScope would then also need to be handled specially. And it might have to be a bit "eager", and not verify specifically that you are calling say "launch" on the right scope, as that again would be a tracking nightmare for the plugin. Thus detecting that Globalscope (or any other scope) is not in the "containing" scope is very likely to much for now, eg: It will also be quite difficult dealing with custom functions etc, since await & join would be special "functions" that the plugin will look for. although, with more annotations, it would be a simple "tracking" like all the other ones... I will try and come up with a rough sketch / POC of this, as it is a good idea, and definitely a thing that the plugin should know about :) |
It would be great if we could declare functions like
callSomething
as safe for throwing lambdas.Then we could make the
Throws
declaration on the caller to also apply to the lambda body.The text was updated successfully, but these errors were encountered: