package com.redhat.ceylon.eclipse.core.builder;

import java.util.List;
import java.util.Set;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;

import com.redhat.ceylon.compiler.typechecker.TypeChecker;
import com.redhat.ceylon.compiler.typechecker.model.Module;
import com.redhat.ceylon.compiler.typechecker.model.Package;

final class WarmupJob extends Job {
	private final TypeChecker typeChecker;

	WarmupJob(String name, TypeChecker typeChecker) {
		super("Warming up completion processor for " + name);
		this.typeChecker = typeChecker;
	}

	@Override
	protected IStatus run(IProgressMonitor monitor) {
		monitor.beginTask("Warming up completion processor", 100000);
		Set<Module> modules = typeChecker.getPhasedUnits().getModuleManager()
				.getContext().getModules().getListOfModules();
		monitor.worked(10000);
		for (Module m: modules) {
			List<Package> packages = m.getAllPackages();
			for (Package p: packages) {
				p.getMembers();
			}
			monitor.worked(90000/packages.size()/modules.size());
			if (monitor.isCanceled()) {
				return Status.CANCEL_STATUS;
			}
		}
		monitor.done();
		return Status.OK_STATUS;
	}
}
@@ -42,16 +42,51 @@
 ilder;%0A%0A
+import static java.lang.Math.max;%0A%0A
 import j
@@ -1130,16 +1130,20 @@
 d(90000/
+max(
 packages
@@ -1149,17 +1149,24 @@
 s.size()
-/
+,1)/max(
 modules.
@@ -1171,16 +1171,19 @@
 s.size()
+,1)
 );%0A%09%09%09if

fix / by 0