use of org.eclipse.xtext.ui.editor.model.XtextDocument in project xtext-xtend by eclipse.
the class DocumentRewriterTest method createDocument.
protected XtextDocument createDocument(final String content) throws Exception {
XtextDocument _xblockexpression = null;
{
final IFile file = this._workbenchTestHelper.createFile("Foo", content);
final Resource resource = this._workbenchTestHelper.getResourceSet().getResource(URI.createPlatformResourceURI(file.getFullPath().toString(), true), true);
XtendDocumentTokenSource _xtendDocumentTokenSource = new XtendDocumentTokenSource();
final Procedure1<XtendDocumentTokenSource> _function = (XtendDocumentTokenSource it) -> {
AntlrTokenDefProvider _antlrTokenDefProvider = new AntlrTokenDefProvider();
final Procedure1<AntlrTokenDefProvider> _function_1 = (AntlrTokenDefProvider it_1) -> {
XtendAntlrTokenFileProvider _xtendAntlrTokenFileProvider = new XtendAntlrTokenFileProvider();
it_1.setAntlrTokenFileProvider(_xtendAntlrTokenFileProvider);
};
AntlrTokenDefProvider _doubleArrow = ObjectExtensions.<AntlrTokenDefProvider>operator_doubleArrow(_antlrTokenDefProvider, _function_1);
it.setTokenDefProvider(_doubleArrow);
final Provider<Lexer> _function_2 = () -> {
InternalXtendLexer _internalXtendLexer = new InternalXtendLexer();
return ((Lexer) _internalXtendLexer);
};
it.setLexer(_function_2);
it.setFlexerFactory(this.flexerFactory);
};
final XtendDocumentTokenSource source = ObjectExtensions.<XtendDocumentTokenSource>operator_doubleArrow(_xtendDocumentTokenSource, _function);
final XtextDocument document = new XtextDocument(source, null, this.outdatedStateManager, this.operationCanceledManager);
document.set(content);
document.setInput(((XtextResource) resource));
_xblockexpression = document;
}
return _xblockexpression;
}
use of org.eclipse.xtext.ui.editor.model.XtextDocument in project xtext-xtend by eclipse.
the class ImportAwareActionTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
this.document = this.<XtextDocument>get(XtextDocument.class);
IDocumentPartitioner partitioner = this.<IDocumentPartitioner>get(IDocumentPartitioner.class);
partitioner.connect(this.document);
this.document.setDocumentPartitioner(partitioner);
}
use of org.eclipse.xtext.ui.editor.model.XtextDocument in project xtext-xtend by eclipse.
the class AbstractOutlineTests method newAssertBuilder.
protected AssertBuilder newAssertBuilder(XtendFile xtendFile) throws Exception, CoreException {
XtextDocument document = documentProvider.get();
document.setInput((XtextResource) xtendFile.eResource());
IOutlineNode root = treeProvider.createRoot(document);
AssertBuilder assertBuilder = new AssertBuilder(root);
return assertBuilder;
}
use of org.eclipse.xtext.ui.editor.model.XtextDocument in project xtext-xtend by eclipse.
the class XtendFormatterPreview method doUpdate.
@SuppressWarnings("deprecation")
public void doUpdate(final Map<String, String> map) {
checkEditorHandleIsSet();
final MapBasedPreferenceValues values = new MapBasedPreferenceValues(map);
String maxLineWidthValue = values.getPreference(maxLineWidth);
if (maxLineWidthValue != null) {
moveMarginToColumn(maxLineWidthValue);
}
StyledText widget = null;
try {
widget = (StyledText) editorHandle.getViewer().getControl();
// disable redraw, otherwise this would causes funny animation effects during formating.
widget.setRedraw(false);
this.modelAccess.updateModel("", previewContent, "");
XtextDocument document = editorHandle.getDocument();
ContentFormatter formatter = formatterProvider.get();
formatter.setPreferencesProvider(values);
formatter.format(document, new Region(0, document.getLength()));
// reset selection, otherwise the whole new content will be selected
editorHandle.getViewer().setSelection(null);
} finally {
if (widget != null)
widget.setRedraw(true);
}
}
use of org.eclipse.xtext.ui.editor.model.XtextDocument in project xtext-xtend by eclipse.
the class ReplacingAppendableTest method testImports_4.
@Test
public void testImports_4() throws Exception {
final XtextDocument document = insertListField("package test\n" + "/**\n" + "*/\n" + "\n" + "class Foo {|}", "foo");
assertEqualsIgnoreWhitespace("package test\n" + "\n" + "import java.util.List\n" + "\n" + "/**\n" + "*/\n" + "\n" + "class Foo {List<?> foo}", document.get());
}
Aggregations