CacheInvalidator(final IResourceDescriptions resourceDescriptions, final String handle, final IContainerState containerState) { this.resourceDescriptions = resourceDescriptions; this.handle = handle; this.containerState = containerState; if (resourceDescriptions instanceof IResourceDescription.Event.Source) { ((IResourceDescription.Event.Source) resourceDescriptions).addListener(this); } }
@Override public void descriptionsChanged(Event event) { URI expectedURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true); for (IResourceDescription.Delta delta : event.getDeltas()) { URI deltaURI = delta.getUri(); if (expectedURI.equals(deltaURI)) { eventFired = true; } } }
@Override public void scheduleUpdateEditorJob(final IResourceDescription.Event event) { N4JSUpdateEditorStateJob job = updateEditorStateJob; if (job == null) { job = createUpdateEditorJob(); updateEditorStateJob = job; } job.scheduleFor(event); }
private Set<URI> collectDeltaURIs(Event event) { Set<URI> deltaURIs = Sets.newHashSet(); for (IResourceDescription.Delta delta : event.getDeltas()) { deltaURIs.add(delta.getUri()); } return deltaURIs; }
/** {@inheritDoc} */ @Override public void descriptionsChanged(final Event event) { for (Delta d : event.getDeltas()) { if (containerState.contains(d.getUri())) { discardCachedContainer(resourceDescriptions, handle); if (resourceDescriptions instanceof IResourceDescription.Event.Source) { ((IResourceDescription.Event.Source) resourceDescriptions).removeListener(this); } break; } } }
@Inject public FastReferenceSearchResultContentProvider(final IResourceDescriptions resourceDescriptions) { super(resourceDescriptions); this.resourceDescriptions = resourceDescriptions; if (resourceDescriptions instanceof IResourceDescription.Event.Source) { ((IResourceDescription.Event.Source) resourceDescriptions).addListener(this); } }
@Inject public ReferenceSearchResultContentProvider(IResourceDescriptions resourceDescriptions) { batchedSearchResultEvents = Lists.newArrayList(); this.resourceDescriptions = resourceDescriptions; if (resourceDescriptions instanceof IResourceDescription.Event.Source) { ((IResourceDescription.Event.Source) resourceDescriptions).addListener(this); } }
@Override public void descriptionsChanged(Event event) { this.events.add(event); }
/***/ public List<Event> getEvents() { return events; }
@Override protected void scheduleFor(IResourceDescription.Event event) { super.scheduleFor(event); }
@Override protected Collection<Resource> collectAffectedResources(XtextResource resource, Event event) { List<Resource> result = doCollectAffectedResources(resource, event); markResourcesAsLoaded(result); return result; }
private List<Resource> doCollectAffectedResources(XtextResource resource, Event event) { Set<URI> deltaURIs = collectDeltaURIs(event); List<Resource> result = collectTransitivelyDependentResources(resource, deltaURIs); return result; }
public DelegatingEventSource(IResourceDescription.Event.Source source) { this.source = source; }
@Override public void descriptionsChanged(Event event) { notifyListeners(event); }
@Override public void descriptionsChanged(final Event event) { PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { @Override public void run() { for (Delta delta : event.getDeltas()) { if (!(delta.getNew() instanceof StatefulResourceDescription)) { for (Iterator<ReferenceSearchViewTreeNode> i = rootNodes.values().iterator(); i.hasNext();) { ReferenceSearchViewTreeNode rootNode = i.next(); if (((IResourceDescription) rootNode.getDescription()).getURI().equals(delta.getUri())) { if (delta.getNew() == null) { i.remove(); viewer.remove(rootNode); break; } else { Iterable<IReferenceDescription> newReferenceDescriptions = delta.getNew().getReferenceDescriptions(); List<ReferenceSearchViewTreeNode> removedReferenceNodes = Lists.newArrayList(); for (ReferenceSearchViewTreeNode referenceNode : rootNode.getChildren()) { final URI referenceSourceURI = ((IReferenceDescription) referenceNode.getDescription()).getSourceEObjectUri(); if (!Iterables.any(newReferenceDescriptions, new Predicate<IReferenceDescription>() { @Override public boolean apply(final IReferenceDescription input) { return input.getSourceEObjectUri().equals(referenceSourceURI); } })) { removedReferenceNodes.add(referenceNode); } } for (ReferenceSearchViewTreeNode removedReferenceNode : removedReferenceNodes) { rootNode.removeChild(removedReferenceNode); } if (rootNode.getChildren().isEmpty()) { i.remove(); viewer.remove(rootNode); break; } else { viewer.remove(rootNode, Iterables.toArray(removedReferenceNodes, ReferenceSearchViewTreeNode.class)); } } } } } } } }); }
public void descriptionsChanged(final Event event) { Display.getDefault().asyncExec(new Runnable() { public void run() { if (rootNodes != null) { for (Delta delta : event.getDeltas()) { if (!(delta.getNew() instanceof StatefulResourceDescription)) { for (Iterator<ReferenceSearchViewTreeNode> i = rootNodes.iterator(); i.hasNext();) { ReferenceSearchViewTreeNode rootNode = i.next(); if (((IResourceDescription) rootNode.getDescription()).getURI().equals(delta.getUri())) { if (delta.getNew() == null) { i.remove(); viewer.remove(rootNode); break; } else { Iterable<IReferenceDescription> newReferenceDescriptions = delta.getNew() .getReferenceDescriptions(); List<ReferenceSearchViewTreeNode> removedReferenceNodes = Lists.newArrayList(); for (ReferenceSearchViewTreeNode referenceNode : rootNode.getChildren()) { final URI referenceSourceURI = ((IReferenceDescription) referenceNode .getDescription()).getSourceEObjectUri(); if (!Iterables.any(newReferenceDescriptions, new Predicate<IReferenceDescription>() { public boolean apply(IReferenceDescription input) { return input.getSourceEObjectUri().equals( referenceSourceURI); } })) { removedReferenceNodes.add(referenceNode); } } for (ReferenceSearchViewTreeNode removedReferenceNode : removedReferenceNodes) { rootNode.removeChild(removedReferenceNode); } if (rootNode.getChildren().isEmpty()) { i.remove(); viewer.remove(rootNode); break; } else { viewer.remove(rootNode, Iterables.toArray(removedReferenceNodes, ReferenceSearchViewTreeNode.class)); } } } } } } } } }); }