public @NotNull LightResolveResult resolveLocally(@NotNull LighterASTNode ref) {
    String refName = JavaLightTreeUtil.getNameIdentifierText(myTree, ref);
    if (refName == null) return LightResolveResult.UNKNOWN;
    if (!canResolveToLocalVariable(myTree, ref)) return LightResolveResult.NON_LOCAL;

    boolean passedClass = false;
    LighterASTNode lastParent = ref;
    while (true) {
      ProgressManager.checkCanceled();
      LighterASTNode scope = myTree.getParent(lastParent);
      if (scope == null) return LightResolveResult.NON_LOCAL;

      for (LighterASTNode var : getDeclarations(scope, lastParent)) {
        if (refName.equals(JavaLightTreeUtil.getNameIdentifierText(myTree, var))) {
          if (passedClass) {
            IElementType type = var.getTokenType();
            return type == FIELD || type == RECORD_COMPONENT ? LightResolveResult.NON_LOCAL : LightResolveResult.UNKNOWN;
          }
          return LightResolveResult.resolved(var);
        }
      }

      lastParent = scope;
      passedClass |= scope.getTokenType() == CLASS || scope.getTokenType() == ANONYMOUS_CLASS;
    }
  }
public @NotNull LightResolveResult resolveLocally(@NotNull LighterASTNode ref)