package com.intellij.sh.psi.impl;

import com.intellij.psi.PsiElement;
import com.intellij.psi.ResolveState;
import com.intellij.psi.scope.PsiScopeProcessor;
import com.intellij.sh.psi.ShCompositeElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public final class ResolveUtil {
  public static boolean treeWalkUp(@Nullable PsiElement place, @NotNull PsiScopeProcessor processor) {
    PsiElement lastParent = null;
    PsiElement run = place;
    while (run != null) {
      if (place != run && !run.processDeclarations(processor, ResolveState.initial(), lastParent, place)) return false;
      lastParent = run;
      run = run.getParent();
    }
    return true;
  }

  static boolean processChildren(@NotNull PsiElement element,
                                 @NotNull PsiScopeProcessor processor,
                                 @NotNull ResolveState substitutor,
                                 @Nullable PsiElement lastParent,
                                 @NotNull PsiElement place) {
    PsiElement run = lastParent == null ? element.getLastChild() : lastParent.getPrevSibling();
    while (run != null) {
      if (run instanceof ShCompositeElement && !run.processDeclarations(processor, substitutor, null, place)) {
        return false;
      }
      run = run.getPrevSibling();
    }
    return true;
  }
}

@@ -288,21 +288,8 @@
 e;%0A%0A
-public final 
 clas
@@ -308,400 +308,8 @@
 l %7B%0A
-  public static boolean treeWalkUp(@Nullable PsiElement place, @NotNull PsiScopeProcessor processor) %7B%0A    PsiElement lastParent = null;%0A    PsiElement run = place;%0A    while (run != null) %7B%0A      if (place != run && !run.processDeclarations(processor, ResolveState.initial(), lastParent, place)) return false;%0A      lastParent = run;%0A      run = run.getParent();%0A    %7D%0A    return true;%0A  %7D%0A%0A
   st

remove an unused method