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

io.deephaven.lang.generated.ChunkerInvoke Maven / Gradle / Ivy

There is a newer version: 0.36.1
Show newest version
/* Generated By:JJTree: Do not edit this line. ChunkerInvoke.java Version 7.0 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=Chunker,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package io.deephaven.lang.generated;

import io.deephaven.lang.api.AbstractChunkerInvokable;
import io.deephaven.lang.api.IsScope;

import java.util.List;

public
class ChunkerInvoke extends AbstractChunkerInvokable implements IsScope {

  private String name;
  private boolean inArguments;

  public ChunkerInvoke(int id) {
    super(id);
  }

  public ChunkerInvoke(Chunker p, int id) {
    super(p, id);
  }


  /** Accept the visitor. **/
  public Object jjtAccept(ChunkerVisitor visitor, Object data) {

    return
    visitor.visitChunkerInvoke(this, data);
  }

  public String getName() {
    if (name == null) {
      final Token first = getNameToken();
      return first.image.replace("(", "").trim();
    }
    return name;
  }

  public void setName(String name) {
    this.name = name.trim();
  }

  public void startArguments() {
    inArguments = true;
  }

  public void endArguments() {
    inArguments = false;
  }

  @Override
  public void jjtAddChild(Node n, int i) {
    super.jjtAddChild(n, i);
    if (inArguments) {
      addArgument(n);
    }
  }

  public int indexOfArgument(Node node) {
    List arguments = getArguments();
    for (int i = 0; i < arguments.size(); i++) {
      final Node argument = arguments.get(i);
      if (argument == node) {
        return i;
      }
    }
    // no direct match; return the argument containing this node.
    for (int i = 0; i < arguments.size(); i++) {
      final Node argument = arguments.get(i);
      if (node.isChildOf(argument)) {
        return i;
      }
    }

    return -1;
  }

  public boolean isCursorInArguments(int offset) {
    Token tok = getNameToken();
    do {
      if (tok.image.contains("(")) {
        return tok.getEndIndex() - 1 <= offset;
      }
      if (tok.containsIndex(offset)) {
        return false;
      }
      tok = tok.next;
    } while (tok != jjtGetLastToken());
    return isWellFormed();
  }

  public boolean isCursorOnName(int offset) {
    Token tok = getNameToken();
    do {
      if (tok.image.contains("(")) {
        return tok.getEndIndex() >= offset &&
            (
                tok.getStartIndex() <= offset
                || (tok.getStartIndex() == offset +1 && getScope().size() > 0)
            );
      }
      tok = tok.next;
    } while (tok != jjtGetLastToken());
    return false;
  }

  @Override
  public boolean isAutocompleteTerminal() {
    return isWellFormed() || getArgumentCount() == 0;
  }

}
/* JavaCC - OriginalChecksum=d4c1e51ddb8abf61102779f0960ab901 (do not edit this line) */




© 2015 - 2024 Weber Informatics LLC | Privacy Policy