How to make it possible to resolve PsiReference for PsiFile instances created based on info from GitCommit


I'm trying to solve the following problem: I have a Project with git repository with which I work via git4idea. For a certain commit I can get a set of files from new revision and I can build a valid PsiFile instances for them. The code for it's construction is something like this:

Collection<Change> changes = commit.getChanges(); // commit is instance of GitCommit
(Change change : changes) {
ContentRevision revision = change.getAfterRevision();
(revision == null)
String path = revision.getFile().getPath();
FileType fileType = FileTypeRegistry.getInstance().getFileTypeByFileName(path);
String content = revision.getContent();
PsiFile file = fileFactory.createFileFromText(path, fileType, content); // fileFactory is instance of PsiFileFactory

One of the things I want to be able to do is to resolve references between loaded files, in my case I'm trying to use PsiRefernce.resolve() to achieve that. It works fine for references in a single file, but when it comes to references from one file to another nothing is being resolved and null is returned.

So, my question is as follows. Is there a good way to make it possible to resolve references between these files?

Please sign in to leave a comment.