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

下面列出了怎么用org.eclipse.jface.text.AbstractDocument的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: aCute   文件: TestLSPIntegration.java
private void workaroundOmniSharpIssue1088(IDocument document) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
	// Wait for document to be connected
	Method getDocumentListenersMethod = AbstractDocument.class.getDeclaredMethod("getDocumentListeners");
	getDocumentListenersMethod.setAccessible(true);
	new DisplayHelper() {
		@Override protected boolean condition() {
			try {
				return ((Collection<?>)getDocumentListenersMethod.invoke(document)).stream().anyMatch(o -> o.getClass().getName().contains("lsp4e"));
			} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
				e.printStackTrace();
				return false;
			}
		}
	}.waitForCondition(Display.getDefault(), 5000);
	assertNotEquals("LS Document listener was not setup after 5s", Collections.emptyList(), getDocumentListenersMethod.invoke(document));
	// workaround https://github.com/OmniSharp/omnisharp-roslyn/issues/1445
	DisplayHelper.sleep(5000);
	// force fake modification for OmniSharp to wake up
	document.set(document.get().replace("Hello", "Kikoo"));
	DisplayHelper.sleep(500);
}
 
源代码2 项目: 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;
}
 
 类所在包
 类方法
 同包方法