use of org.eclipse.xtext.nodemodel.ILeafNode in project mechanoid by robotoworks.
the class NewMechanoidDBFileWizard method onNewResourceEditorOpened.
@Override
protected void onNewResourceEditorOpened(IEditorPart editor) {
final XtextEditor xeditor = (XtextEditor) editor;
final IXtextDocument document = xeditor.getDocument();
xeditor.getDocument().readOnly(new IUnitOfWork.Void<XtextResource>() {
@Override
public void process(XtextResource state) throws Exception {
Model model = (Model) state.getContents().get(0);
MigrationBlock migrationBlock = model.getDatabase().getMigrations().get(0);
//$NON-NLS-1$
ILeafNode node = findFirstLeafNodeForKeyword(migrationBlock, "{");
int position = node.getOffset() + 1;
//$NON-NLS-1$
document.replace(position, 0, "\n\t\t");
xeditor.selectAndReveal(position + 3, 0);
}
});
}
Aggregations