@Override
  public @Nullable PsiElement getCodeBlock(@NotNull PsiElement anchor) {
    if (anchor instanceof PsiSwitchLabelStatementBase) {
      return null; // unsupported yet
    }
    PsiElement e = anchor;
    while (e != null && !(e instanceof PsiClass) && !(e instanceof PsiFileSystemItem)) {
      e = e.getParent();
      if (e instanceof PsiCodeBlock) {
        PsiElement parent = e.getParent();
        if (parent instanceof PsiMethod || parent instanceof PsiLambdaExpression || parent instanceof PsiClassInitializer ||
            // We cannot properly restore context if we started from finally, so let's analyze just finally block
            parent instanceof PsiTryStatement && ((PsiTryStatement)parent).getFinallyBlock() == e ||
            parent instanceof PsiBlockStatement &&
            (parent.getParent() instanceof PsiSwitchLabeledRuleStatement &&
             ((PsiSwitchLabeledRuleStatement)parent.getParent()).getEnclosingSwitchBlock() instanceof PsiSwitchExpression)) {
          return e;
        }
      }
    }
    return null;
  }
@Override
  public @Nullable PsiElement getCodeBlock(@NotNull PsiElement anchor)