/** * @param location the node that can't be evaluated. * @param message a detail message. * @param cause the cause of this exception. */ public EvaluationException(final Node location, final String message, final Throwable cause) { super((location == null) ? message : message + "(at " + location.astGetSource() + ')', cause); }
@Override public String getMessage() { return (src == null) ? super.getMessage() : super.getMessage() + " (" + src.astGetSource() + ")"; }
@Override public String getMessage() { return (src == null) ? super.getMessage() : super.getMessage() + " (" + src.astGetSource() + ")"; } }
private static String getErrorMessage(final Object node, final Class<?> nodeClass) { final StringBuilder sb = new StringBuilder( "The given node does not implement the expected type."); sb.append(" Expected type: '").append(nodeClass.getName()).append("'."); if (node instanceof Node) { sb.append(" Node location: '").append(((Node) node).astGetSource()) .append("'."); } return sb.toString(); } }
public static String sourceToLine(final Node n) { return sourceToLine(n.astGetSource()); } }
protected String interpolate(final Node node, final String s) { final int i = s.indexOf("${"); if (i == -1) return s; final int j = s.indexOf("}", i); if (j == -1) { if (logger.isLoggable(Level.WARNING)) logger.log(Level.WARNING, "At " + node.astGetSource() + ": Invalid string \"" + s + "\""); return s; } final String varName = s.substring(i + 2, j); if (varName.equals("inputADL")) { // Do not substitute ${inputADL} in ADLMapping return s; } String value = System.getProperty(varName); if (value == null) value = System.getenv(varName); if (value == null) { if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE, "At " + node.astGetSource() + ": Unknown variable \"" + varName + "\""); value = ""; } else if (logger.isLoggable(Level.FINEST)) { logger.log(Level.FINEST, "At " + node.astGetSource() + ": replace \"" + varName + "\" by \"" + value + "\"."); } return interpolate(node, s.substring(0, i) + value + s.substring(j + 1)); }
private SubNodeArity checkArityCompatibility(final Node node, final Node superNode, final String subNodeType) throws MergeException { final SubNodeArity nodeArity = getSubNodeArity(node, subNodeType); // if node and superNode are instances of the same class, they have the same // arity for 'subNodeType' if (node.getClass() == superNode.getClass()) { assert nodeArity != SubNodeArity.NONE; return nodeArity; } final SubNodeArity superNodeArity = getSubNodeArity(superNode, subNodeType); if (nodeArity == SubNodeArity.NONE) { assert superNodeArity != SubNodeArity.NONE; return superNodeArity; } if (superNodeArity == SubNodeArity.NONE) { return nodeArity; } if (nodeArity != superNodeArity) { throw new MergeException( "Cannot merge AST, the arity of sub nodes of type '" + subNodeType + "' is not the same for node '" + node.astGetSource() + "' and node '" + superNode.astGetSource() + "'. Check DTDs"); } return nodeArity; }
newNode.astSetSource(node.astGetSource());
result.astSetSource(elem.astGetSource());
@SuppressWarnings("unchecked") private static <T extends Node> T cloneNodeState(final T node) { // first create a new node instance final T newNode = (T) node.astNewInstance(); // copy node attributes newNode.astSetAttributes(node.astGetAttributes()); // copy node decoration newNode.astSetDecorations(node.astGetDecorations()); // copy source newNode.astSetSource(node.astGetSource()); return newNode; }