protected <T> void setNodeAttributes(T data, ParseTree startNode, ParseTree endNode) {
if (data instanceof Node) {
Node node = (Node) data;
if (startNode instanceof ParserRuleContext) {
ParserRuleContext context = (ParserRuleContext) startNode;
node.setStartLine(context.getStart().getLine());
node.setStartColumn(context.getStart().getCharPositionInLine());
} else if (startNode instanceof TerminalNode) {
TerminalNode terminal = (TerminalNode) startNode;
node.setStartLine(terminal.getSymbol().getLine());
node.setStartColumn(terminal.getSymbol().getCharPositionInLine());
}
if (endNode instanceof ParserRuleContext) {
ParserRuleContext context = (ParserRuleContext) endNode;
node.setEndLine(context.getStop().getLine());
node.setEndColumn(context.getStop().getCharPositionInLine()
+ context.getStop().getText().length() - 1);
} else if (endNode instanceof TerminalNode) {
TerminalNode terminal = (TerminalNode) endNode;
node.setEndLine(terminal.getSymbol().getLine());
node.setEndColumn(terminal.getSymbol().getCharPositionInLine()
+ terminal.getSymbol().getText().length() - 1);