Search in sources :

Example 1 with ElementTree

use of org.eclipse.core.internal.watson.ElementTree in project polymap4-core by Polymap4.

the class BuildManager method initializeBuilder.

/**
 * Instantiates the builder with the given name.  If the builder, its plugin, or its nature
 * is missing, create a placeholder builder to takes its place.  This is needed to generate
 * appropriate exceptions when somebody tries to invoke the builder, and to
 * prevent trying to instantiate it every time a build is run.
 * This method NEVER returns null.
 */
private IncrementalProjectBuilder initializeBuilder(String builderName, IProject project, int buildSpecIndex, MultiStatus status) throws CoreException {
    IncrementalProjectBuilder builder = null;
    try {
        builder = instantiateBuilder(builderName);
    } catch (CoreException e) {
        status.add(new ResourceStatus(IResourceStatus.BUILD_FAILED, project.getFullPath(), NLS.bind(Messages.events_instantiate_1, builderName), e));
        status.add(e.getStatus());
    }
    if (builder == null) {
        // unable to create the builder, so create a placeholder to fill in for it
        builder = new MissingBuilder(builderName);
    }
    // get the map of builders to get the last built tree
    ArrayList infos = getBuildersPersistentInfo(project);
    if (infos != null) {
        BuilderPersistentInfo info = getBuilderInfo(infos, builderName, buildSpecIndex);
        if (info != null) {
            infos.remove(info);
            ElementTree tree = info.getLastBuiltTree();
            if (tree != null)
                ((InternalBuilder) builder).setLastBuiltTree(tree);
            ((InternalBuilder) builder).setInterestingProjects(info.getInterestingProjects());
        }
        // delete the build map if it's now empty
        if (infos.size() == 0)
            setBuildersPersistentInfo(project, null);
    }
    return builder;
}
Also used : ElementTree(org.eclipse.core.internal.watson.ElementTree)

Example 2 with ElementTree

use of org.eclipse.core.internal.watson.ElementTree in project polymap4-core by Polymap4.

the class BuildManager method basicBuild.

private void basicBuild(int trigger, IncrementalProjectBuilder builder, Map args, MultiStatus status, IProgressMonitor monitor) {
    try {
        currentBuilder = builder;
        // clear any old requests to forget built state
        currentBuilder.clearForgetLastBuiltState();
        // Figure out want kind of build is needed
        boolean clean = trigger == IncrementalProjectBuilder.CLEAN_BUILD;
        currentLastBuiltTree = currentBuilder.getLastBuiltTree();
        // If no tree is available we have to do a full build
        if (!clean && currentLastBuiltTree == null)
            trigger = IncrementalProjectBuilder.FULL_BUILD;
        // don't build if this builder doesn't respond to the given trigger
        if (!builder.getCommand().isBuilding(trigger)) {
            if (clean)
                currentBuilder.setLastBuiltTree(null);
            return;
        }
        // For incremental builds, grab a pointer to the current state before computing the delta
        currentTree = ((trigger == IncrementalProjectBuilder.FULL_BUILD) || clean) ? null : workspace.getElementTree();
        int depth = -1;
        try {
            // short-circuit if none of the projects this builder cares about have changed.
            if (!needsBuild(currentBuilder, trigger)) {
                // use up the progress allocated for this builder
                // $NON-NLS-1$
                monitor.beginTask("", 1);
                monitor.done();
                return;
            }
            String name = currentBuilder.getLabel();
            String message;
            if (name != null)
                message = NLS.bind(Messages.events_invoking_2, name, builder.getProject().getFullPath());
            else
                message = NLS.bind(Messages.events_invoking_1, builder.getProject().getFullPath());
            monitor.subTask(message);
            hookStartBuild(builder, trigger);
            // release workspace lock while calling builders
            depth = getWorkManager().beginUnprotected();
            // do the build
            SafeRunner.run(getSafeRunnable(trigger, args, status, monitor));
        } finally {
            if (depth >= 0)
                getWorkManager().endUnprotected(depth);
            // Be sure to clean up after ourselves.
            if (clean || currentBuilder.wasForgetStateRequested()) {
                currentBuilder.setLastBuiltTree(null);
            } else {
                // remember the current state as the last built state.
                ElementTree lastTree = workspace.getElementTree();
                lastTree.immutable();
                currentBuilder.setLastBuiltTree(lastTree);
            }
            hookEndBuild(builder);
        }
    } finally {
        currentBuilder = null;
        currentTree = null;
        currentLastBuiltTree = null;
        currentDelta = null;
    }
}
Also used : ElementTree(org.eclipse.core.internal.watson.ElementTree)

Example 3 with ElementTree

use of org.eclipse.core.internal.watson.ElementTree in project polymap4-core by Polymap4.

the class WorkspaceTreeReader_1 method readTree.

public void readTree(IProject project, DataInputStream input, IProgressMonitor monitor) throws CoreException {
    monitor = Policy.monitorFor(monitor);
    String message;
    try {
        message = Messages.resources_reading;
        monitor.beginTask(message, 10);
        /* read the number of builders */
        int numBuilders = input.readInt();
        /* read in the list of builder names */
        String[] builderNames = new String[numBuilders];
        for (int i = 0; i < numBuilders; i++) {
            String builderName = input.readUTF();
            builderNames[i] = builderName;
        }
        monitor.worked(1);
        /* read and link the trees */
        ElementTree[] trees = readTrees(project.getFullPath(), input, Policy.subMonitorFor(monitor, 8));
        /* map builder names to trees */
        if (numBuilders > 0) {
            ArrayList infos = new ArrayList(trees.length * 2 + 1);
            for (int i = 0; i < numBuilders; i++) {
                BuilderPersistentInfo info = new BuilderPersistentInfo(project.getName(), builderNames[i], -1);
                info.setLastBuildTree(trees[i]);
                infos.add(info);
            }
            workspace.getBuildManager().setBuildersPersistentInfo(project, infos);
        }
        monitor.worked(1);
    } catch (IOException e) {
        message = Messages.resources_readProjectTree;
        throw new ResourceException(IResourceStatus.FAILED_READ_METADATA, null, message, e);
    } finally {
        monitor.done();
    }
}
Also used : ElementTree(org.eclipse.core.internal.watson.ElementTree) BuilderPersistentInfo(org.eclipse.core.internal.events.BuilderPersistentInfo)

Example 4 with ElementTree

use of org.eclipse.core.internal.watson.ElementTree in project polymap4-core by Polymap4.

the class WorkspaceTreeReader_1 method readTrees.

/**
 * Read trees from disk and link them to the workspace tree.
 */
protected ElementTree[] readTrees(IPath root, DataInputStream input, IProgressMonitor monitor) throws IOException {
    monitor = Policy.monitorFor(monitor);
    try {
        String message = Messages.resources_reading;
        monitor.beginTask(message, 4);
        ElementTreeReader treeReader = new ElementTreeReader(workspace.getSaveManager());
        ElementTree[] trees = treeReader.readDeltaChain(input);
        monitor.worked(3);
        if (root.isRoot()) {
            // Don't need to link because we're reading the whole workspace.
            // The last tree in the chain is the complete tree.
            ElementTree newTree = trees[trees.length - 1];
            newTree.setTreeData(workspace.tree.getTreeData());
            workspace.tree = newTree;
        } else {
            // splice the restored tree into the current set of trees
            workspace.linkTrees(root, trees);
        }
        monitor.worked(1);
        return trees;
    } finally {
        monitor.done();
    }
}
Also used : ElementTree(org.eclipse.core.internal.watson.ElementTree) ElementTreeReader(org.eclipse.core.internal.watson.ElementTreeReader)

Example 5 with ElementTree

use of org.eclipse.core.internal.watson.ElementTree in project polymap4-core by Polymap4.

the class WorkspaceTreeReader_2 method readTree.

/*
	 * overwritten from WorkspaceTreeReader_1
	 */
public void readTree(IProject project, DataInputStream input, IProgressMonitor monitor) throws CoreException {
    monitor = Policy.monitorFor(monitor);
    String message;
    try {
        message = Messages.resources_reading;
        monitor.beginTask(message, 10);
        /* read in the builder infos */
        List infos = new ArrayList(5);
        readBuildersPersistentInfo(project, input, infos, Policy.subMonitorFor(monitor, 1));
        /* read and link the trees */
        ElementTree[] trees = readTrees(project.getFullPath(), input, Policy.subMonitorFor(monitor, 8));
        /* map builder names to trees */
        linkBuildersToTrees(infos, trees, 0, Policy.subMonitorFor(monitor, 1));
    } catch (IOException e) {
        message = Messages.resources_readProjectTree;
        throw new ResourceException(IResourceStatus.FAILED_READ_METADATA, null, message, e);
    } finally {
        monitor.done();
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) IOException(java.io.IOException) ElementTree(org.eclipse.core.internal.watson.ElementTree)

Aggregations

ElementTree (org.eclipse.core.internal.watson.ElementTree)8 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 BuilderPersistentInfo (org.eclipse.core.internal.events.BuilderPersistentInfo)1 ResourceDelta (org.eclipse.core.internal.events.ResourceDelta)1 Workspace (org.eclipse.core.internal.resources.Workspace)1 ElementTreeReader (org.eclipse.core.internal.watson.ElementTreeReader)1 IResourceDelta (org.eclipse.core.resources.IResourceDelta)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)1 BuildData (org.eclipse.xtext.builder.impl.BuildData)1 QueuedBuildData (org.eclipse.xtext.builder.impl.QueuedBuildData)1 Delta (org.eclipse.xtext.resource.IResourceDescription.Delta)1