void (@NotNull List<? extends PsiElement> elements, @NotNull Collection<? super Pair<PsiFile, PsiElement>> result) { Map<PsiFile, PsiElement> injectedToHost = createInjectedFileMap(); Project project = myPsiFile.getProject(); for (PsiElement element : elements) { InjectedLanguageManager.getInstance(project).enumerateEx(element, myPsiFile, false, (injectedPsi, __) -> { if (injectedToHost.put(injectedPsi, element) == null) { result.add(Pair.create(injectedPsi, element)); } }); } }