FileBasedIndex GetValues

Hi,

I am indexing some custom files using FileBasedIndex'ing. And have an extension class for gotoClassContributor, so we can search for the class in Intellij. In the extension class I implement the getItemsByName() function, which when passed a key, is supposed to processes some values corresponding the key and returns the required NavigationItems[]. Since we already have the key in getItemsByName(), I am trying to get the corresponding values(which have been externalized), using FileBasedIndex.getValues(). The problem is that FileBasedIndex.getValues() returns the corresponding values only when the file in which the class I am searching has been modified. In other cases I getValues() returns an empty list.

For eg. if I modify a file and add a new class to it, getValues() will return the appropriate class names along with the newly added class. If I restart the IDE, the getValues() returns an empty list. Why is this the case? Should I be doing something more to get the values corresponding to a key? Thanks for your help in advance.

Thanks,
Sameer

1 comment

Hi Sameer,
It is hard to answer precisely what can be wrong without looking at the code.
My position is that writing custom indices should be avoided if you can get this data from existing indices (word index for example) or via existing PSI API (for example, class searching).
If you know for sure that you need this particular custom index, it is crutial to carefully implement all required extensions. Can I have a look at the code? Otherwise it is quite hard to advise something.

Regards,

   Eugene Zhuravlev

0

Please sign in to leave a comment.