Closed psuong closed 5 months ago
I'm not very knowledgeable on what it takes to write language servers, but I can give you an idea of what the library can do.
The parser should be able to handle any kind of Unity shader, regardless of the SRP. It can parser either entire shaders, or portions of a shader, like a single function (see this file to get an idea https://github.com/pema99/UnityShaderParser/blob/master/UnityShaderParser/Common/ShaderParser.cs). It has some abstractions for making visitors which traverse the generated syntax trees. And naturally, it stores info about where a piece of syntax came from in the original source text.
However, there is no semantic analysis of any kind. So if you need type information, check for correctness, etc. you will have to implement that yourself. It also doesn't have any out-of-the-box support for re-parsing only portions of a file, which I imagine you might want for a language server. Lastly I should mention that I haven't profiled much on massive shaders - max shader size in my test suite is around 40k lines (https://github.com/pema99/UnityShaderParser/blob/master/UnityShaderParser.Tests/TestShaders/PoiyomiToon/Poiyomi%20Outline.shader) which takes about 800ms to parse on my I7-8700. Not sure if that is fast enough for the purposes.
Okay thanks, will play around with this and see what I can do.
I recently came across your repo and I'm interested to see if it's possible to use this in order to a build a language server for autocompletion in any text editor that supports language server integration. I also imagine that the parser will work with all the render pipelines also (Builtin + any kind of SRP)?
I'm hoping to use this as a basis for exploring how to create a language server for ShaderLab in Unity.