How to specify the indexing order?



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



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?


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:

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:


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


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


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

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