/** * Creates the common resource set to use during compilation. Installs a light weight index. * * @return the resource set */ private ResourceSet createResourceSet() { // TODO try to reuse code from IN4JSCore.createResourceSet XtextResourceSet resourceSet = xtextResourceSetProvider.get(); resourceSet.setClasspathURIContext(classLoader); // Install containerState as adapter. resourceSet.eAdapters().add(new DelegatingIAllContainerAdapter(rsbAcs)); // Install a lightweight index. OrderedResourceDescriptionsData index = new OrderedResourceDescriptionsData(Collections.emptyList()); ResourceDescriptionsData.ResourceSetAdapter.installResourceDescriptionsData(resourceSet, index); return resourceSet; }
/** * Indexes the resources in the given project including the manifest file resource and adds them to the index stored * in the given resource set. Assumes that the resources have been loaded, but not fully processed. * * @param markedProject * the project to index * @param resourceSet * the resource set that contains the index */ private void indexResources(MarkedProject markedProject, ResourceSet resourceSet) { ResourceDescriptionsData index = ResourceDescriptionsData.ResourceSetAdapter .findResourceDescriptionsData(resourceSet); if (logger.isCreateDebugOutput()) { logger.debug("Indexing project " + markedProject.project.getProjectId()); } for (Resource resource : markedProject.resources) { indexResource(resource, index); } // Index manifest file, too. Index artifact names among project types and library dependencies. Optional<URI> manifestUri = markedProject.project.getManifestLocation(); if (manifestUri.isPresent()) { final Resource manifestResource = resourceSet.getResource(manifestUri.get(), true); if (manifestResource != null) { indexResource(manifestResource, index); } } }
/** * Install the given resource's description into the given index. Raw JavaScript files will not be indexed. Note * that when this method is called for the given resource, it is not yet fully processed and therefore the * serialized type model is not added to the index. * <p> * This is due to the fact that we keep a common resource set for all projects that contains the resources of all * projects with unprocessed dependencies, unlike in the IDE case where we have one resource set per open document * and load the type models from the index. * </p> * <p> * Since the type models are available in the resource set as long as they may still be referenced, they need not be * serialized and stored into the index. * </p> * * @param resource * the resource to be indexed * @param index * the index to add the given resource to */ private void indexResource(Resource resource, ResourceDescriptionsData index) { if (!shouldIndexResource(resource)) return; final URI uri = resource.getURI(); IResourceServiceProvider serviceProvider = IResourceServiceProvider.Registry.INSTANCE .getResourceServiceProvider(uri); if (serviceProvider != null) { if (logger.isCreateDebugOutput()) { logger.debug(" Indexing resource " + uri); } IResourceDescription.Manager resourceDescriptionManager = serviceProvider.getResourceDescriptionManager(); IResourceDescription resourceDescription = resourceDescriptionManager.getResourceDescription(resource); if (resourceDescription != null) { index.addDescription(uri, resourceDescription); } } }
@Override public Collection<URI> getContainedURIs(String containerHandle) { if (!HANDLE.equals(containerHandle)) return Collections.emptySet(); if (resourceSet instanceof XtextResourceSet) { ResourceDescriptionsData descriptionsData = findResourceDescriptionsData(resourceSet); if (descriptionsData != null) { return descriptionsData.getAllURIs(); } return newArrayList(((XtextResourceSet) resourceSet).getNormalizationMap().values()); } List<URI> uris = Lists.newArrayListWithCapacity(resourceSet.getResources().size()); URIConverter uriConverter = resourceSet.getURIConverter(); for (Resource r : resourceSet.getResources()) uris.add(uriConverter.normalize(r.getURI())); return uris; }
@Override public boolean containsURI(String containerHandle, URI candidateURI) { if (!HANDLE.equals(containerHandle)) return false; if (resourceSet instanceof XtextResourceSet) { ResourceDescriptionsData descriptionsData = findResourceDescriptionsData(resourceSet); if (descriptionsData != null) { return descriptionsData.getResourceDescription(candidateURI) != null; } Collection<URI> allUris = ((XtextResourceSet) resourceSet).getNormalizationMap().values(); for (URI uri : allUris) { if (uri.equals(candidateURI)) { return true; } } return false; } URIConverter uriConverter = resourceSet.getURIConverter(); for (Resource r : resourceSet.getResources()) { URI normalized = uriConverter.normalize(r.getURI()); if (normalized.equals(candidateURI)) { return true; } } return false; }
protected IContainer createContainer(final IResourceDescriptions resourceDescriptions, final ChunkedResourceDescriptions chunkedResourceDescriptions, final String projectName) { IContainer _xifexpression = null; if ((resourceDescriptions instanceof LiveShadowedChunkedResourceDescriptions)) { _xifexpression = new LiveShadowedChunkedContainer(((LiveShadowedChunkedResourceDescriptions)resourceDescriptions), projectName); } else { ResourceDescriptionsData _elvis = null; ResourceDescriptionsData _container = chunkedResourceDescriptions.getContainer(projectName); if (_container != null) { _elvis = _container; } else { Set<IResourceDescription> _emptySet = CollectionLiterals.<IResourceDescription>emptySet(); ResourceDescriptionsData _resourceDescriptionsData = new ResourceDescriptionsData(_emptySet); _elvis = _resourceDescriptionsData; } _xifexpression = new ResourceDescriptionsBasedContainer(_elvis); } return _xifexpression; }
@Override public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { final int numChunks = in.readInt(); ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, numChunks, true); for (final Integer i : _doubleDotLessThan) { { final String chunkName = in.readUTF(); final int numDescriptions = in.readInt(); final ArrayList<IResourceDescription> descriptions = new ArrayList<IResourceDescription>(numDescriptions); ExclusiveRange _doubleDotLessThan_1 = new ExclusiveRange(0, numDescriptions, true); for (final Integer j : _doubleDotLessThan_1) { Object _readObject = in.readObject(); descriptions.add(((IResourceDescription) _readObject)); } ResourceDescriptionsData _resourceDescriptionsData = new ResourceDescriptionsData(descriptions); this.chunk2resourceDescriptions.put(chunkName, _resourceDescriptionsData); } } }
public IncrementalBuilder.Result build(final BuildRequest request, final Function1<? super URI, ? extends IResourceServiceProvider> languages, final IResourceClusteringPolicy clusteringPolicy) { try { final XtextResourceSet resourceSet = request.getResourceSet(); ResourceDescriptionsData _copy = request.getState().getResourceDescriptions().copy(); Source2GeneratedMapping _copy_1 = request.getState().getFileMappings().copy(); final IndexState oldState = new IndexState(_copy, _copy_1); CancelIndicator _cancelIndicator = request.getCancelIndicator(); final BuildContext context = new BuildContext(languages, resourceSet, oldState, clusteringPolicy, _cancelIndicator); final IncrementalBuilder.InternalStatefulIncrementalBuilder builder = this.provider.get(); builder.context = context; builder.request = request; try { return builder.launch(); } catch (final Throwable _t) { if (_t instanceof Throwable) { final Throwable t = (Throwable)_t; this._operationCanceledManager.propagateIfCancelException(t); throw t; } else { throw Exceptions.sneakyThrow(_t); } } } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
protected BuildRequest newBuildRequest(final List<URI> changedFiles, final List<URI> deletedFiles, final List<IResourceDescription.Delta> externalDeltas, final CancelIndicator cancelIndicator) { BuildRequest _buildRequest = new BuildRequest(); final Procedure1<BuildRequest> _function = (BuildRequest it) -> { it.setBaseDir(this.baseDir); ResourceDescriptionsData _copy = this.indexState.getResourceDescriptions().copy(); Source2GeneratedMapping _copy_1 = this.indexState.getFileMappings().copy(); IndexState _indexState = new IndexState(_copy, _copy_1); it.setState(_indexState); it.setResourceSet(this.createFreshResourceSet(it.getState().getResourceDescriptions())); it.setDirtyFiles(changedFiles); it.setDeletedFiles(deletedFiles); it.setExternalDeltas(externalDeltas); final BuildRequest.IPostValidationCallback _function_1 = (URI uri, Iterable<Issue> issues) -> { this.issueAcceptor.apply(uri, issues); return true; }; it.setAfterValidate(_function_1); it.setCancelIndicator(cancelIndicator); }; return ObjectExtensions.<BuildRequest>operator_doubleArrow(_buildRequest, _function); }
/** * {@inheritDoc} Schedules a full clean build if the target platform changes. */ @Override public void platformChanged(final IResourceDescriptionsData newPlatform, final Collection<Delta> deltas, final boolean mustRebuild) { if (newPlatform == null) { // Hmmm... context deactivated. Events for removing the project from the index will be generated anyway, so no build necessary. // TODO: check! setResourceDescriptionsData(new NullResourceDescriptionsData()); return; } // Deltas? if (isLoaded()) { // If we're not loaded yet, then this event is due to the initial loading of the platform in super.load. In this case, // we are in a build anyway, aren't we? // TODO: this is pretty convoluted. We should try to disentangle this OO spaghetti code. Is it good enough to simply not notify listeners in // AbstractXtextTargetPlatformManager if it was the initial load? if (newPlatform instanceof AbstractResourceDescriptionsData) { ((AbstractResourceDescriptionsData) newPlatform).beginChanges(); } setResourceDescriptionsData((ResourceDescriptionsData) newPlatform); ResourceDescriptionChangeEvent event = new ResourceDescriptionChangeEvent(deltas); notifyListeners(event); } if (mustRebuild) { buildTrigger.scheduleFullBuild(); } }
/** * @param resourceSet * the resource set to index */ private void installIndex(ResourceSet resourceSet) { // Fill index ResourceDescriptionsData index = new ResourceDescriptionsData(Lists.newArrayList()); List<Resource> resources = Lists.newArrayList(resourceSet.getResources()); for (Resource resource : resources) { index(resource, resource.getURI(), index); } ResourceDescriptionsData.ResourceSetAdapter.installResourceDescriptionsData(resourceSet, index); }
/** * Unload all resources associated with this marked project and remove them from the given resource set. * * @param resourceSet * the resource set containing the resources of this project * @param recorder * the progress state recorder */ public void unload(ResourceSet resourceSet, N4ProgressStateRecorder recorder) { recorder.markStartUnloading(this); ResourceDescriptionsData index = ResourceDescriptionsData.ResourceSetAdapter .findResourceDescriptionsData(resourceSet); unloadResources(resourceSet, index, recorder); unloadManifestResource(resourceSet, index, recorder); clearResources(); recorder.markFinishedUnloading(this); }
private void unloadManifestResource(ResourceSet resourceSet, ResourceDescriptionsData index, N4ProgressStateRecorder recorder) { Optional<URI> manifestLocation = project.getManifestLocation(); if (manifestLocation.isPresent()) { Resource resource = resourceSet.getResource(manifestLocation.get(), false); if (resource != null) unloadResource(resource, resourceSet, index, recorder); } }
private void unloadResource(Resource resource, ResourceSet resourceSet, ResourceDescriptionsData index, N4ProgressStateRecorder recorder) { recorder.markUnloadingOf(resource); if (index != null) index.removeDescription(resource.getURI()); resource.unload(); resourceSet.getResources().remove(resource); }
/** * {@inheritDoc} * * Initializes an adapter which is attached to the builder's resource set. This adapter will be used later on to * process each delta after the corresponding resource was validated. * * @param buildData * the data that should be considered for the update * @param newData * the new resource descriptions as they are to be persisted (the new index after the build). Initially * contains the old resource descriptions. * @param monitor * The progress monitor * @return A list of deltas describing all changes made by the build. */ @Override protected Collection<Delta> doUpdate(BuildData buildData, ResourceDescriptionsData newData, IProgressMonitor monitor) { Measurement mes = dcBuild.getMeasurement("build " + Instant.now()); builderStateLogger.log("N4JSGenerateImmediatelyBuilderState.doUpdate() >>>"); logBuildData(buildData, " of before #doUpdate"); IProject project = getProject(buildData); try { BuildType buildType = N4JSBuildTypeTracker.getBuildType(project); IBuildParticipantInstruction instruction; if (buildType == null) { instruction = IBuildParticipantInstruction.NOOP; } else { instruction = findJSBuilderParticipant().prepareBuild(project, buildType); } // removed after the build automatically; // the resource set is discarded afterwards, anyway buildData.getResourceSet().eAdapters().add(instruction); } catch (CoreException e) { handleCoreException(e); } Collection<Delta> modifiedDeltas = super.doUpdate(buildData, newData, monitor); logBuildData(buildData, " of after #doUpdate"); builderStateLogger.log("Modified deltas: " + modifiedDeltas); builderStateLogger.log("N4JSGenerateImmediatelyBuilderState.doUpdate() <<<"); mes.end(); return modifiedDeltas; }
private void installIndex(ResourceSet resourceSet) { // Fill index ResourceDescriptionsData index = new OrderedResourceDescriptionsData( Collections.<IResourceDescription> emptyList()); List<Resource> resources = Lists.newArrayList(resourceSet.getResources()); for (Resource resource : resources) { index(resource, resource.getURI(), index); } Adapter existing = EcoreUtil.getAdapter(resourceSet.eAdapters(), ResourceDescriptionsData.class); if (existing != null) { resourceSet.eAdapters().remove(existing); } ResourceDescriptionsData.ResourceSetAdapter.installResourceDescriptionsData(resourceSet, index); }
@Test public void testGetIndexedJvmTypeByURI() throws ClassNotFoundException { ProjectDescription projectDescription = new ProjectDescription(); projectDescription.setName("test-project"); ChunkedResourceDescriptions index = new ChunkedResourceDescriptions(Collections.emptyMap(), resourceSet); ResourceDescriptionsData data = new ResourceDescriptionsData(new ArrayList<>()); index.setContainer(projectDescription.getName(), data); ResourceDescriptionsData.ResourceSetAdapter.installResourceDescriptionsData(resourceSet, data); Resource resource = resourceSet.createResource(URI.createURI("test.typesRefactoring")); BinaryClass binaryClass = BinaryClass.forName("testdata.Outer", getClass().getClassLoader()); JvmDeclaredType outerType = declaredTypeFactory.createType(binaryClass); resource.getContents().add(outerType); JvmDeclaredType innerType = findType(outerType, "Inner"); JvmDeclaredType innerMostType = findType(outerType, "InnerMost"); IResourceServiceProvider serviceProvider = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(resource.getURI()); IResourceDescription description = serviceProvider.getResourceDescriptionManager().getResourceDescription(resource); data.addDescription(description.getURI(), description); URI javaObjectURI = EcoreUtil.getURI(getOperation(outerType, "getOuter").getReturnType().getType()); EObject outerTypeFromIndex = indexedJvmTypeAccess.getIndexedJvmType(javaObjectURI , resourceSet); assertSame(outerType, outerTypeFromIndex); javaObjectURI = EcoreUtil.getURI(getOperation(outerType, "getInner").getReturnType().getType()); EObject innerTypeFromIndex = indexedJvmTypeAccess.getIndexedJvmType(javaObjectURI , resourceSet); assertSame(innerType, innerTypeFromIndex); javaObjectURI = EcoreUtil.getURI(getOperation(outerType, "getInnerMost").getReturnType().getType()); EObject innerMostTypeFromIndex = indexedJvmTypeAccess.getIndexedJvmType(javaObjectURI , resourceSet); assertSame(innerMostType, innerMostTypeFromIndex); }
private void installIndex(ResourceSet resourceSet) { if (ResourceDescriptionsData.ResourceSetAdapter.findResourceDescriptionsData(resourceSet) == null) { // Fill index ResourceDescriptionsData index = new ResourceDescriptionsData(Collections.<IResourceDescription>emptyList()); List<Resource> resources = Lists.newArrayList(resourceSet.getResources()); for (Resource resource : resources) { index(resource, resource.getURI(), index); } ResourceDescriptionsData.ResourceSetAdapter.installResourceDescriptionsData(resourceSet, index); } }
protected ResourceDescriptionsData getChunk() { ResourceDescriptionsData _elvis = null; ResourceDescriptionsData _container = this.getChunkedResourceDescriptions().getContainer(this.containerName); if (_container != null) { _elvis = _container; } else { ResourceDescriptionsData _resourceDescriptionsData = new ResourceDescriptionsData(Collections.<IResourceDescription>unmodifiableList(CollectionLiterals.<IResourceDescription>newArrayList())); _elvis = _resourceDescriptionsData; } return _elvis; }
@Override public Iterable<IResourceDescription> getAllResourceDescriptions() { final Function1<ResourceDescriptionsData, Iterable<IResourceDescription>> _function = (ResourceDescriptionsData it) -> { return it.getAllResourceDescriptions(); }; return Iterables.<IResourceDescription>concat(IterableExtensions.<ResourceDescriptionsData, Iterable<IResourceDescription>>map(this.chunk2resourceDescriptions.values(), _function)); }
@Override public IResourceDescription getResourceDescription(final URI uri) { Collection<ResourceDescriptionsData> _values = this.chunk2resourceDescriptions.values(); for (final ResourceDescriptionsData selectable : _values) { { final IResourceDescription result = selectable.getResourceDescription(uri); if ((result != null)) { return result; } } } return null; }
public ResourceDescriptionsData getContainer(final URI uri) { Collection<ResourceDescriptionsData> _values = this.chunk2resourceDescriptions.values(); for (final ResourceDescriptionsData container : _values) { { final IResourceDescription result = container.getResourceDescription(uri); if ((result != null)) { return container; } } } return null; }
protected List<IResourceDescription.Delta> getDeltasForChangedResources(final Iterable<URI> affectedUris, final ResourceDescriptionsData oldIndex, @Extension final BuildContext context) { try { this.compilerPhases.setIndexing(context.getResourceSet(), true); final Function1<Resource, IResourceDescription.Delta> _function = (Resource it) -> { return this.addToIndex(it, true, oldIndex, context); }; return IterableExtensions.<IResourceDescription.Delta>toList(context.<IResourceDescription.Delta>executeClustered(affectedUris, _function)); } finally { this.compilerPhases.setIndexing(context.getResourceSet(), false); } }
protected IResourceDescription.Delta addToIndex(final Resource resource, final boolean isPreIndexing, final ResourceDescriptionsData oldIndex, final BuildContext context) { this._operationCanceledManager.checkCanceled(context.getCancelIndicator()); final URI uri = resource.getURI(); final IResourceServiceProvider serviceProvider = context.getResourceServiceProvider(uri); final IResourceDescription.Manager manager = serviceProvider.getResourceDescriptionManager(); final IResourceDescription newDescription = manager.getResourceDescription(resource); final IResourceDescription toBeAdded = new Indexer.ResolvedResourceDescription(newDescription); IResourceDescription _resourceDescription = null; if (oldIndex!=null) { _resourceDescription=oldIndex.getResourceDescription(uri); } final IResourceDescription.Delta delta = manager.createDelta(_resourceDescription, toBeAdded); return delta; }
private void installIndex() { List<IResourceDescription> _emptyList = Collections.<IResourceDescription>emptyList(); final ResourceDescriptionsData index = new ResourceDescriptionsData(_emptyList); final ArrayList<Resource> resources = Lists.<Resource>newArrayList(this.resourceSet.getResources()); for (final Resource resource : resources) { this.index(resource, resource.getURI(), index); } ResourceDescriptionsData.ResourceSetAdapter.installResourceDescriptionsData(this.resourceSet, index); }
@Before public void setUp() { try { WorkspaceConfig _workspaceConfig = new WorkspaceConfig(); this.workspaceConfig = _workspaceConfig; ProjectConfig _projectConfig = new ProjectConfig("foo", this.workspaceConfig); this.fooProject = _projectConfig; ProjectConfig _projectConfig_1 = new ProjectConfig("bar", this.workspaceConfig); this.barProject = _projectConfig_1; final XtextResourceSet rs0 = this.resourceSetProvider.get(); this.fooURI = IterableExtensions.<SourceFolder>head(this.fooProject.getSourceFolders()).getPath().trimSegments(1).appendSegment("foo.livecontainertestlanguage"); this.barURI = IterableExtensions.<SourceFolder>head(this.barProject.getSourceFolders()).getPath().trimSegments(1).appendSegment("bar.livecontainertestlanguage"); ResourceDescriptionsData _createResourceDescriptionData = this.createResourceDescriptionData(this._parseHelper.parse("foo", this.fooURI, rs0).eResource()); Pair<String, ResourceDescriptionsData> _mappedTo = Pair.<String, ResourceDescriptionsData>of("foo", _createResourceDescriptionData); ResourceDescriptionsData _createResourceDescriptionData_1 = this.createResourceDescriptionData(this._parseHelper.parse("bar", this.barURI, rs0).eResource()); Pair<String, ResourceDescriptionsData> _mappedTo_1 = Pair.<String, ResourceDescriptionsData>of("bar", _createResourceDescriptionData_1); final Map<String, ResourceDescriptionsData> chunks = Collections.<String, ResourceDescriptionsData>unmodifiableMap(CollectionLiterals.<String, ResourceDescriptionsData>newHashMap(_mappedTo, _mappedTo_1)); this.rs1 = this.resourceSetProvider.get(); new ChunkedResourceDescriptions(chunks, this.rs1); ProjectConfigAdapter.install(this.rs1, this.fooProject); this.liveShadowedChunkedResourceDescriptions = this.provider.get(); this.liveShadowedChunkedResourceDescriptions.setContext(this.rs1); LiveShadowedChunkedContainer _liveShadowedChunkedContainer = new LiveShadowedChunkedContainer(this.liveShadowedChunkedResourceDescriptions, "foo"); this.fooContainer = _liveShadowedChunkedContainer; LiveShadowedChunkedContainer _liveShadowedChunkedContainer_1 = new LiveShadowedChunkedContainer(this.liveShadowedChunkedResourceDescriptions, "bar"); this.barContainer = _liveShadowedChunkedContainer_1; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
private ResourceDescriptionsData createResourceDescriptionData(final Resource... resources) { final Function1<Resource, IResourceDescription> _function = (Resource it) -> { return this.resourceDescriptionManager.getResourceDescription(it); }; List<IResourceDescription> _map = ListExtensions.<Resource, IResourceDescription>map(((List<Resource>)Conversions.doWrapArray(resources)), _function); return new ResourceDescriptionsData(_map); }
public void initialize(final ProjectDescription description, final IProjectConfig projectConfig, final Procedure2<? super URI, ? super Iterable<Issue>> acceptor, final IExternalContentSupport.IExternalContentProvider openedDocumentsContentProvider, final Provider<Map<String, ResourceDescriptionsData>> indexProvider, final CancelIndicator cancelIndicator) { this.projectDescription = description; this.projectConfig = projectConfig; this.baseDir = projectConfig.getPath(); this.issueAcceptor = acceptor; this.openedDocumentsContentProvider = openedDocumentsContentProvider; this.indexProvider = indexProvider; }
public XtextResourceSet createNewResourceSet(final ResourceDescriptionsData newIndex) { XtextResourceSet _get = this.resourceSetProvider.get(); final Procedure1<XtextResourceSet> _function = (XtextResourceSet it) -> { this.projectDescription.attachToEmfObject(it); ProjectConfigAdapter.install(it, this.projectConfig); Map<String, ResourceDescriptionsData> _get_1 = this.indexProvider.get(); final ChunkedResourceDescriptions index = new ChunkedResourceDescriptions(_get_1, it); index.setContainer(this.projectDescription.getName(), newIndex); this.externalContentSupport.configureResourceSet(it, this.openedDocumentsContentProvider); }; return ObjectExtensions.<XtextResourceSet>operator_doubleArrow(_get, _function); }
protected XtextResourceSet createFreshResourceSet(final ResourceDescriptionsData newIndex) { if ((this.resourceSet == null)) { this.resourceSet = this.createNewResourceSet(newIndex); } else { final ChunkedResourceDescriptions resDescs = ChunkedResourceDescriptions.findInEmfObject(this.resourceSet); Set<Map.Entry<String, ResourceDescriptionsData>> _entrySet = this.indexProvider.get().entrySet(); for (final Map.Entry<String, ResourceDescriptionsData> entry : _entrySet) { resDescs.setContainer(entry.getKey(), entry.getValue()); } resDescs.setContainer(this.projectDescription.getName(), newIndex); } return this.resourceSet; }
protected void refreshWorkspaceConfig(final CancelIndicator cancelIndicator) { this.setWorkspaceConfig(this.workspaceConfigFactory.getWorkspaceConfig(this.baseDir)); final ArrayList<ProjectDescription> newProjects = CollectionLiterals.<ProjectDescription>newArrayList(); Set<String> _keySet = this.projectName2ProjectManager.keySet(); final Set<String> remainingProjectNames = new HashSet<String>(_keySet); final Consumer<IProjectConfig> _function = (IProjectConfig projectConfig) -> { boolean _containsKey = this.projectName2ProjectManager.containsKey(projectConfig.getName()); if (_containsKey) { remainingProjectNames.remove(projectConfig.getName()); } else { final ProjectManager projectManager = this.projectManagerProvider.get(); final ProjectDescription projectDescription = this.projectDescriptionFactory.getProjectDescription(projectConfig); final Provider<Map<String, ResourceDescriptionsData>> _function_1 = () -> { return this.fullIndex; }; projectManager.initialize(projectDescription, projectConfig, this.issueAcceptor, this.openedDocumentsContentProvider, _function_1, cancelIndicator); this.projectName2ProjectManager.put(projectDescription.getName(), projectManager); newProjects.add(projectDescription); } }; this.getWorkspaceConfig().getProjects().forEach(_function); for (final String deletedProject : remainingProjectNames) { { this.projectName2ProjectManager.remove(deletedProject); this.fullIndex.remove(deletedProject); } } final List<IResourceDescription.Delta> result = this.buildManager.doInitialBuild(newProjects, cancelIndicator); this.afterBuild(result); }
/** {@inheritDoc} */ @Override public IResourceDescriptionsData getIResourceDescriptionsData() { if (index == null) { index = new DelegatingResourceDescriptionsData(new ResourceDescriptionsData(stateLoader.load())); } return index; }
/** {@inheritDoc} */ @Override public synchronized void load() { if (!isLoaded) { setResourceDescriptionsData((ResourceDescriptionsData) targetPlatformManager.getPlatform().getIResourceDescriptionsData()); isLoaded = true; } }
/** * Set the resource descriptions data, unless cancellation has been requested. * * @param newData * the new resource descriptions data * @param monitor * the monitor to check for cancellation */ protected void setResourceDescriptionsData(final ResourceDescriptionsData newData, final IProgressMonitor monitor) { checkForCancellation(monitor); rawData = newData; if (newData instanceof IResourceDescriptions2) { myData = (IResourceDescriptions2) newData; } else { myData = new ResourceDescriptions2(newData); } super.setResourceDescriptionsData(newData); if (isLoaded && newData instanceof AbstractResourceDescriptionsData) { ((AbstractResourceDescriptionsData) newData).commitChanges(); } isLoaded = true; }
@Override protected ResourceDescriptionsData getCopiedResourceDescriptionsData() { ResourceDescriptionsData copy = super.getCopiedResourceDescriptionsData(); if (copy instanceof AbstractResourceDescriptionsData) { ((AbstractResourceDescriptionsData) copy).beginChanges(); } return copy; }
@Override @SuppressWarnings("PMD.AvoidInstanceofChecksInCatchClause") public synchronized ImmutableList<Delta> update(final BuildData buildData, final IProgressMonitor monitor) { ensureLoaded(); final SubMonitor subMonitor = SubMonitor.convert(monitor, org.eclipse.xtext.builder.builderState.Messages.AbstractBuilderState_0, 1); subMonitor.subTask(org.eclipse.xtext.builder.builderState.Messages.AbstractBuilderState_0); checkForCancellation(monitor); final ResourceDescriptionsData newData = getCopiedResourceDescriptionsData(); Collection<IResourceDescription.Delta> result = null; try { result = doUpdate(buildData, newData, subMonitor.newChild(1)); // update the reference setResourceDescriptionsData(newData, monitor); // CHECKSTYLE:OFF } catch (Throwable t) { // CHECKSTYLE:ON if (!operationCanceledManager.isOperationCanceledException(t)) { LOGGER.error("Failed to update index. Executing rollback.", t); //$NON-NLS-1$ } if (newData instanceof AbstractResourceDescriptionsData) { ((AbstractResourceDescriptionsData) newData).rollbackChanges(); } throw t; } final ResourceDescriptionChangeEvent event = new ResourceDescriptionChangeEvent(result); notifyListeners(event); return event.getDeltas(); }
/** * Flushes the changes (added / removed resources) to the database without committing them. * * @param newData * resource descriptions data */ protected void flushChanges(final ResourceDescriptionsData newData) { if (newData instanceof IResourceDescriptionsData) { try { traceSet.started(BuildFlushEvent.class); ((IResourceDescriptionsData) newData).flushChanges(); } finally { traceSet.ended(BuildFlushEvent.class); } } }
/** {@inheritDoc} */ @Override public Iterable<IResourceDescription> getLocalResourceDescriptions() { ensureLoaded(); ResourceDescriptionsData indexData = getResourceDescriptionsData(); if (indexData instanceof ILayeredResourceDescriptions) { return ((ILayeredResourceDescriptions) indexData).getLocalResourceDescriptions(); } else { return indexData.getAllResourceDescriptions(); } }
private void unloadResources(ResourceSet resourceSet, ResourceDescriptionsData index, N4ProgressStateRecorder recorder) { for (Resource res : resources) unloadResource(res, resourceSet, index, recorder); }
public void fillIndex(final URI uri, final Resource resource, final ResourceDescriptionsData index) { final IResourceDescription description = this.languageAccess(uri).getResourceDescriptionManager().getResourceDescription(resource); index.addDescription(uri, description); }