private static ComplexSymbolFactory.Location location(int line, int column, Object payload) { if (payload instanceof SoyDocCommentBuffer) { payload = ((SoyDocCommentBuffer)payload).getCapturedText(); } if (payload instanceof CharSequence) { CharSequence value = (CharSequence)payload; for (int i = 0, j = value.length(); i < j; ++i) { switch (value.charAt(i)) { case '\n': ++line; column = 0; break; case '\t': column += 8 - column % 8; break; case '\r': column = 0; break; case '\b': column = Math.max(0, column - 1); break; default: ++column; break; } } } return new ComplexSymbolFactory.Location(line, column); } }
@Override protected void dump(XMLStreamWriter writer) throws XMLStreamException { writer.writeStartElement("nonterminal"); writer.writeAttribute("id", tagname); writer.writeAttribute("variant", variant+""); // if (!list.isEmpty()){ Location loc = left(); if (loc!=null) loc.toXML(writer, "left"); // } for (XMLElement e:list) e.dump(writer); loc = right(); if (loc!=null) loc.toXML(writer, "right"); writer.writeEndElement(); } }
@Override protected void dump(XMLStreamWriter writer) throws XMLStreamException { writer.writeStartElement("nonterminal"); writer.writeAttribute("id", tagname); writer.writeAttribute("variant", variant+""); // if (!list.isEmpty()){ Location loc = left(); if (loc!=null) loc.toXML(writer, "left"); // } for (XMLElement e:list) e.dump(writer); loc = right(); if (loc!=null) loc.toXML(writer, "right"); writer.writeEndElement(); } }
@Override protected void dump(XMLStreamWriter writer) throws XMLStreamException { writer.writeStartElement("nonterminal"); writer.writeAttribute("id", tagname); writer.writeAttribute("variant", variant+""); // if (!list.isEmpty()){ Location loc = left(); if (loc!=null) loc.toXML(writer, "left"); // } for (XMLElement e:list) e.dump(writer); loc = right(); if (loc!=null) loc.toXML(writer, "right"); writer.writeEndElement(); } }
private static ComplexSymbolFactory.Location location(int line, int column) { return new ComplexSymbolFactory.Location(line, column); }
/** * Cloning factory method * @param other * @return new cloned Location */ public static Location clone(Location other){ return new Location(other); } /**