Search in sources :

Example 1 with ToBeBuilt

use of org.eclipse.xtext.builder.impl.ToBeBuilt in project dsl-devkit by dsldevkit.

the class RebuildingXtextBuilder method incrementalBuild.

@Override
protected void incrementalBuild(final IResourceDelta delta, final IProgressMonitor monitor) throws CoreException {
    final SubMonitor progress = SubMonitor.convert(monitor, Messages.XtextBuilder_CollectingResources, 2);
    progress.subTask(Messages.XtextBuilder_CollectingResources);
    final ToBeBuilt toBeBuilt = new ToBeBuilt();
    IResourceDeltaVisitor visitor = new IResourceDeltaVisitor() {

        @Override
        public boolean visit(final IResourceDelta delta) throws CoreException {
            if (progress.isCanceled()) {
                throw new OperationCanceledException();
            }
            if (delta.getResource() instanceof IProject) {
                return delta.getResource() == getProject();
            }
            if (delta.getResource() instanceof IStorage) {
                if (delta.getKind() == IResourceDelta.REMOVED) {
                    return getToBeBuiltComputer().removeStorage(null, toBeBuilt, (IStorage) delta.getResource());
                } else if (delta.getKind() == IResourceDelta.ADDED || delta.getKind() == IResourceDelta.CHANGED) {
                    return getToBeBuiltComputer().updateStorage(null, toBeBuilt, (IStorage) delta.getResource());
                }
            }
            return true;
        }
    };
    delta.accept(visitor);
    if (progress.isCanceled()) {
        throw new OperationCanceledException();
    }
    progress.worked(1);
    doBuild(toBeBuilt, progress.newChild(1), BuildType.INCREMENTAL);
}
Also used : ToBeBuilt(org.eclipse.xtext.builder.impl.ToBeBuilt) IResourceDeltaVisitor(org.eclipse.core.resources.IResourceDeltaVisitor) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) SubMonitor(org.eclipse.core.runtime.SubMonitor) IStorage(org.eclipse.core.resources.IStorage) IProject(org.eclipse.core.resources.IProject) IResourceDelta(org.eclipse.core.resources.IResourceDelta)

Example 2 with ToBeBuilt

use of org.eclipse.xtext.builder.impl.ToBeBuilt in project dsl-devkit by dsldevkit.

the class RebuildingXtextBuilder method clean.

@Override
protected void clean(final IProgressMonitor monitor) throws CoreException {
    SubMonitor progress = SubMonitor.convert(monitor, 2);
    try {
        ToBeBuilt toBeBuilt = getToBeBuiltComputer().removeProject(getProject(), progress.newChild(1));
        doClean(toBeBuilt, progress.newChild(1));
    } finally {
        if (monitor != null) {
            monitor.done();
        }
    }
}
Also used : ToBeBuilt(org.eclipse.xtext.builder.impl.ToBeBuilt) SubMonitor(org.eclipse.core.runtime.SubMonitor)

Example 3 with ToBeBuilt

use of org.eclipse.xtext.builder.impl.ToBeBuilt in project dsl-devkit by dsldevkit.

the class RebuildingXtextBuilder method fullBuild.

@Override
protected void fullBuild(final IProgressMonitor monitor, final boolean isRecoveryBuild) throws CoreException {
    SubMonitor progress = SubMonitor.convert(monitor, 2);
    IProject project = getProject();
    ToBeBuilt toBeBuilt = isRecoveryBuild ? getToBeBuiltComputer().updateProjectNewResourcesOnly(project, progress.newChild(1)) : getToBeBuiltComputer().updateProject(project, progress.newChild(1));
    doBuild(toBeBuilt, progress.newChild(1), isRecoveryBuild ? BuildType.RECOVERY : BuildType.FULL);
}
Also used : ToBeBuilt(org.eclipse.xtext.builder.impl.ToBeBuilt) SubMonitor(org.eclipse.core.runtime.SubMonitor) IProject(org.eclipse.core.resources.IProject)

Example 4 with ToBeBuilt

use of org.eclipse.xtext.builder.impl.ToBeBuilt in project xtext-eclipse by eclipse.

the class Bug349445Test method testUpdate.

@Test
public void testUpdate() {
    testMe.update(new BuildData(null, null, new ToBeBuilt(), new QueuedBuildData(null)), null);
    assertEquals(1, loadCalled);
}
Also used : QueuedBuildData(org.eclipse.xtext.builder.impl.QueuedBuildData) BuildData(org.eclipse.xtext.builder.impl.BuildData) ToBeBuilt(org.eclipse.xtext.builder.impl.ToBeBuilt) QueuedBuildData(org.eclipse.xtext.builder.impl.QueuedBuildData) Test(org.junit.Test)

Example 5 with ToBeBuilt

use of org.eclipse.xtext.builder.impl.ToBeBuilt in project xtext-eclipse by eclipse.

the class PersistableResourceDescriptionsTest method update.

private Map<URI, IResourceDescription.Delta> update(Set<URI> toBeUpdated, Set<URI> toBeDeleted) {
    ResourceSet resourceSet = createResourceSet();
    try {
        ToBeBuilt toBeBuilt = new ToBeBuilt();
        if (toBeDeleted != null)
            toBeBuilt.getToBeDeleted().addAll(toBeDeleted);
        if (toBeUpdated != null)
            toBeBuilt.getToBeUpdated().addAll(toBeUpdated);
        BuildData buildData = new BuildData("", resourceSet, toBeBuilt, builderInjector.getInstance(QueuedBuildData.class));
        ImmutableList<Delta> update = builderState.update(buildData, new NullProgressMonitor());
        return Maps.uniqueIndex(update, new Function<IResourceDescription.Delta, URI>() {

            @Override
            public URI apply(IResourceDescription.Delta from) {
                return from.getUri();
            }
        });
    } finally {
        resourceSet.getResources().clear();
    }
}
Also used : BuildData(org.eclipse.xtext.builder.impl.BuildData) QueuedBuildData(org.eclipse.xtext.builder.impl.QueuedBuildData) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ToBeBuilt(org.eclipse.xtext.builder.impl.ToBeBuilt) IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) QueuedBuildData(org.eclipse.xtext.builder.impl.QueuedBuildData) Delta(org.eclipse.xtext.resource.IResourceDescription.Delta) Delta(org.eclipse.xtext.resource.IResourceDescription.Delta) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) URI(org.eclipse.emf.common.util.URI)

Aggregations

ToBeBuilt (org.eclipse.xtext.builder.impl.ToBeBuilt)5 SubMonitor (org.eclipse.core.runtime.SubMonitor)3 IProject (org.eclipse.core.resources.IProject)2 BuildData (org.eclipse.xtext.builder.impl.BuildData)2 QueuedBuildData (org.eclipse.xtext.builder.impl.QueuedBuildData)2 IResourceDelta (org.eclipse.core.resources.IResourceDelta)1 IResourceDeltaVisitor (org.eclipse.core.resources.IResourceDeltaVisitor)1 IStorage (org.eclipse.core.resources.IStorage)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 URI (org.eclipse.emf.common.util.URI)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)1 Delta (org.eclipse.xtext.resource.IResourceDescription.Delta)1 Test (org.junit.Test)1