How to specify the indexing order?

Answered

Hello,

The language I'm writing a plugin for requires a specific indexing order, since the files are based on each other. Imagine something like CLion, however the files aren't separate headers and sources but rather include each other, such that there is a whole file tree and the scopes of the files depend on each other. I'd basically like to tell the indexer during the process which file is next to be indexed if possible.

Is there a way to specify the order without writing a custom indexer? Something like a priority queue for indexing?

Kind regards

0
2 comments

Hi,

This is not possible. Indexing result must depend only on an indexed file and must not depend on any other files. C files indexing follows this principle.

Depending on your requirements and use case, we can suggest another solution. Why do you need such indexing dependencies?

0

Well in a language where each file's scope depends on the outer scope you have to somehow remember the files' scopes. In CLion this problem seems to be existent, too, but there people don't do such nested includery, as C has separate headers and sources. So CLion also just watches inner-file scopes, not outer-file (or parent-file) scopes as can be seen on my screenshot here:

https://intellij-support.jetbrains.com/hc/en-us/community/posts/360009710039/comments/14420046798354

Now imagine people who code in C wouldn't distinguish between headers and sources. All you can do is include files and there is one main file from which the whole source is included. You don't want to do a full project lexing every time you change one line of code in one file. Example:

Main.c

// Initial scope: empty
#define ABC 1
...
#include "SubA.c"
// scope now contains X = 1
#include "SubB.c"

SubA.c

// Initial scope inherited from Main.c will have a defined ABC
#ifdef ABC
#define X 1
#else
#define X 2
#endif
...

SubB.c

// Initial scope: ABC = 1, X = 1
#if X == 1
#message "This will be shown because SubA has been included before SubB in Main"
#endif

So I want to store some “initial scope” per file, just like an indexer would do.

0

Please sign in to leave a comment.