All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.deephaven.lang.api.HasScope Maven / Gradle / Ivy

There is a newer version: 0.36.1
Show newest version
/**
 * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending
 */
package io.deephaven.lang.api;

import io.deephaven.lang.generated.Node;

import java.util.List;

/**
 */
public interface HasScope extends Node {
    void setScope(List scope);

    List getScope();

    @Override
    default void addScope(List scope) {
        if (scope.isEmpty()) {
            return;
        }
        final List curScope = getScope();
        IsScope prevScope = null;
        Node target = curScope.isEmpty() ? this : curScope.get(curScope.size() - 1);
        curScope.addAll(0, scope);
        for (int i = scope.size(); i-- > 0;) {
            final IsScope item = scope.get(i);
            insertChild(item, 0);
            if (target != this) {
                target.addScope(item);
            } else {
                if (prevScope == null) {
                    item.setScopeTarget(target);
                } else {
                    item.setScopeTarget(prevScope);
                }
            }
            target = prevScope = item;
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy