HighlightingSession (@NotNull PsiFile file) { DaemonProgressIndicator indicator = GlobalInspectionContextBase.assertUnderDaemonProgress(); Map<PsiFile, HighlightingSession> map = indicator.getUserData(HIGHLIGHTING_SESSION); if (map == null) { throw new IllegalStateException("No HighlightingSession stored in "+indicator); } HighlightingSession session = map.get(file); if (session == null) { String mapStr = map.entrySet().stream().map(e -> { PsiFile storedFile = e.getKey(); return storedFile + ": " + System.identityHashCode(storedFile) + " (" + storedFile.getClass() + ") -> " + e.getValue(); }).collect(Collectors.joining("; ")); throw new IllegalStateException("No HighlightingSession found for " + file + ": " + System.identityHashCode(file) + " (" + file.getClass() + ") in " + indicator + " in map: " + mapStr); } return session; }