PsiFile (InjectedLanguageManager instance, PsiLanguageInjectionHost host) { Language language = myTracker.myCopyFile.getLanguage(); var visitor = new PsiLanguageInjectionHost.InjectedPsiVisitor() { PsiFile myFile = null; @Override public void visit(@NotNull PsiFile injectedPsi, @NotNull List<? extends PsiLanguageInjectionHost.Shred> places) { if (injectedPsi.getLanguage() == language) { myFile = injectedPsi; } } }; instance.enumerate(host, visitor); return Objects.requireNonNull(visitor.myFile); }