本文整理了Java中org.eclipse.xtext.util.Strings.countLines()
方法的一些代码示例,展示了Strings.countLines()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Strings.countLines()
方法的具体详情如下:
包路径:org.eclipse.xtext.util.Strings
类名称:Strings
方法名:countLines
[英]Counts the number of lines where #separator is assumed to be a valid line break.
[中]统计假定#分隔符为有效换行符的行数。
代码示例来源:origin: org.eclipse.xtext/util
/**
* Counts the number of lines where {@link #separator} is assumed to be a valid line break.
*/
public static int countLines(String text) {
return countLines(text, separator);
}
代码示例来源:origin: org.eclipse.xtext/org.eclipse.xtext.util
/**
* Counts the number of lines where {@link #separator} is assumed to be the only valid line break sequence.
* A string without any line separators returns {@code 0} as the number of lines.
*/
public static int countLines(String text) {
return countLines(text, separator);
}
代码示例来源:origin: org.eclipse.xtext/org.eclipse.xtext.util
/**
* Counts the number of lines where the given separator sequence is the only valid line break sequence.
* A string without any line separators returns {@code 0} as the number of lines.
*/
public static int countLines(String text, char[] separator) {
return countLines(text, separator, 0, text.length());
}
代码示例来源:origin: org.eclipse/xtext
/**
* @since 2.0
*/
protected int basicGetLineOfOffset(INode rootNode, int offset) {
if (rootNode instanceof RootNode) {
int[] lineBreakOffsets = ((RootNode) rootNode).basicGetLineBreakOffsets();
int insertionPoint = Arrays.binarySearch(lineBreakOffsets, offset);
if (insertionPoint >= 0) {
return insertionPoint + 1;
} else {
return -insertionPoint;
}
}
String leadingText = rootNode.getText().substring(0, offset);
int result = Strings.countLines(leadingText);
return result + 1;
}
代码示例来源:origin: org.eclipse/xtext
if (parserNode != null) {
String completeText = parserNode.getRootNode().getText();
int startLine = Strings.countLines(completeText.substring(0, castedDiagnostic.getOffset())) + 1;
result.lineNumber = startLine;
内容来源于网络,如有侵权,请联系作者删除!