Java 类org.eclipse.jface.text.AbstractDocument 实例源码

项目:n4js    文件:ChangeProvider.java   
/**
 * Determine the current Line delimiter at the given offset.
 *
 * @param doc
 *            the document to query for the newline sequence.
 * @param offset
 *            absolute character position
 * @return the new line sequence used in the line containing offset
 * @throws BadLocationException
 *             in case offset doesn't fit a legal position
 */
public static String lineDelimiter(IXtextDocument doc, int offset) throws BadLocationException {
    String nl = doc.getLineDelimiter(doc.getLineOfOffset(offset));
    if (nl == null) {
        if (doc instanceof AbstractDocument) {
            nl = ((AbstractDocument) doc).getDefaultLineDelimiter();
        }
    }
    return nl;
}