Page Comparison - Caches (v.3 vs v.4)

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

You have no doubt seen ReSharper say it’s ‘loading caches’. These caches are collections that are kept in RAM so that when ReSharper needs to access them, they are available quickly. For example, R# has a declarations cache, which is basically a large set of data regarding the various declarations that R# has encountered while parsing code.

These caches are available to plugin developers. To get to the caches, all you need to do is use the CacheManager class and then get the cache you want.

Here's an example: say you want to get at all the type names that R# knows about. To do that, you get the instance of the CacheManager, call a GetDeclarationsCache() method to get the cache itself, and then simply call, e.g., GetAllShortNames() on the cache to get the names of all the CLR types that R# has encountered:

Code Block
IDeclarationsCache dc = provider.Solution.GetPsiServices().CacheManager.GetDeclarationsCache(provider.PsiModule, true, true);
var shortNames = dc.GetAllShortNames();