Open lppedd opened 1 year ago
My idea was to add a CLI flag to print compilation results as JSON, which could be used by IDEs. However, that is not implemented yet.
But to make your IDE extension work, I think all you need is jni-rs. You can follow this tutorial (maybe there are better ones, this is just the first one I found) and make a crate that exports a Java_Pomsky_compile
function for the JNI. Then you just need to map Rust types to Java types. For example, a CompileError
can be returned as two integers for the Span
and a string.
By the way, I was planning to look at your lexer and BNF grammar but didn't have time until now. I'll try to give you some feedback tomorrow.
@Aloso JSON is a good idea. However, are we sure it's ok performance wise? I would like to call it every time there is an edit, like in the playground, and it has to report errors as fast as possible. Playground uses a WASM module, so it's basically a native interaction.
If I make a crate, do I have to recompile each time a new version comes out? I believe the answer is yes, which means it becomes a bit cumbersome.
This is how an IDE would handle this situation.
Creating a process takes less than a millisecond on recent hardware, I think, so it's not that expensive to call pomsky's CLI. But to get the best performance, using something like JNI would be better. Yes, that requires recompiling the dynamic library every time a new version comes out, but maybe that can be automated somewhat.
@Aloso just keep in mind extensions should just inherit from the tool. If extensions have to carry their own compiled versions of Pomsky, it becomes a binary hell.
Distributing Pomsky not only in the CLI format, but also as a native library (
.so
,.dll
), allows tools to compile and receive an output in a standardized format which can be interpreted through interfaces like JNI or JNA. Example usage: compilation and error reporting inside of an IDE.I think a project like this https://github.com/Dushistov/flapigen-rs might come handy.