Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile button now creates a separate resource for each compilation. #848

Merged
merged 1 commit into from
Jan 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 9 additions & 17 deletions org.lflang.ui/src/org/lflang/ui/actions/CompileActionHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.emf.common.util.URI;
Expand All @@ -63,7 +64,6 @@
import org.eclipse.xtext.ui.editor.validation.MarkerIssueProcessor;
import org.eclipse.xtext.ui.validation.MarkerTypeProvider;
import org.eclipse.xtext.util.CancelIndicator;
import org.eclipse.xtext.util.concurrent.IUnitOfWork;
import org.eclipse.xtext.validation.CheckMode;
import org.eclipse.xtext.validation.IResourceValidator;
import org.lflang.ui.LFUiModuleImpl;
Expand Down Expand Up @@ -135,17 +135,14 @@ public Object execute(final ExecutionEvent event) throws ExecutionException {
if (xtextEditor != null) {
var xtextDocument = xtextEditor.getDocument();
if (xtextDocument != null) {
// Get editor's resource
var work = new IUnitOfWork<XtextResource, XtextResource>() {
@Override
public XtextResource exec(XtextResource state) throws Exception {
return state;
}

};
var resource = xtextDocument.readOnly(work);
var file = (IFile) xtextEditor.getResource();
lfFiles.add(new LFFile(resource, file, file.getProject(), xtextEditor));
// Save editor
if (xtextEditor.isDirty()) {
xtextEditor.doSave(new NullProgressMonitor());
}
// Load the resource of this editor based on its associated file (collect).
// This does not retrieve the model resource from the editor directly but creates a new one.
// => workaround for issue #746.
lfFiles.addAll(collect((IFile) xtextEditor.getResource()));
}
}
} else if (selection instanceof IStructuredSelection) { // Invoked from context menu in project explorer
Expand All @@ -172,11 +169,6 @@ protected IStatus run(IProgressMonitor monitor) {
new Status(Status.ERROR, "org.lflang.ui", "Could not delete error markers", e), StatusManager.LOG);
}

// Save editor
if (lfFile.editor != null && lfFile.editor.isDirty()) {
lfFile.editor.doSave(monitor.slice(0));
}

try {
// Validate
monitor.subTask(String.format(VALIDATE_LABEL, lfFile.file.getProjectRelativePath().toString()));
Expand Down