Java Code Examples for org.eclipse.xtext.resource.XtextResourceSet#eSetDeliver()

The following examples show how to use org.eclipse.xtext.resource.XtextResourceSet#eSetDeliver() . 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: XWorkspaceManager.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/** Removes a project from the workspace */
synchronized public void removeProject(IProjectConfig projectConfig) {
	String projectName = projectConfig.getName();
	XProjectManager projectManager = getProjectManager(projectName);
	XtextResourceSet resourceSet = projectManager.getResourceSet();
	boolean wasDeliver = resourceSet.eDeliver();
	try {
		resourceSet.eSetDeliver(false);
		resourceSet.getResources().clear();
	} finally {
		resourceSet.eSetDeliver(wasDeliver);
	}
	projectName2ProjectManager.remove(projectName);
	fullIndex.removeContainer(projectName);
}
 
Example 2
Source File: XClusteringStorageAwareResourceLoader.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Remove all resoures from the resource set without delivering notifications.
 */
protected void clearResourceSet() {
	XtextResourceSet resourceSet = context.getResourceSet();
	boolean wasDeliver = resourceSet.eDeliver();
	try {
		resourceSet.eSetDeliver(false);
		resourceSet.getResources().clear();
	} finally {
		resourceSet.eSetDeliver(wasDeliver);
	}
}
 
Example 3
Source File: ClusteringStorageAwareResourceLoader.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Remove all resoures from the resource set without delivering notifications.
 */
protected void clearResourceSet() {
	XtextResourceSet resourceSet = context.getResourceSet();
	boolean wasDeliver = resourceSet.eDeliver();
	try {
		resourceSet.eSetDeliver(false);
		resourceSet.getResources().clear();
	} finally {
		resourceSet.eSetDeliver(wasDeliver);
	}
}
 
Example 4
Source File: AbstractXtextResourceSetTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testResourcesAreClearedWithDeliverFalse_01() {
  final XtextResourceSet rs = this.createEmptyResourceSet();
  Assert.assertEquals(0, rs.getURIResourceMap().size());
  final XtextResource resource = new XtextResource();
  resource.setURI(URI.createFileURI(new File("foo").getAbsolutePath()));
  EList<Resource> _resources = rs.getResources();
  ArrayList<Resource> _newArrayList = CollectionLiterals.<Resource>newArrayList(resource);
  Iterables.<Resource>addAll(_resources, _newArrayList);
  Assert.assertEquals(1, rs.getURIResourceMap().size());
  rs.eSetDeliver(false);
  rs.getResources().clear();
  Assert.assertTrue(resource.eAdapters().isEmpty());
  Assert.assertEquals(0, rs.getURIResourceMap().size());
}
 
Example 5
Source File: AbstractXtextResourceSetTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testResourcesAreClearedWithDeliverFalseWithNormalizedURI_01() {
  final XtextResourceSet rs = this.createEmptyResourceSet();
  Assert.assertEquals(0, rs.getURIResourceMap().size());
  final XtextResource resource = new XtextResource();
  resource.setURI(URI.createURI("//a/../foo"));
  EList<Resource> _resources = rs.getResources();
  ArrayList<Resource> _newArrayList = CollectionLiterals.<Resource>newArrayList(resource);
  Iterables.<Resource>addAll(_resources, _newArrayList);
  Assert.assertEquals(2, rs.getURIResourceMap().size());
  rs.eSetDeliver(false);
  rs.getResources().clear();
  Assert.assertTrue(resource.eAdapters().isEmpty());
  Assert.assertEquals(0, rs.getURIResourceMap().size());
}