void (@NotNull VirtualFile file, @NotNull Language prevLang, @NotNull Language substitutedLang) { ourReparsingRequests.put(file, new SubstitutionInfo(prevLang, substitutedLang)); if (REQUESTS_DRAIN_NEEDED.compareAndSet(true, false)) { ApplicationManager.getApplication().invokeLater(() -> { REQUESTS_DRAIN_NEEDED.set(true); List<Map.Entry<VirtualFile, SubstitutionInfo>> set = new ArrayList<>(ourReparsingRequests.entrySet()); List<VirtualFile> files = new ArrayList<>(set.size()); int id = 1; for (Map.Entry<VirtualFile, SubstitutionInfo> entry : set) { VirtualFile f = entry.getKey(); SubstitutionInfo info = entry.getValue(); ourReparsingRequests.remove(f); if (f.isValid()) { LOG.info("Reparsing " + f.getPath() + " because of language substitution " + info.myPrevLang.getID() + "->" + info.mySubstitutedLang.getID() + ", #" + (id++)); files.add(f); } } if (files.size() > 0) { FileContentUtilCore.reparseFiles(files); } }); } }