@Override
    public @Nullable PsiFile getContainingFile() {
      if (!isValid()) {
        return null;
      }

      PsiFile file = myElement.getContainingFile();
      final PsiElement context = myElement.getContext();
      if (file == null && context != null) {
        file = context.getContainingFile();
      }
      PsiFile f;
      if ((f = PsiTreeUtil.getContextOfType(file, PsiFile.class, true)) instanceof XmlFile) {
        return f;
      }
      return file;
    }
@Override
    public @Nullable PsiFile getContainingFile()