summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Piskarev2012-01-10 08:53:07 (EST)
committer Sven Efftinge2012-01-23 09:02:51 (EST)
commitd2f891e0e90861e2f1e38f4ba3294da9ea72bb83 (patch)
tree6cde190b5fc801b2238f27c9a6730d51910893f6
parent7d05a818416cb61069681c1adc3f5f5e909a0534 (diff)
downloadorg.eclipse.xtext-d2f891e0e90861e2f1e38f4ba3294da9ea72bb83.zip
org.eclipse.xtext-d2f891e0e90861e2f1e38f4ba3294da9ea72bb83.tar.gz
org.eclipse.xtext-d2f891e0e90861e2f1e38f4ba3294da9ea72bb83.tar.bz2
Scalability improvement in BuilderParticipant
-rw-r--r--plugins/org.eclipse.xtext.builder/src/org/eclipse/xtext/builder/BuilderParticipant.java32
-rw-r--r--plugins/org.eclipse.xtext.builder/src/org/eclipse/xtext/builder/DerivedResourceMarkers.java28
2 files changed, 54 insertions, 6 deletions
diff --git a/plugins/org.eclipse.xtext.builder/src/org/eclipse/xtext/builder/BuilderParticipant.java b/plugins/org.eclipse.xtext.builder/src/org/eclipse/xtext/builder/BuilderParticipant.java
index ca6d3f5..b5d6099 100644
--- a/plugins/org.eclipse.xtext.builder/src/org/eclipse/xtext/builder/BuilderParticipant.java
+++ b/plugins/org.eclipse.xtext.builder/src/org/eclipse/xtext/builder/BuilderParticipant.java
@@ -7,6 +7,7 @@
*******************************************************************************/
package org.eclipse.xtext.builder;
+import static com.google.common.collect.Lists.*;
import static com.google.common.collect.Maps.*;
import static com.google.common.collect.Sets.*;
@@ -100,7 +101,13 @@ public class BuilderParticipant implements IXtextBuilderParticipant {
if (!isEnabled(context)) {
return;
}
- final int numberOfDeltas = context.getDeltas().size();
+
+ final List<IResourceDescription.Delta> deltas = getRelevantDeltas(context);
+ if (deltas.isEmpty()) {
+ return;
+ }
+
+ final int numberOfDeltas = deltas.size();
// monitor handling
if (monitor.isCanceled())
@@ -121,8 +128,16 @@ public class BuilderParticipant implements IXtextBuilderParticipant {
if (context.getBuildType() == BuildType.CLEAN)
return;
}
+
+ Map<OutputConfiguration, List<IMarker>> generatorMarkers = newHashMap();
+ for (OutputConfiguration config : outputConfigurations.values()) {
+ if (config.isCleanUpDerivedResources()) {
+ generatorMarkers.put(config, derivedResourceMarkers.findGeneratorMarkers(builtProject.getFolder(config.getOutputDirectory())));
+ }
+ }
+
for (int i = 0 ; i < numberOfDeltas ; i++) {
- final IResourceDescription.Delta delta = context.getDeltas().get(i);
+ final IResourceDescription.Delta delta = deltas.get(i);
// monitor handling
if (subMonitor.isCanceled())
@@ -134,7 +149,7 @@ public class BuilderParticipant implements IXtextBuilderParticipant {
final Set<IFile> derivedResources = newLinkedHashSet();
for (OutputConfiguration config : outputConfigurations.values()) {
if (config.isCleanUpDerivedResources()) {
- List<IFile> resources = derivedResourceMarkers.findDerivedResources(builtProject.getFolder(config.getOutputDirectory()), uri);
+ List<IFile> resources = derivedResourceMarkers.findDerivedResources(generatorMarkers.get(config), uri);
derivedResources.addAll(resources);
}
}
@@ -185,6 +200,15 @@ public class BuilderParticipant implements IXtextBuilderParticipant {
return builderPreferenceAccess.isAutoBuildEnabled(context.getBuiltProject());
}
+ protected List<IResourceDescription.Delta> getRelevantDeltas(IBuildContext context) {
+ List<IResourceDescription.Delta> result = newArrayList();
+ for (IResourceDescription.Delta delta : context.getDeltas()) {
+ if (resourceServiceProvider.canHandle(delta.getUri()))
+ result.add(delta);
+ }
+ return result;
+ }
+
protected void refreshOutputFolders(IBuildContext ctx, Map<String, OutputConfiguration> outputConfigurations, IProgressMonitor monitor) throws CoreException {
SubMonitor subMonitor = SubMonitor.convert(monitor, outputConfigurations.size());
for (OutputConfiguration config : outputConfigurations.values()) {
@@ -214,8 +238,6 @@ public class BuilderParticipant implements IXtextBuilderParticipant {
}
protected void handleChangedContents(Delta delta, IBuildContext context, EclipseResourceFileSystemAccess2 fileSystemAccess) throws CoreException {
- if (!resourceServiceProvider.canHandle(delta.getUri()))
- return;
// TODO: we will run out of memory here if the number of deltas is large enough
Resource resource = context.getResourceSet().getResource(delta.getUri(), true);
if (shouldGenerate(resource, context)) {
diff --git a/plugins/org.eclipse.xtext.builder/src/org/eclipse/xtext/builder/DerivedResourceMarkers.java b/plugins/org.eclipse.xtext.builder/src/org/eclipse/xtext/builder/DerivedResourceMarkers.java
index 79fde8f..3502a97 100644
--- a/plugins/org.eclipse.xtext.builder/src/org/eclipse/xtext/builder/DerivedResourceMarkers.java
+++ b/plugins/org.eclipse.xtext.builder/src/org/eclipse/xtext/builder/DerivedResourceMarkers.java
@@ -44,7 +44,33 @@ public class DerivedResourceMarkers implements IDerivedResourceMarkers {
@Inject
private GeneratorIdProvider generatorIdProvider;
-
+
+ public List<IMarker> findGeneratorMarkers(IContainer container) throws CoreException {
+ return findGeneratorMarkers(container, generatorIdProvider.getGeneratorIdentifier());
+ }
+
+ public List<IMarker> findGeneratorMarkers(IContainer container, String generator) throws CoreException {
+ List<IMarker> result = newArrayList();
+ if (!container.exists())
+ return result;
+ IMarker[] markers = container.findMarkers(MARKER_ID, true, IResource.DEPTH_INFINITE);
+ for (IMarker marker : markers) {
+ if (generator.equals(marker.getAttribute(ATTR_GENERATOR)))
+ result.add(marker);
+ }
+ return result;
+ }
+
+ public List<IFile> findDerivedResources(List<IMarker> generatorMarkers, String source) throws CoreException {
+ List<IFile> result = newArrayList();
+ for (IMarker marker : generatorMarkers) {
+ if (marker.exists() && (source == null || source.equals(marker.getAttribute(ATTR_SOURCE)))) {
+ result.add((IFile)marker.getResource());
+ }
+ }
+ return result;
+ }
+
public List<IFile> findDerivedResources(IContainer container, String source) throws CoreException {
return findDerivedResources(container,generatorIdProvider.getGeneratorIdentifier(), source);
}