Gets the line number of the character at the specified index.
        If the result is unknown, -1 is returned.
502043
def linenum(self, index):
        """"""
        if len(self._lines) == 0 and self.refstring != "":
            self._lines = self.refstring.split("\n")
            #Add one for the \n that we split on for each line
            self._chars = [ len(x) + 1 for x in self._lines ]
            #Remove the last line break since it doesn't exist
            self._chars[-1] -= 1

            #Now we want to add up the number of characters in each line
            #as the lines progress so that it is easy to search for the
            #line of a single character index
            total = 0
            for i in range(len(self._chars)):
                total += self._chars[i]
                self._chars[i] = total

        if len(self._lines) > 0:
            #Now, find the first index where the character value is >= index
            result = -1
            i = 0
            while result == -1 and i < len(self._chars):
                if index <= self._chars[i]:
                    result = [ i, self._chars[i] - index]
                i += 1

            return result
        else:
            return [ -1, -1 ]
1025179
public int getLineNumber() {
    Node cur = curNode;
    while (cur != null) {
      int line = cur.getLineno();
      if (line >= 0) {
        return line;
      }
      cur = cur.getParent();
    }
    return 0;
  }
761118
private static int indexOfNonDigit(String string, int offset) {
        for (int i = offset; i < string.length(); i++) {
            char c = string.charAt(i);
            if (c < '0' || c > '9') return i;
        }
        return string.length();
    }
1274699
public String get(int columnIndex) throws IOException {
		checkClosed();

		if (columnIndex > -1 && columnIndex < columnsCount) {
			return values[columnIndex];
		} else {
			return "";
		}
	}
233663
private static int getPairIndex(int ch)
    {
        int probe = pairedCharPower;
        int index = 0;

        if (ch >= pairedChars[pairedCharExtra]) {
            index = pairedCharExtra;
        }

        while (probe > (1 << 0)) {
            probe >>= 1;

            if (ch >= pairedChars[index + probe]) {
                index += probe;
            }
        }

        if (pairedChars[index] != ch) {
            index = -1;
        }

        return index;
    }
1266531
def next(self):
    "  "

    char = self.char
    if char == '\n':
      self.lineno += 1
      self.colno = 0
    else:
      self.colno += 1
    self.index += 1
    return self.char
1105494
private int findLeftBrace(char chLeft, int fromIndex) {

        // 查找出现的左括号。
        for (int index = fromIndex; index < length; index++) {

            char ch = pattern.charAt(index);

            // 如果出现左括号，返回。
            if (ch == chLeft) {
                return index;
            }
            // 如果出现非空白字符，返回 - 1.
            else if (!Character.isWhitespace(ch)) {
                return -1;
            }
        }

        // 没有找到匹配的括号。
        return -1;
    }
1077282
def get_line_color(self, increment=1):
        

        i = self.line_colors_index

        self.line_colors_index += increment
        if self.line_colors_index >= len(self.line_colors):
            self.line_colors_index = self.line_colors_index-len(self.line_colors)
            if self.line_colors_index >= len(self.line_colors): self.line_colors_index=0 # to be safe

        return self.line_colors[i]
522066
public static int indexFrom(String s,String chars)
    {
        for (int i=0;i<s.length();i++)
           if (chars.indexOf(s.charAt(i))>=0)
              return i;
        return -1;
    }
1286756
@Private Location lookup(int index) {
    int size = lineBreakIndices.size();
    if (size == 0) return location(0, index);
    int lineNumber = binarySearch(lineBreakIndices, index);
    if (lineNumber == 0) return location(0, index);
    int previousBreak = lineBreakIndices.get(lineNumber - 1);
    return location(lineNumber, index - previousBreak - 1);
  }
51005
private int offset(long index) {
    int offset = (int) (index % buffer.length);
    if (offset < 0) {
      offset += buffer.length;
    }
    return offset;
  }
673529
public final String getString(int index)
    {
        Utf8 utf8 = (Utf8) getConstantInfo(index);
        return utf8.getString();
    }
1091678
function line_number(index, source) {
  // To speed things up, remember the index until which we counted,
  // then next time just begin counting from there.  This way we
  // only count each line once.
  var i = start_index;
  var count = 0;
  while (i < index) {
    if (source[i] === "\n") {
      count++;
    }
    i++;
  }

  start_linenr = count + start_linenr;
  start_index = index;

  return start_linenr;
}
530459
def current_line_num(self):
        '''
        '''
        if self.is_optimized_out():
            return None
        f_trace = self.field('f_trace')
        if long(f_trace) != 0:
            # we have a non-NULL f_trace:
            return self.f_lineno
        else:
            #try:
            return self.co.addr2line(self.f_lasti)
497058
public int getInt(int index)
    {
        checkPositionIndexes(index, index + SIZE_OF_INT, this.length);
        index += offset;
        return (data[index] & 0xff) |
                (data[index + 1] & 0xff) << 8 |
                (data[index + 2] & 0xff) << 16 |
                (data[index + 3] & 0xff) << 24;
    }
1026125
public int getLine()
  {
    if (_line >= 0)
      return _line;

    Attribute attr = getAttribute("LineNumberTable");

    if (attr == null) {
      _line = 0;
      return _line;
    }

    _line = 0;
    return _line;
  }
1288784
public static int getLineCount(String str) {
        if (null == str || str.isEmpty()) {
            return 0;
        }
        int count = 1;
        for (char c : str.toCharArray()) {
            if ('\n' == c) {
                count++;
            }
        }
        return count;
    }