use of org.eclipse.xtext.ui.editor.formatting2.ContentFormatter 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);
}
}
Aggregations