Пример #1
0
 /**
  * Returns a line corresponding to the position denoted by getStartOffset. Returns null if this
  * information is not available.
  */
 public Integer getStartLine() {
   LineAndColumn lac = getStartLineAndColumn();
   if (lac == null) {
     return null;
   }
   return lac.getLine();
 }
Пример #2
0
  /** Returns this location in the format "filename:line". */
  public String printPathAndLine() {
    StringBuilder builder = new StringBuilder();
    PathFragment path = getPath();
    if (path != null) {
      builder.append(path.getPathString());
    }

    LineAndColumn position = getStartLineAndColumn();
    if (position != null) {
      builder.append(":").append(position.getLine());
    }
    return builder.toString();
  }
Пример #3
0
 private String printWithPath(PathFragment path) {
   StringBuilder buf = new StringBuilder();
   if (path != null) {
     buf.append(path).append(':');
   }
   LineAndColumn start = getStartLineAndColumn();
   if (start == null) {
     if (getStartOffset() == 0 && getEndOffset() == 0) {
       buf.append("1"); // i.e. line 1 (special case: no information at all)
     } else {
       buf.append("char offsets ").append(getStartOffset()).append("--").append(getEndOffset());
     }
   } else {
     buf.append(start.getLine()).append(':').append(start.getColumn());
   }
   return buf.toString();
 }