IBuildParticipantPredicate changed to IBuildParticipantFilter
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/builder/IBuildParticipantPredicate.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/builder/IBuildParticipantFilter.java
similarity index 71%
rename from core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/builder/IBuildParticipantPredicate.java
rename to core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/builder/IBuildParticipantFilter.java
index 16731fb..4a79aa9 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/builder/IBuildParticipantPredicate.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/builder/IBuildParticipantFilter.java
@@ -15,20 +15,21 @@
  * Predicate for checking if the specified {@link IBuildParticipant} should be
  * called for the specified file.
  * 
- * Created via {@link IBuildParticipantPredicateFactory}
+ * Created via {@link IBuildParticipantFilterFactory}
  * 
  * @since 4.0
  */
-public interface IBuildParticipantPredicate {
+public interface IBuildParticipantFilter {
 
 	/**
-	 * Returns if the specified {@link IBuildParticipant} should handle the file
-	 * identified with the context.
+	 * Filters the array of {@link IBuildParticipant}s and returns only allowed
+	 * ones.
 	 * 
-	 * @param participant
+	 * @param participants
 	 * @param context
 	 * @return
 	 */
-	boolean apply(IBuildParticipant participant, IBuildContext context);
+	IBuildParticipant[] filter(IBuildParticipant[] participants,
+			IBuildContext context);
 
 }
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/builder/IBuildParticipantPredicateFactory.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/builder/IBuildParticipantFilterFactory.java
similarity index 85%
rename from core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/builder/IBuildParticipantPredicateFactory.java
rename to core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/builder/IBuildParticipantFilterFactory.java
index fa758c1..664e094 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/builder/IBuildParticipantPredicateFactory.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/builder/IBuildParticipantFilterFactory.java
@@ -20,7 +20,7 @@
  * 
  * @since 4.0
  */
-public interface IBuildParticipantPredicateFactory {
+public interface IBuildParticipantFilterFactory {
 
 	/**
 	 * Creates the predicate for checking if each {@link IBuildParticipant}
@@ -28,10 +28,11 @@
 	 * predicate is required for the project.
 	 * 
 	 * @param project
+	 * @param context
 	 * @return
 	 * @throws CoreException
 	 */
-	IBuildParticipantPredicate createPredicate(IScriptProject project)
-			throws CoreException;
+	IBuildParticipantFilter createPredicate(IScriptProject project,
+			Object context) throws CoreException;
 
 }
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/StructureBuilder.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/StructureBuilder.java
index 2d8ae7a..1719836 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/StructureBuilder.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/StructureBuilder.java
@@ -21,7 +21,7 @@
 import org.eclipse.dltk.core.builder.IBuildContext;
 import org.eclipse.dltk.core.builder.IBuildParticipant;
 import org.eclipse.dltk.core.builder.IBuildParticipantExtension;
-import org.eclipse.dltk.core.builder.IBuildParticipantPredicate;
+import org.eclipse.dltk.core.builder.IBuildParticipantFilter;
 import org.eclipse.dltk.core.environment.IFileHandle;
 import org.eclipse.dltk.internal.core.builder.AbstractBuildContext;
 import org.eclipse.dltk.internal.core.builder.BuildParticipantManager;
@@ -62,22 +62,23 @@
 			AccumulatingProblemReporter reporter) {
 		final NullProgressMonitor monitor = new NullProgressMonitor();
 		final IScriptProject project = module.getScriptProject();
-		final IBuildParticipant[] participants = beginBuild(natureId, project);
+		IBuildParticipant[] participants = beginBuild(natureId, project);
 		if (participants.length == 0) {
 			return;
 		}
-		final IBuildParticipantPredicate[] predicates = BuildParticipantManager
-				.getPredicates(project, natureId);
 		final ReconcileBuildContext context = new ReconcileBuildContext(module,
 				reporter);
+		final IBuildParticipantFilter[] filters = BuildParticipantManager
+				.getFilters(project, natureId, reporter);
+		for (IBuildParticipantFilter filter : filters) {
+			participants = filter.filter(participants, context);
+			if (participants == null || participants.length == 0) {
+				return;
+			}
+		}
 		try {
-			OUTER: for (int k = 0; k < participants.length; ++k) {
-				final IBuildParticipant participant = participants[k];
-				for (IBuildParticipantPredicate predicate : predicates) {
-					if (!predicate.apply(participant, context))
-						continue OUTER;
-				}
-				participant.build(context);
+			for (int k = 0; k < participants.length; ++k) {
+				participants[k].build(context);
 			}
 		} catch (CoreException e) {
 			DLTKCore.error("error", e); //$NON-NLS-1$
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/builder/BuildParticipantManager.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/builder/BuildParticipantManager.java
index 25fa8db..e0fe8be 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/builder/BuildParticipantManager.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/builder/BuildParticipantManager.java
@@ -20,8 +20,8 @@
 import org.eclipse.dltk.core.IScriptProject;
 import org.eclipse.dltk.core.builder.IBuildParticipant;
 import org.eclipse.dltk.core.builder.IBuildParticipantFactory;
-import org.eclipse.dltk.core.builder.IBuildParticipantPredicate;
-import org.eclipse.dltk.core.builder.IBuildParticipantPredicateFactory;
+import org.eclipse.dltk.core.builder.IBuildParticipantFilter;
+import org.eclipse.dltk.core.builder.IBuildParticipantFilterFactory;
 import org.eclipse.dltk.internal.core.builder.BuildParticipantManager.FactoryValue;
 import org.eclipse.dltk.utils.NatureExtensionManager;
 import org.eclipse.osgi.util.NLS;
@@ -58,10 +58,10 @@
 
 	}
 
-	public static class PredicateFactoryValue extends
-			FactoryValue<IBuildParticipantPredicateFactory> {
+	public static class FilterFactoryValue extends
+			FactoryValue<IBuildParticipantFilterFactory> {
 
-		public PredicateFactoryValue(IBuildParticipantPredicateFactory factory) {
+		public FilterFactoryValue(IBuildParticipantFilterFactory factory) {
 			super(factory);
 		}
 
@@ -75,7 +75,7 @@
 	private static final String REQUIRES_ID = "id"; //$NON-NLS-1$
 
 	private static final String PARTICIPANT = "buildParticipant";
-	private static final String PREDICATE = "predicate";
+	private static final String FILTER = "filter";
 
 	private static final String ATTR_ID = "id"; //$NON-NLS-1$
 	private static final String ATTR_NAME = "name"; //$NON-NLS-1$
@@ -106,20 +106,20 @@
 				}
 			}
 			return factoryValue;
-		} else if (PREDICATE.equals(element.getName())) {
+		} else if (FILTER.equals(element.getName())) {
 			final Object factory = element.createExecutableExtension(classAttr);
-			if (!(factory instanceof IBuildParticipantPredicateFactory)) {
-				DLTKCore.warn(NLS.bind(
-						"{0} contributed by {1} must implement {2}",
-						new Object[] {
-								element.getName(),
-								element.getContributor(),
-								IBuildParticipantPredicateFactory.class
-										.getName() }));
+			if (!(factory instanceof IBuildParticipantFilterFactory)) {
+				DLTKCore.warn(NLS
+						.bind("{0} contributed by {1} must implement {2}",
+								new Object[] {
+										element.getName(),
+										element.getContributor(),
+										IBuildParticipantFilterFactory.class
+												.getName() }));
 				return null;
 			}
-			return new PredicateFactoryValue(
-					(IBuildParticipantPredicateFactory) factory);
+			return new FilterFactoryValue(
+					(IBuildParticipantFilterFactory) factory);
 		} else {
 			DLTKCore.warn(NLS
 					.bind("Wrong element {0} in {1} extension point contributed by {2}",
@@ -140,7 +140,7 @@
 
 	private static final IBuildParticipant[] NO_PARTICIPANTS = new IBuildParticipant[0];
 
-	private static final IBuildParticipantPredicate[] NO_PREDICATES = new IBuildParticipantPredicate[0];
+	private static final IBuildParticipantFilter[] NO_PREDICATES = new IBuildParticipantFilter[0];
 
 	/**
 	 * Returns {@link IBuildParticipant} instances of the specified nature. If
@@ -205,30 +205,30 @@
 		}
 	}
 
-	public static IBuildParticipantPredicate[] getPredicates(
-			IScriptProject project, String natureId) {
+	public static IBuildParticipantFilter[] getFilters(IScriptProject project,
+			String natureId, Object context) {
 		final FactoryValue<?>[] factories = getInstance()
 				.getInstances(natureId);
 		if (factories == null || factories.length == 0) {
 			return NO_PREDICATES;
 		}
-		return createPredicates(project, factories);
+		return createFilters(project, factories, context);
 	}
 
-	public static IBuildParticipantPredicate[] createPredicates(
-			IScriptProject project, FactoryValue<?>[] factories) {
-		final IBuildParticipantPredicate[] result = new IBuildParticipantPredicate[factories.length];
+	public static IBuildParticipantFilter[] createFilters(
+			IScriptProject project, FactoryValue<?>[] factories, Object context) {
+		final IBuildParticipantFilter[] result = new IBuildParticipantFilter[factories.length];
 		int created = 0;
 		for (int i = 0; i < factories.length; ++i) {
-			if (!(factories[i] instanceof PredicateFactoryValue)) {
+			if (!(factories[i] instanceof FilterFactoryValue)) {
 				continue;
 			}
-			final PredicateFactoryValue factory = (PredicateFactoryValue) factories[i];
+			final FilterFactoryValue factory = (FilterFactoryValue) factories[i];
 			try {
-				final IBuildParticipantPredicate predicate = factory.factory
-						.createPredicate(project);
-				if (predicate != null) {
-					result[created++] = predicate;
+				final IBuildParticipantFilter filter = factory.factory
+						.createPredicate(project, context);
+				if (filter != null) {
+					result[created++] = filter;
 				}
 			} catch (CoreException e) {
 				final String tpl = Messages.BuildParticipantManager_buildParticipantCreateError;
@@ -240,7 +240,7 @@
 			if (created == 0) {
 				return NO_PREDICATES;
 			}
-			final IBuildParticipantPredicate[] newResult = new IBuildParticipantPredicate[created];
+			final IBuildParticipantFilter[] newResult = new IBuildParticipantFilter[created];
 			System.arraycopy(result, 0, newResult, 0, created);
 			return newResult;
 		} else {
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/builder/StandardScriptBuilder.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/builder/StandardScriptBuilder.java
index 96cecef..4b0e08d 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/builder/StandardScriptBuilder.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/builder/StandardScriptBuilder.java
@@ -37,7 +37,7 @@
 import org.eclipse.dltk.core.builder.IBuildParticipantExtension;
 import org.eclipse.dltk.core.builder.IBuildParticipantExtension2;
 import org.eclipse.dltk.core.builder.IBuildParticipantExtension3;
-import org.eclipse.dltk.core.builder.IBuildParticipantPredicate;
+import org.eclipse.dltk.core.builder.IBuildParticipantFilter;
 import org.eclipse.dltk.core.builder.IBuildState;
 import org.eclipse.dltk.core.builder.IProjectChange;
 import org.eclipse.dltk.core.builder.IScriptBuilder;
@@ -243,19 +243,20 @@
 	}
 
 	private void buildModule(IBuildContext context) {
-		OUTER: for (int k = 0; k < participants.length; ++k) {
-			final IBuildParticipant participant = participants[k];
-			for (IBuildParticipantPredicate predicate : predicates) {
-				if (!predicate.apply(participant, context)) {
-					continue OUTER;
-				}
+		IBuildParticipant[] selected = participants;
+		for (IBuildParticipantFilter filter : filters) {
+			selected = filter.filter(selected, context);
+			if (selected == null || selected.length == 0) {
+				return;
 			}
-			try {
-				participant.build(context);
-			} catch (CoreException e) {
-				DLTKCore.error(
-						Messages.StandardScriptBuilder_errorBuildingModule, e);
+		}
+		try {
+			for (int k = 0; k < selected.length; ++k) {
+				selected[k].build(context);
 			}
+		} catch (CoreException e) {
+			DLTKCore.error(Messages.StandardScriptBuilder_errorBuildingModule,
+					e);
 		}
 	}
 
@@ -301,7 +302,7 @@
 	private boolean beginBuildDone = false;
 	private boolean endBuildNeeded = false;
 	private IBuildParticipant[] participants = null;
-	private IBuildParticipantPredicate[] predicates = null;
+	private IBuildParticipantFilter[] filters = null;
 	private IDLTKLanguageToolkit toolkit = null;
 	private IProblemFactory problemFactory = null;
 
@@ -318,8 +319,8 @@
 		if (participants == null || participants.length == 0) {
 			return false;
 		}
-		predicates = BuildParticipantManager.getPredicates(project,
-				toolkit.getNatureId());
+		filters = BuildParticipantManager.getFilters(project,
+				toolkit.getNatureId(), this);
 		problemFactory = createProblemFactory();
 		beginBuildDone = false;
 		endBuildNeeded = false;
@@ -363,7 +364,7 @@
 			reporters = null;
 		}
 		participants = null;
-		predicates = null;
+		filters = null;
 		toolkit = null;
 		problemFactory = null;
 		beginBuildDone = false;
diff --git a/core/plugins/org.eclipse.dltk.core/schema/buildParticipant.exsd b/core/plugins/org.eclipse.dltk.core/schema/buildParticipant.exsd
index b411d78..621fe86 100644
--- a/core/plugins/org.eclipse.dltk.core/schema/buildParticipant.exsd
+++ b/core/plugins/org.eclipse.dltk.core/schema/buildParticipant.exsd
@@ -19,7 +19,7 @@
       <complexType>
          <choice minOccurs="1" maxOccurs="unbounded">
             <element ref="buildParticipant"/>
-            <element ref="predicate"/>
+            <element ref="filter"/>
          </choice>
          <attribute name="point" type="string" use="required">
             <annotation>
@@ -99,7 +99,7 @@
       </complexType>
    </element>
 
-   <element name="predicate">
+   <element name="filter">
       <complexType>
          <attribute name="class" type="string" use="required">
             <annotation>