org.eclipse.jface.text.AbstractDocument Java Examples
The following examples show how to use
org.eclipse.jface.text.AbstractDocument.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestLSPIntegration.java From aCute with Eclipse Public License 2.0 | 6 votes |
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); }
Example #2
Source File: ChangeProvider.java From n4js with Eclipse Public License 1.0 | 3 votes |
/** * 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; }