List<PsiElement> () { assert project != null; return ReadAction.compute( () -> { if (!myFile.isValid()) { // file may be been deleted since search started return Collections.emptyList(); } final PsiFile file = PsiManager.getInstance(project).findFile(myFile); if (file == null) { return Collections.emptyList(); } final FileViewProvider viewProvider = file.getViewProvider(); final List<PsiElement> elementsToProcess = new SmartList<>(); for (Language lang : viewProvider.getLanguages()) { elementsToProcess.add(viewProvider.getPsi(lang)); } return elementsToProcess; } ); }