Last active
September 9, 2016 12:23
-
-
Save nbhusare/13ef1fd7c609e1747077970c1e8c2277 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyDslDocumentProvider extends XtextDocumentProvider { | |
@Override | |
protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) | |
throws CoreException { | |
try { | |
final IHandlerService service = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class); | |
service.executeCommand("org.eclipse.xtext.ui.FormatAction", null); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
super.doSaveDocument(monitor, element, document, overwrite); | |
} | |
} | |
// Add binding in the DSL UI Module | |
def Class<? extends XtextDocumentProvider> bindXtextDocumentProvider() { return MyDslDocumentProvider } | |
// Courtesy: http://stackoverflow.com/questions/31116928/auto-pretty-formatting-in-xtext |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment