@Test public void get_specified_line_in_multiply_line_str() throws Exception { String text = "aaa\nbbb\nccc\nddd"; assertThat(AntlrUtils.errorLine(text, 1), is("aaa")); assertThat(AntlrUtils.errorLine(text, 2), is("bbb")); assertThat(AntlrUtils.errorLine(text, 3), is("ccc")); assertThat(AntlrUtils.errorLine(text, 4), is("ddd")); }
String errorLine(String errorMessage, int lineNumber) { int startIndex = 0; int endIndex = 0; for (int i = 0; i < lineNumber; i++) { int index = errorMessage.indexOf('\n', endIndex + 1); if (i > 0) { startIndex = endIndex + 1; } if (index >= 0) { endIndex = index; } else { endIndex = errorMessage.length(); } } return errorMessage.substring(startIndex, endIndex); }
AntlrUtils { String errorLine(String errorMessage, int lineNumber) { int startIndex = 0; int endIndex = 0; for (int i = 0; i < lineNumber; i++) { int index = errorMessage.indexOf('\n', endIndex + 1); if (i > 0) { startIndex = endIndex + 1; } if (index >= 0) { endIndex = index; } else { endIndex = errorMessage.length(); } } return errorMessage.substring(startIndex, endIndex); } }
AntlrUtils { String errorLine(String errorMessage, int lineNumber) { int startIndex = 0; int endIndex = 0; for (int i = 0; i < lineNumber; i++) { int index = errorMessage.indexOf('\n', endIndex + 1); if (i > 0) { startIndex = endIndex + 1; } if (index >= 0) { endIndex = index; } else { endIndex = errorMessage.length(); } } return errorMessage.substring(startIndex, endIndex); }  }
AntlrUtils { String errorLine(String errorMessage, int lineNumber) { int startIndex = 0; int endIndex = 0; for (int i = 0; i < lineNumber; i++) { int index = errorMessage.indexOf('\n', endIndex + 1); if (i > 0) { startIndex = endIndex + 1; } if (index >= 0) { endIndex = index; } else { endIndex = errorMessage.length(); } } return errorMessage.substring(startIndex, endIndex); }  String underlineError(String fullText, String symbolText, int line, int charPositionInLine); }
AntlrUtils { String errorLine(String errorMessage, int lineNumber) { int startIndex = 0; int endIndex = 0; for (int i = 0; i < lineNumber; i++) { int index = errorMessage.indexOf('\n', endIndex + 1); if (i > 0) { startIndex = endIndex + 1; } if (index >= 0) { endIndex = index; } else { endIndex = errorMessage.length(); } } return errorMessage.substring(startIndex, endIndex); }  String underlineError(String fullText, String symbolText, int line, int charPositionInLine);  }