Stub index injection

Hello,

I often need fast access to list of certain PsiLiteralExpressions, particularly these:

  • return values of certain overridden method
  • first parameter of all usages of another method.


What I do now (attachment) is ReferencesSearch.search and OverridingMethodsSearch.search and thus getting hold of PsiLiteralExpressions I'm interested in. This solution is very slow (one pass ~ 500 ms), therefore I use static variable as cache, which is updated with probability 1:100. I'd like to use this list as completion contributor as well.
So is there any way to somehow inject custom stub indexing to PsiLiteralExpression? Or is there better solution than stub index for this?

I've got one more very similar problem. I'll often need to query javascript psi trees from my templates to find declarations of functions in certain namespace (e.g. foo.anything, foo.anything.anything etc.). I'll need the whole list for code completion too. But I think that none of the existing javascript stub indexes can be used for that.



Attachment(s):
MyTemplateReferenceExpressionResolver.java.zip
2 comments
Comment actions Permalink

PsiLiteralExpression is not a stub element, so you can't provide any custom index for it. You can write your own file-based index for the string literals you need.

0
Comment actions Permalink

So I used file based index for some time, which actually didn't turn up to be the best solution, because of lots of confusing regular expressions and the fact, that I cannot resolve references / constant expressions at the time of indexing (in dumb mode). I decided to try CachedValueProvider and I'm perfectly happy with that. The result code is here.

0

Please sign in to leave a comment.