use of org.eclipse.xtext.ui.editor.model.XtextDocument in project xtext-eclipse by eclipse.
the class BacktrackingLexerPresentationDamagerTest method createDocument.
@Override
protected Document createDocument(String before) throws Exception {
DocumentTokenSource source = new BacktrackingLexerDocumentTokenSource();
source.setLexer(new Provider<Lexer>() {
@Override
public Lexer get() {
return createLexer();
}
});
XtextDocument document = new XtextDocument(source, null, outdatedStateManager, operationCanceledManager);
document.set(before);
return document;
}
use of org.eclipse.xtext.ui.editor.model.XtextDocument in project xtext-eclipse by eclipse.
the class EditorForAbsentFileTest method testOpenEditorViaIFile.
@Test
public void testOpenEditorViaIFile() throws Exception {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IEditorPart openEditor = IDE.openEditor(getActivePage(), root.getFile(root.getFullPath().append("someProject").append("absent.testlanguage")));
assertNotNull(openEditor);
Display display = Display.getCurrent();
while (display.readAndDispatch()) {
}
assertTrue(openEditor instanceof XtextEditor);
XtextEditor xtextEditor = (XtextEditor) openEditor;
ISourceViewer sourceViewer = xtextEditor.getInternalSourceViewer();
IDocument document = sourceViewer.getDocument();
assertTrue(document instanceof XtextDocument);
StyledText textWidget = sourceViewer.getTextWidget();
Composite parent = textWidget.getParent();
while (parent != null && !(parent.getLayout() instanceof StackLayout)) {
parent = parent.getParent();
}
assertNotNull(parent);
Control[] children = parent.getChildren();
Composite errorPageControl = (Composite) children[1];
while (errorPageControl.getChildren().length == 1) {
errorPageControl = (Composite) errorPageControl.getChildren()[0];
}
Control[] errorPageChildren = errorPageControl.getChildren();
for (Control c : errorPageChildren) {
if (c instanceof StyledText) {
String errorText = ((StyledText) c).getText();
assertEquals("Resource '/someProject/absent.testlanguage' does not exist.", errorText);
return;
}
}
fail("Did not find StyledText with matching error text");
}
use of org.eclipse.xtext.ui.editor.model.XtextDocument in project xtext-eclipse by eclipse.
the class XtextGrammarQuickfixProviderTest method validateInEditor.
private void validateInEditor(IXtextDocument document) {
Job validationJob = ((XtextDocument) document).getValidationJob();
validationJob.schedule();
boolean wasInterrupted = false;
do {
try {
Job.getJobManager().join(ValidationJob.XTEXT_VALIDATION_FAMILY, new NullProgressMonitor());
wasInterrupted = false;
} catch (OperationCanceledException e) {
e.printStackTrace();
} catch (InterruptedException e) {
wasInterrupted = true;
}
} while (wasInterrupted);
}
use of org.eclipse.xtext.ui.editor.model.XtextDocument in project xtext-eclipse by eclipse.
the class AbstractDamagerRepairerTest method createDocument.
protected Document createDocument(String before) throws Exception {
DocumentTokenSource source = new DocumentTokenSource();
source.setLexer(new Provider<Lexer>() {
@Override
public Lexer get() {
return createLexer();
}
});
XtextDocument document = new XtextDocument(source, null, outdatedStateManager, operationCanceledManager);
document.set(before);
return document;
}
use of org.eclipse.xtext.ui.editor.model.XtextDocument in project xtext-eclipse by eclipse.
the class OutlineTreeProviderTest method testCreateRoot.
@Test
public void testCreateRoot() throws Exception {
XtextDocument document = createXtextDocument("element {}");
IOutlineNode rootNode = treeProvider.createRoot(document);
assertTrue(rootNode instanceof DocumentRootNode);
assertEquals(treeProvider, ((DocumentRootNode) rootNode).getTreeProvider());
assertEquals(new TextRegion(0, 10), rootNode.getFullTextRegion());
assertEquals(new TextRegion(0, 10), rootNode.getSignificantTextRegion());
assertEquals(document, ((DocumentRootNode) rootNode).getDocument());
}
Aggregations