Grammar-Kit and stub trees

Hi everyone,

I am developing a plugin for a custom language using Grammar-Kit, everything is going pretty well so far. I would like to see how I can add indexing using PSI stubs, as decribed in confluence. As I need to modify classes generated by Grammar-Kit, for example to add constructors to PSI elements classes, this means I need to modify Grammar-Kit itself.

So here is my question : is it theoretically possible for Grammar-Kit to generate code that allows indexing the generated PSI classes? I did a first attempt at doing this (using custom attributes in the grammar), but since I'm very new to indexing, I'm not sure I'm going the right way.

Anyway, it seems that such feature could be very interesting for people who develop plugins using Grammar-Kit.

Thanks for your help

Comment actions Permalink

Bump, anyone? Perhaps Greg?

Comment actions Permalink

We have a number of languages with PSI generated by Grammar-Kit. Currently none of them uses stubs that's why Grammar-Kit lacks support for stubs. Eventually it will be added but I can't say when exactly.

From what I see in your changes you go in the right direction:

1. generated classes and interfaces should be parametrized with stub class
2. implementation classes should also define constructor that takes stub as parameter

3. elementTypeFactory attribute can already be specified for each rule independently so one can provide IStubElementType instances.
4. per-rule extends/implements attributes can specify stub-enabled PSI interfaces and classes so maybe there's no need to generate them explicitely
5. .. some other things :)

Comment actions Permalink

(woops sorry for double posting)

Comment actions Permalink

I'm not sure to really understand point 4, but it seems that point 5 is pretty much what I wanted to know in the first place, so I guess the answer depends on projects/needs :)

Anyway, I have created 2 indexes for my custom language using my modified version of Grammar-Kit, they seem to work as expected. I think I will try to do a pull request and see if my contribution will be included in the next release...

Thanks for your help Gregory (also thanks for your plugin, it saves me a lot of time!)


Please sign in to leave a comment.