Java 类org.eclipse.xtext.resource.impl.ResourceDescriptionChangeEvent 实例源码

项目:dsl-devkit    文件:MonitoredClusteringBuilderState.java   
/**
 * {@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();
  }
}
项目:bts    文件:DirtyStateEditorSupport.java   
protected Pair<IResourceDescription.Event, Integer> mergePendingDeltas() {
    Map<URI, IResourceDescription.Delta> uriToDelta = Maps.newLinkedHashMap();
    Iterator<IResourceDescription.Delta> iter = pendingChanges.iterator();
    int size = 0;
    while(iter.hasNext()) {
        IResourceDescription.Delta delta = iter.next();
        URI uri = delta.getUri();
        IResourceDescription.Delta prev = uriToDelta.get(uri);
        if (prev == null) {
            uriToDelta.put(uri, delta);
        } else if (prev.getOld() != delta.getNew()){
            uriToDelta.put(uri, createDelta(delta, prev));
        } else {
            uriToDelta.remove(uri);
        }
        size++;
    }
    IResourceDescription.Event event = new ResourceDescriptionChangeEvent(uriToDelta.values(), dirtyStateManager);
    return Tuples.create(event, size);
}
项目:xtext-core    文件:StateBasedContainerTest.java   
@Override
@Test public void testBug352214() {
    container.getResourceDescriptions(); // initialize uri map
    ResourceDescriptionChangeEvent event = new ResourceDescriptionChangeEvent(Collections.<IResourceDescription.Delta>singletonList(
            new ChangedResourceDescriptionDelta(resourceDescription, null)));
    simulateEmpty = true;
    container.descriptionsChanged(event);
    assertEquals(0, container.getResourceDescriptionCount());
    assertTrue(Iterables.all(container.getResourceDescriptions(), Predicates.notNull()));
    assertFalse(container.hasResourceDescription(uri)); 
    assertNull(container.getResourceDescription(uri));
}
项目:dsl-devkit    文件:MonitoredClusteringBuilderState.java   
@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();
}
项目:n4js    文件:PrevStateAwareDirtyStateManager.java   
private void notifyListeners(IResourceDescription.Delta delta) {
    notifyListeners(new ResourceDescriptionChangeEvent(Collections.singletonList(delta)));
}