use of org.eclipse.xtext.ui.util.DisplayRunnable in project xtext-eclipse by eclipse.
the class SaveHelper method saveEditors.
public void saveEditors(final IRenameElementContext context) {
new DisplayRunnable() {
@Override
protected void run() throws Exception {
workspace.run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
IWorkbenchPage workbenchPage = getWorkbenchPage(context);
if (prefs.isSaveAllBeforeRefactoring())
workbenchPage.saveAllEditors(false);
else
saveDeclaringEditor(context, workbenchPage);
}
}, new NullProgressMonitor());
}
}.syncExec();
syncUtil.waitForBuild(null);
}
use of org.eclipse.xtext.ui.util.DisplayRunnable in project xtext-eclipse by eclipse.
the class XtextReconcilerDebugger method assertResouceParsedCorrectly.
public void assertResouceParsedCorrectly(XtextResource resource, final ReconcilerReplaceRegion region) {
IParseResult parseResult = resource.getParseResult();
if (parseResult != null) {
ICompositeNode rootNode = parseResult.getRootNode();
final String resourceContent = rootNode.getText();
IParseResult reparseResult = parser.parse(new StringReader(resourceContent));
if (!emfStructureComparator.isSameStructure(parseResult.getRootASTElement(), reparseResult.getRootASTElement())) {
new DisplayRunnable() {
@Override
protected void run() throws Exception {
LOG.error("PartialParsing produced wrong model");
LOG.error("Events: \n\t" + Joiner.on("\n\t").join(region.getDocumentEvents()));
LOG.error("ReplaceRegion: \n\t'" + region + "'");
MessageDialog.openError(Display.getCurrent().getActiveShell(), "XtextReconcilerDebugger", "PartialParsing produced wrong model." + "\n\nSee log for details.");
}
};
}
}
}
use of org.eclipse.xtext.ui.util.DisplayRunnable in project xtext-eclipse by eclipse.
the class XtextReconcilerDebugger method assertModelInSyncWithDocument.
public void assertModelInSyncWithDocument(IDocument document, XtextResource resource, final ReconcilerReplaceRegion region) {
if (document instanceof IDocumentExtension4 && resource != null) {
long beforeGet = ((IDocumentExtension4) document).getModificationStamp();
final String documentContent = document.get();
long afterGet = ((IDocumentExtension4) document).getModificationStamp();
if (beforeGet == afterGet && beforeGet == resource.getModificationStamp()) {
IParseResult parseResult = resource.getParseResult();
if (parseResult != null) {
ICompositeNode rootNode = parseResult.getRootNode();
final String resourceContent = rootNode.getText();
if (!resourceContent.equals(documentContent)) {
new DisplayRunnable() {
@Override
protected void run() throws Exception {
LOG.error("XtextDocument and XtextResource have run out of sync:\n" + DiffUtil.diff(documentContent, resourceContent));
LOG.error("Events: \n\t" + Joiner.on("\n\t").join(region.getDocumentEvents()));
LOG.error("ReplaceRegion: \n\t'" + region + "'");
MessageDialog.openError(Display.getCurrent().getActiveShell(), "XtextReconcilerDebugger", "XtextDocument and XtextResource have run out of sync." + "\n\nSee log for details.");
}
}.syncExec();
} else {
if (LOG.isDebugEnabled())
LOG.debug("Model and document are in sync");
}
}
}
}
}
Aggregations