예제 #1
0
 @Override
 public String toString() {
   final CheckerErrorTraceLocation errorLocation = getErrorLocation();
   final StringBuilder sb = new StringBuilder("[");
   sb.append(NumberFormat.getIntegerInstance().format(getImportance())).append("] ");
   final String path = new File(errorLocation.getUnitName()).getAbsolutePath();
   // relativize
   path.replaceFirst(Stanse.getInstance().getRootDirectory() + '/', "");
   sb.append(path)
       .append(", line ")
       .append(errorLocation.getLineNumber())
       .append(": ")
       .append(getShortDesc());
   return sb.toString();
 }
예제 #2
0
  /**
   * Add path to error traces
   *
   * @param errTraces List of CheckerErrorTraces to be filled with new error trace
   * @param path new error trace
   */
  private void addTrace(List<CheckerErrorTrace> errTraces, List<CFGNode> path) {
    List<CheckerErrorTraceLocation> trace = new ArrayList<CheckerErrorTraceLocation>();

    CFGHandle handle = dictionary.get(path.get(0));

    ListIterator<CFGNode> it = path.listIterator();
    for (; it.hasNext(); ) it.next();

    for (; it.hasPrevious(); ) {
      CFGNode node = it.previous();
      CheckerErrorTraceLocation traceNode =
          new CheckerErrorTraceLocation(
              Stanse.getUnitManager().getUnitName(handle),
              node.getLine(),
              node.getColumn(),
              node.getElement().asXML());
      trace.add(traceNode);
    }
    errTraces.add(new CheckerErrorTrace(trace, "trace " + (errTraces.size() + 1)));
  }