diff --git a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/validation/BatchVerificationJob.java b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/validation/BatchVerificationJob.java index c63794a2..76c32d86 100644 --- a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/validation/BatchVerificationJob.java +++ b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/validation/BatchVerificationJob.java @@ -4,6 +4,7 @@ import java.util.LinkedHashMap; import java.util.Map; +import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -75,4 +76,20 @@ public BatchUpdater getUpdater() { return updater; } + @Override + public boolean matches(IProject project) { + for (IDocument doc : updater.documents) { + IResource resource = GherkinEditorDocumentManager.resourceForDocument(doc); + if (resource != null && resource.getProject() == project) { + return true; + } + } + for (IResource resource : updater.resources) { + if (resource.getProject() == project) { + return true; + } + } + return false; + } + } diff --git a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/validation/DocumentValidator.java b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/validation/DocumentValidator.java index c931e872..ce5ea80a 100644 --- a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/validation/DocumentValidator.java +++ b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/validation/DocumentValidator.java @@ -9,6 +9,7 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.jobs.IJobChangeEvent; import org.eclipse.core.runtime.jobs.IJobChangeListener; import org.eclipse.core.runtime.jobs.Job; @@ -367,4 +368,32 @@ public void close() { return batch; } + /** + * Waits for all validation jobs for the specified project to complete. + *
+ * This method finds all running verification jobs that are processing resources + * from the given project and joins on them, waiting for their completion. + * This is more efficient than waiting for all validation jobs when only + * a specific project's validation is needed. + *
+ * + * @param project the project whose validation jobs should be joined + * @throws InterruptedException if the wait is interrupted + * @throws OperationCanceledException if the operation is canceled + */ + public static void joinValidation(IProject project) throws InterruptedException, OperationCanceledException { + if (project == null) { + return; + } + Job[] jobs = Job.getJobManager().find(IGlueValidator.class); + for (Job job : jobs) { + if (job instanceof VerificationJob) { + VerificationJob verificationJob = (VerificationJob) job; + if (verificationJob.matches(project)) { + job.join(); + } + } + } + } + } diff --git a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/validation/ResourceVerificationJob.java b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/validation/ResourceVerificationJob.java index 05307c69..7943bd23 100644 --- a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/validation/ResourceVerificationJob.java +++ b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/validation/ResourceVerificationJob.java @@ -3,6 +3,7 @@ import java.util.Collection; import java.util.List; +import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import io.cucumber.eclipse.editor.document.GherkinEditorDocument; @@ -42,4 +43,9 @@ protected Collection