private @NotNull Iterable<LighterASTNode> getDeclarations(LighterASTNode scope, @Nullable LighterASTNode lastParent) {
    IElementType type = scope.getTokenType();
    if (type == CODE_BLOCK) {
      return walkChildrenScopes(before(LightTreeUtil.getChildrenOfType(myTree, scope, DECLARATION_STATEMENT), lastParent));
    }
    if (type == DECLARATION_STATEMENT) {
      return before(LightTreeUtil.getChildrenOfType(myTree, scope, LOCAL_VARIABLE), lastParent);
    }
    if (type == FOR_STATEMENT) {
      return walkChildrenScopes(before(LightTreeUtil.getChildrenOfType(myTree, scope, ElementType.JAVA_STATEMENT_BIT_SET), lastParent));
    }
    if (type == FOREACH_STATEMENT || type == CATCH_SECTION) {
      return JBIterable.of(LightTreeUtil.firstChildOfType(myTree, scope, PARAMETER));
    }
    if (type == TRY_STATEMENT) {
      return walkChildrenScopes(before(LightTreeUtil.getChildrenOfType(myTree, scope, RESOURCE_LIST), lastParent));
    }
    if (type == RESOURCE_LIST) {
      return before(LightTreeUtil.getChildrenOfType(myTree, scope, RESOURCE_VARIABLE), lastParent);
    }
    if (type == CLASS) {
      List<LighterASTNode> fields = LightTreeUtil.getChildrenOfType(myTree, scope, FIELD);
      LighterASTNode recordHeader = LightTreeUtil.firstChildOfType(myTree, scope, RECORD_HEADER);
      if (recordHeader == null) return fields;
      return JBIterable.from(fields).append(LightTreeUtil.getChildrenOfType(myTree, recordHeader, RECORD_COMPONENT));
    }
    if (type == LAMBDA_EXPRESSION || type == METHOD) {
      LighterASTNode paramList = LightTreeUtil.firstChildOfType(myTree, scope, PARAMETER_LIST);
      return paramList == null ? ContainerUtil.emptyList() : LightTreeUtil.getChildrenOfType(myTree, paramList, PARAMETER);
    }
    return Collections.emptyList();
  }
private @NotNull Iterable<LighterASTNode> getDeclarations(LighterASTNode scope, @Nullable LighterASTNode lastParent)