Set<Module> () { Set<Module> dirtyModules; synchronized (myLock) { dirtyModules = new HashSet<>(myVFSChangedModules); } FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance(); for (Document document : fileDocumentManager.getUnsavedDocuments()) { VirtualFile file = fileDocumentManager.getFile(document); if (file == null) { continue; } Module m = getModuleForSourceContentFile(file); if (m != null) { dirtyModules.add(m); } } PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(myProject); for (Document document : psiDocumentManager.getUncommittedDocuments()) { final PsiFile psiFile = psiDocumentManager.getPsiFile(document); if (psiFile == null) continue; final VirtualFile file = psiFile.getVirtualFile(); if (file == null) continue; final Module m = getModuleForSourceContentFile(file); if (m != null) dirtyModules.add(m); } return dirtyModules; }