/* Generated By:JJTree: Do not edit this line. SimpleNode.java Version 4.3 */
/* JavaCCOptions:MULTI=false,NODE_USES_PARSER=true,VISITOR=false,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=*,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package org.python.pydev.parser.fastparser.grammar_fstrings_common;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
import org.python.pydev.parser.grammar_fstrings.FStringsGrammar;
import org.python.pydev.parser.grammar_fstrings.FStringsGrammarTreeConstants;
import org.python.pydev.shared_core.string.StringUtils;
import org.python.pydev.shared_core.string.TextSelectionUtils;
public class SimpleNode implements Node {
protected Node parent;
protected Node[] children;
public final int id;
protected Object value;
public int beginColumn;
public int endColumn;
public int beginLine;
public int endLine;
public SimpleNode(int i) {
id = i;
}
public static Node jjtCreate(FStringsGrammar p, int id) {
return new SimpleNode(id);
}
@Override
public void jjtOpen(FStringsGrammar parser) {
}
@Override
public void jjtClose(FStringsGrammar parser) {
}
@Override
public void jjtSetParent(Node n) {
parent = n;
}
@Override
public Node jjtGetParent() {
return parent;
}
@Override
public void jjtAddChild(Node n, int i) {
if (children == null) {
children = new Node[i + 1];
} else if (i >= children.length) {
Node c[] = new Node[i + 1];
System.arraycopy(children, 0, c, 0, children.length);
children = c;
}
children[i] = n;
}
@Override
public Node jjtGetChild(int i) {
return children[i];
}
@Override
public int jjtGetNumChildren() {
return (children == null) ? 0 : children.length;
}
public void jjtSetValue(Object value) {
this.value = value;
}
public Object jjtGetValue() {
return value;
}
/* You can override these two methods in subclasses of SimpleNode to
customize the way the node appears when the tree is dumped. If
your output uses more than one line you should override
toString(String), otherwise overriding toString() is probably all
you need to do. */
@Override
public String toString() {
return StringUtils.join("", FStringsGrammarTreeConstants.jjtNodeName[id], " (", beginLine, ", ",
beginColumn, ") -> (", endLine, ", ", endColumn, ")");
}
public String toString(String prefix) {
return prefix + toString();
}
/* Override this method if you want to customize how the node dumps
out its children. */
public void dump(String prefix) {
System.out.println(toString(prefix));
if (children != null) {
for (int i = 0; i < children.length; ++i) {
SimpleNode n = (SimpleNode) children[i];
if (n != null) {
n.dump(prefix + " ");
}
}
}
}
public String getContentsFromString(String str, Document doc) throws BadLocationException {
int offset1 = TextSelectionUtils.getAbsoluteCursorOffset(doc, this.beginLine - 1, this.beginColumn - 1);
int offset2 = TextSelectionUtils.getAbsoluteCursorOffset(doc, this.endLine - 1, this.endColumn);
return doc.get(offset1, offset2 - offset1);
}
}
/* JavaCC - OriginalChecksum=169f55ab032ee70675f83cac2ef6f376 (do not edit this line) */