org.eclipse.xtext.resource.IResourceDescription.Event Java Examples

The following examples show how to use org.eclipse.xtext.resource.IResourceDescription.Event. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Bug486584Test.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testFullBuildWhenClasspathChanged_2() throws CoreException, InterruptedException {
	IJavaProject project = setupProject();
	IFile libaryFile = copyAndGetXtendExampleJar(project);
	IClasspathEntry libraryEntry = JavaCore.newLibraryEntry(libaryFile.getFullPath(), null, null);
	addToClasspath(project, libraryEntry);
	build();
	assertFalse(getEvents().isEmpty());
	getEvents().clear();

	libaryFile.touch(null);
	libaryFile.refreshLocal(IResource.DEPTH_INFINITE, null);
	build();
	assertEquals(1, getEvents().size());
	Event singleEvent = getEvents().get(0);
	ImmutableList<Delta> deltas = singleEvent.getDeltas();
	assertEquals(1, deltas.size());
}
 
Example #2
Source File: TestEventListener.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@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;
		}
	}
}
 
Example #3
Source File: FastReferenceSearchResultContentProvider.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
@Inject
public FastReferenceSearchResultContentProvider(final IResourceDescriptions resourceDescriptions) {
  super(resourceDescriptions);
  this.resourceDescriptions = resourceDescriptions;
  if (resourceDescriptions instanceof IResourceDescription.Event.Source) {
    ((IResourceDescription.Event.Source) resourceDescriptions).addListener(this);
  }
}
 
Example #4
Source File: N4JSDirtyStateEditorSupport.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void scheduleUpdateEditorJob(final IResourceDescription.Event event) {
	N4JSUpdateEditorStateJob job = updateEditorStateJob;
	if (job == null) {
		job = createUpdateEditorJob();
		updateEditorStateJob = job;
	}
	job.scheduleFor(event);
}
 
Example #5
Source File: CachingStateBasedContainerManager.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/** {@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;
    }
  }
}
 
Example #6
Source File: CachingStateBasedContainerManager.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
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);
  }
}
 
Example #7
Source File: N4JSDirtyStateEditorSupport.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
private Set<URI> collectDeltaURIs(Event event) {
	Set<URI> deltaURIs = Sets.newHashSet();
	for (IResourceDescription.Delta delta : event.getDeltas()) {
		deltaURIs.add(delta.getUri());
	}
	return deltaURIs;
}
 
Example #8
Source File: Bug486584Test.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testFullBuildWhenClasspathChanged_1() throws CoreException, InterruptedException {
	IJavaProject project = setupProject();
	assertFalse(getEvents().isEmpty());
	getEvents().clear();
	IFile libaryFile = copyAndGetXtendExampleJar(project);
	IClasspathEntry libraryEntry = JavaCore.newLibraryEntry(libaryFile.getFullPath(), null, null);
	addToClasspath(project, libraryEntry);
	assertEquals(1, getEvents().size());
	Event singleEvent = getEvents().get(0);
	ImmutableList<Delta> deltas = singleEvent.getDeltas();
	assertEquals(1, deltas.size());
}
 
Example #9
Source File: Bug486584Test.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testNoFullBuildIfAttachmentChangeOnly() throws CoreException, InterruptedException {
	IJavaProject project = setupProject();
	assertFalse(getEvents().isEmpty());
	getEvents().clear();
	IFile libaryFile = copyAndGetXtendExampleJar(project);
	IClasspathEntry libraryEntry = JavaCore.newLibraryEntry(libaryFile.getFullPath(), null, null);
	addToClasspath(project, libraryEntry);
	build();
	assertEquals(1, getEvents().size());
	Event singleEvent = getEvents().get(0);
	ImmutableList<Delta> deltas = singleEvent.getDeltas();
	assertEquals(1, deltas.size());
	getEvents().clear();
	IClasspathEntry[] classpath = project.getRawClasspath();
	for (int i = 0; i < classpath.length; ++i) {
		IPath entryPath = classpath[i].getPath();
		if (libraryEntry.getPath().equals(entryPath)) {
			IClasspathEntry[] newClasspath = new IClasspathEntry[classpath.length];
			System.arraycopy(classpath, 0, newClasspath, 0, classpath.length);

			classpath[i] = JavaCore.newLibraryEntry(libaryFile.getFullPath(), libaryFile.getFullPath(), null);
			project.setRawClasspath(classpath, null);

		}
	}
	build();
	assertEquals(0, getEvents().size());
}
 
Example #10
Source File: FastReferenceSearchResultContentProvider.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
@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));
                }
              }
            }
          }
        }
      }
    }
  });
}
 
Example #11
Source File: DelegatingEventSource.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void descriptionsChanged(Event event) {
	notifyListeners(event);
}
 
Example #12
Source File: DelegatingEventSource.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public DelegatingEventSource(IResourceDescription.Event.Source source) {
	this.source = source;
}
 
Example #13
Source File: ReferenceSearchResultContentProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void descriptionsChanged(final Event event) {
	Display.getDefault().asyncExec(new Runnable() {
		@Override
		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 = new ArrayList<>();
									for (ReferenceSearchViewTreeNode referenceNode : rootNode.getChildren()) {
										URI referenceSourceURI = ((IReferenceDescription) referenceNode
												.getDescription()).getSourceEObjectUri();
										if (!Iterables.any(newReferenceDescriptions, input -> 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, removedReferenceNodes.toArray());
									}
								}
							}
						}
					}
				}
			}
		}
	});
}
 
Example #14
Source File: ReferenceSearchResultContentProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @since 2.22
 */
protected void detachListenerFromIndex() {
	if (resourceDescriptions instanceof IResourceDescription.Event.Source) {
		((IResourceDescription.Event.Source) resourceDescriptions).removeListener(this);
	}
}
 
Example #15
Source File: ReferenceSearchResultContentProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @since 2.22
 */
protected void attachListenerToIndex(IResourceDescriptions resourceDescriptions) {
	if (resourceDescriptions instanceof IResourceDescription.Event.Source) {
		((IResourceDescription.Event.Source) resourceDescriptions).addListener(this);
	}
}
 
Example #16
Source File: ProfilerAbstractBuilderTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void descriptionsChanged(Event event) {
	this.events.add(event);
}
 
Example #17
Source File: AbstractBuilderTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public List<Event> getEvents() {
	return events;
}
 
Example #18
Source File: AbstractBuilderTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void descriptionsChanged(Event event) {
	this.events.add(event);
}
 
Example #19
Source File: AbstractBuilderTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public List<Event> getEvents() {
	return events;
}
 
Example #20
Source File: AbstractBuilderTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void descriptionsChanged(Event event) {
	this.events.add(event);
}
 
Example #21
Source File: N4JSDirtyStateEditorSupport.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
private List<Resource> doCollectAffectedResources(XtextResource resource, Event event) {
	Set<URI> deltaURIs = collectDeltaURIs(event);
	List<Resource> result = collectTransitivelyDependentResources(resource, deltaURIs);
	return result;
}
 
Example #22
Source File: N4JSDirtyStateEditorSupport.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected Collection<Resource> collectAffectedResources(XtextResource resource, Event event) {
	List<Resource> result = doCollectAffectedResources(resource, event);
	markResourcesAsLoaded(result);
	return result;
}
 
Example #23
Source File: N4JSDirtyStateEditorSupport.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void scheduleFor(IResourceDescription.Event event) {
	super.scheduleFor(event);
}
 
Example #24
Source File: MyReferenceSearchResultContentProvider.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void descriptionsChanged(final Event event) {
	// Do nothing. Workaround to fix GH-724
}