@Inject public DirtyStateAwareResourceDescriptions2(final IBuilderState globalDescriptions, final IDirtyStateManager dirtyStateManager, final IStateChangeEventBroker stateChangeEventBroker) { super(globalDescriptions, dirtyStateManager, stateChangeEventBroker); dirtyResources = Sets.newHashSet(); this.dirtyStateManager = dirtyStateManager; this.globalDescriptions = (IResourceDescriptions2) (globalDescriptions instanceof IResourceDescriptions2 ? globalDescriptions : new ResourceDescriptions2(globalDescriptions)); }
public void configureIResourceDescriptionsPersisted(Binder binder) { binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(IBuilderState.class); }
/***/ public static IBuilderState getBuilderState() { return Access.getIBuilderState().get(); }
/** * 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); } }
/** * Binds the ProjectAwareClusteringState to avoid getting stuck rebuilding things and improive performance. * * @return {@link ProjectAwareClusteringBuilderState} */ public Class<? extends IBuilderState> bindIBuilderState() { return ProjectAwareClusteringBuilderState.class; }
/** * Provide a default binding for the builder state. * * @return The class to instantiate for the builder state */ public Class<? extends IBuilderState> bindIBuilderState() { return MonitoredClusteringBuilderState.class; }