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

io.deephaven.lang.api.ChunkerInvokable 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.ChunkerConstants;
import io.deephaven.lang.generated.ChunkerMethodName;
import io.deephaven.lang.generated.Node;
import io.deephaven.lang.generated.Token;

import java.util.List;

/**
 * Represents an ast node that could be invokable.
 *
 * For now, this is methods and constructors, but will likely be expanded to handle closures to some degree as well.
 */
public interface ChunkerInvokable extends IsScope {

    void addArgument(Node argument);

    void addToken(Token token);

    default Token getNameToken() {
        final List kids = getChildren();
        for (int i = kids.size(); i-- > 0;) {
            final Node child = kids.get(i);
            if (child instanceof ChunkerMethodName) {
                return child.jjtGetFirstToken();
            } else if (child instanceof ChunkerInvokable) {
                return ((ChunkerInvokable) child).getNameToken();
            }
        }
        // this fallback shouldn't really be needed.
        assert false : "Invokable without a method name: " + this;
        return tokens(true)
                .filter(tok -> tok.kind == ChunkerConstants.INVOKE)
                .first();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy