PsiFile (int offset, @NotNull PsiFile psiFile) { PsiElement injectedElement = InjectedLanguageManager.getInstance(psiFile.getProject()).findInjectedElementAt(psiFile, offset); if (injectedElement != null) { PsiFile injected = injectedElement.getContainingFile(); if (injected != null) { return injected; } } return psiFile; }