Closed klenium closed 2 years ago
Oh, even JetBrains use the dummy file to create code from text. Surprising for me...
Yeah, the AST/PSI classes are build upon the assumption that there is underlying text. In essence the AST/PSI is generated to match source text, not the other way around. So while you could add some pretty-printing capability to generate a completely new source from the AST/PSI tree, it would not be easy to create that tree in the first place.
What do you want to do? (Or perhaps: why?)
(I am closing, since it is not actually an issue, but feel free to keep commenting.)
Yup, thank you. I'm creating a project that will translate Kotlin to GLSL, execute the Kotlin program on CPU, and the GLSL on GPU. The IntelliJ plugin will generate this code. Your GLSL plugin will be useful for this project, and it would be nice if the output GLSL code would be saved as well-formatted. I think I could help improving the auto-formatting of the GLSL code later, I saw there's already an open issue for that.
Very interesting, I'm looking forward to that project.
I don't think that the code in this repository will be useful for it, because from my experience it is usually easier to pretty-print already well formatted code directly from internal representation than to reformat source code. Especially when the reformating capabilities of this project aren't exactly amazing. Doing it yourself directly will give you much better control over the formatting and the reduced complexity of not having to integrate with complex 3rd party code is also a plus. In short, do whatever you think is most beneficial to your project, but I don't think that integrating with this project is it (at least not for this purpose).
Hello there! I wonder if it would be possible to reuse the classes under the
glslplugin.lang.elements
namespace to create GLSL source code? My idea would be that I instantiate GLSL lang classes, put this tree into a virtual file, and just let the IDE print and format the code. I see that constructors accept aASTNode
which is closely related to code parsing, but maybe if I create a fake implementation (ie. minimal info for only code snippets)? Do you think it would work or fail?