public void associatePsi(@NotNull Document document, @NotNull PsiFile file) {
    if (file.getProject() != myProject) {
      throw new IllegalArgumentException("Method associatePsi() called with file from the wrong project. Expected: "+myProject+" but got: "+file.getProject());
    }
    VirtualFile vFile = file.getViewProvider().getVirtualFile();
    Document cachedDocument = FileDocumentManager.getInstance().getCachedDocument(vFile);
    if (cachedDocument != null && cachedDocument != document) {
      throw new IllegalStateException("Can't replace existing document");
    }

    FileDocumentManagerBase.registerDocument(document, vFile);
  }
public void associatePsi(@NotNull Document document, @NotNull PsiFile file)