@Override protected ToBeBuilt getToBeBuilt(ToBeBuiltComputer computer, IProject project, IProgressMonitor monitor) { try { return computer.updateProject(project, monitor); } catch (OperationCanceledException | CoreException e) { final String name = project.getName(); LOGGER.error("Error occurred while calculating to be build data for '" + name + "' project.", e); throw Exceptions.sneakyThrow(e); } }
@Override protected void configure() { bind(ToBeBuiltComputer.class).to(SadlToBeBuiltComputer.class); bind(ProjectClasspathChangeListener.class).asEagerSingleton(); bind(IStorage2UriMapper.class).to(IStorage2UriMapperJdtExtensions.class); bind(IStorage2UriMapperJdtExtensions.class).to(Storage2UriMapperJavaImpl.class); bind(IResourceSetProvider.class).to(XtextResourceSetProvider.class); // bind(TypeResourceUnloader.class).asEagerSingleton(); bind(JavaChangeQueueFiller.class).asEagerSingleton(); bind(StorageAwareTrace.class).to(JarEntryAwareTrace.class); bind(DefaultTraceURIConverter.class).to(DefaultUITraceURIConverter.class); }
/** * Runs the operation in a blocking fashion. * * @param helper * the build helper to get the injected services. * @param project * the project to clean/build. * @param monitor * monitor for the operation. */ private void run(final ExternalLibraryBuilderHelper helper, IProject project, IProgressMonitor monitor) { checkArgument(project instanceof ExternalProject, "Expected external project: " + project); final SubMonitor subMonitor = SubMonitor.convert(monitor, 2); final ToBeBuiltComputer computer = helper.builtComputer; final IProgressMonitor computeMonitor = subMonitor.newChild(1, SUPPRESS_BEGINTASK); monitor.setTaskName("Collecting resource for '" + project.getName() + "'..."); final ToBeBuilt toBeBuilt = getToBeBuilt(computer, project, computeMonitor); if (toBeBuilt.getToBeDeleted().isEmpty() && toBeBuilt.getToBeUpdated().isEmpty()) { subMonitor.newChild(1, SUPPRESS_NONE).worked(1); return; } try { final IN4JSCore core = helper.core; final QueuedBuildData queuedBuildData = helper.queuedBuildData; final IBuilderState builderState = helper.builderState; final ExternalProject externalProject = (ExternalProject) project; final String path = externalProject.getExternalResource().getAbsolutePath(); final URI uri = URI.createFileURI(path); final IN4JSProject n4Project = core.findProject(uri).orNull(); ResourceSet resourceSet = null; try { resourceSet = core.createResourceSet(Optional.of(n4Project)); if (!resourceSet.getLoadOptions().isEmpty()) { resourceSet.getLoadOptions().clear(); } resourceSet.getLoadOptions().put(ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE, Boolean.TRUE); if (resourceSet instanceof ResourceSetImpl) { ((ResourceSetImpl) resourceSet).setURIResourceMap(newHashMap()); } final BuildData buildData = new BuildData( project.getName(), resourceSet, toBeBuilt, queuedBuildData, true /* indexingOnly */); monitor.setTaskName("Building '" + project.getName() + "'..."); final IProgressMonitor buildMonitor = subMonitor.newChild(1, SUPPRESS_BEGINTASK); builderState.update(buildData, buildMonitor); } finally { if (null != resourceSet) { resourceSet.getResources().clear(); resourceSet.eAdapters().clear(); } } } catch (Exception e) { final String message = "Error occurred while " + toString().toLowerCase() + "ing external library " + project.getName() + "."; LOGGER.error(message, e); throw new RuntimeException(message, e); } }
protected ToBeBuiltComputer getToBeBuiltComputer() { return toBeBuiltComputer; }
public void configureToBeBuildComputer (Binder binder) { binder.bind(ToBeBuiltComputer.class).to(SadlToBeBuiltComputer.class); }
@Override protected ToBeBuilt getToBeBuilt(ToBeBuiltComputer computer, IProject project, IProgressMonitor monitor) { return computer.removeProject(project, monitor); }
/** * Calculates the {@link ToBeBuilt} for the project. * * @param computer * the computer for the calculation. * @param project * the object of the operation. * @param monitor * the monitor for the process. * @return the calculated {@link ToBeBuilt} instance. */ abstract ToBeBuilt getToBeBuilt(ToBeBuiltComputer computer, IProject project, IProgressMonitor monitor);