code: final void appendSnippet(StringBuilder builder,
                               Token from,
                               Token to,
                               Token offending)
      {
          if (!areTokensValid(from, to, offending))
              return;
  
          String[] lines = query.split("\n");
  
          boolean includeQueryStart = (from.getLine() == 1) && (from.getCharPositionInLine() == 0);
          boolean includeQueryEnd = (to.getLine() == lines.length)
                  && (getLastCharPositionInLine(to) == lines[lines.length - 1].length());
  
          builder.append(" (");
  
          if (!includeQueryStart)
              builder.append("...");
  
          lines[lineIndex(to)] = lines[lineIndex(to)].substring(0, getLastCharPositionInLine(to));
          lines[lineIndex(offending)] = highlightToken(lines[lineIndex(offending)], offending);
          lines[lineIndex(from)] = lines[lineIndex(from)].substring(from.getCharPositionInLine());
  
          for (int i = lineIndex(from), m = lineIndex(to); i <= m; i++)
              builder.append(lines[i]);
  
          if (!includeQueryEnd)
              builder.append("...");
  
          builder.append(")");
      }
docs: Appends a query snippet to the message to help the user to understand the problem.
  
  @param from the first token to include within the snippet
  @param to the last token to include within the snippet
  @param offending the token which is responsible for the error