VirtualFile (final String resPath, final @Nullable String dtdUrl, Project project) { final Ref<VirtualFile> ref = new Ref<>(); ApplicationManager.getApplication().invokeAndWait(() -> ApplicationManager.getApplication().runWriteAction(() -> { ref.set(LocalFileSystem.getInstance().refreshAndFindFileByPath(resPath.replace(File.separatorChar, '/'))); if (dtdUrl != null) { ExternalResourceManager.getInstance().addResource(dtdUrl, resPath); } else if (!project.isDisposed()){ ExternalResourceManager.getInstance().incModificationCount(); PsiManager.getInstance(project).dropPsiCaches(); } })); return ref.get(); }